ZSCRIPT PROGRAMMING LANGUAGE SCRIPTS FOR GZDOOM ENGINE!!!! // Base class for the acolytes ---------------------------------------------- class Acolyte : StrifeHumanoid { Default { Health 70; PainChance 150; Speed 7; Radius 24; Height 64; Mass 400; Monster; +SEESDAGGERS +NOSPLASHALERT +FLOORCLIP +NEVERRESPAWN MinMissileChance 150; Tag "$TAG_ACOLYTE"; SeeSound "acolyte/sight"; PainSound "acolyte/pain"; AttackSound "acolyte/rifle"; DeathSound "acolyte/death"; ActiveSound "acolyte/active"; Obituary "$OB_ACOLYTE"; } States { Spawn: AGRD A 5 A_Look2; Wait; AGRD B 8 A_ClearShadow; Loop; AGRD D 8; Loop; AGRD ABCDABCD 5 A_Wander; Loop; See: AGRD A 6 Fast Slow A_AcolyteBits; AGRD BCD 6 Fast Slow A_Chase; Loop; Missile: AGRD E 8 Fast Slow A_FaceTarget; AGRD FE 4 Fast Slow A_ShootGun; AGRD F 6 Fast Slow A_ShootGun; Goto See; Pain: AGRD O 8 Fast Slow A_Pain; Goto See; Death: AGRD G 4; AGRD H 4 A_Scream; AGRD I 4; AGRD J 3; AGRD K 3 A_NoBlocking; AGRD L 3; AGRD M 3 A_AcolyteDie; AGRD N -1; Stop; XDeath: GIBS A 5 A_NoBlocking; GIBS BC 5 A_TossGib; GIBS D 4 A_TossGib; GIBS E 4 A_XScream; GIBS F 4 A_TossGib; GIBS GH 4; GIBS I 5; GIBS J 5 A_AcolyteDie; GIBS K 5; GIBS L 1400; Stop; } //============================================================================ // // A_AcolyteDie // //============================================================================ void A_AcolyteDie () { // [RH] Disable translucency here. A_SetRenderStyle(1, STYLE_Normal); // Only the Blue Acolyte does extra stuff on death. if (self is "AcolyteBlue") { int i; // Make sure somebody is still alive for (i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i] && players[i].health > 0) break; } if (i == MAXPLAYERS) return; // Make sure all the other blue acolytes are dead, but do this only once in case of simultaneous kills. if (CheckBossDeath() && !players[i].mo.FindInventory("QuestItem7")) { players[i].mo.GiveInventoryType ("QuestItem7"); players[i].SetLogNumber (14); players[i].SetSubtitleNumber (14, "svox/voc14"); A_StopSound (CHAN_VOICE); A_StartSound ("svox/voc14", CHAN_VOICE, CHANF_DEFAULT, 1., ATTN_NONE); } } } //============================================================================ // // A_BeShadowyFoe // //============================================================================ void A_BeShadowyFoe() { A_SetRenderStyle(HR_SHADOW, STYLE_Translucent); bFriendly = false; } //============================================================================ // // A_AcolyteBits // //============================================================================ void A_AcolyteBits() { if (SpawnFlags & MTF_SHADOW) { A_BeShadowyFoe(); } if (SpawnFlags & MTF_ALTSHADOW) { if (bShadow) { // I dunno. } else { A_SetRenderStyle(0, STYLE_None); } } } } // Acolyte 1 ---------------------------------------------------------------- class AcolyteTan : Acolyte { Default { +MISSILEMORE +MISSILEEVENMORE DropItem "ClipOfBullets"; } } // Acolyte 2 ---------------------------------------------------------------- class AcolyteRed : Acolyte { Default { +MISSILEMORE +MISSILEEVENMORE Translation 0; } } // Acolyte 3 ---------------------------------------------------------------- class AcolyteRust : Acolyte { Default { +MISSILEMORE +MISSILEEVENMORE Translation 1; } } // Acolyte 4 ---------------------------------------------------------------- class AcolyteGray : Acolyte { Default { +MISSILEMORE +MISSILEEVENMORE Translation 2; } } // Acolyte 5 ---------------------------------------------------------------- class AcolyteDGreen : Acolyte { Default { +MISSILEMORE +MISSILEEVENMORE Translation 3; } } // Acolyte 6 ---------------------------------------------------------------- class AcolyteGold : Acolyte { Default { +MISSILEMORE +MISSILEEVENMORE Translation 4; } } // Acolyte 7 ---------------------------------------------------------------- class AcolyteLGreen : Acolyte { Default { Health 60; Translation 5; } } // Acolyte 8 ---------------------------------------------------------------- class AcolyteBlue : Acolyte { Default { Health 60; Translation 6; } } // Shadow Acolyte ----------------------------------------------------------- class AcolyteShadow : Acolyte { Default { +MISSILEMORE DropItem "ClipOfBullets"; } States { See: AGRD A 6 A_BeShadowyFoe; Goto Super::See+1; Pain: AGRD O 0 Fast Slow A_SetShadow; AGRD O 8 Fast Slow A_Pain; Goto See; } } // Some guy turning into an acolyte ----------------------------------------- class AcolyteToBe : Acolyte { Default { Health 61; Radius 20; Height 56; DeathSound "becoming/death"; -COUNTKILL -ISMONSTER } States { Spawn: ARMR A -1; Stop; Pain: ARMR A -1 A_HideDecepticon; Stop; Death: Goto XDeath; } //============================================================================ // // A_HideDecepticon // // Hide the Acolyte-to-be -> // Hide the guy transforming into an Acolyte -> // Hide the transformer -> // Transformers are Autobots and Decepticons, and // Decepticons are the bad guys, so... -> // // Hide the Decepticon! // //============================================================================ void A_HideDecepticon () { Door_Close(999, 64); if (target != null && target.player != null) { SoundAlert (target); } } } extend class Actor { private void CheckStopped() { let player = self.player; if (player && player.mo == self && !(player.cheats & CF_PREDICTING) && Vel == (0, 0, 0)) { player.mo.PlayIdle(); player.Vel = (0, 0); } } //=========================================================================== // // A_Stop // resets all velocity of the actor to 0 // //=========================================================================== void A_Stop() { let player = self.player; Vel = (0, 0, 0); CheckStopped(); } //=========================================================================== // // A_ScaleVelocity // // Scale actor's velocity. // //=========================================================================== void A_ScaleVelocity(double scale, int ptr = AAPTR_DEFAULT) { let ref = GetPointer(ptr); if (ref == NULL) { return; } bool was_moving = ref.Vel != (0, 0, 0); ref.Vel *= scale; // If the actor was previously moving but now is not, and is a player, // update its player variables. (See A_Stop.) if (was_moving) { ref.CheckStopped(); } } //=========================================================================== // // A_ChangeVelocity // //=========================================================================== void A_ChangeVelocity(double x = 0, double y = 0, double z = 0, int flags = 0, int ptr = AAPTR_DEFAULT) { let ref = GetPointer(ptr); if (ref == NULL) { return; } bool was_moving = ref.Vel != (0, 0, 0); let newvel = (x, y, z); double sina = sin(ref.Angle); double cosa = cos(ref.Angle); if (flags & 1) // relative axes - make x, y relative to actor's current angle { newvel.X = x * cosa - y * sina; newvel.Y = x * sina + y * cosa; } if (flags & 2) // discard old velocity - replace old velocity with new velocity { ref.Vel = newvel; } else // add new velocity to old velocity { ref.Vel += newvel; } if (was_moving) { ref.CheckStopped(); } } void A_SpriteOffset(double ox = 0.0, double oy = 0.0) { SpriteOffset.X = ox; SpriteOffset.Y = oy; } } struct FCheckPosition { // in native Actor thing; native Vector3 pos; // out native Sector cursector; native double floorz; native double ceilingz; native double dropoffz; native TextureID floorpic; native int floorterrain; native Sector floorsector; native TextureID ceilingpic; native Sector ceilingsector; native bool touchmidtex; native bool abovemidtex; native bool floatok; native bool FromPMove; native line ceilingline; native Actor stepthing; native bool DoRipping; native bool portalstep; native int portalgroup; native int PushTime; // These are internal helpers to properly initialize an object of this type. private native void _Constructor(); private native void _Destructor(); native void ClearLastRipped(); } struct FLineTraceData { enum ETraceResult { TRACE_HitNone, TRACE_HitFloor, TRACE_HitCeiling, TRACE_HitWall, TRACE_HitActor, TRACE_CrossingPortal, TRACE_HasHitSky }; native Actor HitActor; native Line HitLine; native Sector HitSector; native F3DFloor Hit3DFloor; native TextureID HitTexture; native Vector3 HitLocation; native Vector3 HitDir; native double Distance; native int NumPortals; native int LineSide; native int LinePart; native int SectorPlane; native int HitType; } struct LinkContext { voidptr sector_list; // really msecnode but that's not exported yet. voidptr render_list; } class ViewPosition native { native readonly Vector3 Offset; native readonly int Flags; } class Actor : Thinker native { const DEFAULT_HEALTH = 1000; const ONFLOORZ = -2147483648.0; const ONCEILINGZ = 2147483647.0; const STEEPSLOPE = (46342./65536.); // [RH] Minimum floorplane.c value for walking const FLOATRANDZ = ONCEILINGZ-1; const TELEFRAG_DAMAGE = 1000000; const MinVel = 1./65536; const LARGE_MASS = 10000000; // not INT_MAX on purpose const ORIG_FRICTION = (0xE800/65536.); // original value const ORIG_FRICTION_FACTOR = (2048/65536.); // original value const DEFMORPHTICS = 40 * TICRATE; const MELEEDELTA = 20; // flags are not defined here, the native fields for those get synthesized from the internal tables. // for some comments on these fields, see their native representations in actor.h. native readonly Actor snext; // next in sector list. native PlayerInfo Player; native readonly ViewPosition ViewPos; // Will be null until A_SetViewPos() is called for the first time. native readonly vector3 Pos; native vector3 Prev; native uint ThruBits; native vector2 SpriteOffset; native vector3 WorldOffset; native double spriteAngle; native double spriteRotation; native float VisibleStartAngle; native float VisibleStartPitch; native float VisibleEndAngle; native float VisibleEndPitch; native double Angle; native double Pitch; native double Roll; native vector3 Vel; native double Speed; native double FloatSpeed; native SpriteID sprite; native uint8 frame; native vector2 Scale; native TextureID picnum; native double Alpha; native readonly color fillcolor; // must be set with SetShade to initialize correctly. native Sector CurSector; native double CeilingZ; native double FloorZ; native double DropoffZ; native Sector floorsector; native TextureID floorpic; native int floorterrain; native Sector ceilingsector; native TextureID ceilingpic; native double Height; native readonly double Radius; native readonly double RenderRadius; native double projectilepassheight; native int tics; native readonly State CurState; native readonly int Damage; native int projectilekickback; native int special1; native int special2; native double specialf1; native double specialf2; native int weaponspecial; native int Health; native uint8 movedir; native int8 visdir; native int16 movecount; native int16 strafecount; native Actor Target; native Actor Master; native Actor Tracer; native Actor LastHeard; native Actor LastEnemy; native Actor LastLookActor; native int ReactionTime; native int Threshold; native readonly int DefThreshold; native vector3 SpawnPoint; native uint16 SpawnAngle; native int StartHealth; native uint8 WeaveIndexXY; native uint8 WeaveIndexZ; native uint16 skillrespawncount; native int Args[5]; native int Mass; native int Special; native readonly int TID; native readonly int TIDtoHate; native readonly int WaterLevel; native readonly double WaterDepth; native int Score; native int Accuracy; native int Stamina; native double MeleeRange; native int PainThreshold; native double Gravity; native double FloorClip; native name DamageType; native name DamageTypeReceived; native uint8 FloatBobPhase; native double FloatBobStrength; native int RipperLevel; native int RipLevelMin; native int RipLevelMax; native name Species; native Actor Alternative; native Actor goal; native uint8 MinMissileChance; native int8 LastLookPlayerNumber; native uint SpawnFlags; native double meleethreshold; native double maxtargetrange; native double bouncefactor; native double wallbouncefactor; native int bouncecount; native double friction; native int FastChaseStrafeCount; native double pushfactor; native int lastpush; native int activationtype; native int lastbump; native int DesignatedTeam; native Actor BlockingMobj; native Line BlockingLine; native Line MovementBlockingLine; native Sector Blocking3DFloor; native Sector BlockingCeiling; native Sector BlockingFloor; native int PoisonDamage; native name PoisonDamageType; native int PoisonDuration; native int PoisonPeriod; native int PoisonDamageReceived; native name PoisonDamageTypeReceived; native int PoisonDurationReceived; native int PoisonPeriodReceived; native Actor Poisoner; native Inventory Inv; native uint8 smokecounter; native uint8 FriendPlayer; native uint Translation; native sound AttackSound; native sound DeathSound; native sound SeeSound; native sound PainSound; native sound ActiveSound; native sound UseSound; native sound BounceSound; native sound WallBounceSound; native sound CrushPainSound; native double MaxDropoffHeight; native double MaxStepHeight; native double MaxSlopeSteepness; native int16 PainChance; native name PainType; native name DeathType; native double DamageFactor; native double DamageMultiply; native Class TelefogSourceType; native Class TelefogDestType; native readonly State SpawnState; native readonly State SeeState; native State MeleeState; native State MissileState; native voidptr /*DecalBase*/ DecalGenerator; native uint8 fountaincolor; native double CameraHeight; // Height of camera when used as such native double CameraFOV; native double ViewAngle, ViewPitch, ViewRoll; native double RadiusDamageFactor; // Radius damage factor native double SelfDamageFactor; native double ShadowAimFactor, ShadowPenaltyFactor; native double StealthAlpha; native int WoundHealth; // Health needed to enter wound state native readonly color BloodColor; native readonly int BloodTranslation; native int RenderHidden; native int RenderRequired; native int FriendlySeeBlocks; native int16 lightlevel; native readonly int SpawnTime; private native int InventoryID; // internal counter. native uint freezetics; meta String Obituary; // Player was killed by this actor meta String HitObituary; // Player was killed by this actor in melee meta double DeathHeight; // Height on normal death meta double BurnHeight; // Height on burning death meta int GibHealth; // Negative health below which this monster dies an extreme death meta Sound HowlSound; // Sound being played when electrocuted or poisoned meta Name BloodType; // Blood replacement type meta Name BloodType2; // Bloopsplatter replacement type meta Name BloodType3; // AxeBlood replacement type meta bool DontHurtShooter; meta int ExplosionRadius; meta int ExplosionDamage; meta int MeleeDamage; meta Sound MeleeSound; meta Sound RipSound; meta double MissileHeight; meta Name MissileName; meta double FastSpeed; // speed in fast mode meta Sound PushSound; // Sound being played when pushed by something // todo: implement access to native meta properties. // native meta int infighting_group; // native meta int projectile_group; // native meta int splash_group; Property prefix: none; Property Obituary: Obituary; Property HitObituary: HitObituary; Property MeleeDamage: MeleeDamage; Property MeleeSound: MeleeSound; Property MissileHeight: MissileHeight; Property MissileType: MissileName; Property DontHurtShooter: DontHurtShooter; Property ExplosionRadius: ExplosionRadius; Property ExplosionDamage: ExplosionDamage; //Property BloodType: BloodType, BloodType2, BloodType3; Property FastSpeed: FastSpeed; Property HowlSound: HowlSound; Property GibHealth: GibHealth; Property DeathHeight: DeathHeight; Property BurnHeight: BurnHeight; property Health: health; property WoundHealth: WoundHealth; property ReactionTime: reactiontime; property PainThreshold: PainThreshold; property DamageMultiply: DamageMultiply; property ProjectileKickback: ProjectileKickback; property Speed: speed; property FloatSpeed: FloatSpeed; property Radius: radius; property RenderRadius: RenderRadius; property Height: height; property ProjectilePassHeight: ProjectilePassHeight; property Mass: mass; property XScale: ScaleX; property YScale: ScaleY; property SeeSound: SeeSound; property AttackSound: AttackSound; property BounceSound: BounceSound; property WallBounceSound: WallBounceSound; property PainSound: PainSound; property DeathSound: DeathSound; property ActiveSound: ActiveSound; property CrushPainSound: CrushPainSound; property PushSound: PushSound; property Alpha: Alpha; property MaxTargetRange: MaxTargetRange; property MeleeThreshold: MeleeThreshold; property MeleeRange: MeleeRange; property PushFactor: PushFactor; property BounceCount: BounceCount; property WeaveIndexXY: WeaveIndexXY; property WeaveIndexZ: WeaveIndexZ; property MinMissileChance: MinMissileChance; property MaxStepHeight: MaxStepHeight; property MaxDropoffHeight: MaxDropoffHeight; property MaxSlopeSteepness: MaxSlopeSteepness; property PoisonDamageType: PoisonDamageType; property RadiusDamageFactor: RadiusDamageFactor; property SelfDamageFactor: SelfDamageFactor; property StealthAlpha: StealthAlpha; property CameraHeight: CameraHeight; property CameraFOV: CameraFOV; property VSpeed: velz; property SpriteRotation: SpriteRotation; property VisibleAngles: VisibleStartAngle, VisibleEndAngle; property VisiblePitch: VisibleStartPitch, VisibleEndPitch; property Species: Species; property Accuracy: accuracy; property Stamina: stamina; property TelefogSourceType: TelefogSourceType; property TelefogDestType: TelefogDestType; property Ripperlevel: RipperLevel; property RipLevelMin: RipLevelMin; property RipLevelMax: RipLevelMax; property RipSound: RipSound; property RenderHidden: RenderHidden; property RenderRequired: RenderRequired; property FriendlySeeBlocks: FriendlySeeBlocks; property ThruBits: ThruBits; property LightLevel: LightLevel; property ShadowAimFactor: ShadowAimFactor; property ShadowPenaltyFactor: ShadowPenaltyFactor; // need some definition work first //FRenderStyle RenderStyle; native private int RenderStyle; // This is kept private until its real type has been implemented into the VM. But some code needs to copy this. //int ConversationRoot; // THe root of the current dialogue // deprecated things. native readonly deprecated("2.3", "Use Pos.X instead") double X; native readonly deprecated("2.3", "Use Pos.Y instead") double Y; native readonly deprecated("2.3", "Use Pos.Z instead") double Z; native readonly deprecated("2.3", "Use Vel.X instead") double VelX; native readonly deprecated("2.3", "Use Vel.Y instead") double VelY; native readonly deprecated("2.3", "Use Vel.Z instead") double VelZ; native readonly deprecated("2.3", "Use Vel.X instead") double MomX; native readonly deprecated("2.3", "Use Vel.Y instead") double MomY; native readonly deprecated("2.3", "Use Vel.Z instead") double MomZ; native deprecated("2.3", "Use Scale.X instead") double ScaleX; native deprecated("2.3", "Use Scale.Y instead") double ScaleY; //FStrifeDialogueNode *Conversation; // [RH] The dialogue to show when this actor is used.; Default { LightLevel -1; Scale 1; Health DEFAULT_HEALTH; Reactiontime 8; Radius 20; RenderRadius 0; Height 16; Mass 100; RenderStyle 'Normal'; Alpha 1; MinMissileChance 200; MeleeRange 64 - MELEEDELTA; MaxDropoffHeight 24; MaxStepHeight 24; MaxSlopeSteepness STEEPSLOPE; BounceFactor 0.7; WallBounceFactor 0.75; BounceCount -1; FloatSpeed 4; FloatBobPhase -1; // randomly initialize by default FloatBobStrength 1.0; Gravity 1; Friction 1; DamageFactor 1.0; // damage multiplier as target of damage. DamageMultiply 1.0; // damage multiplier as source of damage. PushFactor 0.25; WeaveIndexXY 0; WeaveIndexZ 16; DesignatedTeam 255; PainType "Normal"; DeathType "Normal"; TeleFogSourceType "TeleportFog"; TeleFogDestType 'TeleportFog'; RipperLevel 0; RipLevelMin 0; RipLevelMax 0; RipSound "misc/ripslop"; DefThreshold 100; BloodType "Blood", "BloodSplatter", "AxeBlood"; ExplosionDamage 128; ExplosionRadius -1; // i.e. use ExplosionDamage value MissileHeight 32; SpriteAngle 0; SpriteRotation 0; StencilColor "00 00 00"; VisibleAngles 0, 0; VisiblePitch 0, 0; DefaultStateUsage SUF_ACTOR|SUF_OVERLAY; CameraHeight int.min; CameraFOV 90.f; FastSpeed -1; RadiusDamageFactor 1; SelfDamageFactor 1; ShadowAimFactor 1; ShadowPenaltyFactor 1; StealthAlpha 0; WoundHealth 6; GibHealth int.min; DeathHeight -1; BurnHeight -1; RenderHidden 0; RenderRequired 0; FriendlySeeBlocks 10; // 10 (blocks) * 128 (one map unit block) } // Functions // 'parked' global functions. native clearscope static double deltaangle(double ang1, double ang2); native clearscope static double absangle(double ang1, double ang2); native clearscope static Vector2 AngleToVector(double angle, double length = 1); native clearscope static Vector2 RotateVector(Vector2 vec, double angle); native clearscope static double Normalize180(double ang); virtual void MarkPrecacheSounds() { MarkSound(SeeSound); MarkSound(AttackSound); MarkSound(PainSound); MarkSound(DeathSound); MarkSound(ActiveSound); MarkSound(UseSound); MarkSound(BounceSound); MarkSound(WallBounceSound); MarkSound(CrushPainSound); MarkSound(HowlSound); MarkSound(MeleeSound); MarkSound(PushSound); } bool IsPointerEqual(int ptr_select1, int ptr_select2) { return GetPointer(ptr_select1) == GetPointer(ptr_select2); } clearscope static double BobSin(double fb) { return sin(fb * (180./32)) * 8; } native clearscope bool isFrozen() const; virtual native void BeginPlay(); virtual native void Activate(Actor activator); virtual native void Deactivate(Actor activator); virtual native int DoSpecialDamage (Actor target, int damage, Name damagetype); virtual native int TakeSpecialDamage (Actor inflictor, Actor source, int damage, Name damagetype); virtual native void Die(Actor source, Actor inflictor, int dmgflags = 0, Name MeansOfDeath = 'none'); virtual native bool Slam(Actor victim); virtual void Touch(Actor toucher) {} virtual native void FallAndSink(double grav, double oldfloorz); private native void Substitute(Actor replacement); native ui void DisplayNameTag(); // Called by inventory items to see if this actor is capable of touching them. // If true, the item will attempt to be picked up. Useful for things like // allowing morphs to pick up limited items such as keys while preventing // them from picking other items up. virtual bool CanTouchItem(Inventory item) { return true; } // Called by PIT_CheckThing to check if two actors actually can collide. virtual bool CanCollideWith(Actor other, bool passive) { return true; } // Called by PIT_CheckLine to check if an actor can cross a line. virtual bool CanCrossLine(Line crossing, Vector3 next) { return true; } // Called by revival/resurrection to check if one can resurrect the other. // "other" can be null when not passive. virtual bool CanResurrect(Actor other, bool passive) { return true; } // Called when an actor is to be reflected by a disc of repulsion. // Returns true to continue normal blast processing. virtual bool SpecialBlastHandling (Actor source, double strength) { return true; } // This is called before a missile gets exploded. virtual int SpecialMissileHit (Actor victim) { return -1; } // This is called when a missile bounces off something. virtual int SpecialBounceHit(Actor bounceMobj, Line bounceLine, SecPlane bouncePlane) { return -1; } // Called when the player presses 'use' and an actor is found, except if the // UseSpecial flag is set. Use level.ExecuteSpecial to call action specials // instead. virtual bool Used(Actor user) { return false; } virtual class GetBloodType(int type) { Class bloodcls; if (type == 0) { bloodcls = BloodType; } else if (type == 1) { bloodcls = BloodType2; } else if (type == 2) { bloodcls = BloodType3; } else { return NULL; } if (bloodcls != NULL) { bloodcls = GetReplacement(bloodcls); } return bloodcls; } virtual int GetGibHealth() { if (GibHealth != int.min) { return -abs(GibHealth); } else { return -int(GetSpawnHealth() * gameinfo.gibfactor); } } virtual double GetDeathHeight() { // [RH] Allow the death height to be overridden using metadata. double metaheight = -1; if (DamageType == 'Fire') { metaheight = BurnHeight; } if (metaheight < 0) { metaheight = DeathHeight; } if (metaheight < 0) { return Height * 0.25; } else { return MAX(metaheight, 0); } } virtual String GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack) { if (mod == 'Telefrag') { return "$OB_MONTELEFRAG"; } else if (mod == 'Melee' && HitObituary.Length() > 0) { return HitObituary; } return Obituary; } virtual int OnDrain(Actor victim, int damage, Name dmgtype) { return damage; } // called on getting a secret, return false to disable default "secret found" message/sound virtual bool OnGiveSecret(bool printmsg, bool playsound) { return true; } // called before and after triggering a teleporter // return false in PreTeleport() to cancel the action early virtual bool PreTeleport( Vector3 destpos, double destangle, int flags ) { return true; } virtual void PostTeleport( Vector3 destpos, double destangle, int flags ) {} native virtual bool OkayToSwitchTarget(Actor other); native clearscope static class GetReplacement(class cls); native clearscope static class GetReplacee(class cls); native static int GetSpriteIndex(name sprt); native clearscope static double GetDefaultSpeed(class type); native static class GetSpawnableType(int spawnnum); native clearscope static int ApplyDamageFactors(class itemcls, Name damagetype, int damage, int defdamage); native void RemoveFromHash(); native void ChangeTid(int newtid); deprecated("3.8", "Use Level.FindUniqueTid() instead") static int FindUniqueTid(int start = 0, int limit = 0) { return level.FindUniqueTid(start, limit); } native void SetShade(color col); native clearscope int GetRenderStyle() const; native clearscope bool CheckKeys(int locknum, bool remote, bool quiet = false); protected native void CheckPortalTransition(bool linked = true); native clearscope string GetTag(string defstr = "") const; native clearscope string GetCharacterName() const; native void SetTag(string defstr = ""); native clearscope double GetBobOffset(double frac = 0) const; native void ClearCounters(); native bool GiveBody (int num, int max=0); native bool HitFloor(); native virtual bool Grind(bool items); native clearscope bool isTeammate(Actor other) const; native clearscope int PlayerNumber() const; native void SetFriendPlayer(PlayerInfo player); native void SoundAlert(Actor target, bool splash = false, double maxdist = 0); native void ClearBounce(); native TerrainDef GetFloorTerrain(); native bool CheckLocalView(int consoleplayer = -1 /* parameter is not used anymore but needed for backward compatibilityö. */); native bool CheckNoDelay(); native bool UpdateWaterLevel (bool splash = true); native bool IsZeroDamage(); native void ClearInterpolation(); native void ClearFOVInterpolation(); native clearscope Vector3 PosRelative(sector sec) const; native void RailAttack(FRailParams p); native void HandleSpawnFlags(); native void ExplodeMissile(line lin = null, Actor target = null, bool onsky = false); native void RestoreDamage(); native clearscope int SpawnHealth() const; virtual clearscope int GetMaxHealth(bool withupgrades = false) const // this only exists to make checks for player health easier so they can avoid the type check and just call this method. { return SpawnHealth(); } native void SetDamage(int dmg); native clearscope double Distance2D(Actor other) const; native clearscope double Distance3D(Actor other) const; native clearscope double Distance2DSquared(Actor other) const; native clearscope double Distance3DSquared(Actor other) const; native void SetOrigin(vector3 newpos, bool moving); native void SetXYZ(vector3 newpos); native clearscope Actor GetPointer(int aaptr); native double BulletSlope(out FTranslatedLineTarget pLineTarget = null, int aimflags = 0); native void CheckFakeFloorTriggers (double oldz, bool oldz_has_viewheight = false); native bool CheckFor3DFloorHit(double z, bool trigger); native bool CheckFor3DCeilingHit(double z, bool trigger); native int CheckMonsterUseSpecials(Line blocking = null); native bool CheckMissileSpawn(double maxdist); native bool CheckPosition(Vector2 pos, bool actorsonly = false, FCheckPosition tm = null); native bool TestMobjLocation(); native static Actor Spawn(class type, vector3 pos = (0,0,0), int replace = NO_REPLACE); native Actor SpawnMissile(Actor dest, class type, Actor owner = null); native Actor SpawnMissileXYZ(Vector3 pos, Actor dest, Class type, bool checkspawn = true, Actor owner = null); native Actor SpawnMissileZ (double z, Actor dest, class type); native Actor SpawnMissileAngleZSpeed (double z, class type, double angle, double vz, double speed, Actor owner = null, bool checkspawn = true); native Actor SpawnMissileZAimed (double z, Actor dest, Class type); native Actor SpawnSubMissile(Class type, Actor target); native Actor, Actor SpawnPlayerMissile(class type, double angle = 1e37, double x = 0, double y = 0, double z = 0, out FTranslatedLineTarget pLineTarget = null, bool nofreeaim = false, bool noautoaim = false, int aimflags = 0); native void SpawnTeleportFog(Vector3 pos, bool beforeTele, bool setTarget); native Actor RoughMonsterSearch(int distance, bool onlyseekable = false, bool frontonly = false, double fov = 0); native clearscope int ApplyDamageFactor(Name damagetype, int damage); native int GetModifiedDamage(Name damagetype, int damage, bool passive, Actor inflictor = null, Actor source = null, int flags = 0); native bool CheckBossDeath(); native bool CheckFov(Actor target, double fov); void A_Light(int extralight) { if (player) player.extralight = clamp(extralight, -20, 20); } void A_Light0() { if (player) player.extralight = 0; } void A_Light1() { if (player) player.extralight = 1; } void A_Light2() { if (player) player.extralight = 2; } void A_LightInverse() { if (player) player.extralight = 0x80000000; } native Actor OldSpawnMissile(Actor dest, class type, Actor owner = null); native Actor SpawnPuff(class pufftype, vector3 pos, double hitdir, double particledir, int updown, int flags = 0, Actor victim = null); native void SpawnBlood (Vector3 pos1, double dir, int damage); native void BloodSplatter (Vector3 pos, double hitangle, bool axe = false); native bool HitWater (sector sec, Vector3 pos, bool checkabove = false, bool alert = true, bool force = false); native void PlaySpawnSound(Actor missile); native clearscope bool CountsAsKill() const; native bool Teleport(Vector3 pos, double angle, int flags); native void TraceBleed(int damage, Actor missile); native void TraceBleedAngle(int damage, double angle, double pitch); native void SetIdle(bool nofunction = false); native bool CheckMeleeRange(double range = -1); native bool TriggerPainChance(Name mod, bool forcedPain = false); native virtual int DamageMobj(Actor inflictor, Actor source, int damage, Name mod, int flags = 0, double angle = 0); native void PoisonMobj (Actor inflictor, Actor source, int damage, int duration, int period, Name type); native double AimLineAttack(double angle, double distance, out FTranslatedLineTarget pLineTarget = null, double vrange = 0., int flags = 0, Actor target = null, Actor friender = null); native Actor, int LineAttack(double angle, double distance, double pitch, int damage, Name damageType, class pufftype, int flags = 0, out FTranslatedLineTarget victim = null, double offsetz = 0., double offsetforward = 0., double offsetside = 0.); native bool LineTrace(double angle, double distance, double pitch, int flags = 0, double offsetz = 0., double offsetforward = 0., double offsetside = 0., out FLineTraceData data = null); native bool CheckSight(Actor target, int flags = 0); native bool IsVisible(Actor other, bool allaround, LookExParams params = null); native bool HitFriend(); native bool MonsterMove(); native SeqNode StartSoundSequenceID (int sequence, int type, int modenum, bool nostop = false); native SeqNode StartSoundSequence (Name seqname, int modenum); native void StopSoundSequence(); native void FindFloorCeiling(int flags = 0); native double, double GetFriction(); native bool, Actor TestMobjZ(bool quick = false); native clearscope static bool InStateSequence(State newstate, State basestate); bool TryWalk () { if (!MonsterMove ()) { return false; } movecount = random[TryWalk](0, 15); return true; } native bool TryMove(vector2 newpos, int dropoff, bool missilecheck = false, FCheckPosition tm = null); native bool CheckMove(vector2 newpos, int flags = 0, FCheckPosition tm = null); native void NewChaseDir(); native void RandomChaseDir(); native bool CheckMissileRange(); native bool SetState(state st, bool nofunction = false); clearscope native state FindState(statelabel st, bool exact = false) const; bool SetStateLabel(statelabel st, bool nofunction = false) { return SetState(FindState(st), nofunction); } native action state ResolveState(statelabel st); // this one, unlike FindState, is context aware. native void LinkToWorld(LinkContext ctx = null); native void UnlinkFromWorld(out LinkContext ctx = null); native bool CanSeek(Actor target); native clearscope double AngleTo(Actor target, bool absolute = false) const; native void AddZ(double zadd, bool moving = true); native void SetZ(double z); native clearscope vector2 Vec2To(Actor other) const; native clearscope vector3 Vec3To(Actor other) const; native clearscope vector3 Vec3Offset(double x, double y, double z, bool absolute = false) const; native clearscope vector3 Vec3Angle(double length, double angle, double z = 0, bool absolute = false) const; native clearscope vector2 Vec2Angle(double length, double angle, bool absolute = false) const; native clearscope vector2 Vec2Offset(double x, double y, bool absolute = false) const; native clearscope vector3 Vec2OffsetZ(double x, double y, double atz, bool absolute = false) const; native double PitchFromVel(); native void VelIntercept(Actor targ, double speed = -1, bool aimpitch = true, bool oldvel = false, bool resetvel = false); native void VelFromAngle(double speed = 1e37, double angle = 1e37); native void Vel3DFromAngle(double speed, double angle, double pitch); native void Thrust(double speed = 1e37, double angle = 1e37); native clearscope bool isFriend(Actor other) const; native clearscope bool isHostile(Actor other) const; native void AdjustFloorClip(); native clearscope DropItem GetDropItems() const; native void CopyFriendliness (Actor other, bool changeTarget, bool resetHealth = true); native bool LookForMonsters(); native bool LookForTid(bool allaround, LookExParams params = null); native bool LookForEnemies(bool allaround, LookExParams params = null); native bool LookForPlayers(bool allaround, LookExParams params = null); native bool TeleportMove(Vector3 pos, bool telefrag, bool modifyactor = true); native clearscope double DistanceBySpeed(Actor other, double speed) const; native name GetSpecies(); native void PlayActiveSound(); native void Howl(); native void DrawSplash (int count, double angle, int kind); native void GiveSecret(bool printmsg = true, bool playsound = true); native clearscope double GetCameraHeight() const; native clearscope double GetGravity() const; native void DoMissileDamage(Actor target); native void PlayPushSound(); native bool BounceActor(Actor blocking, bool onTop); native bool BounceWall(Line l = null); native bool BouncePlane(SecPlane plane); native void PlayBounceSound(bool onFloor); native bool ReflectOffActor(Actor blocking); clearscope double PitchTo(Actor target, double zOfs = 0, double targZOfs = 0, bool absolute = false) const { Vector3 origin = (pos.xy, pos.z - floorClip + zOfs); Vector3 dest = (target.pos.xy, target.pos.z - target.floorClip + targZOfs); Vector3 diff; if (!absolute) diff = level.Vec3Diff(origin, dest); else diff = dest - origin; return -atan2(diff.z, diff.xy.Length()); } //========================================================================== // // AActor :: GetLevelSpawnTime // // Returns the time when this actor was spawned, // relative to the current level. // //========================================================================== clearscope int GetLevelSpawnTime() const { return SpawnTime - level.totaltime + level.time; } //========================================================================== // // AActor :: GetAge // // Returns the number of ticks passed since this actor was spawned. // //========================================================================== clearscope int GetAge() const { return level.totaltime - SpawnTime; } clearscope double AccuracyFactor() const { return 1. / (1 << (accuracy * 5 / 100)); } protected native void DestroyAllInventory(); // This is not supposed to be called by user code! native clearscope Inventory FindInventory(class itemtype, bool subclass = false) const; native Inventory GiveInventoryType(class itemtype); native bool UsePuzzleItem(int PuzzleItemType); action native void SetCamera(Actor cam, bool revert = false); native bool Warp(Actor dest, double xofs = 0, double yofs = 0, double zofs = 0, double angle = 0, int flags = 0, double heightoffset = 0, double radiusoffset = 0, double pitch = 0); // DECORATE compatible functions native double GetZAt(double px = 0, double py = 0, double angle = 0, int flags = 0, int pick_pointer = AAPTR_DEFAULT); native clearscope int GetSpawnHealth() const; native double GetCrouchFactor(int ptr = AAPTR_PLAYER1); native double GetCVar(string cvar); native string GetCVarString(string cvar); native int GetPlayerInput(int inputnum, int ptr = AAPTR_DEFAULT); native int CountProximity(class classname, double distance, int flags = 0, int ptr = AAPTR_DEFAULT); native int GetMissileDamage(int mask, int add, int ptr = AAPTR_DEFAULT); action native int OverlayID(); action native double OverlayX(int layer = 0); action native double OverlayY(int layer = 0); action native double OverlayAlpha(int layer = 0); // DECORATE setters - it probably makes more sense to set these values directly now... void A_SetMass(int newmass) { mass = newmass; } void A_SetInvulnerable() { bInvulnerable = true; } void A_UnSetInvulnerable() { bInvulnerable = false; } void A_SetReflective() { bReflective = true; } void A_UnSetReflective() { bReflective = false; } void A_SetReflectiveInvulnerable() { bInvulnerable = true; bReflective = true; } void A_UnSetReflectiveInvulnerable() { bInvulnerable = false; bReflective = false; } void A_SetShootable() { bShootable = true; bNonShootable = false; } void A_UnSetShootable() { bShootable = false; bNonShootable = true; } void A_NoGravity() { bNoGravity = true; } void A_Gravity() { bNoGravity = false; Gravity = 1; } void A_LowGravity() { bNoGravity = false; Gravity = 0.125; } void A_SetGravity(double newgravity) { gravity = clamp(newgravity, 0., 10.); } void A_SetFloorClip() { bFloorClip = true; AdjustFloorClip(); } void A_UnSetFloorClip() { bFloorClip = false; FloorClip = 0; } void A_HideThing() { bInvisible = true; } void A_UnHideThing() { bInvisible = false; } void A_SetArg(int arg, int val) { if (arg >= 0 && arg < 5) args[arg] = val; } void A_Turn(double turn = 0) { angle += turn; } void A_SetDamageType(name newdamagetype) { damagetype = newdamagetype; } void A_SetSolid() { bSolid = true; } void A_UnsetSolid() { bSolid = false; } void A_SetFloat() { bFloat = true; } void A_UnsetFloat() { bFloat = false; } void A_SetFloatBobPhase(int bob) { if (bob >= 0 && bob <= 63) FloatBobPhase = bob; } void A_SetRipperLevel(int level) { RipperLevel = level; } void A_SetRipMin(int minimum) { RipLevelMin = minimum; } void A_SetRipMax(int maximum) { RipLevelMax = maximum; } void A_ScreamAndUnblock() { A_Scream(); A_NoBlocking(); } void A_ActiveAndUnblock() { A_ActiveSound(); A_NoBlocking(); } //--------------------------------------------------------------------------- // // FUNC P_SpawnMissileAngle // // Returns NULL if the missile exploded immediately, otherwise returns // a mobj_t pointer to the missile. // //--------------------------------------------------------------------------- Actor SpawnMissileAngle (class type, double angle, double vz) { return SpawnMissileAngleZSpeed (pos.z + 32 + GetBobOffset(), type, angle, vz, GetDefaultSpeed (type)); } Actor SpawnMissileAngleZ (double z, class type, double angle, double vz, Actor owner = null) { return SpawnMissileAngleZSpeed (z, type, angle, vz, GetDefaultSpeed (type), owner); } void A_SetScale(double scalex, double scaley = 0, int ptr = AAPTR_DEFAULT, bool usezero = false) { Actor aptr = GetPointer(ptr); if (aptr) { aptr.Scale.X = scalex; aptr.Scale.Y = scaley != 0 || usezero? scaley : scalex; // use scalex here, too, if only one parameter. } } void A_SetSpeed(double speed, int ptr = AAPTR_DEFAULT) { Actor aptr = GetPointer(ptr); if (aptr) aptr.Speed = speed; } void A_SetFloatSpeed(double speed, int ptr = AAPTR_DEFAULT) { Actor aptr = GetPointer(ptr); if (aptr) aptr.FloatSpeed = speed; } void A_SetPainThreshold(int threshold, int ptr = AAPTR_DEFAULT) { Actor aptr = GetPointer(ptr); if (aptr) aptr.PainThreshold = threshold; } bool A_SetSpriteAngle(double angle = 0, int ptr = AAPTR_DEFAULT) { Actor aptr = GetPointer(ptr); if (!aptr) return false; aptr.SpriteAngle = angle; return true; } bool A_SetSpriteRotation(double angle = 0, int ptr = AAPTR_DEFAULT) { Actor aptr = GetPointer(ptr); if (!aptr) return false; aptr.SpriteRotation = angle; return true; } deprecated("2.3", "This function does nothing and is only for Zandronum compatibility") void A_FaceConsolePlayer(double MaxTurnAngle = 0) {} void A_SetSpecial(int spec, int arg0 = 0, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0) { special = spec; args[0] = arg0; args[1] = arg1; args[2] = arg2; args[3] = arg3; args[4] = arg4; } void A_ClearTarget() { target = null; lastheard = null; lastenemy = null; } void A_ChangeLinkFlags(int blockmap = FLAG_NO_CHANGE, int sector = FLAG_NO_CHANGE) { UnlinkFromWorld(); if (blockmap != FLAG_NO_CHANGE) bNoBlockmap = blockmap; if (sector != FLAG_NO_CHANGE) bNoSector = sector; LinkToWorld(); } // killough 11/98: kill an object void A_Die(name damagetype = "none") { DamageMobj(null, null, health, damagetype, DMG_FORCED); } void SpawnDirt (double radius) { static const class chunks[] = { "Dirt1", "Dirt2", "Dirt3", "Dirt4", "Dirt5", "Dirt6" }; double zo = random[Dirt]() / 128. + 1; Vector3 pos = Vec3Angle(radius, random[Dirt]() * (360./256), zo); Actor mo = Spawn (chunks[random[Dirt](0, 5)], pos, ALLOW_REPLACE); if (mo) { mo.Vel.Z = random[Dirt]() / 64.; } } // // A_SinkMobj // Sink a mobj incrementally into the floor // bool SinkMobj (double speed) { if (Floorclip < Height) { Floorclip += speed; return false; } return true; } // // A_RaiseMobj // Raise a mobj incrementally from the floor to // bool RaiseMobj (double speed) { // Raise a mobj from the ground if (Floorclip > 0) { Floorclip -= speed; if (Floorclip <= 0) { Floorclip = 0; return true; } else { return false; } } return true; } Actor AimTarget() { FTranslatedLineTarget t; BulletSlope(t, ALF_PORTALRESTRICT); return t.linetarget; } void RestoreRenderStyle() { bShadow = default.bShadow; bGhost = default.bGhost; RenderStyle = default.RenderStyle; Alpha = default.Alpha; } virtual bool ShouldSpawn() { return true; } native void A_Face(Actor faceto, double max_turn = 0, double max_pitch = 270, double ang_offset = 0, double pitch_offset = 0, int flags = 0, double z_ofs = 0); void A_FaceTarget(double max_turn = 0, double max_pitch = 270, double ang_offset = 0, double pitch_offset = 0, int flags = 0, double z_ofs = 0) { A_Face(target, max_turn, max_pitch, ang_offset, pitch_offset, flags, z_ofs); } void A_FaceTracer(double max_turn = 0, double max_pitch = 270, double ang_offset = 0, double pitch_offset = 0, int flags = 0, double z_ofs = 0) { A_Face(tracer, max_turn, max_pitch, ang_offset, pitch_offset, flags, z_ofs); } void A_FaceMaster(double max_turn = 0, double max_pitch = 270, double ang_offset = 0, double pitch_offset = 0, int flags = 0, double z_ofs = 0) { A_Face(master, max_turn, max_pitch, ang_offset, pitch_offset, flags, z_ofs); } // Action functions // Meh, MBF redundant functions. Only for DeHackEd support. native bool A_LineEffect(int boomspecial = 0, int tag = 0); // End of MBF redundant functions. native void A_MonsterRail(); native void A_Pain(); native void A_NoBlocking(bool drop = true); void A_Fall() { A_NoBlocking(); } native void A_Look(); native void A_Chase(statelabel melee = '_a_chase_default', statelabel missile = '_a_chase_default', int flags = 0); native void A_VileChase(); native bool A_CheckForResurrection(State state = null, Sound snd = 0); native void A_BossDeath(); bool A_CallSpecial(int special, int arg1=0, int arg2=0, int arg3=0, int arg4=0, int arg5=0) { return Level.ExecuteSpecial(special, self, null, false, arg1, arg2, arg3, arg4, arg5); } native void A_FastChase(); native void A_PlayerScream(); native void A_CheckTerrain(); native void A_Wander(int flags = 0); native void A_Look2(); deprecated("2.3", "Use A_CustomBulletAttack() instead") native void A_BulletAttack(); native void A_WolfAttack(int flags = 0, sound whattoplay = "weapons/pistol", double snipe = 1.0, int maxdamage = 64, int blocksize = 128, int pointblank = 2, int longrange = 4, double runspeed = 160.0, class pufftype = "BulletPuff"); deprecated("4.3", "Use A_StartSound() instead") native clearscope void A_PlaySound(sound whattoplay = "weapons/pistol", int slot = CHAN_BODY, double volume = 1.0, bool looping = false, double attenuation = ATTN_NORM, bool local = false, double pitch = 0.0); native clearscope void A_StartSound(sound whattoplay, int slot = CHAN_BODY, int flags = 0, double volume = 1.0, double attenuation = ATTN_NORM, double pitch = 0.0, double startTime = 0.0); native clearscope void A_StartSoundIfNotSame(sound whattoplay, sound checkagainst, int slot = CHAN_BODY, int flags = 0, double volume = 1.0, double attenuation = ATTN_NORM, double pitch = 0.0, double startTime = 0.0); native void A_SoundVolume(int slot, double volume); native void A_SoundPitch(int slot, double pitch); deprecated("2.3", "Use A_StartSound(, CHAN_WEAPON) instead") void A_PlayWeaponSound(sound whattoplay, bool fullvol = false) { A_StartSound(whattoplay, CHAN_WEAPON, 0, 1, fullvol? ATTN_NONE : ATTN_NORM); } native void A_StopSound(int slot = CHAN_VOICE); // Bad default but that's what is originally was... void A_StopAllSounds() { A_StopSounds(0,0); } native void A_StopSounds(int chanmin, int chanmax); deprecated("2.3", "Use A_StartSound() instead") native void A_PlaySoundEx(sound whattoplay, name slot, bool looping = false, int attenuation = 0); deprecated("2.3", "Use A_StopSound() instead") native void A_StopSoundEx(name slot); native clearscope bool IsActorPlayingSound(int channel, Sound snd = -1); native void A_SeekerMissile(int threshold, int turnmax, int flags = 0, int chance = 50, int distance = 10); native action state A_Jump(int chance, statelabel label, ...); native Actor A_SpawnProjectile(class missiletype, double spawnheight = 32, double spawnofs_xy = 0, double angle = 0, int flags = 0, double pitch = 0, int ptr = AAPTR_TARGET); native void A_CustomRailgun(int damage, int spawnofs_xy = 0, color color1 = 0, color color2 = 0, int flags = 0, int aim = 0, double maxdiff = 0, class pufftype = "BulletPuff", double spread_xy = 0, double spread_z = 0, double range = 0, int duration = 0, double sparsity = 1.0, double driftspeed = 1.0, class spawnclass = null, double spawnofs_z = 0, int spiraloffset = 270, int limit = 0, double veleffect = 3); native void A_Print(string whattoprint, double time = 0, name fontname = "none"); native void A_PrintBold(string whattoprint, double time = 0, name fontname = "none"); native void A_Log(string whattoprint, bool local = false); native void A_LogInt(int whattoprint, bool local = false); native void A_LogFloat(double whattoprint, bool local = false); native void A_SetTranslucent(double alpha, int style = 0); native void A_SetRenderStyle(double alpha, int style); native void A_FadeIn(double reduce = 0.1, int flags = 0); native void A_FadeOut(double reduce = 0.1, int flags = 1); //bool remove == true native void A_FadeTo(double target, double amount = 0.1, int flags = 0); native void A_SpawnDebris(class spawntype, bool transfer_translation = false, double mult_h = 1, double mult_v = 1); native void A_SpawnParticle(color color1, int flags = 0, int lifetime = TICRATE, double size = 1, double angle = 0, double xoff = 0, double yoff = 0, double zoff = 0, double velx = 0, double vely = 0, double velz = 0, double accelx = 0, double accely = 0, double accelz = 0, double startalphaf = 1, double fadestepf = -1, double sizestep = 0); native void A_SpawnParticleEx(color color1, TextureID texture, int style = STYLE_None, int flags = 0, int lifetime = TICRATE, double size = 1, double angle = 0, double xoff = 0, double yoff = 0, double zoff = 0, double velx = 0, double vely = 0, double velz = 0, double accelx = 0, double accely = 0, double accelz = 0, double startalphaf = 1, double fadestepf = -1, double sizestep = 0, double startroll = 0, double rollvel = 0, double rollacc = 0); native void A_ExtChase(bool usemelee, bool usemissile, bool playactive = true, bool nightmarefast = false); native void A_DropInventory(class itemtype, int amount = -1); native void A_SetBlend(color color1, double alpha, int tics, color color2 = 0, double alpha2 = 0.); deprecated("2.3", "Use 'b = [true/false]' instead") native void A_ChangeFlag(string flagname, bool value); native void A_ChangeCountFlags(int kill = FLAG_NO_CHANGE, int item = FLAG_NO_CHANGE, int secret = FLAG_NO_CHANGE); action native void A_ChangeModel(name modeldef, int modelindex = 0, string modelpath = "", name model = "", int skinindex = 0, string skinpath = "", name skin = "", int flags = 0, int generatorindex = -1, int animationindex = 0, string animationpath = "", name animation = ""); void A_SetFriendly (bool set) { if (CountsAsKill() && health > 0) level.total_monsters--; bFriendly = set; if (CountsAsKill() && health > 0) level.total_monsters++; } native void A_RaiseMaster(int flags = 0); native void A_RaiseChildren(int flags = 0); native void A_RaiseSiblings(int flags = 0); native bool A_RaiseSelf(int flags = 0); native bool RaiseActor(Actor other, int flags = 0); native bool CanRaise(); native void Revive(); native void A_Weave(int xspeed, int yspeed, double xdist, double ydist); action native state, bool A_Teleport(statelabel teleportstate = null, class targettype = "BossSpot", class fogtype = "TeleportFog", int flags = 0, double mindist = 128, double maxdist = 0, int ptr = AAPTR_DEFAULT); action native state, bool A_Warp(int ptr_destination, double xofs = 0, double yofs = 0, double zofs = 0, double angle = 0, int flags = 0, statelabel success_state = null, double heightoffset = 0, double radiusoffset = 0, double pitch = 0); native void A_CountdownArg(int argnum, statelabel targstate = null); native state A_MonsterRefire(int chance, statelabel label); native void A_LookEx(int flags = 0, double minseedist = 0, double maxseedist = 0, double maxheardist = 0, double fov = 0, statelabel label = null); native void A_Recoil(double xyvel); native int A_RadiusGive(class itemtype, double distance, int flags, int amount = 0, class filter = null, name species = "None", double mindist = 0, int limit = 0); native void A_CustomMeleeAttack(int damage = 0, sound meleesound = "", sound misssound = "", name damagetype = "none", bool bleed = true); native void A_CustomComboAttack(class missiletype, double spawnheight, int damage, sound meleesound = "", name damagetype = "none", bool bleed = true); native void A_Burst(class chunktype); native void A_RadiusDamageSelf(int damage = 128, double distance = 128, int flags = 0, class flashtype = null); native int GetRadiusDamage(Actor thing, int damage, int distance, int fulldmgdistance = 0, bool oldradiusdmg = false, bool circular = false); native int RadiusAttack(Actor bombsource, int bombdamage, int bombdistance, Name bombmod = 'none', int flags = RADF_HURTSOURCE, int fulldamagedistance = 0, name species = "None"); native void A_Respawn(int flags = 1); native void A_RestoreSpecialPosition(); native void A_QueueCorpse(); native void A_DeQueueCorpse(); native void A_ClearLastHeard(); native void A_ClassBossHealth(); native void A_SetAngle(double angle = 0, int flags = 0, int ptr = AAPTR_DEFAULT); native void A_SetPitch(double pitch, int flags = 0, int ptr = AAPTR_DEFAULT); native void A_SetRoll(double roll, int flags = 0, int ptr = AAPTR_DEFAULT); native void A_SetViewAngle(double angle = 0, int flags = 0, int ptr = AAPTR_DEFAULT); native void A_SetViewPitch(double pitch, int flags = 0, int ptr = AAPTR_DEFAULT); native void A_SetViewRoll(double roll, int flags = 0, int ptr = AAPTR_DEFAULT); native void SetViewPos(Vector3 offset, int flags = -1); deprecated("2.3", "User variables are deprecated in ZScript. Actor variables are directly accessible") native void A_SetUserVar(name varname, int value); deprecated("2.3", "User variables are deprecated in ZScript. Actor variables are directly accessible") native void A_SetUserArray(name varname, int index, int value); deprecated("2.3", "User variables are deprecated in ZScript. Actor variables are directly accessible") native void A_SetUserVarFloat(name varname, double value); deprecated("2.3", "User variables are deprecated in ZScript. Actor variables are directly accessible") native void A_SetUserArrayFloat(name varname, int index, double value); native void A_Quake(double intensity, int duration, int damrad, int tremrad, sound sfx = "world/quake"); native void A_QuakeEx(double intensityX, double intensityY, double intensityZ, int duration, int damrad, int tremrad, sound sfx = "world/quake", int flags = 0, double mulWaveX = 1, double mulWaveY = 1, double mulWaveZ = 1, int falloff = 0, int highpoint = 0, double rollIntensity = 0, double rollWave = 0, double damageMultiplier = 1, double thrustMultiplier = 0.5, int damage = 0); action native void A_SetTics(int tics); native void A_DamageSelf(int amount, name damagetype = "none", int flags = 0, class filter = null, name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); native void A_DamageTarget(int amount, name damagetype = "none", int flags = 0, class filter = null, name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); native void A_DamageMaster(int amount, name damagetype = "none", int flags = 0, class filter = null, name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); native void A_DamageTracer(int amount, name damagetype = "none", int flags = 0, class filter = null, name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); native void A_DamageChildren(int amount, name damagetype = "none", int flags = 0, class filter = null, name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); native void A_DamageSiblings(int amount, name damagetype = "none", int flags = 0, class filter = null, name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); native void A_KillTarget(name damagetype = "none", int flags = 0, class filter = null, name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); native void A_KillMaster(name damagetype = "none", int flags = 0, class filter = null, name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); native void A_KillTracer(name damagetype = "none", int flags = 0, class filter = null, name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); native void A_KillChildren(name damagetype = "none", int flags = 0, class filter = null, name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); native void A_KillSiblings(name damagetype = "none", int flags = 0, class filter = null, name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); native void A_RemoveTarget(int flags = 0, class filter = null, name species = "None"); native void A_RemoveMaster(int flags = 0, class filter = null, name species = "None"); native void A_RemoveTracer(int flags = 0, class filter = null, name species = "None"); native void A_RemoveChildren(bool removeall = false, int flags = 0, class filter = null, name species = "None"); native void A_RemoveSiblings(bool removeall = false, int flags = 0, class filter = null, name species = "None"); native void A_Remove(int removee, int flags = 0, class filter = null, name species = "None"); native void A_SetTeleFog(class oldpos, class newpos); native void A_SwapTeleFog(); native void A_SetHealth(int health, int ptr = AAPTR_DEFAULT); native void A_ResetHealth(int ptr = AAPTR_DEFAULT); native void A_SetSpecies(name species, int ptr = AAPTR_DEFAULT); native void A_SetChaseThreshold(int threshold, bool def = false, int ptr = AAPTR_DEFAULT); native bool A_FaceMovementDirection(double offset = 0, double anglelimit = 0, double pitchlimit = 0, int flags = 0, int ptr = AAPTR_DEFAULT); native int A_ClearOverlays(int sstart = 0, int sstop = 0, bool safety = true); native bool A_CopySpriteFrame(int from, int to, int flags = 0); native bool A_SetVisibleRotation(double anglestart = 0, double angleend = 0, double pitchstart = 0, double pitchend = 0, int flags = 0, int ptr = AAPTR_DEFAULT); native void A_SetTranslation(name transname); native bool A_SetSize(double newradius = -1, double newheight = -1, bool testpos = false); native void A_SprayDecal(String name, double dist = 172, vector3 offset = (0, 0, 0), vector3 direction = (0, 0, 0), bool useBloodColor = false, color decalColor = 0); native void A_SetMugshotState(String name); native void CopyBloodColor(Actor other); native void A_RearrangePointers(int newtarget, int newmaster = AAPTR_DEFAULT, int newtracer = AAPTR_DEFAULT, int flags=0); native void A_TransferPointer(int ptr_source, int ptr_recipient, int sourcefield, int recipientfield=AAPTR_DEFAULT, int flags=0); native void A_CopyFriendliness(int ptr_source = AAPTR_MASTER); action native bool A_Overlay(int layer, statelabel start = null, bool nooverride = false); native void A_WeaponOffset(double wx = 0, double wy = 32, int flags = 0); action native void A_OverlayScale(int layer, double wx = 1, double wy = 0, int flags = 0); action native void A_OverlayRotate(int layer, double degrees = 0, int flags = 0); action native void A_OverlayPivot(int layer, double wx = 0.5, double wy = 0.5, int flags = 0); action native void A_OverlayPivotAlign(int layer, int halign, int valign); action native void A_OverlayVertexOffset(int layer, int index, double x, double y, int flags = 0); action native void A_OverlayOffset(int layer = PSP_WEAPON, double wx = 0, double wy = 32, int flags = 0); action native void A_OverlayFlags(int layer, int flags, bool set); action native void A_OverlayAlpha(int layer, double alph); action native void A_OverlayRenderStyle(int layer, int style); action native void A_OverlayTranslation(int layer, name trname); native bool A_AttachLightDef(Name lightid, Name lightdef); native bool A_AttachLight(Name lightid, int type, Color lightcolor, int radius1, int radius2, int flags = 0, Vector3 ofs = (0,0,0), double param = 0, double spoti = 10, double spoto = 25, double spotp = 0); native bool A_RemoveLight(Name lightid); int ACS_NamedExecute(name script, int mapnum=0, int arg1=0, int arg2=0, int arg3=0) { return ACS_Execute(-int(script), mapnum, arg1, arg2, arg3); } int ACS_NamedSuspend(name script, int mapnum=0) { return ACS_Suspend(-int(script), mapnum); } int ACS_NamedTerminate(name script, int mapnum=0) { return ACS_Terminate(-int(script), mapnum); } int ACS_NamedLockedExecute(name script, int mapnum=0, int arg1=0, int arg2=0, int lock=0) { return ACS_LockedExecute(-int(script), mapnum, arg1, arg2, lock); } int ACS_NamedLockedExecuteDoor(name script, int mapnum=0, int arg1=0, int arg2=0, int lock=0) { return ACS_LockedExecuteDoor(-int(script), mapnum, arg1, arg2, lock); } int ACS_NamedExecuteWithResult(name script, int arg1=0, int arg2=0, int arg3=0, int arg4=0) { return ACS_ExecuteWithResult(-int(script), arg1, arg2, arg3, arg4); } int ACS_NamedExecuteAlways(name script, int mapnum=0, int arg1=0, int arg2=0, int arg3=0) { return ACS_ExecuteAlways(-int(script), mapnum, arg1, arg2, arg3); } int ACS_ScriptCall(name script, int arg1=0, int arg2=0, int arg3=0, int arg4=0) { return ACS_ExecuteWithResult(-int(script), arg1, arg2, arg3, arg4); } //=========================================================================== // // Sounds // //=========================================================================== void A_Scream() { if (DeathSound) { A_StartSound(DeathSound, CHAN_VOICE, CHANF_DEFAULT, 1, bBoss || bFullvolDeath? ATTN_NONE : ATTN_NORM); } } void A_XScream() { A_StartSound(player? Sound("*gibbed") : Sound("misc/gibbed"), CHAN_VOICE); } void A_ActiveSound() { if (ActiveSound) { A_StartSound(ActiveSound, CHAN_VOICE); } } virtual void PlayerLandedMakeGruntSound(actor onmobj) { bool grunted; // [RH] only make noise if alive if (self.health > 0 && self.player.morphTics == 0) { grunted = false; // Why should this number vary by gravity? if (self.Vel.Z < -self.player.mo.GruntSpeed) { A_StartSound("*grunt", CHAN_VOICE); grunted = true; } bool isliquid = (pos.Z <= floorz) && HitFloor (); if (onmobj != NULL || !isliquid) { if (!grunted) { A_StartSound("*land", CHAN_AUTO); } else { A_StartSoundIfNotSame("*land", "*grunt", CHAN_AUTO); } } } } //---------------------------------------------------------------------------- // // PROC A_CheckSkullDone // //---------------------------------------------------------------------------- void A_CheckPlayerDone() { if (player == NULL) Destroy(); } States(Actor, Overlay, Weapon, Item) { Spawn: TNT1 A -1; Stop; Null: TNT1 A 1; Stop; GenericFreezeDeath: // Generic freeze death frames. Woo! #### # 5 A_GenericFreezeDeath; ---- A 1 A_FreezeDeathChunks; Wait; GenericCrush: POL5 A -1; Stop; DieFromSpawn: TNT1 A 1; TNT1 A 1 { self.Die(null, null); } } // Internal functions deprecated("2.3") private native int __decorate_internal_int__(int i); deprecated("2.3") private native bool __decorate_internal_bool__(bool b); deprecated("2.3") private native double __decorate_internal_float__(double f); } // Alien Spectre 1 ----------------------------------------------------------- class AlienSpectre1 : SpectralMonster { Default { Health 1000; Painchance 250; Speed 12; Radius 64; Height 64; FloatSpeed 5; Mass 1000; MinMissileChance 150; RenderStyle "Translucent"; Alpha 0.666; Tag "$TAG_ALIENSPECTRE"; SeeSound "alienspectre/sight"; AttackSound "alienspectre/blade"; PainSound "alienspectre/pain"; DeathSound "alienspectre/death"; ActiveSound "alienspectre/active"; Obituary "$OB_ALIENSPECTRE"; +NOGRAVITY +FLOAT +SHADOW +NOTDMATCH +DONTMORPH +NOBLOCKMONST +INCOMBAT +LOOKALLAROUND +NOICEDEATH } States { Spawn: ALN1 A 10 A_Look; ALN1 B 10 A_SentinelBob; Loop; See: ALN1 AB 4 Bright A_Chase; ALN1 C 4 Bright A_SentinelBob; ALN1 DEF 4 Bright A_Chase; ALN1 G 4 Bright A_SentinelBob; ALN1 HIJ 4 Bright A_Chase; ALN1 K 4 Bright A_SentinelBob; Loop; Melee: ALN1 J 4 Bright A_FaceTarget; ALN1 I 4 Bright A_CustomMeleeAttack((random[SpectreMelee](0,255)&9)*5); ALN1 H 4 Bright; Goto See; Missile: ALN1 J 4 Bright A_FaceTarget; ALN1 I 4 Bright A_SpotLightning; ALN1 H 4 Bright; Goto See+10; Pain: ALN1 J 2 A_Pain; Goto See+6; Death: AL1P A 6 Bright A_SpectreChunkSmall; AL1P B 6 Bright A_Scream; AL1P C 6 Bright A_SpectreChunkSmall; AL1P DE 6 Bright; AL1P F 6 Bright A_SpectreChunkSmall; AL1P G 6 Bright; AL1P H 6 Bright A_SpectreChunkSmall; AL1P IJK 6 Bright; AL1P LM 5 Bright; AL1P N 5 Bright A_SpectreChunkLarge; AL1P OPQ 5 Bright; AL1P R 5 Bright A_AlienSpectreDeath; Stop; } //============================================================================ void A_AlienSpectreDeath () { PlayerPawn player = null; int log = 0; A_NoBlocking(); // [RH] Need this for Sigil rewarding if (!CheckBossDeath ()) { return; } for (int i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i] && players[i].health > 0) { player = players[i].mo; break; } } if (player == null) { return; } class cls = GetClass(); if (cls == "AlienSpectre1") { Floor_LowerToLowest(999, 8); log = 95; } else if (cls == "AlienSpectre2") { Console.MidPrint(null, "$TXT_KILLED_BISHOP"); log = 74; player.GiveInventoryType ("QuestItem21"); } else if (cls == "AlienSpectre3") { Console.MidPrint(null, "$TXT_KILLED_ORACLE"); // If there are any Oracles still alive, kill them. ThinkerIterator it = ThinkerIterator.Create("Oracle"); Actor oracle; while ( (oracle = Actor(it.Next())) != null) { if (oracle.health > 0) { oracle.health = 0; oracle.Die (self, self); } } player.GiveInventoryType ("QuestItem23"); if (player.FindInventory ("QuestItem21")) { // If the Bishop is dead, set quest item 22 player.GiveInventoryType ("QuestItem22"); } if (player.FindInventory ("QuestItem24") == null) { // Macil is calling us back... log = 87; } else { // You wield the power of the complete Sigil. log = 85; } Door_Open(222, 64); } else if (cls == "AlienSpectre4") { Console.MidPrint(null, "$TXT_KILLED_MACIL"); player.GiveInventoryType ("QuestItem24"); if (player.FindInventory ("QuestItem25") == null) { // Richter has taken over. Macil is a snake. log = 79; } else { // Back to the factory for another Sigil! log = 106; } } else if (cls == "AlienSpectre5") { Console.MidPrint(null, "$TXT_KILLED_LOREMASTER"); player.GiveInventoryType ("QuestItem26"); if (!multiplayer) { player.GiveInventoryType ("UpgradeStamina"); player.GiveInventoryType ("UpgradeAccuracy"); } Sigil sigl = Sigil(player.FindInventory("Sigil")); if (sigl != null && sigl.health == 5) { // You wield the power of the complete Sigil. log = 85; } else { // Another Sigil piece. Woohoo! log = 83; } Floor_LowerToLowest(666, 8); } if (log > 0) { String voc = "svox/voc" .. log; A_StartSound(voc, CHAN_VOICE, CHANF_DEFAULT, 1., ATTN_NONE); player.player.SetLogNumber (log); player.player.SetSubtitleNumber (log, voc); } } } // Alien Spectre 2 ----------------------------------------------------------- class AlienSpectre2 : AlienSpectre1 { Default { Health 1200; Painchance 50; Radius 24; DropItem "Sigil2"; } States { Missile: ALN1 F 4 A_FaceTarget; ALN1 I 4 A_SpawnProjectile("SpectralLightningH3", 32, 0); ALN1 E 4; Goto See+10; } } // Alien Spectre 3 ---------------------------------------------------------- // This is the Oracle's personal spectre, so it's a little different. class AlienSpectre3 : AlienSpectre1 { Default { Health 1500; Painchance 50; Radius 24; +SPAWNCEILING DropItem "Sigil3"; DamageFactor "SpectralLow", 0; } States { Spawn: ALN1 ABCDEFGHIJK 5; Loop; See: ALN1 AB 5 A_Chase; ALN1 C 5 A_SentinelBob; ALN1 DEF 5 A_Chase; ALN1 G 5 A_SentinelBob; ALN1 HIJ 5 A_Chase; ALN1 K 5 A_SentinelBob; Loop; Melee: ALN1 J 4 A_FaceTarget; ALN1 I 4 A_CustomMeleeAttack((random[SpectreMelee](0,255)&9)*5); ALN1 C 4; Goto See+2; Missile: ALN1 F 4 A_FaceTarget; ALN1 I 4 A_Spectre3Attack; ALN1 E 4; Goto See+10; Pain: ALN1 J 2 A_Pain; Goto See+6; } } // Alien Spectre 4 ----------------------------------------------------------- class AlienSpectre4 : AlienSpectre1 { Default { Health 1700; Painchance 50; Radius 24; DropItem "Sigil4"; } States { Missile: ALN1 F 4 A_FaceTarget; ALN1 I 4 A_SpawnProjectile("SpectralLightningBigV2", 32, 0); ALN1 E 4; Goto See+10; } } // Alien Spectre 5 ----------------------------------------------------------- class AlienSpectre5 : AlienSpectre1 { Default { Health 2000; Painchance 50; Radius 24; DropItem "Sigil5"; } States { Missile: ALN1 F 4 A_FaceTarget; ALN1 I 4 A_SpawnProjectile("SpectralLightningBigBall2", 32, 0); ALN1 E 4; Goto See+10; } } // Small Alien Chunk -------------------------------------------------------- class AlienChunkSmall : Actor { Default { +NOBLOCKMAP +NOCLIP } States { Spawn: NODE ABCDEFG 6 Bright; Stop; } } // Large Alien Chunk -------------------------------------------------------- class AlienChunkLarge : Actor { Default { +NOBLOCKMAP +NOCLIP } States { Spawn: MTHD ABCDEFGHIJK 5 Bright; Stop; } } /* ** Enhanced heads up 'overlay' for fullscreen ** **--------------------------------------------------------------------------- ** Copyright 2003-2008 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ class AltHud ui { TextureID tnt1a0; TextureID invgem_left, invgem_right; TextureID fragpic; int hudwidth, hudheight; int statspace; Font HudFont; // The font for the health and armor display Font IndexFont; // The font for the inventory indices Array< Class > orderedammos; const POWERUPICONSIZE = 32; virtual void Init() { switch (gameinfo.gametype) { case GAME_Heretic: case GAME_Hexen: HudFont = Font.FindFont("HUDFONT_RAVEN"); break; case GAME_Strife: HudFont = BigFont; // Strife doesn't have anything nice so use the standard font break; default: HudFont = Font.FindFont("HUDFONT_DOOM"); break; } IndexFont = Font.GetFont("INDEXFONT"); if (HudFont == NULL) HudFont = BigFont; if (IndexFont == NULL) IndexFont = ConFont; // Emergency fallback invgem_left = TexMan.CheckForTexture("INVGEML1", TexMan.Type_MiscPatch); invgem_right = TexMan.CheckForTexture("INVGEMR1", TexMan.Type_MiscPatch); tnt1a0 = TexMan.CheckForTexture("TNT1A0", TexMan.Type_Sprite); fragpic = TexMan.CheckForTexture("HU_FRAGS", TexMan.Type_MiscPatch); statspace = SmallFont.StringWidth("Ac:"); } //--------------------------------------------------------------------------- // // Draws an image into a box with its bottom center at the bottom // center of the box. The image is scaled down if it doesn't fit // //--------------------------------------------------------------------------- void DrawImageToBox(TextureID tex, int x, int y, int w, int h, double trans = 0.75, bool animate = false) { double scale1, scale2; if (tex) { let texsize = TexMan.GetScaledSize(tex); if (w < texsize.X) scale1 = w / texsize.X; else scale1 = 1.0; if (h < texsize.Y) scale2 = h / texsize.Y; else scale2 = 1.0; scale1 = min(scale1, scale2); if (scale2 < scale1) scale1=scale2; x += w >> 1; y += h; w = (int)(texsize.X * scale1); h = (int)(texsize.Y * scale1); screen.DrawTexture(tex, animate, x, y, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, trans, DTA_DestWidth, w, DTA_DestHeight, h, DTA_CenterBottomOffset, 1); } } //--------------------------------------------------------------------------- // // Draws a text but uses a fixed width for all characters // //--------------------------------------------------------------------------- void DrawHudText(Font fnt, int color, String text, int x, int y, double trans = 0.75) { int zerowidth = fnt.GetCharWidth("0"); screen.DrawText(fnt, color, x, y-fnt.GetHeight(), text, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_KeepRatio, true, DTA_Alpha, trans, DTA_Monospace, MONO_CellCenter, DTA_Spacing, zerowidth); } //--------------------------------------------------------------------------- // // Draws a number with a fixed width for all digits // //--------------------------------------------------------------------------- void DrawHudNumber(Font fnt, int color, int num, int x, int y, double trans = 0.75) { DrawHudText(fnt, color, String.Format("%d", num), x, y, trans); } //--------------------------------------------------------------------------- // // Draws a time string as hh:mm:ss // //--------------------------------------------------------------------------- virtual void DrawTimeString(Font fnt, int color, int timer, int x, int y, double trans = 0.75) { let seconds = Thinker.Tics2Seconds(timer); String s = String.Format("%02i:%02i:%02i", seconds / 3600, (seconds % 3600) / 60, seconds % 60); int length = 8 * fnt.GetCharWidth("0"); DrawHudText(fnt, color, s, x-length, y, trans); } //=========================================================================== // // draw the status (number of kills etc) // //=========================================================================== virtual void DrawStatLine(int x, in out int y, String prefix, String text) { y -= SmallFont.GetHeight()-1; screen.DrawText(SmallFont, hudcolor_statnames, x, y, prefix, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0.75); screen.DrawText(SmallFont, hudcolor_stats, x+statspace, y, text, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0.75); } virtual void DrawStatus(PlayerInfo CPlayer, int x, int y) { let mo = CPlayer.mo; if (hud_showscore) { DrawStatLine(x, y, "Sc:", String.Format("%d ", mo.Score)); } if (hud_showstats) { DrawStatLine(x, y, "Ac:", String.Format("%i ", mo.accuracy)); DrawStatLine(x, y, "St:", String.Format("%i ", mo.stamina)); } if (!deathmatch) { if (hud_showsecrets) { DrawStatLine(x, y, "S:", multiplayer ? String.Format("%i/%i/%i ", CPlayer.secretcount, Level.found_secrets, Level.total_secrets) : String.Format("%i/%i ", Level.found_secrets, Level.total_secrets)); } if (hud_showitems) { DrawStatLine(x, y, "I:", multiplayer ? String.Format("%i/%i/%i ", CPlayer.itemcount, Level.found_items, Level.total_items) : String.Format("%i/%i ", Level.found_items, Level.total_items)); } if (hud_showmonsters) { DrawStatLine(x, y, "K:", multiplayer ? String.Format("%i/%i/%i ", CPlayer.killcount, Level.killed_monsters, Level.total_monsters) : String.Format("%i/%i ", Level.killed_monsters, Level.total_monsters)); } if (hud_showtimestat) { String s; let seconds = Thinker.Tics2Seconds(level.time); if (seconds >= 3600) s = String.Format("%02i:%02i:%02i", seconds / 3600, (seconds % 3600) / 60, seconds % 60); else s = String.Format("%02i:%02i", seconds / 60, seconds % 60); DrawStatLine(x, y, "T:", s); } } } //=========================================================================== // // draw health // //=========================================================================== virtual void DrawHealth(PlayerInfo CPlayer, int x, int y) { int health = CPlayer.health; // decide on the color first int fontcolor = health < hud_health_red ? Font.CR_RED : health < hud_health_yellow ? Font.CR_GOLD : health <= hud_health_green ? Font.CR_GREEN : Font.CR_BLUE; bool haveBerserk = hud_berserk_health && !gameinfo.berserkpic.IsNull() && CPlayer.mo.FindInventory('PowerStrength'); DrawImageToBox(haveBerserk ? gameinfo.berserkpic : gameinfo.healthpic, x, y, 31, 17); DrawHudNumber(HudFont, fontcolor, health, x + 33, y + 17); } //=========================================================================== // // Draw Armor. // very similar to drawhealth, but adapted to handle Hexen armor too // //=========================================================================== virtual void DrawArmor(BasicArmor barmor, HexenArmor harmor, int x, int y) { int ap = 0; int bestslot = 4; if (harmor) { let ac = (harmor.Slots[0] + harmor.Slots[1] + harmor.Slots[2] + harmor.Slots[3] + harmor.Slots[4]); ap += int(ac); if (ac) { // Find the part of armor that protects the most bestslot = 0; for (int i = 1; i < 4; ++i) { if (harmor.Slots[i] > harmor.Slots[bestslot]) { bestslot = i; } } } } if (barmor) { ap += barmor.Amount; } if (ap) { // decide on color int fontcolor = ap < hud_armor_red ? Font.CR_RED : ap < hud_armor_yellow ? Font.CR_GOLD : ap <= hud_armor_green ? Font.CR_GREEN : Font.CR_BLUE; // Use the sprite of one of the predefined Hexen armor bonuses. // This is not a very generic approach, but it is not possible // to truly create new types of Hexen armor bonus items anyway. if (harmor && bestslot < 4) { static const String harmorIcons[] = { "AR_1A0", "AR_2A0", "AR_3A0", "AR_4A0" }; DrawImageToBox(TexMan.CheckForTexture(harmorIcons[bestslot], TexMan.Type_Sprite), x, y, 31, 17); } else if (barmor) DrawImageToBox(barmor.Icon, x, y, 31, 17); DrawHudNumber(HudFont, fontcolor, ap, x + 33, y + 17); } } //=========================================================================== // // KEYS // //=========================================================================== //--------------------------------------------------------------------------- // // Draw one key // // Regarding key icons, Doom's are too small, Heretic doesn't have any, // for Hexen the in-game sprites look better and for Strife it doesn't matter // so always use the spawn state's sprite instead of the icon here unless an // override is specified in ALTHUDCF. // //--------------------------------------------------------------------------- virtual bool DrawOneKey(int xo, int x, int y, in out int c, Key inv) { TextureID icon; if (!inv) return false; TextureID AltIcon = inv.AltHUDIcon; if (!AltIcon.Exists()) return false; // Setting a non-existent AltIcon hides this key. if (AltIcon.isValid()) { icon = AltIcon; } else if (inv.SpawnState && inv.SpawnState.sprite!=0) { let state = inv.SpawnState; if (state != null) icon = state.GetSpriteTexture(0); else icon.SetNull(); } // missing sprites map to TNT1A0. So if that gets encountered, use the default icon instead. if (icon.isNull() || icon == tnt1a0) icon = inv.Icon; if (icon.isValid()) { DrawImageToBox(icon, x, y, 8, 10); return true; } return false; } //--------------------------------------------------------------------------- // // Draw all keys // //--------------------------------------------------------------------------- virtual int DrawKeys(PlayerInfo CPlayer, int x, int y) { int yo = y; int xo = x; int i; int c = 0; Key inv; if (!deathmatch) { int count = Key.GetKeyTypeCount(); // Go through the key in reverse order of definition, because we start at the right. for(int i = count-1; i >= 0; i--) { if ((inv = Key(CPlayer.mo.FindInventory(Key.GetKeyType(i))))) { if (DrawOneKey(xo, x - 9, y, c, inv)) { x -= 9; if (++c >= 10) { x = xo; y -= 11; c = 0; } } } } } if (x == xo && y != yo) y += 11; // undo the last wrap if the current line is empty. return y - 11; } //--------------------------------------------------------------------------- // // Drawing Ammo helpers // //--------------------------------------------------------------------------- void AddAmmoToList(readonly weapdef) { for (int i = 0; i < 2; i++) { let ti = i == 0? weapdef.AmmoType1 : weapdef.AmmoType2; if (ti) { let ammodef = GetDefaultByType(ti); if (ammodef && !ammodef.bInvBar) { if (orderedAmmos.Find(ti) == orderedAmmos.Size()) { orderedammos.Push(ti); } } } } } static int GetDigitCount(int value) { int digits = 0; do { value /= 10; ++digits; } while (0 != value); return digits; } int, int GetAmmoTextLengths(PlayerInfo CPlayer) { int tammomax = 0, tammocur = 0; for(int i = 0; i < orderedammos.Size(); i++) { let type = orderedammos[i]; let ammoitem = CPlayer.mo.FindInventory(type); int ammomax, ammocur; if (ammoitem == null) { ammomax = GetDefaultByType(type).MaxAmount; ammocur = 0; } else { ammomax = ammoitem.MaxAmount; ammocur = ammoItem.Amount; } tammocur = MAX(ammocur, tammocur); tammomax = MAX(ammomax, tammomax); } return GetDigitCount(tammocur), GetDigitCount(tammomax); } //--------------------------------------------------------------------------- // // Drawing Ammo // //--------------------------------------------------------------------------- virtual int DrawAmmo(PlayerInfo CPlayer, int x, int y) { int i,j,k; String buf; Inventory inv; let wi = CPlayer.ReadyWeapon; orderedammos.Clear(); if (0 == hud_showammo) { // Show ammo for current weapon if any if (wi) AddAmmoToList(wi.default); } else { // Order ammo by use of weapons in the weapon slots for (k = 0; k < PlayerPawn.NUM_WEAPON_SLOTS; k++) { int slotsize = CPlayer.weapons.SlotSize(k); for(j = 0; j < slotsize; j++) { let weap = CPlayer.weapons.GetWeapon(k, j); if (weap) { // Show ammo for available weapons if hud_showammo CVAR is 1 // or show ammo for all weapons if hud_showammo is greater than 1 if (hud_showammo > 1 || CPlayer.mo.FindInventory(weap)) { AddAmmoToList(GetDefaultByType(weap)); } } } } // Now check for the remaining weapons that are in the inventory but not in the weapon slots for(inv = CPlayer.mo.Inv; inv; inv = inv.Inv) { let weap = Weapon(inv); if (weap) { AddAmmoToList(weap.default); } } } // ok, we got all ammo types. Now draw the list back to front (bottom to top) int ammocurlen = 0; int ammomaxlen = 0; [ammocurlen, ammomaxlen] = GetAmmoTextLengths(CPlayer); //buf = String.Format("%0d/%0d", 0, 0); buf = String.Format("%0*d/%0*d", ammocurlen, 0, ammomaxlen, 0); int def_width = ConFont.StringWidth(buf); int yadd = ConFont.GetHeight(); int xtext = x - def_width; int ximage = x; if (hud_ammo_order > 0) { xtext -= 24; ximage -= 20; } else { ximage -= def_width + 20; } for(i = orderedammos.Size() - 1; i >= 0; i--) { let type = orderedammos[i]; let ammoitem = CPlayer.mo.FindInventory(type); let inv = GetDefaultByType(type); let AltIcon = inv.AltHUDIcon; int maxammo = ammoitem? ammoitem.MaxAmount : inv.MaxAmount; let icon = !AltIcon.isNull()? AltIcon : inv.Icon; if (!icon.isValid()) continue; double trans= (wi && (type == wi.AmmoType1 || type == wi.AmmoType2)) ? 0.75 : 0.375; int ammo = ammoitem? ammoitem.Amount : 0; // buf = String.Format("%d/%d", ammo, maxammo); buf = String.Format("%*d/%*d", ammocurlen, ammo, ammomaxlen, maxammo); int tex_width= clamp(ConFont.StringWidth(buf) - def_width, 0, 1000); int fontcolor=( !maxammo ? Font.CR_GRAY : ammo < ( (maxammo * hud_ammo_red) / 100) ? Font.CR_RED : ammo < ( (maxammo * hud_ammo_yellow) / 100) ? Font.CR_GOLD : Font.CR_GREEN ); DrawHudText(ConFont, fontcolor, buf, xtext-tex_width, y+yadd, trans); DrawImageToBox(icon, ximage, y, 16, 8, trans); y-=10; } return y; } //--------------------------------------------------------------------------- // // Drawing weapons // //--------------------------------------------------------------------------- virtual void DrawOneWeapon(PlayerInfo CPlayer, int x, in out int y, Weapon weapon) { double trans; // Powered up weapons and inherited sister weapons are not displayed. if (weapon.bPOWERED_UP) return; let SisterWeapon = weapon.SisterWeapon; if (SisterWeapon && (weapon is SisterWeapon.GetClass())) return; trans=0.4; let ReadyWeapon = CPlayer.ReadyWeapon; if (ReadyWeapon) { if (weapon == CPlayer.ReadyWeapon || SisterWeapon == CPlayer.ReadyWeapon) trans = 0.85; } TextureID picnum = StatusBar.GetInventoryIcon(weapon, StatusBar.DI_ALTICONFIRST); if (picnum.isValid()) { // don't draw tall sprites too small. int w, h; [w, h] = TexMan.GetSize(picnum); int rh; if (w > h) rh = 8; else { rh = 16; y -= 8; } DrawImageToBox(picnum, x-24, y, 20, rh, trans); y-=10; } } virtual void DrawWeapons(PlayerInfo CPlayer, int x, int y) { int k,j; Inventory inv; // First draw all weapons in the inventory that are not assigned to a weapon slot for(inv = CPlayer.mo.Inv; inv; inv = inv.Inv) { let weap = Weapon(inv); if (weap && !CPlayer.weapons.LocateWeapon(weap.GetClass())) { DrawOneWeapon(CPlayer, x, y, weap); } } // And now everything in the weapon slots back to front for (k = PlayerPawn.NUM_WEAPON_SLOTS - 1; k >= 0; k--) for(j = CPlayer.weapons.SlotSize(k) - 1; j >= 0; j--) { let weap = CPlayer.weapons.GetWeapon(k, j); if (weap) { let weapitem = Weapon(CPlayer.mo.FindInventory(weap)); if (weapitem) { DrawOneWeapon(CPlayer, x, y, weapitem); } } } } //--------------------------------------------------------------------------- // // Draw the Inventory // //--------------------------------------------------------------------------- virtual void DrawInventory(PlayerInfo CPlayer, int x,int y) { Inventory rover; int numitems = (hudwidth - 2*x) / 32; int i; CPlayer.mo.InvFirst = rover = StatusBar.ValidateInvFirst(numitems); if (rover!=NULL) { if(rover.PrevInv()) { screen.DrawTexture(invgem_left, true, x-10, y, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0.4); } for(i = 0; i < numitems && rover; rover = rover.NextInv()) { if (rover.Amount > 0) { let AltIcon = rover.AltHUDIcon; if (AltIcon.Exists() && (rover.Icon.isValid() || AltIcon.isValid()) ) { double trans = rover == CPlayer.mo.InvSel ? 1.0 : 0.4; DrawImageToBox(AltIcon.isValid()? AltIcon : rover.Icon, x, y, 19, 25, trans, true); if (rover.Amount > 1) { int xx; String buffer = String.Format("%d", rover.Amount); if (rover.Amount >= 1000) xx = 32 - IndexFont.StringWidth(buffer); else xx = 22; screen.DrawText(IndexFont, Font.CR_GOLD, x+xx, y+20, buffer, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, trans); } x+=32; i++; } } } if(rover) { screen.DrawTexture(invgem_right, true, x-10, y, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0.4); } } } //--------------------------------------------------------------------------- // // Draw the Frags // //--------------------------------------------------------------------------- virtual void DrawFrags(PlayerInfo CPlayer, int x, int y) { DrawImageToBox(fragpic, x, y, 31, 17); DrawHudNumber(HudFont, Font.CR_GRAY, CPlayer.fragcount, x + 33, y + 17); } //--------------------------------------------------------------------------- // // PROC DrawCoordinates // //--------------------------------------------------------------------------- void DrawCoordinateEntry(int xpos, int ypos, String coordstr, Font fnt = nullptr) { if (fnt == nullptr) fnt = SmallFont; screen.DrawText(fnt, hudcolor_xyco, xpos, ypos, coordstr, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight); } virtual void DrawCoordinates(PlayerInfo CPlayer, bool withmapname) { Vector3 pos; String coordstr; let fnt = generic_ui ? NewSmallFont : SmallFont; int h = fnt.GetHeight(); let mo = CPlayer.mo; if (!map_point_coordinates || !automapactive) { pos = mo.Pos; } else { pos.xy = Level.GetAutomapPosition(); pos.z = Level.PointInSector(pos.xy).floorplane.ZatPoint(pos.xy); } int xpos = hudwidth - fnt.StringWidth("X: -00000")-6; int ypos = 18; if (withmapname) { let font = generic_ui? NewSmallFont : SmallFont.CanPrint(Level.LevelName)? SmallFont : OriginalSmallFont; int hh = font.GetHeight(); screen.DrawText(font, hudcolor_titl, hudwidth - 6 - font.StringWidth(Level.MapName), ypos, Level.MapName, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight); screen.DrawText(font, hudcolor_titl, hudwidth - 6 - font.StringWidth(Level.LevelName), ypos + hh, Level.LevelName, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight); ypos += 2 * hh + h; } DrawCoordinateEntry(xpos, ypos, String.Format("X: %.0f", pos.X), fnt); ypos += h; DrawCoordinateEntry(xpos, ypos, String.Format("Y: %.0f", pos.Y), fnt); ypos += h; DrawCoordinateEntry(xpos, ypos, String.Format("Z: %.0f", pos.Z), fnt); ypos += h; if (hud_showangles) { DrawCoordinateEntry(xpos, ypos, String.Format("Y: %.0f", Actor.Normalize180(mo.Angle)), fnt); ypos += h; DrawCoordinateEntry(xpos, ypos, String.Format("P: %.0f", Actor.Normalize180(mo.Pitch)), fnt); ypos += h; DrawCoordinateEntry(xpos, ypos, String.Format("R: %.0f", Actor.Normalize180(mo.Roll)), fnt); } } //--------------------------------------------------------------------------- // // Draw in-game time // // Check AltHUDTime option value in wadsrc/static/menudef.txt // for meaning of all display modes // //--------------------------------------------------------------------------- virtual bool DrawTime(int y) { if (hud_showtime > 0 && hud_showtime <= 9) { int timeSeconds; String timeString; if (hud_showtime < 8) { int timeTicks = hud_showtime < 4 ? Level.maptime : (hud_showtime < 6 ? Level.time : Level.totaltime); timeSeconds = Thinker.Tics2Seconds(timeTicks); int hours = timeSeconds / 3600; int minutes = (timeSeconds % 3600) / 60; int seconds = timeSeconds % 60; bool showMillis = 1 == hud_showtime; bool showSeconds = showMillis || (0 == hud_showtime % 2); if (showMillis) { int millis = (Level.time % GameTicRate) * 1000 / GameTicRate; timeString = String.Format("%02i:%02i:%02i.%03i", hours, minutes, seconds, millis); } else if (showSeconds) { timeString = String.Format("%02i:%02i:%02i", hours, minutes, seconds); } else { timeString = String.Format("%02i:%02i", hours, minutes); } } else if (hud_showtime == 8) { timeString = SystemTime.Format("%H:%M:%S",SystemTime.Now()); } else //if (hud_showtime == 9) { timeString = SystemTime.Format("%H:%M",SystemTime.Now()); } int characterCount = timeString.length(); int width = SmallFont.GetCharWidth("0") * characterCount + 2; // small offset from screen's border DrawHudText(SmallFont, hud_timecolor, timeString, hudwidth - width, y, 1); return true; } return false; } //--------------------------------------------------------------------------- // // Draw in-game latency // // // //--------------------------------------------------------------------------- native static int, int, int GetLatency(); virtual bool DrawLatency(int y) { if ((hud_showlag == 1 && netgame) || hud_showlag == 2) { int severity, localdelay, arbitratordelay; [severity, localdelay, arbitratordelay] = GetLatency(); int color = severity == 0? Font.CR_GREEN : severity == 1? Font.CR_YELLOW : severity == 2? Font.CR_ORANGE : Font.CR_RED; String tempstr = String.Format("a:%dms - l:%dms", arbitratordelay, localdelay); int characterCount = tempstr.Length(); int width = SmallFont.GetCharWidth("0") * characterCount + 2; // small offset from screen's border DrawHudText(SmallFont, color, tempstr, hudwidth - width, y, 1); return true; } return false; } //--------------------------------------------------------------------------- // // draw the overlay // //--------------------------------------------------------------------------- virtual void DrawPowerups(PlayerInfo CPlayer, int y) { // Each icon gets a 32x32 block to draw itself in. int x, y; Inventory item; x = hudwidth - POWERUPICONSIZE - 4; for (item = CPlayer.mo.Inv; item != NULL; item = item.Inv) { let power = Powerup(item); if (power) { let icon = power.GetPowerupIcon(); if (icon.isValid()) { if (!power.isBlinking()) DrawImageToBox(icon, x, y, POWERUPICONSIZE, POWERUPICONSIZE, 1, true); x -= POWERUPICONSIZE; if (x < -hudwidth / 2) { x = hudwidth - 20; y += POWERUPICONSIZE * 3 / 2; } } } } } //--------------------------------------------------------------------------- // // main drawer // //--------------------------------------------------------------------------- virtual void DrawInGame(PlayerInfo CPlayer) { // No HUD in the title level! if (gamestate == GS_TITLELEVEL || !CPlayer) return; if (!deathmatch) { DrawStatus(CPlayer, 5, hudheight-50); } else { DrawStatus(CPlayer, 5, hudheight-75); DrawFrags(CPlayer, 5, hudheight-70); } DrawHealth(CPlayer, 5, hudheight-45); DrawArmor(BasicArmor(CPlayer.mo.FindInventory('BasicArmor')), HexenArmor(CPlayer.mo.FindInventory('HexenArmor')), 5, hudheight-20); int y = DrawKeys(CPlayer, hudwidth-4, hudheight-10); y = DrawAmmo(CPlayer, hudwidth-5, y); if (hud_showweapons) DrawWeapons(CPlayer, hudwidth - 5, y); DrawInventory(CPlayer, 144, hudheight - 28); if (idmypos) DrawCoordinates(CPlayer, true); int h = SmallFont.GetHeight(); y = h; if (DrawTime(y)) y += h; if (DrawLatency(y)) y += h; DrawPowerups(CPlayer, y - h + POWERUPICONSIZE * 5 / 4); } //--------------------------------------------------------------------------- // // automap drawer // //--------------------------------------------------------------------------- virtual void DrawAutomap(PlayerInfo CPlayer) { let font = generic_ui? NewSmallFont : SmallFont; int fonth = font.GetHeight() + 1; int bottom = hudheight - 1; if (am_showtotaltime) { DrawTimeString(font, hudcolor_ttim, Level.totaltime, hudwidth-2, bottom, 1); bottom -= fonth; } if (am_showtime) { if (Level.clusterflags & Level.CLUSTER_HUB) { DrawTimeString(font, hudcolor_time, Level.time, hudwidth-2, bottom, 1); bottom -= fonth; } // Single level time for hubs DrawTimeString(font, hudcolor_ltim, Level.maptime, hudwidth-2, bottom, 1); } let amstr = Level.FormatMapName(hudcolor_titl); font = generic_ui? NewSmallFont : SmallFont.CanPrint(amstr)? SmallFont : OriginalSmallFont; bottom = hudheight - fonth - 1; screen.DrawText(font, Font.CR_BRICK, 2, bottom, amstr, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight); if (am_showcluster && (Level.clusterflags & Level.CLUSTER_HUB)) { let text = Level.GetClusterName(); if (text != "") { bottom -= fonth; screen.DrawText(font, Font.CR_ORANGE, 2, bottom, text, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight); } } if (am_showepisode) { let text = Level.GetEpisodeName(); if (text != "") { bottom -= fonth; screen.DrawText(font, Font.CR_RED, 2, bottom, text, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight); } } DrawCoordinates(CPlayer, false); } //--------------------------------------------------------------------------- // // main drawer // //--------------------------------------------------------------------------- virtual void Draw(PlayerInfo CPlayer, int w, int h) { hudwidth = w; hudheight = h; if (!automapactive) { DrawInGame(CPlayer); } else { DrawAutomap(CPlayer); } } } /* ** a_ammo.cpp ** Implements ammo and backpack items. ** **--------------------------------------------------------------------------- ** Copyright 2000-2016 Randy Heit ** Copyright 2006-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ class Ammo : Inventory { int BackpackAmount; int BackpackMaxAmount; meta int DropAmount; property BackpackAmount: BackpackAmount; property BackpackMaxAmount: BackpackMaxAmount; property DropAmount: DropAmount; Default { +INVENTORY.KEEPDEPLETED Inventory.PickupSound "misc/ammo_pkup"; } //=========================================================================== // // AAmmo :: GetParentAmmo // // Returns the least-derived ammo type that this ammo is a descendant of. // That is, if this ammo is an immediate subclass of Ammo, then this ammo's // type is returned. If this ammo's superclass is not Ammo, then this // function travels up the inheritance chain until it finds a type that is // an immediate subclass of Ammo and returns that. // // The intent of this is that all unique ammo types will be immediate // subclasses of Ammo. To make different pickups with different ammo amounts, // you subclass the type of ammo you want a different amount for and edit // that. // //=========================================================================== virtual Class GetParentAmmo () { class type = GetClass(); while (type.GetParentClass() != "Ammo" && type.GetParentClass() != NULL) { type = type.GetParentClass(); } return (class)(type); } //=========================================================================== // // AAmmo :: HandlePickup // //=========================================================================== override bool HandlePickup (Inventory item) { let ammoitem = Ammo(item); if (ammoitem != null && ammoitem.GetParentAmmo() == GetClass()) { if (Amount < MaxAmount || sv_unlimited_pickup) { int receiving = item.Amount; if (!item.bIgnoreSkill) { // extra ammo in baby mode and nightmare mode receiving = int(receiving * (G_SkillPropertyFloat(SKILLP_AmmoFactor) * sv_ammofactor)); } int oldamount = Amount; if (Amount > 0 && Amount + receiving < 0) { Amount = 0x7fffffff; } else { Amount += receiving; } if (Amount > MaxAmount && !sv_unlimited_pickup) { Amount = MaxAmount; } item.bPickupGood = true; // If the player previously had this ammo but ran out, possibly switch // to a weapon that uses it, but only if the player doesn't already // have a weapon pending. if (oldamount == 0 && Owner != null && Owner.player != null) { PlayerPawn(Owner).CheckWeaponSwitch(GetClass()); } } return true; } return false; } //=========================================================================== // // AAmmo :: CreateCopy // //=========================================================================== override Inventory CreateCopy (Actor other) { Inventory copy; int amount = Amount; // extra ammo in baby mode and nightmare mode if (!bIgnoreSkill) { amount = int(amount * (G_SkillPropertyFloat(SKILLP_AmmoFactor) * sv_ammofactor)); } let type = GetParentAmmo(); if (GetClass() != type && type != null) { if (!GoAway ()) { Destroy (); } copy = Inventory(Spawn (type)); copy.Amount = amount; copy.BecomeItem (); } else { copy = Super.CreateCopy (other); copy.Amount = amount; } if (copy.Amount > copy.MaxAmount) { // Don't pick up more ammo than you're supposed to be able to carry. copy.Amount = copy.MaxAmount; } return copy; } //=========================================================================== // // AAmmo :: CreateTossable // //=========================================================================== override Inventory CreateTossable(int amt) { Inventory copy = Super.CreateTossable(amt); if (copy != null) { // Do not increase ammo by dropping it and picking it back up at // certain skill levels. copy.bIgnoreSkill = true; } return copy; } //--------------------------------------------------------------------------- // // Modifies the drop amount of this item according to the current skill's // settings (also called by ADehackedPickup::TryPickup) // //--------------------------------------------------------------------------- override void ModifyDropAmount(int dropamount) { bool ignoreskill = true; double dropammofactor = G_SkillPropertyFloat(SKILLP_DropAmmoFactor); // Default drop amount is half of regular amount * regular ammo multiplication if (dropammofactor == -1) { dropammofactor = 0.5; ignoreskill = false; } if (dropamount > 0) { if (ignoreskill) { self.Amount = int(dropamount * dropammofactor); bIgnoreSkill = true; } else { self.Amount = dropamount; } } else { // Half ammo when dropped by bad guys. int amount = self.DropAmount; if (amount <= 0) { amount = MAX(1, int(self.Amount * dropammofactor)); } self.Amount = amount; bIgnoreSkill = ignoreskill; } } } class BackpackItem : Inventory { bool bDepleted; //=========================================================================== // // ABackpackItem :: CreateCopy // // A backpack is being added to a player who doesn't yet have one. Give them // every kind of ammo, and increase their max amounts. // //=========================================================================== override Inventory CreateCopy (Actor other) { // Find every unique type of ammoitem. Give it to the player if // he doesn't have it already, and double its maximum capacity. uint end = AllActorClasses.Size(); for (uint i = 0; i < end; ++i) { let ammotype = (class)(AllActorClasses[i]); if (ammotype && GetDefaultByType(ammotype).GetParentAmmo() == ammotype) { let ammoitem = Ammo(other.FindInventory(ammotype)); int amount = GetDefaultByType(ammotype).BackpackAmount; // extra ammo in baby mode and nightmare mode if (!bIgnoreSkill) { amount = int(amount * (G_SkillPropertyFloat(SKILLP_AmmoFactor) * sv_ammofactor)); } if (amount < 0) amount = 0; if (ammoitem == NULL) { // The player did not have the ammoitem. Add it. ammoitem = Ammo(Spawn(ammotype)); ammoitem.Amount = bDepleted ? 0 : amount; if (ammoitem.BackpackMaxAmount > ammoitem.MaxAmount) { ammoitem.MaxAmount = ammoitem.BackpackMaxAmount; } if (ammoitem.Amount > ammoitem.MaxAmount) { ammoitem.Amount = ammoitem.MaxAmount; } ammoitem.AttachToOwner (other); } else { // The player had the ammoitem. Give some more. if (ammoitem.MaxAmount < ammoitem.BackpackMaxAmount) { ammoitem.MaxAmount = ammoitem.BackpackMaxAmount; } if (!bDepleted && ammoitem.Amount < ammoitem.MaxAmount) { ammoitem.Amount += amount; if (ammoitem.Amount > ammoitem.MaxAmount) { ammoitem.Amount = ammoitem.MaxAmount; } } } } } return Super.CreateCopy (other); } //=========================================================================== // // ABackpackItem :: HandlePickup // // When the player picks up another backpack, just give them more ammoitem. // //=========================================================================== override bool HandlePickup (Inventory item) { // Since you already have a backpack, that means you already have every // kind of ammo in your inventory, so we don't need to look at the // entire PClass list to discover what kinds of ammo exist, and we don't // have to alter the MaxAmount either. if (item is 'BackpackItem') { for (let probe = Owner.Inv; probe != NULL; probe = probe.Inv) { let ammoitem = Ammo(probe); if (ammoitem && ammoitem.GetParentAmmo() == ammoitem.GetClass()) { if (ammoitem.Amount < ammoitem.MaxAmount || sv_unlimited_pickup) { int amount = ammoitem.Default.BackpackAmount; // extra ammo in baby mode and nightmare mode if (!bIgnoreSkill) { amount = int(amount * (G_SkillPropertyFloat(SKILLP_AmmoFactor) * sv_ammofactor)); } ammoitem.Amount += amount; if (ammoitem.Amount > ammoitem.MaxAmount && !sv_unlimited_pickup) { ammoitem.Amount = ammoitem.MaxAmount; } } } } // The pickup always succeeds, even if you didn't get anything item.bPickupGood = true; return true; } return false; } //=========================================================================== // // ABackpackItem :: CreateTossable // // The tossed backpack must not give out any more ammo, otherwise a player // could cheat by dropping their backpack and picking it up for more ammoitem. // //=========================================================================== override Inventory CreateTossable (int amount) { let pack = BackpackItem(Super.CreateTossable(-1)); if (pack != NULL) { pack.bDepleted = true; } return pack; } //=========================================================================== // // ABackpackItem :: DetachFromOwner // //=========================================================================== override void DetachFromOwner () { // When removing a backpack, drop the player's ammo maximums to normal for (let item = Owner.Inv; item != NULL; item = item.Inv) { if (item is 'Ammo' && item.MaxAmount == Ammo(item).BackpackMaxAmount) { item.MaxAmount = item.Default.MaxAmount; if (item.Amount > item.MaxAmount) { item.Amount = item.MaxAmount; } } } } } //============================================================================= // // os_AnyOrAllOption class represents an Option Item for Option Search menu. // Changing the value of this option causes the menu to refresh the search // results. // //============================================================================= class os_AnyOrAllOption : OptionMenuItemOption { os_AnyOrAllOption Init(os_Menu menu) { Super.Init("", "os_isanyof", "os_isanyof_values"); mMenu = menu; return self; } override bool MenuEvent(int mkey, bool fromcontroller) { bool result = Super.MenuEvent(mkey, fromcontroller); if (mKey == Menu.MKEY_Left || mKey == Menu.MKEY_Right || mkey == Menu.MKEY_Enter) { mMenu.search(); } return result; } private os_Menu mMenu; } //=========================================================================== // // Arachnotron // //=========================================================================== class Arachnotron : Actor { Default { Health 500; Radius 64; Height 64; Mass 600; Speed 12; PainChance 128; Monster; +FLOORCLIP +BOSSDEATH +MAP07BOSS2 SeeSound "baby/sight"; PainSound "baby/pain"; DeathSound "baby/death"; ActiveSound "baby/active"; Obituary "$OB_BABY"; Tag "$FN_ARACH"; } States { Spawn: BSPI AB 10 A_Look; Loop; See: BSPI A 20; BSPI A 3 A_BabyMetal; BSPI ABBCC 3 A_Chase; BSPI D 3 A_BabyMetal; BSPI DEEFF 3 A_Chase; Goto See+1; Missile: BSPI A 20 BRIGHT A_FaceTarget; BSPI G 4 BRIGHT A_BspiAttack; BSPI H 4 BRIGHT; BSPI H 1 BRIGHT A_SpidRefire; Goto Missile+1; Pain: BSPI I 3; BSPI I 3 A_Pain; Goto See+1; Death: BSPI J 20 A_Scream; BSPI K 7 A_NoBlocking; BSPI LMNO 7; BSPI P -1 A_BossDeath; Stop; Raise: BSPI P 5; BSPI ONMLKJ 5; Goto See+1; } } //=========================================================================== // // Arachnotron plasma // //=========================================================================== class ArachnotronPlasma : Actor { Default { Radius 13; Height 8; Speed 25; Damage 5; Projectile; +RANDOMIZE +ZDOOMTRANS RenderStyle "Add"; Alpha 0.75; SeeSound "baby/attack"; DeathSound "baby/shotx"; } States { Spawn: APLS AB 5 BRIGHT; Loop; Death: APBX ABCDE 5 BRIGHT; Stop; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== extend class Actor { void A_BspiAttack() { if (target) { A_FaceTarget(); SpawnMissile(target, "ArachnotronPlasma"); } } void A_BabyMetal() { A_StartSound("baby/walk", CHAN_BODY, CHANF_DEFAULT, 1, ATTN_IDLE); A_Chase(); } } //=========================================================================== // // Arch Vile // //=========================================================================== class Archvile : Actor { Default { Health 700; Radius 20; Height 56; Mass 500; Speed 15; PainChance 10; Monster; MaxTargetRange 896; +QUICKTORETALIATE +FLOORCLIP +NOTARGET SeeSound "vile/sight"; PainSound "vile/pain"; DeathSound "vile/death"; ActiveSound "vile/active"; MeleeSound "vile/stop"; Obituary "$OB_VILE"; Tag "$FN_ARCH"; } States { Spawn: VILE AB 10 A_Look; Loop; See: VILE AABBCCDDEEFF 2 A_VileChase; Loop; Missile: VILE G 0 BRIGHT A_VileStart; VILE G 10 BRIGHT A_FaceTarget; VILE H 8 BRIGHT A_VileTarget; VILE IJKLMN 8 BRIGHT A_FaceTarget; VILE O 8 BRIGHT A_VileAttack; VILE P 20 BRIGHT; Goto See; Heal: VILE [\] 10 BRIGHT; Goto See; Pain: VILE Q 5; VILE Q 5 A_Pain; Goto See; Death: VILE Q 7; VILE R 7 A_Scream; VILE S 7 A_NoBlocking; VILE TUVWXY 7; VILE Z -1; Stop; } } //=========================================================================== // // Arch Vile Fire // //=========================================================================== class ArchvileFire : Actor { Default { +NOBLOCKMAP +NOGRAVITY +ZDOOMTRANS RenderStyle "Add"; Alpha 1; } States { Spawn: FIRE A 2 BRIGHT A_StartFire; FIRE BAB 2 BRIGHT A_Fire; FIRE C 2 BRIGHT A_FireCrackle; FIRE BCBCDCDCDEDED 2 BRIGHT A_Fire; FIRE E 2 BRIGHT A_FireCrackle; FIRE FEFEFGHGHGH 2 BRIGHT A_Fire; Stop; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== // A_VileAttack flags //#define VAF_DMGTYPEAPPLYTODIRECT 1 extend class Actor { void A_VileStart() { A_StartSound ("vile/start", CHAN_VOICE); } // // A_VileTarget // Spawn the hellfire // void A_VileTarget(class fire = "ArchvileFire") { if (target) { A_FaceTarget (); Actor fog = Spawn (fire, target.Pos, ALLOW_REPLACE); if (fog != null) { tracer = fog; fog.target = self; fog.tracer = self.target; fog.A_Fire(0); } } } void A_VileAttack(sound snd = "vile/stop", int initialdmg = 20, int blastdmg = 70, int blastradius = 70, double thrust = 1.0, name damagetype = "Fire", int flags = 0) { Actor targ = target; if (targ) { A_FaceTarget(); if (!CheckSight(targ, 0)) return; A_StartSound(snd, CHAN_WEAPON); int newdam = targ.DamageMobj (self, self, initialdmg, (flags & VAF_DMGTYPEAPPLYTODIRECT)? damagetype : 'none'); targ.TraceBleed (newdam > 0 ? newdam : initialdmg, self); Actor fire = tracer; if (fire) { // move the fire between the vile and the player fire.SetOrigin(targ.Vec3Angle(-24., angle, 0), true); fire.A_Explode(blastdmg, blastradius, XF_NOSPLASH, false, 0, 0, 0, "BulletPuff", damagetype); } if (!targ.bDontThrust) { targ.Vel.z = thrust * 1000 / max(1, targ.Mass); } } } void A_StartFire() { A_StartSound ("vile/firestrt", CHAN_BODY); A_Fire(); } // // A_Fire // Keep fire in front of player unless out of sight // void A_Fire(double spawnheight = 0) { Actor dest = tracer; if (!dest || !target) return; // don't move it if the vile lost sight if (!target.CheckSight (dest, 0) ) return; SetOrigin(dest.Vec3Angle(24, dest.angle, spawnheight), true); } void A_FireCrackle() { A_StartSound ("vile/firecrkl", CHAN_BODY); A_Fire(); } } /* ** armor.txt ** Implements all variations of armor objects ** **--------------------------------------------------------------------------- ** Copyright 2002-2016 Randy Heit ** Copyright 2006-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ class Armor : Inventory { Default { Inventory.PickupSound "misc/armor_pkup"; +INVENTORY.ISARMOR } } //=========================================================================== // // // BasicArmor // // Basic armor absorbs a specific percent of the damage. You should // never pickup a BasicArmor. Instead, you pickup a BasicArmorPickup // or BasicArmorBonus and those gives you BasicArmor when it activates. // // //=========================================================================== class BasicArmor : Armor { int AbsorbCount; double SavePercent; int MaxAbsorb; int MaxFullAbsorb; int BonusCount; Name ArmorType; int ActualSaveAmount; Default { Inventory.Amount 0; +Inventory.KEEPDEPLETED } //=========================================================================== // // ABasicArmor :: Tick // // If BasicArmor is given to the player by means other than a // BasicArmorPickup, then it may not have an icon set. Fix that here. // //=========================================================================== override void Tick () { Super.Tick (); AbsorbCount = 0; if (!Icon.isValid()) { String icontex = gameinfo.ArmorIcon1; if (SavePercent >= gameinfo.Armor2Percent && gameinfo.ArmorIcon2.Length() != 0) icontex = gameinfo.ArmorIcon2; if (icontex.Length() != 0) Icon = TexMan.CheckForTexture (icontex, TexMan.TYPE_Any); } } //=========================================================================== // // ABasicArmor :: CreateCopy // //=========================================================================== override Inventory CreateCopy (Actor other) { // BasicArmor that is in use is stored in the inventory as BasicArmor. // BasicArmor that is in reserve is not. let copy = BasicArmor(Spawn("BasicArmor")); copy.SavePercent = SavePercent != 0 ? SavePercent : 0.33335; // slightly more than 1/3 to avoid roundoff errors. copy.Amount = Amount; copy.MaxAmount = MaxAmount; copy.Icon = Icon; copy.BonusCount = BonusCount; copy.ArmorType = ArmorType; copy.ActualSaveAmount = ActualSaveAmount; GoAwayAndDie (); return copy; } //=========================================================================== // // ABasicArmor :: HandlePickup // //=========================================================================== override bool HandlePickup (Inventory item) { if (item.GetClass() == "BasicArmor") { // You shouldn't be picking up BasicArmor anyway. return true; } return false; } //=========================================================================== // // ABasicArmor :: AbsorbDamage // //=========================================================================== override void AbsorbDamage (int damage, Name damageType, out int newdamage, Actor inflictor, Actor source, int flags) { int saved; if (!DamageTypeDefinition.IgnoreArmor(damageType)) { int full = MAX(0, MaxFullAbsorb - AbsorbCount); if (damage < full) { saved = damage; } else { saved = full + int((damage - full) * SavePercent); if (MaxAbsorb > 0 && saved + AbsorbCount > MaxAbsorb) { saved = MAX(0, MaxAbsorb - AbsorbCount); } } if (Amount < saved) { saved = Amount; } newdamage -= saved; Amount -= saved; AbsorbCount += saved; if (Amount == 0) { // The armor has become useless SavePercent = 0; ArmorType = 'None'; // Not NAME_BasicArmor. // Now see if the player has some more armor in their inventory // and use it if so. As in Strife, the best armor is used up first. BasicArmorPickup best = null; Inventory probe = Owner.Inv; while (probe != null) { let inInv = BasicArmorPickup(probe); if (inInv != null) { if (best == null || best.SavePercent < inInv.SavePercent) { best = inInv; } } probe = probe.Inv; } if (best != null) { Owner.UseInventory (best); } } damage = newdamage; } // Once the armor has absorbed its part of the damage, then apply its damage factor, if any, to the player if ((damage > 0) && (ArmorType != 'None')) // BasicArmor is not going to have any damage factor, so skip it. { newdamage = ApplyDamageFactors(ArmorType, damageType, damage, damage); } } } //=========================================================================== // // // BasicArmorBonus // // //=========================================================================== class BasicArmorBonus : Armor { double SavePercent; // The default, for when you don't already have armor int MaxSaveAmount; int MaxAbsorb; int MaxFullAbsorb; int SaveAmount; int BonusCount; int BonusMax; property prefix: Armor; property MaxSaveAmount: MaxSaveAmount; property SaveAmount : SaveAmount; property SavePercent: SavePercent; property MaxAbsorb: MaxAbsorb; property MaxFullAbsorb: MaxFullAbsorb; property MaxBonus: BonusCount; property MaxBonusMax: BonusMax; Default { +Inventory.AUTOACTIVATE +Inventory.ALWAYSPICKUP Inventory.MaxAmount 0; Armor.SavePercent 33.335; } //=========================================================================== // // ABasicArmorBonus :: CreateCopy // //=========================================================================== override Inventory CreateCopy (Actor other) { let copy = BasicArmorBonus(Super.CreateCopy (other)); copy.SavePercent = SavePercent; copy.SaveAmount = SaveAmount; copy.MaxSaveAmount = MaxSaveAmount; copy.BonusCount = BonusCount; copy.BonusMax = BonusMax; copy.MaxAbsorb = MaxAbsorb; copy.MaxFullAbsorb = MaxFullAbsorb; return copy; } //=========================================================================== // // ABasicArmorBonus :: Use // // Tries to add to the amount of BasicArmor a player has. // //=========================================================================== override bool Use (bool pickup) { let armor = BasicArmor(Owner.FindInventory("BasicArmor")); bool result = false; // This should really never happen but let's be prepared for a broken inventory. if (armor == null) { armor = BasicArmor(Spawn("BasicArmor")); armor.BecomeItem (); armor.Amount = 0; armor.MaxAmount = MaxSaveAmount; Owner.AddInventory (armor); } if (BonusCount > 0 && armor.BonusCount < BonusMax) { armor.BonusCount = min(armor.BonusCount + BonusCount, BonusMax); result = true; } int saveAmount = min(GetSaveAmount(), MaxSaveAmount); if (saveAmount <= 0) { // If it can't give you anything, it's as good as used. return BonusCount > 0 ? result : true; } // If you already have more armor than this item can give you, you can't // use it. if (armor.Amount >= MaxSaveAmount + armor.BonusCount) { return result; } if (armor.Amount <= 0) { // Should never be less than 0, but might as well check anyway armor.Amount = 0; armor.Icon = Icon; armor.SavePercent = clamp(SavePercent, 0, 100) / 100; armor.MaxAbsorb = MaxAbsorb; armor.ArmorType = GetClassName(); armor.MaxFullAbsorb = MaxFullAbsorb; armor.ActualSaveAmount = MaxSaveAmount; } armor.Amount = min(armor.Amount + saveAmount, MaxSaveAmount + armor.BonusCount); armor.MaxAmount = max(armor.MaxAmount, MaxSaveAmount); return true; } override void SetGiveAmount(Actor receiver, int amount, bool bycheat) { SaveAmount *= amount; } int GetSaveAmount () { return !bIgnoreSkill ? int(SaveAmount * G_SkillPropertyFloat(SKILLP_ArmorFactor)) : SaveAmount; } } //=========================================================================== // // // BasicArmorPickup // // //=========================================================================== class BasicArmorPickup : Armor { double SavePercent; int MaxAbsorb; int MaxFullAbsorb; int SaveAmount; property prefix: Armor; property SaveAmount : SaveAmount; property SavePercent: SavePercent; property MaxAbsorb: MaxAbsorb; property MaxFullAbsorb: MaxFullAbsorb; Default { +Inventory.AUTOACTIVATE; Inventory.MaxAmount 0; } //=========================================================================== // // ABasicArmorPickup :: CreateCopy // //=========================================================================== override Inventory CreateCopy (Actor other) { let copy = BasicArmorPickup(Super.CreateCopy (other)); copy.SavePercent = SavePercent; copy.SaveAmount = SaveAmount; copy.MaxAbsorb = MaxAbsorb; copy.MaxFullAbsorb = MaxFullAbsorb; return copy; } //=========================================================================== // // ABasicArmorPickup :: Use // // Either gives you new armor or replaces the armor you already have (if // the SaveAmount is greater than the amount of armor you own). When the // item is auto-activated, it will only be activated if its max amount is 0 // or if you have no armor active already. // //=========================================================================== override bool Use (bool pickup) { int SaveAmount = GetSaveAmount(); let armor = BasicArmor(Owner.FindInventory("BasicArmor")); // This should really never happen but let's be prepared for a broken inventory. if (armor == null) { armor = BasicArmor(Spawn("BasicArmor")); armor.BecomeItem (); Owner.AddInventory (armor); } else { // If you already have more armor than this item gives you, you can't // use it. if (armor.Amount >= SaveAmount + armor.BonusCount) { return false; } // Don't use it if you're picking it up and already have some. if (pickup && armor.Amount > 0 && MaxAmount > 0) { return false; } } armor.SavePercent = clamp(SavePercent, 0, 100) / 100; armor.Amount = SaveAmount + armor.BonusCount; armor.MaxAmount = SaveAmount; armor.Icon = Icon; armor.MaxAbsorb = MaxAbsorb; armor.MaxFullAbsorb = MaxFullAbsorb; armor.ArmorType = GetClassName(); armor.ActualSaveAmount = SaveAmount; return true; } override void SetGiveAmount(Actor receiver, int amount, bool bycheat) { SaveAmount *= amount; } int GetSaveAmount () { return !bIgnoreSkill ? int(SaveAmount * G_SkillPropertyFloat(SKILLP_ArmorFactor)) : SaveAmount; } } //=========================================================================== // // // HexenArmor // // Hexen armor consists of four separate armor types plus a conceptual armor // type (the player himself) that work together as a single armor. // // //=========================================================================== class HexenArmor : Armor { double Slots[5]; double SlotsIncrement[4]; Default { +Inventory.KEEPDEPLETED +Inventory.UNTOSSABLE } //=========================================================================== // // AHexenArmor :: CreateCopy // //=========================================================================== override Inventory CreateCopy (Actor other) { // Like BasicArmor, HexenArmor is used in the inventory but not the map. // health is the slot this armor occupies. // Amount is the quantity to give (0 = normal max). let copy = HexenArmor(Spawn("HexenArmor")); copy.AddArmorToSlot (health, Amount); GoAwayAndDie (); return copy; } //=========================================================================== // // AHexenArmor :: CreateTossable // // Since this isn't really a single item, you can't drop it. Ever. // //=========================================================================== override Inventory CreateTossable (int amount) { return NULL; } //=========================================================================== // // AHexenArmor :: HandlePickup // //=========================================================================== override bool HandlePickup (Inventory item) { if (item is "HexenArmor") { if (AddArmorToSlot (item.health, item.Amount)) { item.bPickupGood = true; } return true; } return false; } //=========================================================================== // // AHexenArmor :: AddArmorToSlot // //=========================================================================== protected bool AddArmorToSlot (int slot, int amount) { double hits; if (slot < 0 || slot > 3) { return false; } if (amount <= 0) { hits = SlotsIncrement[slot]; if (Slots[slot] < hits) { Slots[slot] = hits; return true; } } else { hits = amount * 5; let total = Slots[0] + Slots[1] + Slots[2] + Slots[3] + Slots[4]; let max = SlotsIncrement[0] + SlotsIncrement[1] + SlotsIncrement[2] + SlotsIncrement[3] + Slots[4] + 4 * 5; if (total < max) { Slots[slot] += hits; return true; } } return false; } //=========================================================================== // // AHexenArmor :: AbsorbDamage // //=========================================================================== override void AbsorbDamage (int damage, Name damageType, out int newdamage, Actor inflictor, Actor source, int flags) { if (!DamageTypeDefinition.IgnoreArmor(damageType)) { double savedPercent = Slots[0] + Slots[1] + Slots[2] + Slots[3] + Slots[4]; if (savedPercent) { // armor absorbed some damage if (savedPercent > 100) { savedPercent = 100; } for (int i = 0; i < 4; i++) { if (Slots[i]) { // 300 damage always wipes out the armor unless some was added // with the dragon skin bracers. if (damage < 10000) { Slots[i] -= damage * SlotsIncrement[i] / 300.; if (Slots[i] < 2) { Slots[i] = 0; } } else { Slots[i] = 0; } } } int saved = int(damage * savedPercent / 100.); if (saved > savedPercent*2) { saved = int(savedPercent*2); } newdamage -= saved; damage = newdamage; } } } //=========================================================================== // // AHexenArmor :: DepleteOrDestroy // //=========================================================================== override void DepleteOrDestroy() { for (int i = 0; i < 4; i++) { Slots[i] = 0; } } } // Egg missile -------------------------------------------------------------- class EggFX : MorphProjectile { Default { Radius 8; Height 8; Speed 18; MorphProjectile.PlayerClass "ChickenPlayer"; MorphProjectile.MonsterClass "Chicken"; MorphProjectile.MorphStyle MRF_UNDOBYTOMEOFPOWER; } States { Spawn: EGGM ABCDE 4; Loop; Death: FX01 FFGH 3 Bright; Stop; } } // Morph Ovum ---------------------------------------------------------------- class ArtiEgg : CustomInventory { Default { +COUNTITEM +FLOATBOB +INVENTORY.INVBAR Inventory.PickupFlash "PickupFlash"; +INVENTORY.FANCYPICKUPSOUND Inventory.Icon "ARTIEGGC"; Inventory.PickupSound "misc/p_pkup"; Inventory.PickupMessage "$TXT_ARTIEGG"; Inventory.DefMaxAmount; Tag "$TAG_ARTIEGG"; } States { Spawn: EGGC ABCB 6; Loop; Use: TNT1 A 0 { for (double i = -15; i <= 15; i += 7.5) A_FireProjectile("EggFX", i, false, 0, 0, FPF_AIMATANGLE); } Stop; } } // Pork missile -------------------------------------------------------------- class PorkFX : MorphProjectile { Default { Radius 8; Height 8; Speed 18; MorphProjectile.PlayerClass "PigPlayer"; MorphProjectile.MonsterClass "Pig"; MorphProjectile.MorphStyle MRF_UNDOBYTOMEOFPOWER|MRF_UNDOBYCHAOSDEVICE; } States { Spawn: PRKM ABCDE 4; Loop; Death: FHFX IJKL 3 Bright; Stop; } } // Porkalator --------------------------------------------------------------- class ArtiPork : CustomInventory { Default { +COUNTITEM +FLOATBOB +INVENTORY.INVBAR Inventory.PickupFlash "PickupFlash"; +INVENTORY.FANCYPICKUPSOUND Inventory.Icon "ARTIPORK"; Inventory.PickupSound "misc/p_pkup"; Inventory.PickupMessage "$TXT_ARTIEGG2"; Inventory.DefMaxAmount; Tag "$TAG_ARTIPORK"; } States { Spawn: PORK ABCDEFGH 5; Loop; Use: TNT1 A 0 { for (double i = -15; i <= 15; i += 7.5) A_FireProjectile("PorkFX", i, false, 0, 0, FPF_AIMATANGLE); } Stop; } } // Teleport (self) ---------------------------------------------------------- class ArtiTeleport : Inventory { Default { +COUNTITEM +FLOATBOB +INVENTORY.INVBAR Inventory.PickupFlash "PickupFlash"; +INVENTORY.FANCYPICKUPSOUND Inventory.DefMaxAmount; Inventory.Icon "ARTIATLP"; Inventory.PickupSound "misc/p_pkup"; Inventory.PickupMessage "$TXT_ARTITELEPORT"; Tag "$TAG_ARTITELEPORT"; } States { Spawn: ATLP ABCB 4; Loop; } override bool Use (bool pickup) { Vector3 dest; int destAngle; if (deathmatch) { [dest, destAngle] = level.PickDeathmatchStart(); } else { [dest, destAngle] = level.PickPlayerStart(Owner.PlayerNumber()); } if (!level.useplayerstartz) dest.Z = ONFLOORZ; Owner.Teleport (dest, destAngle, TELF_SOURCEFOG | TELF_DESTFOG); bool canlaugh = true; Playerinfo p = Owner.player; if (p && p.morphTics && (p.MorphStyle & MRF_UNDOBYCHAOSDEVICE)) { // Teleporting away will undo any morph effects (pig) if (!p.mo.UndoPlayerMorph (p, MRF_UNDOBYCHAOSDEVICE) && (p.MorphStyle & MRF_FAILNOLAUGH)) { canlaugh = false; } } if (canlaugh) { // Full volume laugh Owner.A_StartSound ("*evillaugh", CHAN_VOICE, CHANF_DEFAULT, 1., ATTN_NONE); } return true; } } extend class Actor { //--------------------------------------------------------------------------- // // Used by A_CustomBulletAttack and A_FireBullets // //--------------------------------------------------------------------------- static void AimBulletMissile(Actor proj, Actor puff, int flags, bool temp, bool cba) { if (proj && puff) { // FAF_BOTTOM = 1 // Aim for the base of the puff as that's where blood puffs will spawn... roughly. proj.A_Face(puff, 0., 0., 0., 0., 1); proj.Vel3DFromAngle(proj.Speed, proj.Angle, proj.Pitch); if (!temp) { if (cba) { if (flags & CBAF_PUFFTARGET) proj.target = puff; if (flags & CBAF_PUFFMASTER) proj.master = puff; if (flags & CBAF_PUFFTRACER) proj.tracer = puff; } else { if (flags & FBF_PUFFTARGET) proj.target = puff; if (flags & FBF_PUFFMASTER) proj.master = puff; if (flags & FBF_PUFFTRACER) proj.tracer = puff; } } } if (puff && temp) { puff.Destroy(); } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- void A_CustomBulletAttack(double spread_xy, double spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", double range = 0, int flags = 0, int ptr = AAPTR_TARGET, class missile = null, double Spawnheight = 32, double Spawnofs_xy = 0) { let ref = GetPointer(ptr); if (range == 0) range = MISSILERANGE; int i; double bangle; double bslope = 0.; int laflags = (flags & CBAF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 0; FTranslatedLineTarget t; if (ref != NULL || (flags & CBAF_AIMFACING)) { if (!(flags & CBAF_AIMFACING)) { A_Face(ref); } bangle = self.Angle; if (!(flags & CBAF_NOPITCH)) bslope = AimLineAttack (bangle, MISSILERANGE); if (pufftype == null) pufftype = 'BulletPuff'; A_StartSound(AttackSound, CHAN_WEAPON); for (i = 0; i < numbullets; i++) { double pangle = bangle; double slope = bslope; if (flags & CBAF_EXPLICITANGLE) { pangle += spread_xy; slope += spread_z; } else { pangle += spread_xy * Random2[cwbullet]() / 255.; slope += spread_z * Random2[cwbullet]() / 255.; } int damage = damageperbullet; if (!(flags & CBAF_NORANDOM)) damage *= random[cwbullet](1, 3); let puff = LineAttack(pangle, range, slope, damage, 'Hitscan', pufftype, laflags, t); if (missile != null && pufftype != null) { double ang = pangle - 90; let ofs = AngleToVector(ang, Spawnofs_xy); let pos = self.pos; SetXYZ(Vec3Offset(ofs.x, ofs.y, 0.)); let proj = SpawnMissileAngleZSpeed(Pos.Z + GetBobOffset() + Spawnheight, missile, self.Angle, 0, GetDefaultByType(missile).Speed, self, false); SetXYZ(pos); if (proj) { bool temp = (puff == null); if (!puff) { puff = LineAttack(pangle, range, slope, 0, 'Hitscan', pufftype, laflags | LAF_NOINTERACT, t); } if (puff) { AimBulletMissile(proj, puff, flags, temp, true); if (t.unlinked) { // Arbitary portals will make angle and pitch calculations unreliable. // So use the angle and pitch we passed instead. proj.Angle = pangle; proj.Pitch = bslope; proj.Vel3DFromAngle(proj.Speed, proj.Angle, proj.Pitch); } } } } } } } //============================================================================ // // P_DaggerAlert // //============================================================================ void DaggerAlert(Actor target) { Actor looker; if (LastHeard != NULL) return; if (health <= 0) return; if (!bIsMonster) return; if (bInCombat) return; bInCombat = true; self.target = target; let painstate = FindState('Pain.Dagger'); if (painstate != NULL) { SetState(painstate); } for (looker = cursector.thinglist; looker != NULL; looker = looker.snext) { if (looker == self || looker == target) continue; if (looker.health <= 0) continue; if (!looker.bSeesDaggers) continue; if (!looker.bInCombat) { if (!looker.CheckSight(target) && !looker.CheckSight(self)) continue; looker.target = target; if (looker.SeeSound) { looker.A_StartSound(looker.SeeSound, CHAN_VOICE); } looker.SetState(looker.SeeState); looker.bInCombat = true; } } } //=========================================================================== // // Common code for A_SpawnItem and A_SpawnItemEx // //=========================================================================== bool InitSpawnedItem(Actor mo, int flags) { if (mo == NULL) { return false; } Actor originator = self; if (!(mo.bDontTranslate)) { if (flags & SXF_TRANSFERTRANSLATION) { mo.Translation = Translation; } else if (flags & SXF_USEBLOODCOLOR) { // [XA] Use the spawning actor's BloodColor to translate the newly-spawned object. mo.Translation = BloodTranslation; } } if (flags & SXF_TRANSFERPOINTERS) { mo.target = self.target; mo.master = self.master; // This will be overridden later if SXF_SETMASTER is set mo.tracer = self.tracer; } mo.Angle = self.Angle; if (flags & SXF_TRANSFERPITCH) { mo.Pitch = self.Pitch; } if (!(flags & SXF_ORIGINATOR)) { while (originator && (originator.bMissile || originator.default.bMissile)) { originator = originator.target; } } if (flags & SXF_TELEFRAG) { mo.TeleportMove(mo.Pos, true); // This is needed to ensure consistent behavior. // Otherwise it will only spawn if nothing gets telefragged flags |= SXF_NOCHECKPOSITION; } if (mo.bIsMonster) { if (!(flags & SXF_NOCHECKPOSITION) && !mo.TestMobjLocation()) { // The monster is blocked so don't spawn it at all! mo.ClearCounters(); mo.Destroy(); return false; } else if (originator && !(flags & SXF_NOPOINTERS)) { if (originator.bIsMonster) { // If this is a monster transfer all friendliness information mo.CopyFriendliness(originator, true); } else if (originator.player) { // A player always spawns a monster friendly to him mo.bFriendly = true; mo.SetFriendPlayer(originator.player); Actor attacker=originator.player.attacker; if (attacker) { if (!(attacker.bFriendly) || (deathmatch && attacker.FriendPlayer != 0 && attacker.FriendPlayer != mo.FriendPlayer)) { // Target the monster which last attacked the player mo.LastHeard = mo.target = attacker; } } } } } else if (!(flags & SXF_TRANSFERPOINTERS)) { // If this is a missile or something else set the target to the originator mo.target = originator ? originator : self; } if (flags & SXF_NOPOINTERS) { //[MC]Intentionally eliminate pointers. Overrides TRANSFERPOINTERS, but is overridden by SETMASTER/TARGET/TRACER. mo.LastHeard = NULL; //Sanity check. mo.target = NULL; mo.master = NULL; mo.tracer = NULL; } if (flags & SXF_SETMASTER) { // don't let it attack you (optional)! mo.master = originator; } if (flags & SXF_SETTARGET) { mo.target = originator; } if (flags & SXF_SETTRACER) { mo.tracer = originator; } if (flags & SXF_TRANSFERSCALE) { mo.Scale = self.Scale; } if (flags & SXF_TRANSFERAMBUSHFLAG) { mo.bAmbush = bAmbush; } if (flags & SXF_CLEARCALLERTID) { self.ChangeTid(0); } if (flags & SXF_TRANSFERSPECIAL) { mo.special = self.special; mo.args[0] = self.args[0]; mo.args[1] = self.args[1]; mo.args[2] = self.args[2]; mo.args[3] = self.args[3]; mo.args[4] = self.args[4]; } if (flags & SXF_CLEARCALLERSPECIAL) { self.special = 0; self.args[0] = 0; self.args[1] = 0; self.args[2] = 0; self.args[3] = 0; self.args[4] = 0; } if (flags & SXF_TRANSFERSTENCILCOL) { mo.SetShade(self.fillcolor); } if (flags & SXF_TRANSFERALPHA) { mo.Alpha = self.Alpha; } if (flags & SXF_TRANSFERRENDERSTYLE) { mo.RenderStyle = self.RenderStyle; } if (flags & SXF_TRANSFERSPRITEFRAME) { mo.sprite = self.sprite; mo.frame = self.frame; } if (flags & SXF_TRANSFERROLL) { mo.Roll = self.Roll; } if (flags & SXF_ISTARGET) { self.target = mo; } if (flags & SXF_ISMASTER) { self.master = mo; } if (flags & SXF_ISTRACER) { self.tracer = mo; } return true; } //=========================================================================== // // A_SpawnItem // // Spawns an item in front of the caller like Heretic's time bomb // //=========================================================================== action bool, Actor A_SpawnItem(class missile = "Unknown", double distance = 0, double zheight = 0, bool useammo = true, bool transfer_translation = false) { if (missile == NULL) { return false, null; } // Don't spawn monsters if this actor has been massacred if (DamageType == 'Massacre' && GetDefaultByType(missile).bIsMonster) { return true, null; } if (stateinfo != null && stateinfo.mStateType == STATE_Psprite) { let player = self.player; if (player == null) return false, null; let weapon = player.ReadyWeapon; // Used from a weapon, so use some ammo if (weapon == NULL || (useammo && !weapon.DepleteAmmo(weapon.bAltFire))) { return true, null; } } let mo = Spawn(missile, Vec3Angle(distance, Angle, -Floorclip + GetBobOffset() + zheight), ALLOW_REPLACE); int flags = (transfer_translation ? SXF_TRANSFERTRANSLATION : 0) + (useammo ? SXF_SETMASTER : 0); bool res = InitSpawnedItem(mo, flags); // for an inventory item's use state return res, mo; } //=========================================================================== // // A_SpawnItemEx // // Enhanced spawning function // //=========================================================================== bool, Actor A_SpawnItemEx(class missile, double xofs = 0, double yofs = 0, double zofs = 0, double xvel = 0, double yvel = 0, double zvel = 0, double angle = 0, int flags = 0, int failchance = 0, int tid=0) { if (missile == NULL) { return false, null; } if (failchance > 0 && random[spawnitemex]() < failchance) { return true, null; } // Don't spawn monsters if this actor has been massacred if (DamageType == 'Massacre' && GetDefaultByType(missile).bIsMonster) { return true, null; } Vector2 pos; if (!(flags & SXF_ABSOLUTEANGLE)) { angle += self.Angle; } double s = sin(angle); double c = cos(angle); if (flags & SXF_ABSOLUTEPOSITION) { pos = Vec2Offset(xofs, yofs); } else { // in relative mode negative y values mean 'left' and positive ones mean 'right' // This is the inverse orientation of the absolute mode! pos = Vec2Offset(xofs * c + yofs * s, xofs * s - yofs*c); } if (!(flags & SXF_ABSOLUTEVELOCITY)) { // Same orientation issue here! double newxvel = xvel * c + yvel * s; yvel = xvel * s - yvel * c; xvel = newxvel; } let mo = Spawn(missile, (pos, self.pos.Z - Floorclip + GetBobOffset() + zofs), ALLOW_REPLACE); bool res = InitSpawnedItem(mo, flags); if (res) { if (tid != 0) { mo.ChangeTid(tid); } mo.Vel = (xvel, yvel, zvel); if (flags & SXF_MULTIPLYSPEED) { mo.Vel *= mo.Speed; } mo.Angle = angle; } return res, mo; } //=========================================================================== // // A_ThrowGrenade // // Throws a grenade (like Hexen's fighter flechette) // //=========================================================================== action bool, Actor A_ThrowGrenade(class missile, double zheight = 0, double xyvel = 0, double zvel = 0, bool useammo = true) { if (missile == NULL) { return false, null; } if (stateinfo != null && stateinfo.mStateType == STATE_Psprite) { let player = self.player; if (player == null) return false, null; let weapon = player.ReadyWeapon; // Used from a weapon, so use some ammo if (weapon == NULL || (useammo && !weapon.DepleteAmmo(weapon.bAltFire))) { return true, null; } } let bo = Spawn(missile, pos + (0, 0, (-Floorclip + GetBobOffset() + zheight + 35 + (player? player.crouchoffset : 0.))), ALLOW_REPLACE); if (bo) { self.PlaySpawnSound(bo); if (xyvel != 0) bo.Speed = xyvel; bo.Angle = Angle + (random[grenade](-4, 3) * (360./256.)); let pitch = -self.Pitch; let angle = bo.Angle; // There are two vectors we are concerned about here: xy and z. We rotate // them separately according to the shooter's pitch and then sum them to // get the final velocity vector to shoot with. double xy_xyscale = bo.Speed * cos(pitch); double xy_velz = bo.Speed * sin(pitch); double xy_velx = xy_xyscale * cos(angle); double xy_vely = xy_xyscale * sin(angle); pitch = self.Pitch; double z_xyscale = zvel * sin(pitch); double z_velz = zvel * cos(pitch); double z_velx = z_xyscale * cos(angle); double z_vely = z_xyscale * sin(angle); bo.Vel.X = xy_velx + z_velx + Vel.X / 2; bo.Vel.Y = xy_vely + z_vely + Vel.Y / 2; bo.Vel.Z = xy_velz + z_velz; bo.target = self; if (!bo.CheckMissileSpawn(radius)) bo = null; return true, bo; } else { return false, null; } } //--------------------------------------------------------------------------- // // P_CheckSplash // // Checks for splashes caused by explosions // //--------------------------------------------------------------------------- void CheckSplash(double distance) { double floorh; sector floorsec; [floorh, floorsec] = curSector.LowestFloorAt(pos.XY); if (pos.Z <= floorz + distance && floorsector == floorsec && curSector.GetHeightSec() == NULL && floorsec.heightsec == NULL) { // Explosion splashes never alert monsters. This is because A_Explode has // a separate parameter for that so this would get in the way of proper // behavior. Vector3 pos = PosRelative(floorsec); pos.Z = floorz; HitWater (floorsec, pos, false, false); } } //========================================================================== // // Parameterized version of A_Explode // //========================================================================== int A_Explode(int damage = -1, int distance = -1, int flags = XF_HURTSOURCE, bool alert = false, int fulldamagedistance = 0, int nails = 0, int naildamage = 10, class pufftype = "BulletPuff", name damagetype = "none") { if (damage < 0) // get parameters from metadata { damage = ExplosionDamage; distance = ExplosionRadius; flags = !DontHurtShooter; alert = false; } if (distance <= 0) distance = damage; // NailBomb effect, from SMMU but not from its source code: instead it was implemented and // generalized from the documentation at http://www.doomworld.com/eternity/engine/codeptrs.html if (nails) { double ang; for (int i = 0; i < nails; i++) { ang = i*360./nails; // Comparing the results of a test wad with Eternity, it seems A_NailBomb does not aim LineAttack(ang, MISSILERANGE, 0., //P_AimLineAttack (self, ang, MISSILERANGE), naildamage, 'Hitscan', pufftype, bMissile ? LAF_TARGETISSOURCE : 0); } } if (!(flags & XF_EXPLICITDAMAGETYPE) && damagetype == 'None') { damagetype = self.DamageType; } int pflags = 0; if (flags & XF_HURTSOURCE) pflags |= RADF_HURTSOURCE; if (flags & XF_NOTMISSILE) pflags |= RADF_SOURCEISSPOT; if (flags & XF_THRUSTZ) pflags |= RADF_THRUSTZ; if (flags & XF_THRUSTLESS) pflags |= RADF_THRUSTLESS; if (flags & XF_NOALLIES) pflags |= RADF_NOALLIES; if (flags & XF_CIRCULAR) pflags |= RADF_CIRCULAR; int count = RadiusAttack (target, damage, distance, damagetype, pflags, fulldamagedistance); if (!(flags & XF_NOSPLASH)) CheckSplash(distance); if (alert && target != NULL && target.player != NULL) { SoundAlert(target); } return count; } deprecated("2.3", "For Dehacked use only") void A_NailBomb() { A_Explode(nails:30); } deprecated("2.3", "For Dehacked use only") void A_RadiusDamage(int dam, int dist) { A_Explode(dam, dist); } //========================================================================== // // A_RadiusThrust // //========================================================================== void A_RadiusThrust(int force = 128, int distance = -1, int flags = RTF_AFFECTSOURCE, int fullthrustdistance = 0, name species = "None") { if (force == 0) force = 128; if (distance <= 0) distance = abs(force); bool nothrust = false; if (target) { nothrust = target.bNoDamageThrust; // Temporarily negate MF2_NODMGTHRUST on the shooter, since it renders this function useless. if (!(flags & RTF_NOTMISSILE)) { target.bNoDamageThrust = false; } } RadiusAttack (target, force, distance, DamageType, flags | RADF_NODAMAGE, fullthrustdistance, species); CheckSplash(distance); if (target) target.bNoDamageThrust = nothrust; } //========================================================================== // // A_Detonate // killough 8/9/98: same as A_Explode, except that the damage is variable // //========================================================================== void A_Detonate() { int damage = GetMissileDamage(0, 1); RadiusAttack (target, damage, damage, DamageType, RADF_HURTSOURCE); CheckSplash(damage); } //========================================================================== // // old customizable attack functions which use actor parameters. // //========================================================================== private void DoAttack (bool domelee, bool domissile, int MeleeDamage, Sound MeleeSound, Class MissileType,double MissileHeight) { let targ = target; if (targ == NULL) return; A_FaceTarget (); if (domelee && MeleeDamage>0 && CheckMeleeRange ()) { int damage = random[CustomMelee](1, 8) * MeleeDamage; if (MeleeSound) A_StartSound (MeleeSound, CHAN_WEAPON); int newdam = targ.DamageMobj (self, self, damage, 'Melee'); targ.TraceBleed (newdam > 0 ? newdam : damage, self); } else if (domissile && MissileType != NULL) { // This seemingly senseless code is needed for proper aiming. double add = MissileHeight + GetBobOffset() - 32; AddZ(add); Actor missile = SpawnMissileXYZ (Pos + (0, 0, 32), targ, MissileType, false); AddZ(-add); if (missile) { // automatic handling of seeker missiles if (missile.bSeekerMissile) { missile.tracer = targ; } missile.CheckMissileSpawn(radius); } } } deprecated("2.3", "Use CustomMeleeAttack() instead") void A_MeleeAttack() { DoAttack(true, false, MeleeDamage, MeleeSound, NULL, 0); } deprecated("2.3", "Use A_SpawnProjectile() instead") void A_MissileAttack() { Class MissileType = MissileName; DoAttack(false, true, 0, 0, MissileType, MissileHeight); } deprecated("2.3", "Use A_BasicAttack() instead") void A_ComboAttack() { Class MissileType = MissileName; DoAttack(true, true, MeleeDamage, MeleeSound, MissileType, MissileHeight); } void A_BasicAttack(int melee_damage, sound melee_sound, class missile_type, double missile_height) { DoAttack(true, true, melee_damage, melee_sound, missile_type, missile_height); } //========================================================================== // // called with the victim as 'self' // //========================================================================== virtual void SpawnLineAttackBlood(Actor attacker, Vector3 bleedpos, double SrcAngleFromTarget, int originaldamage, int actualdamage) { if (!bNoBlood && !bDormant && !bInvulnerable) { let player = attacker.player; let weapon = player? player.ReadyWeapon : null; let axeBlood = (weapon && weapon.bAxeBlood); let bloodsplatter = attacker.bBloodSplatter || axeBlood; if (!bloodsplatter) { SpawnBlood(bleedpos, SrcAngleFromTarget, actualdamage > 0 ? actualdamage : originaldamage); } else if (originaldamage) { if (axeBlood) { BloodSplatter(bleedpos, SrcAngleFromTarget, true); } // No else here... if (random[LineAttack]() < 192) { BloodSplatter(bleedpos, SrcAngleFromTarget, false); } } } } } // constants for A_PlaySound enum ESoundFlags { CHAN_AUTO = 0, CHAN_WEAPON = 1, CHAN_VOICE = 2, CHAN_ITEM = 3, CHAN_BODY = 4, CHAN_5 = 5, CHAN_6 = 6, CHAN_7 = 7, // modifier flags CHAN_LISTENERZ = 8, CHAN_MAYBE_LOCAL = 16, CHAN_UI = 32, CHAN_NOPAUSE = 64, CHAN_LOOP = 256, CHAN_PICKUP = (CHAN_ITEM|CHAN_MAYBE_LOCAL), // Do not use this with A_StartSound! It would not do what is expected. CHAN_NOSTOP = 4096, CHAN_OVERLAP = 8192, // Same as above, with an F appended to allow better distinction of channel and channel flags. CHANF_DEFAULT = 0, // just to make the code look better and avoid literal 0's. CHANF_LISTENERZ = 8, CHANF_MAYBE_LOCAL = 16, CHANF_UI = 32, CHANF_NOPAUSE = 64, CHANF_LOOP = 256, CHANF_NOSTOP = 4096, CHANF_OVERLAP = 8192, CHANF_LOCAL = 16384, CHANF_LOOPING = CHANF_LOOP | CHANF_NOSTOP, // convenience value for replicating the old 'looping' boolean. }; // sound attenuation values const ATTN_NONE = 0; const ATTN_NORM = 1; const ATTN_IDLE = 1.001; const ATTN_STATIC = 3; enum ERenderStyle { STYLE_None, // Do not draw STYLE_Normal, // Normal; just copy the image to the screen STYLE_Fuzzy, // Draw silhouette using "fuzz" effect STYLE_SoulTrans, // Draw translucent with amount in r_transsouls STYLE_OptFuzzy, // Draw as fuzzy or translucent, based on user preference STYLE_Stencil, // Fill image interior with alphacolor STYLE_Translucent, // Draw translucent STYLE_Add, // Draw additive STYLE_Shaded, // Treat patch data as alpha values for alphacolor STYLE_TranslucentStencil, STYLE_Shadow, STYLE_Subtract, // Actually this is 'reverse subtract' but this is what normal people would expect by 'subtract'. STYLE_AddStencil, // Fill image interior with alphacolor STYLE_AddShaded, // Treat patch data as alpha values for alphacolor STYLE_Multiply, // Multiply source with destination (HW renderer only.) STYLE_InverseMultiply, // Multiply source with inverse of destination (HW renderer only.) STYLE_ColorBlend, // Use color intensity as transparency factor STYLE_Source, // No blending (only used internally) STYLE_ColorAdd, // Use color intensity as transparency factor and blend additively. }; enum EGameState { GS_LEVEL, GS_INTERMISSION, GS_FINALE, GS_DEMOSCREEN, GS_FULLCONSOLE, // [RH] Fullscreen console GS_HIDECONSOLE, // [RH] The menu just did something that should hide fs console GS_STARTUP, // [RH] Console is fullscreen, and game is just starting GS_TITLELEVEL, // [RH] A combination of GS_LEVEL and GS_DEMOSCREEN GS_INTRO, GS_CUTSCENE, GS_MENUSCREEN = GS_DEMOSCREEN, } const TEXTCOLOR_BRICK = "\034A"; const TEXTCOLOR_TAN = "\034B"; const TEXTCOLOR_GRAY = "\034C"; const TEXTCOLOR_GREY = "\034C"; const TEXTCOLOR_GREEN = "\034D"; const TEXTCOLOR_BROWN = "\034E"; const TEXTCOLOR_GOLD = "\034F"; const TEXTCOLOR_RED = "\034G"; const TEXTCOLOR_BLUE = "\034H"; const TEXTCOLOR_ORANGE = "\034I"; const TEXTCOLOR_WHITE = "\034J"; const TEXTCOLOR_YELLOW = "\034K"; const TEXTCOLOR_UNTRANSLATED = "\034L"; const TEXTCOLOR_BLACK = "\034M"; const TEXTCOLOR_LIGHTBLUE = "\034N"; const TEXTCOLOR_CREAM = "\034O"; const TEXTCOLOR_OLIVE = "\034P"; const TEXTCOLOR_DARKGREEN = "\034Q"; const TEXTCOLOR_DARKRED = "\034R"; const TEXTCOLOR_DARKBROWN = "\034S"; const TEXTCOLOR_PURPLE = "\034T"; const TEXTCOLOR_DARKGRAY = "\034U"; const TEXTCOLOR_CYAN = "\034V"; const TEXTCOLOR_ICE = "\034W"; const TEXTCOLOR_FIRE = "\034X"; const TEXTCOLOR_SAPPHIRE = "\034Y"; const TEXTCOLOR_TEAL = "\034Z"; const TEXTCOLOR_NORMAL = "\034-"; const TEXTCOLOR_BOLD = "\034+"; const TEXTCOLOR_CHAT = "\034*"; const TEXTCOLOR_TEAMCHAT = "\034!"; enum EMonospacing { Mono_Off = 0, Mono_CellLeft = 1, Mono_CellCenter = 2, Mono_CellRight = 3 }; enum EPrintLevel { PRINT_LOW, // pickup messages PRINT_MEDIUM, // death messages PRINT_HIGH, // critical messages PRINT_CHAT, // chat messages PRINT_TEAMCHAT, // chat messages from a teammate PRINT_LOG, // only to logfile PRINT_BOLD = 200, // What Printf_Bold used PRINT_TYPES = 1023, // Bitmask. PRINT_NONOTIFY = 1024, // Flag - do not add to notify buffer PRINT_NOLOG = 2048, // Flag - do not print to log file }; enum EConsoleState { c_up = 0, c_down = 1, c_falling = 2, c_rising = 3 }; /* // These are here to document the intrinsic methods and fields available on // the built-in ZScript types struct Vector2 { Vector2(x, y); double x, y; native double Length(); native Vector2 Unit(); // The dot product of two vectors can be calculated like this: // double d = a dot b; } struct Vector3 { Vector3(x, y, z); double x, y, z; Vector2 xy; // Convenient access to the X and Y coordinates of a 3D vector native double Length(); native Vector3 Unit(); // The dot product of two vectors can be calculated like this: // double d = a dot b; // The cross product of two vectors can be calculated like this: // Vector3 d = a cross b; } */ struct _ native // These are the global variables, the struct is only here to avoid extending the parser for this. { native readonly Array AllClasses; native internal readonly Map AllServices; native readonly bool multiplayer; native @KeyBindings Bindings; native @KeyBindings AutomapBindings; native readonly @GameInfoStruct gameinfo; native readonly ui bool netgame; native readonly uint gameaction; native readonly int gamestate; native readonly Font smallfont; native readonly Font smallfont2; native readonly Font bigfont; native readonly Font confont; native readonly Font NewConsoleFont; native readonly Font NewSmallFont; native readonly Font AlternativeSmallFont; native readonly Font AlternativeBigFont; native readonly Font OriginalSmallFont; native readonly Font OriginalBigFont; native readonly Font intermissionfont; native readonly int CleanXFac; native readonly int CleanYFac; native readonly int CleanWidth; native readonly int CleanHeight; native readonly int CleanXFac_1; native readonly int CleanYFac_1; native readonly int CleanWidth_1; native readonly int CleanHeight_1; native ui int menuactive; native readonly @FOptionMenuSettings OptionMenuSettings; native readonly bool demoplayback; native ui int BackbuttonTime; native ui float BackbuttonAlpha; native readonly @MusPlayingInfo musplaying; native readonly bool generic_ui; native readonly int GameTicRate; native MenuDelegateBase menuDelegate; native readonly int consoleplayer; native readonly double NotifyFontScale; native readonly int paused; native readonly ui uint8 ConsoleState; } struct System native { native static void StopMusic(); native static void StopAllSounds(); native static bool SoundEnabled(); native static bool MusicEnabled(); native static double GetTimeFrac(); static bool specialKeyEvent(InputEvent ev) { if (ev.type == InputEvent.Type_KeyDown || ev.type == InputEvent.Type_KeyUp) { int key = ev.KeyScan; let binding = Bindings.GetBinding(key); bool volumekeys = key == InputEvent.KEY_VOLUMEDOWN || key == InputEvent.KEY_VOLUMEUP; bool gamepadkeys = key > InputEvent.KEY_LASTJOYBUTTON && key < InputEvent.KEY_PAD_LTHUMB_RIGHT; bool altkeys = key == InputEvent.KEY_LALT || key == InputEvent.KEY_RALT; if (volumekeys || gamepadkeys || altkeys || binding ~== "screenshot") return true; } return false; } } struct MusPlayingInfo native { native String name; native int baseorder; native bool loop; native voidptr handle; }; struct TexMan { enum EUseTypes { Type_Any, Type_Wall, Type_Flat, Type_Sprite, Type_WallPatch, Type_Build, Type_SkinSprite, Type_Decal, Type_MiscPatch, Type_FontChar, Type_Override, // For patches between TX_START/TX_END Type_Autopage, // Automap background - used to enable the use of FAutomapTexture Type_SkinGraphic, Type_Null, Type_FirstDefined, }; enum EFlags { TryAny = 1, Overridable = 2, ReturnFirst = 4, AllowSkins = 8, ShortNameOnly = 16, DontCreate = 32, Localize = 64, ForceLookup = 128, NoAlias = 256 }; enum ETexReplaceFlags { NOT_BOTTOM = 1, NOT_MIDDLE = 2, NOT_TOP = 4, NOT_FLOOR = 8, NOT_CEILING = 16, NOT_WALL = 7, NOT_FLAT = 24 }; native static TextureID CheckForTexture(String name, int usetype = Type_Any, int flags = TryAny); native static String GetName(TextureID tex); native static int, int GetSize(TextureID tex); native static Vector2 GetScaledSize(TextureID tex); native static Vector2 GetScaledOffset(TextureID tex); native static int CheckRealHeight(TextureID tex); native static bool OkForLocalization(TextureID patch, String textSubstitute); native static bool UseGamePalette(TextureID tex); native static Canvas GetCanvas(String texture); } /* // Intrinsic TextureID methods // This isn't really a class, and can be used as an integer struct TextureID { native bool IsValid(); native bool IsNull(); native bool Exists(); native void SetInvalid(); native void SetNull(); } // 32-bit RGBA color - each component is one byte, or 8-bit // This isn't really a class, and can be used as an integer struct Color { // Constructor - alpha channel is optional Color(int alpha, int red, int green, int blue); Color(int red, int green, int blue); // Alpha is 0 if omitted int r; // Red int g; // Green int b; // Blue int a; // Alpha } // Name - a string with an integer ID struct Name { Name(Name name); Name(String name); } // Sound ID - can be created by casting from a string (name from SNDINFO) or an // integer (sound ID as integer). struct Sound { Sound(String soundName); Sound(int id); } */ enum EScaleMode { FSMode_None = 0, FSMode_ScaleToFit = 1, FSMode_ScaleToFill = 2, FSMode_ScaleToFit43 = 3, FSMode_ScaleToScreen = 4, FSMode_ScaleToFit43Top = 5, FSMode_ScaleToFit43Bottom = 6, FSMode_ScaleToHeight = 7, FSMode_Max, // These all use ScaleToFit43, their purpose is to cut down on verbosity because they imply the virtual screen size. FSMode_Predefined = 1000, FSMode_Fit320x200 = 1000, FSMode_Fit320x240, FSMode_Fit640x400, FSMode_Fit640x480, FSMode_Fit320x200Top, FSMode_Predefined_Max, }; enum DrawTextureTags { TAG_USER = (1<<30), DTA_Base = TAG_USER + 5000, DTA_DestWidth, // width of area to draw to DTA_DestHeight, // height of area to draw to DTA_Alpha, // alpha value for translucency DTA_FillColor, // color to stencil onto the destination (RGB is the color for truecolor drawers, A is the palette index for paletted drawers) DTA_TranslationIndex, // translation table to recolor the source DTA_AlphaChannel, // bool: the source is an alpha channel; used with DTA_FillColor DTA_Clean, // bool: scale texture size and position by CleanXfac and CleanYfac DTA_320x200, // bool: scale texture size and position to fit on a virtual 320x200 screen DTA_Bottom320x200, // bool: same as DTA_320x200 but centers virtual screen on bottom for 1280x1024 targets DTA_CleanNoMove, // bool: like DTA_Clean but does not reposition output position DTA_CleanNoMove_1, // bool: like DTA_CleanNoMove, but uses Clean[XY]fac_1 instead DTA_FlipX, // bool: flip image horizontally //FIXME: Does not work with DTA_Window(Left|Right) DTA_ShadowColor, // color of shadow DTA_ShadowAlpha, // alpha of shadow DTA_Shadow, // set shadow color and alphas to defaults DTA_VirtualWidth, // pretend the canvas is this wide DTA_VirtualHeight, // pretend the canvas is this tall DTA_TopOffset, // override texture's top offset DTA_LeftOffset, // override texture's left offset DTA_CenterOffset, // bool: override texture's left and top offsets and set them for the texture's middle DTA_CenterBottomOffset,// bool: override texture's left and top offsets and set them for the texture's bottom middle DTA_WindowLeft, // don't draw anything left of this column (on source, not dest) DTA_WindowRight, // don't draw anything at or to the right of this column (on source, not dest) DTA_ClipTop, // don't draw anything above this row (on dest, not source) DTA_ClipBottom, // don't draw anything at or below this row (on dest, not source) DTA_ClipLeft, // don't draw anything to the left of this column (on dest, not source) DTA_ClipRight, // don't draw anything at or to the right of this column (on dest, not source) DTA_Masked, // true(default)=use masks from texture, false=ignore masks DTA_HUDRules, // use fullscreen HUD rules to position and size textures DTA_HUDRulesC, // only used internally for marking HUD_HorizCenter DTA_KeepRatio, // doesn't adjust screen size for DTA_Virtual* if the aspect ratio is not 4:3 DTA_RenderStyle, // same as render style for actors DTA_ColorOverlay, // DWORD: ARGB to overlay on top of image; limited to black for software DTA_Internal1, DTA_Internal2, DTA_Desaturate, // explicit desaturation factor (does not do anything in Legacy OpenGL) DTA_Fullscreen, // Draw image fullscreen (same as DTA_VirtualWidth/Height with graphics size.) // floating point duplicates of some of the above: DTA_DestWidthF, DTA_DestHeightF, DTA_TopOffsetF, DTA_LeftOffsetF, DTA_VirtualWidthF, DTA_VirtualHeightF, DTA_WindowLeftF, DTA_WindowRightF, // For DrawText calls only: DTA_TextLen, // stop after this many characters, even if \0 not hit DTA_CellX, // horizontal size of character cell DTA_CellY, // vertical size of character cell DTA_Color, DTA_FlipY, // bool: flip image vertically DTA_SrcX, // specify a source rectangle (this supersedes the poorly implemented DTA_WindowLeft/Right DTA_SrcY, DTA_SrcWidth, DTA_SrcHeight, DTA_LegacyRenderStyle, // takes an old-style STYLE_* constant instead of an FRenderStyle DTA_Internal3, DTA_Spacing, // Strings only: Additional spacing between characters DTA_Monospace, // Strings only: Use a fixed distance between characters. DTA_FullscreenEx, // advanced fullscreen control. DTA_FullscreenScale, // enable DTA_Fullscreen coordinate calculation for placed overlays. DTA_ScaleX, DTA_ScaleY, DTA_ViewportX, // Defines the viewport on the screen that should be rendered to. DTA_ViewportY, DTA_ViewportWidth, DTA_ViewportHeight, DTA_CenterOffsetRel, // Apply texture offsets relative to center, instead of top left. This is standard alignment for Build's 2D content. DTA_TopLeft, // always align to top left. Added to have a boolean condition for this alignment. DTA_Pin, // Pin a non-widescreen image to the left/right edge of the screen. DTA_Rotate, DTA_FlipOffsets, // Flips offsets when using DTA_FlipX and DTA_FlipY, this cannot be automatic due to unexpected behavior with unoffsetted graphics. DTA_Indexed, // Use an indexed texture combined with the given translation. DTA_CleanTop, // Like DTA_Clean but aligns to the top of the screen instead of the center. DTA_NoOffset, // Ignore 2D drawer's offset. DTA_Localize, // localize drawn string, for DrawText only }; enum StencilOp { SOP_Keep = 0, SOP_Increment = 1, SOP_Decrement = 2 }; enum StencilFlags { SF_AllOn = 0, SF_ColorMaskOff = 1, SF_DepthMaskOff = 2 }; class Shape2DTransform : Object native { native void Clear(); native void Rotate(double angle); native void Scale(Vector2 scaleVec); native void Translate(Vector2 translateVec); native void From2D(double m00, double m01, double m10, double m11, double vx, double vy); } class Shape2D : Object native { enum EClearWhich { C_Verts = 1, C_Coords = 2, C_Indices = 4, }; native void SetTransform(Shape2DTransform transform); native void Clear( int which = C_Verts|C_Coords|C_Indices ); native void PushVertex( Vector2 v ); native void PushCoord( Vector2 c ); native void PushTriangle( int a, int b, int c ); } class Canvas : Object native abstract { native void Clear(int left, int top, int right, int bottom, Color color, int palcolor = -1); native void Dim(Color col, double amount, int x, int y, int w, int h, ERenderStyle style = STYLE_Translucent); native vararg void DrawTexture(TextureID tex, bool animate, double x, double y, ...); native vararg void DrawShape(TextureID tex, bool animate, Shape2D s, ...); native vararg void DrawShapeFill(Color col, double amount, Shape2D s, ...); native vararg void DrawChar(Font font, int normalcolor, double x, double y, int character, ...); native vararg void DrawText(Font font, int normalcolor, double x, double y, String text, ...); native void DrawLine(double x0, double y0, double x1, double y1, Color color, int alpha = 255); native void DrawLineFrame(Color color, int x0, int y0, int w, int h, int thickness = 1); native void DrawThickLine(double x0, double y0, double x1, double y1, double thickness, Color color, int alpha = 255); native Vector2, Vector2 VirtualToRealCoords(Vector2 pos, Vector2 size, Vector2 vsize, bool vbottom=false, bool handleaspect=true); native void SetClipRect(int x, int y, int w, int h); native void ClearClipRect(); native int, int, int, int GetClipRect(); native double, double, double, double GetFullscreenRect(double vwidth, double vheight, int fsmode); native Vector2 SetOffset(double x, double y); native void ClearScreen(color col = 0); native void SetScreenFade(double factor); native void EnableStencil(bool on); native void SetStencil(int offs, int op, int flags = -1); native void ClearStencil(); native void SetTransform(Shape2DTransform transform); native void ClearTransform(); } struct Screen native { native static Color PaletteColor(int index); native static int GetWidth(); native static int GetHeight(); native static Vector2 GetTextScreenSize(); native static void Clear(int left, int top, int right, int bottom, Color color, int palcolor = -1); native static void Dim(Color col, double amount, int x, int y, int w, int h, ERenderStyle style = STYLE_Translucent); native static vararg void DrawTexture(TextureID tex, bool animate, double x, double y, ...); native static vararg void DrawShape(TextureID tex, bool animate, Shape2D s, ...); native static vararg void DrawShapeFill(Color col, double amount, Shape2D s, ...); native static vararg void DrawChar(Font font, int normalcolor, double x, double y, int character, ...); native static vararg void DrawText(Font font, int normalcolor, double x, double y, String text, ...); native static void DrawLine(double x0, double y0, double x1, double y1, Color color, int alpha = 255); native static void DrawLineFrame(Color color, int x0, int y0, int w, int h, int thickness = 1); native static void DrawThickLine(double x0, double y0, double x1, double y1, double thickness, Color color, int alpha = 255); native static Vector2, Vector2 VirtualToRealCoords(Vector2 pos, Vector2 size, Vector2 vsize, bool vbottom=false, bool handleaspect=true); native static double GetAspectRatio(); native static void SetClipRect(int x, int y, int w, int h); native static void ClearClipRect(); native static int, int, int, int GetClipRect(); native static int, int, int, int GetViewWindow(); native static double, double, double, double GetFullscreenRect(double vwidth, double vheight, int fsmode); native static Vector2 SetOffset(double x, double y); native static void ClearScreen(color col = 0); native static void SetScreenFade(double factor); native static void EnableStencil(bool on); native static void SetStencil(int offs, int op, int flags = -1); native static void ClearStencil(); native static void SetTransform(Shape2DTransform transform); native static void ClearTransform(); } struct Font native { enum EColorRange { CR_UNDEFINED = -1, CR_NATIVEPAL = -1, CR_BRICK, CR_TAN, CR_GRAY, CR_GREY = CR_GRAY, CR_GREEN, CR_BROWN, CR_GOLD, CR_RED, CR_BLUE, CR_ORANGE, CR_WHITE, CR_YELLOW, CR_UNTRANSLATED, CR_BLACK, CR_LIGHTBLUE, CR_CREAM, CR_OLIVE, CR_DARKGREEN, CR_DARKRED, CR_DARKBROWN, CR_PURPLE, CR_DARKGRAY, CR_CYAN, CR_ICE, CR_FIRE, CR_SAPPHIRE, CR_TEAL, NUM_TEXT_COLORS }; const TEXTCOLOR_BRICK = "\034A"; const TEXTCOLOR_TAN = "\034B"; const TEXTCOLOR_GRAY = "\034C"; const TEXTCOLOR_GREY = "\034C"; const TEXTCOLOR_GREEN = "\034D"; const TEXTCOLOR_BROWN = "\034E"; const TEXTCOLOR_GOLD = "\034F"; const TEXTCOLOR_RED = "\034G"; const TEXTCOLOR_BLUE = "\034H"; const TEXTCOLOR_ORANGE = "\034I"; const TEXTCOLOR_WHITE = "\034J"; const TEXTCOLOR_YELLOW = "\034K"; const TEXTCOLOR_UNTRANSLATED = "\034L"; const TEXTCOLOR_BLACK = "\034M"; const TEXTCOLOR_LIGHTBLUE = "\034N"; const TEXTCOLOR_CREAM = "\034O"; const TEXTCOLOR_OLIVE = "\034P"; const TEXTCOLOR_DARKGREEN = "\034Q"; const TEXTCOLOR_DARKRED = "\034R"; const TEXTCOLOR_DARKBROWN = "\034S"; const TEXTCOLOR_PURPLE = "\034T"; const TEXTCOLOR_DARKGRAY = "\034U"; const TEXTCOLOR_CYAN = "\034V"; const TEXTCOLOR_ICE = "\034W"; const TEXTCOLOR_FIRE = "\034X"; const TEXTCOLOR_SAPPHIRE = "\034Y"; const TEXTCOLOR_TEAL = "\034Z"; const TEXTCOLOR_NORMAL = "\034-"; const TEXTCOLOR_BOLD = "\034+"; const TEXTCOLOR_CHAT = "\034*"; const TEXTCOLOR_TEAMCHAT = "\034!"; // native Font(const String name); // String/name to font casts // native Font(const Name name); native int GetCharWidth(int code); native int StringWidth(String code, bool localize = true); native int GetMaxAscender(String code, bool localize = true); native bool CanPrint(String code, bool localize = true); native int GetHeight(); native int GetDisplacement(); native String GetCursor(); native static int FindFontColor(Name color); native double GetBottomAlignOffset(int code); native double GetDisplayTopOffset(int code); native static Font FindFont(Name fontname); native static Font GetFont(Name fontname); native BrokenLines BreakLines(String text, int maxlen); native int GetGlyphHeight(int code); native int GetDefaultKerning(); } struct Console native { native static void HideConsole(); native static vararg void Printf(string fmt, ...); native static vararg void PrintfEx(int printlevel, string fmt, ...); } struct CVar native { enum ECVarType { CVAR_Bool, CVAR_Int, CVAR_Float, CVAR_String, CVAR_Color, }; native static CVar FindCVar(Name name); bool GetBool() { return GetInt(); } native int GetInt(); native double GetFloat(); native String GetString(); void SetBool(bool b) { SetInt(b); } native void SetInt(int v); native void SetFloat(double v); native void SetString(String s); native int GetRealType(); native int ResetToDefault(); } class CustomIntCVar abstract { abstract int ModifyValue(Name CVarName, int val); } class CustomFloatCVar abstract { abstract double ModifyValue(Name CVarName, double val); } class CustomStringCVar abstract { abstract String ModifyValue(Name CVarName, String val); } class CustomBoolCVar abstract { abstract bool ModifyValue(Name CVarName, bool val); } class CustomColorCVar abstract { abstract Color ModifyValue(Name CVarName, Color val); } struct GIFont version("2.4") { Name fontname; Name color; }; struct GameInfoStruct native { native int gametype; native String mBackButton; native Name mSliderColor; native Name mSliderBackColor; } struct SystemTime { native static ui int Now(); // This returns the epoch time native static clearscope String Format(String timeForm, int timeVal); // This converts an epoch time to a local time, then uses the strftime syntax to format it } class Object native { const TICRATE = 35; native bool bDestroyed; // These must be defined in some class, so that the compiler can find them. Object is just fine, as long as they are private to external code. private native static Object BuiltinNew(Class cls, int outerclass, int compatibility); private native static int BuiltinRandom(voidptr rng, int min, int max); private native static double BuiltinFRandom(voidptr rng, double min, double max); private native static int BuiltinRandom2(voidptr rng, int mask); private native static void BuiltinRandomSeed(voidptr rng, int seed); private native static Class BuiltinNameToClass(Name nm, Class filter); private native static Object BuiltinClassCast(Object inptr, Class test); private native static Function BuiltinFunctionPtrCast(Function inptr, voidptr newtype); native static uint MSTime(); native static double MSTimeF(); native vararg static void ThrowAbortException(String fmt, ...); native static Function FindFunction(Class cls, Name fn); native virtualscope void Destroy(); // This does not call into the native method of the same name to avoid problems with objects that get garbage collected late on shutdown. virtual virtualscope void OnDestroy() {} // // Object intrinsics // Every ZScript "class" inherits from Object, and so inherits these methods as well // clearscope bool IsAbstract(); // Query whether or not the class of this object is abstract // clearscope Object GetParentClass(); // Get the parent class of this object // clearscope Name GetClassName(); // Get the name of this object's class // clearscope Class GetClass(); // Get the object's class // clearscope Object new(class type); // Create a new object with this class. This is only valid for thinkers and plain objects, except menus. For actors, use Actor.Spawn(); // // // Intrinsic random number generation functions. Note that the square // bracket syntax for specifying an RNG ID is only available for these // functions. // clearscope void SetRandomSeed[Name rngId = 'None'](int seed); // Set the seed for the given RNG. // clearscope int Random[Name rngId = 'None'](int min, int max); // Use the given RNG to generate a random integer number in the range (min, max) inclusive. // clearscope int Random2[Name rngId = 'None'](int mask); // Use the given RNG to generate a random integer number, and do a "union" (bitwise AND, AKA &) operation with the bits in the mask integer. // clearscope double FRandom[Name rngId = 'None'](double min, double max); // Use the given RNG to generate a random real number in the range (min, max) inclusive. // clearscope int RandomPick[Name rngId = 'None'](int choices...); // Use the given RNG to generate a random integer from the given choices. // clearscope double FRandomPick[Name rngId = 'None'](double choices...); // Use the given RNG to generate a random real number from the given choices. // // // Intrinsic math functions - the argument and return types for these // functions depend on the arguments given. Other than that, they work the // same way similarly-named functions in other programming languages work. // Note that trigonometric functions work with degrees instead of radians // clearscope T abs(T x); // clearscope T atan2(T y, T x); // NOTE: Returns a value in degrees instead of radians // clearscope T vectorangle(T x, T y); // Same as Atan2 with the arguments in a different order // clearscope T min(T x...); // clearscope T max(T x...); // clearscope T clamp(T x, T min, T max); // // These math functions only work with doubles - they are defined in FxFlops // clearscope double exp(double x); // clearscope double log(double x); // clearscope double log10(double x); // clearscope double sqrt(double x); // clearscope double ceil(double x); // clearscope double floor(double x); // clearscope double acos(double x); // clearscope double asin(double x); // clearscope double atan(double x); // clearscope double cos(double x); // clearscope double sin(double x); // clearscope double tan(double x); // clearscope double cosh(double x); // clearscope double sinh(double x); // clearscope double tanh(double x); // clearscope double round(double x); } class BrokenLines : Object native version("2.4") { native int Count(); native int StringWidth(int line); native String StringAt(int line); } struct StringTable native { native static String Localize(String val, bool prefixed = true); } struct Wads // todo: make FileSystem an alias to 'Wads' { enum WadNamespace { ns_hidden = -1, ns_global = 0, ns_sprites, ns_flats, ns_colormaps, ns_acslibrary, ns_newtextures, ns_bloodraw, ns_bloodsfx, ns_bloodmisc, ns_strifevoices, ns_hires, ns_voxels, ns_specialzipdirectory, ns_sounds, ns_patches, ns_graphics, ns_music, ns_firstskin, } enum FindLumpNamespace { GlobalNamespace = 0, AnyNamespace = 1, } native static int CheckNumForName(string name, int ns, int wadnum = -1, bool exact = false); native static int CheckNumForFullName(string name); native static int FindLump(string name, int startlump = 0, FindLumpNamespace ns = GlobalNamespace); native static int FindLumpFullName(string name, int startlump = 0, bool noext = false); native static string ReadLump(int lump); native static int GetNumLumps(); native static string GetLumpName(int lump); native static string GetLumpFullName(int lump); native static int GetLumpNamespace(int lump); } enum EmptyTokenType { TOK_SKIPEMPTY = 0, TOK_KEEPEMPTY = 1, } // Although String is a builtin type, this is a convenient way to attach methods to it. // All of these methods are available on strings struct StringStruct native { native static vararg String Format(String fmt, ...); native vararg void AppendFormat(String fmt, ...); // native int Length(); // Intrinsic // native bool operator==(String other); // Equality comparison // native bool operator~==(String other); // Case-insensitive equality comparison // native String operator..(String other); // Concatenate with another String native void Replace(String pattern, String replacement); native String Left(int len) const; native String Mid(int pos = 0, int len = 2147483647) const; native void Truncate(int newlen); native void Remove(int index, int remlen); deprecated("4.1", "use Left() or Mid() instead") native String CharAt(int pos) const; deprecated("4.1", "use ByteAt() instead") native int CharCodeAt(int pos) const; native int ByteAt(int pos) const; native String Filter(); native int IndexOf(String substr, int startIndex = 0) const; deprecated("3.5.1", "use RightIndexOf() instead") native int LastIndexOf(String substr, int endIndex = 2147483647) const; native int RightIndexOf(String substr, int endIndex = 2147483647) const; deprecated("4.1", "use MakeUpper() instead") native void ToUpper(); deprecated("4.1", "use MakeLower() instead") native void ToLower(); native String MakeUpper() const; native String MakeLower() const; native static int CharUpper(int ch); native static int CharLower(int ch); native int ToInt(int base = 0) const; native double ToDouble() const; native void Split(out Array tokens, String delimiter, EmptyTokenType keepEmpty = TOK_KEEPEMPTY) const; native void AppendCharacter(int c); native void DeleteLastCharacter(); native int CodePointCount() const; native int, int GetNextCodePoint(int position) const; native void Substitute(String str, String replace); native void StripLeft(String junk = ""); native void StripRight(String junk = ""); native void StripLeftRight(String junk = ""); } struct Translation version("2.4") { static int MakeID(int group, int num) { return (group << 16) + num; } } // Convenient way to attach functions to Quat struct QuatStruct native { native static Quat SLerp(Quat from, Quat to, double t); native static Quat NLerp(Quat from, Quat to, double t); native static Quat FromAngles(double yaw, double pitch, double roll); native static Quat AxisAngle(Vector3 xyz, double angle); native Quat Conjugate(); native Quat Inverse(); // native double Length(); // native double LengthSquared(); // native Quat Unit(); } // this struct does not exist. It is just a type for being referenced by an opaque pointer. struct VMFunction native version("4.10") { } // The Doom and Heretic players are not excluded from pickup in case // somebody wants to use these weapons with either of those games. class FighterWeapon : Weapon { Default { Weapon.Kickback 150; Inventory.ForbiddenTo "ClericPlayer", "MagePlayer"; } } class ClericWeapon : Weapon { Default { Weapon.Kickback 150; Inventory.ForbiddenTo "FighterPlayer", "MagePlayer"; } } class MageWeapon : Weapon { Default { Weapon.Kickback 150; Inventory.ForbiddenTo "FighterPlayer", "ClericPlayer"; } } extend class Actor { //============================================================================ // // AdjustPlayerAngle // //============================================================================ const MAX_ANGLE_ADJUST = (5.); void AdjustPlayerAngle(FTranslatedLineTarget t) { double difference = deltaangle(angle, t.angleFromSource); if (abs(difference) > MAX_ANGLE_ADJUST) { if (difference > 0) { angle += MAX_ANGLE_ADJUST; } else { angle -= MAX_ANGLE_ADJUST; } } else { angle = t.angleFromSource; } } //============================================================================ // // A_DropQuietusPieces // //============================================================================ void A_DropWeaponPieces(class p1, class p2, class p3) { for (int i = 0, j = 0; i < 3; ++i) { Actor piece = Spawn (j == 0 ? p1 : j == 1 ? p2 : p3, Pos, ALLOW_REPLACE); if (piece != null) { piece.Vel = self.Vel + AngleToVector(i * 120., 1); piece.bDropped = true; j = (j == 0) ? random[PieceDrop](1, 2) : 3-j; } } } } // Bat Spawner -------------------------------------------------------------- class BatSpawner : SwitchableDecoration { Default { +NOBLOCKMAP +NOSECTOR +NOGRAVITY RenderStyle "None"; } States { Spawn: Active: TNT1 A 2; TNT1 A 2 A_BatSpawnInit; TNT1 A 2 A_BatSpawn; Wait; Inactive: TNT1 A -1; Stop; } //=========================================================================== // Bat Spawner Variables // special1 frequency counter // special2 // args[0] frequency of spawn (1=fastest, 10=slowest) // args[1] spread angle (0..255) // args[2] // args[3] duration of bats (in octics) // args[4] turn amount per move (in degrees) // // Bat Variables // special2 lifetime counter // args[4] turn amount per move (in degrees) //=========================================================================== void A_BatSpawnInit() { special1 = 0; // Frequency count } void A_BatSpawn() { // Countdown until next spawn if (special1-- > 0) return; special1 = args[0]; // Reset frequency count int delta = args[1]; if (delta == 0) delta = 1; double ang = Angle + ((random[BatSpawn](0, delta-1) - (delta >> 1)) * (360 / 256.)); Actor mo = SpawnMissileAngle ("Bat", ang, 0); if (mo) { mo.args[0] = random[BatSpawn](0, 63); // floatbob index mo.args[4] = args[4]; // turn degrees mo.special2 = args[3] << 3; // Set lifetime mo.target = self; } } } // Bat ---------------------------------------------------------------------- class Bat : Actor { Default { Speed 5; Radius 3; Height 3; +NOBLOCKMAP +NOGRAVITY +MISSILE +NOTELEPORT +CANPASS } States { Spawn: ABAT ABC 2 A_BatMove; Loop; Death: ABAT A 2; Stop; } void A_BatMove() { if (special2 < 0) { SetStateLabel ("Death"); } special2 -= 2; // Called every 2 tics double newangle; if (random[BatMove]() < 128) { newangle = Angle + args[4]; } else { newangle = Angle - args[4]; } // Adjust velocity vector to new direction VelFromAngle(Speed, newangle); if (random[BatMove]() < 15) { A_StartSound ("BatScream", CHAN_VOICE, CHANF_DEFAULT, 1, ATTN_IDLE); } // Handle Z movement SetZ(target.pos.Z + 2 * BobSin(args[0])); args[0] = (args[0] + 3) & 63; } } // Beast -------------------------------------------------------------------- class Beast : Actor { Default { Health 220; Radius 32; Height 74; Mass 200; Speed 14; Painchance 100; Monster; +FLOORCLIP SeeSound "beast/sight"; AttackSound "beast/attack"; PainSound "beast/pain"; DeathSound "beast/death"; ActiveSound "beast/active"; Obituary "$OB_BEAST"; Tag "$FN_BEAST"; DropItem "CrossbowAmmo", 84, 10; } States { Spawn: BEAS AB 10 A_Look; Loop; See: BEAS ABCDEF 3 A_Chase; Loop; Missile: BEAS H 10 A_FaceTarget; BEAS I 10 A_CustomComboAttack("BeastBall", 32, random[BeastAttack](1,8)*3, "beast/attack"); Goto See; Pain: BEAS G 3; BEAS G 3 A_Pain; Goto See; Death: BEAS R 6; BEAS S 6 A_Scream; BEAS TUV 6; BEAS W 6 A_NoBlocking; BEAS XY 6; BEAS Z -1; Stop; XDeath: BEAS J 5; BEAS K 6 A_Scream; BEAS L 5; BEAS M 6; BEAS N 5; BEAS O 6 A_NoBlocking; BEAS P 5; BEAS Q -1; Stop; } } // Beast ball --------------------------------------------------------------- class BeastBall : Actor { Default { Radius 9; Height 8; Speed 12; FastSpeed 20; Damage 4; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS -NOBLOCKMAP +WINDTHRUST +SPAWNSOUNDSOURCE +ZDOOMTRANS RenderStyle "Add"; SeeSound "beast/attack"; } States { Spawn: FRB1 AABBCC 2 A_SpawnItemEx("Puffy", random2[BeastPuff]()*0.015625, random2[BeastPuff]()*0.015625, random2[BeastPuff]()*0.015625, 0,0,0,0,SXF_ABSOLUTEPOSITION, 64); Loop; Death: FRB1 DEFGH 4; Stop; } } // Puffy -------------------------------------------------------------------- class Puffy : Actor { Default { Radius 6; Height 8; Speed 10; +NOBLOCKMAP +NOGRAVITY +MISSILE +NOTELEPORT +DONTSPLASH +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: FRB1 DEFGH 4; Stop; } } // Base class for the beggars --------------------------------------------- class Beggar : StrifeHumanoid { Default { Health 20; PainChance 250; Speed 3; Radius 20; Height 56; Monster; +JUSTHIT -COUNTKILL +NOSPLASHALERT MinMissileChance 150; Tag "$TAG_BEGGAR"; MaxStepHeight 16; MaxDropoffHeight 32; HitObituary "$OB_BEGGAR"; AttackSound "beggar/attack"; PainSound "beggar/pain"; DeathSound "beggar/death"; } States { Spawn: BEGR A 10 A_Look; Loop; See: BEGR AABBCC 4 A_Wander; Loop; Melee: BEGR D 8; BEGR D 8 A_CustomMeleeAttack(2*random[PeasantAttack](1,5)+2); BEGR E 1 A_Chase; BEGR D 8 A_SentinelRefire; Loop; Pain: BEGR A 3 A_Pain; BEGR A 3 A_Chase; Goto Melee; Death: BEGR F 4; BEGR G 4 A_Scream; BEGR H 4; BEGR I 4 A_NoBlocking; BEGR JKLM 4; BEGR N -1; Stop; XDeath: BEGR F 5 A_TossGib; GIBS M 5 A_TossGib; GIBS N 5 A_XScream; GIBS O 5 A_NoBlocking; GIBS PQRST 4 A_TossGib; GIBS U 5; GIBS V 1400; Stop; } } // Beggars ----------------------------------------------------------------- class Beggar1 : Beggar { } class Beggar2 : Beggar { } class Beggar3 : Beggar { } class Beggar4 : Beggar { } class Beggar5 : Beggar { } // Bishop ------------------------------------------------------------------- class Bishop : Actor { int missilecount; int bobstate; Default { Health 130; Radius 22; Height 65; Speed 10; PainChance 110; Monster; +FLOAT +NOGRAVITY +NOBLOOD +TELESTOMP +DONTOVERLAP +NOTARGETSWITCH SeeSound "BishopSight"; AttackSound "BishopAttack"; PainSound "BishopPain"; DeathSound "BishopDeath"; ActiveSound "BishopActiveSounds"; Obituary"$OB_BISHOP"; Tag "$FN_BISHOP"; } States { Spawn: BISH A 10 A_Look; Loop; See: BISH A 2 A_Chase; BISH A 2 A_BishopChase; BISH A 2; BISH B 2 A_BishopChase; BISH B 2 A_Chase; BISH B 2 A_BishopChase; BISH A 1 A_BishopDecide; Loop; Blur: BISH A 2 A_BishopDoBlur; BISH A 4 A_BishopSpawnBlur; Wait; Pain: BISH C 6 A_Pain; BISH CCC 6 A_BishopPainBlur; BISH C 0; Goto See; Missile: BISH A 3 A_FaceTarget; BISH DE 3 A_FaceTarget; BISH F 3 A_BishopAttack; BISH F 5 A_BishopAttack2; Wait; Death: BISH G 6; BISH H 6 Bright A_Scream; BISH I 5 Bright A_NoBlocking; BISH J 5 BRIGHT A_Explode(random[BishopBoom](25,40)); BISH K 5 Bright; BISH LM 4 Bright; BISH N 4 A_SpawnItemEx("BishopPuff", 0,0,40, 0,0,0.5); BISH O 4 A_QueueCorpse; BISH P -1; Stop; Ice: BISH X 5 A_FreezeDeath; BISH X 1 A_FreezeDeathChunks; Wait; } //============================================================================ // // A_BishopAttack // //============================================================================ void A_BishopAttack() { let targ = target; if (!targ) { return; } A_StartSound (AttackSound, CHAN_BODY); if (CheckMeleeRange()) { int damage = random[BishopAttack](1, 8) * 4; int newdam = targ.DamageMobj (self, self, damage, 'Melee'); targ.TraceBleed (newdam > 0 ? newdam : damage, self); return; } missilecount = random[BishopAttack](5, 8); } //============================================================================ // // A_BishopAttack2 // // Spawns one of a string of bishop missiles //============================================================================ void A_BishopAttack2() { if (!target || !missilecount) { missilecount = 0; SetState (SeeState); return; } Actor mo = SpawnMissile (target, "BishopFX"); if (mo != null) { mo.tracer = target; } missilecount--; return; } //============================================================================ // // A_BishopDecide // //============================================================================ void A_BishopDecide() { if (random[BishopDecide]() >= 220) { SetStateLabel ("Blur"); } } //============================================================================ // // A_BishopDoBlur // //============================================================================ void A_BishopDoBlur() { missilecount = random[BishopDoBlur](3, 6); // Random number of blurs if (random[BishopDoBlur]() < 120) { Thrust(11, Angle + 90); } else if (random[BishopDoBlur]() > 125) { Thrust(11, Angle - 90); } else { // Thrust forward Thrust(11); } A_StartSound ("BishopBlur", CHAN_BODY); } //============================================================================ // // A_BishopSpawnBlur // //============================================================================ void A_BishopSpawnBlur() { if (!--missilecount) { Vel.XY = (0,0);// = Vel.Y = 0; if (random[BishopSpawnBlur]() > 96) { SetState (SeeState); } else { SetState (MissileState); } } Actor mo = Spawn ("BishopBlur", Pos, ALLOW_REPLACE); if (mo) { mo.angle = angle; } } //============================================================================ // // A_BishopChase // //============================================================================ void A_BishopChase() { double newz = pos.z - BobSin(bobstate) / 2.; bobstate = (bobstate + 4) & 63; newz += BobSin(bobstate) / 2.; SetZ(newz); } //============================================================================ // // A_BishopPainBlur // //============================================================================ void A_BishopPainBlur() { if (random[BishopPainBlur]() < 64) { SetStateLabel ("Blur"); return; } double xo = random2[BishopPainBlur]() / 16.; double yo = random2[BishopPainBlue]() / 16.; double zo = random2[BishopPainBlue]() / 32.; Actor mo = Spawn ("BishopPainBlur", Vec3Offset(xo, yo, zo), ALLOW_REPLACE); if (mo) { mo.angle = angle; } } } extend class Actor { //============================================================================ // // A_BishopMissileWeave (this function must be in Actor) // //============================================================================ void A_BishopMissileWeave() { A_Weave(2, 2, 2., 1.); } } // Bishop puff -------------------------------------------------------------- class BishopPuff : Actor { Default { +NOBLOCKMAP +NOGRAVITY RenderStyle "Translucent"; Alpha 0.6; } States { Spawn: BISH QRST 5; BISH UV 6; BISH W 5; Stop; } } // Bishop pain blur --------------------------------------------------------- class BishopPainBlur : Actor { Default { +NOBLOCKMAP +NOGRAVITY RenderStyle "Translucent"; Alpha 0.6; } States { Spawn: BISH C 8; Stop; } } // Bishop FX ---------------------------------------------------------------- class BishopFX : Actor { Default { Radius 10; Height 6; Speed 10; Damage 1; Projectile; +SEEKERMISSILE -ACTIVATEIMPACT -ACTIVATEPCROSS +STRIFEDAMAGE +ZDOOMTRANS RenderStyle "Add"; DeathSound "BishopMissileExplode"; } States { Spawn: BPFX ABAB 1 Bright A_BishopMissileWeave; BPFX B 0 Bright A_SeekerMissile(2,3); Loop; Death: BPFX CDEF 4 Bright; BPFX GH 3 Bright; Stop; } } // Bishop blur -------------------------------------------------------------- class BishopBlur : Actor { Default { +NOBLOCKMAP +NOGRAVITY RenderStyle "Translucent"; Alpha 0.6; } States { Spawn: BISH A 16; BISH A 8 A_SetTranslucent(0.4); Stop; } } class ArtiBlastRadius : CustomInventory { Default { +FLOATBOB Inventory.DefMaxAmount; Inventory.PickupFlash "PickupFlash"; +INVENTORY.INVBAR +INVENTORY.FANCYPICKUPSOUND Inventory.Icon "ARTIBLST"; Inventory.PickupSound "misc/p_pkup"; Inventory.PickupMessage "$TXT_ARTIBLASTRADIUS"; Tag "$TAG_ARTIBLASTRADIUS"; } States { Spawn: BLST ABCDEFGH 4 Bright; Loop; Use: TNT1 A 0 A_Blast; } } //========================================================================== // // A_Blast is public to Actor // //========================================================================== extend class Actor { /* For reference, the default values: #define BLAST_RADIUS_DIST 255.0 #define BLAST_SPEED 20.0 #define BLAST_FULLSTRENGTH 255 */ //========================================================================== // // AArtiBlastRadius :: BlastActor // //========================================================================== private void BlastActor (Actor victim, double strength, double speed, Class blasteffect, bool dontdamage) { if (!victim.SpecialBlastHandling (self, strength)) { return; } double ang = AngleTo(victim); Vector2 move = AngleToVector(ang, speed); victim.Vel.XY = move; // Spawn blast puff ang -= 180.; Vector3 spawnpos = victim.Vec3Offset( (victim.radius + 1) * cos(ang), (victim.radius + 1) * sin(ang), (victim.Height / 2) - victim.Floorclip); Actor mo = blasteffect? Spawn (blasteffect, spawnpos, ALLOW_REPLACE) : null; if (mo) { mo.Vel.XY = victim.Vel.XY; } if (victim.bMissile) { // [RH] Floor and ceiling huggers should not be blasted vertically. if (!victim.bFloorHugger && !victim.bCeilingHugger) { victim.Vel.Z = 8; if (mo != null) mo.Vel.Z = 8; } } else { victim.Vel.Z = 1000. / victim.Mass; } if (victim.player) { // Players handled automatically } else if (!dontdamage) { victim.bBlasted = true; } if (victim.bTouchy) { // Touchy objects die when blasted victim.bArmed = false; // Disarm victim.DamageMobj(self, self, victim.health, 'Melee', DMG_FORCED|DMG_EXPLOSION); } } //========================================================================== // // AArtiBlastRadius :: Activate // // Blast all actors away // //========================================================================== 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 == player.ReadyWeapon && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { Weapon weapon = player.ReadyWeapon; if (weapon != null && !weapon.DepleteAmmo(weapon.bAltFire)) { return; } } A_StartSound (blastsound, CHAN_AUTO); if (!(blastflags & BF_DONTWARN)) { SoundAlert (self); } ThinkerIterator it = ThinkerIterator.Create("Actor"); Actor mo; while ( (mo = Actor(it.Next ())) ) { if (mo == self || (mo.bBoss && !(blastflags & BF_AFFECTBOSSES)) || mo.bDormant || mo.bDontBlast) { // Not a valid monster: originator, boss, dormant, or otherwise protected continue; } if (mo.bIceCorpse || mo.bCanBlast) { // Let these special cases go } else if (mo.bIsMonster && mo.health <= 0) { continue; } else if (!mo.player && !mo.bMissile && !mo.bIsMonster && !mo.bCanBlast && !mo.bTouchy && !mo.bVulnerable) { // Must be monster, player, missile, touchy or vulnerable continue; } if (Distance2D(mo) > radius) { // Out of range continue; } if (mo.CurSector.PortalGroup != CurSector.PortalGroup && !CheckSight(mo)) { // in another region and cannot be seen. continue; } if ((blastflags & BF_ONLYVISIBLETHINGS) && !isVisible(mo, true)) { //only blast if target can bee seen by calling actor continue; } BlastActor (mo, strength, speed, blasteffect, !!(blastflags & BF_NOIMPACTDAMAGE)); } } } // Blast Effect ------------------------------------------------------------- class BlastEffect : Actor { Default { +NOBLOCKMAP +NOGRAVITY +NOCLIP +NOTELEPORT RenderStyle "Translucent"; Alpha 0.666; } States { Spawn: RADE ABCDEFGHI 4; Stop; } } // Blood sprite ------------------------------------------------------------ class Blood : Actor { Default { Mass 5; +NOBLOCKMAP +NOTELEPORT +ALLOWPARTICLES } States { Spawn: BLUD CBA 8; Stop; Spray: SPRY ABCDEF 3; SPRY G 2; Stop; } } // Blood splatter ----------------------------------------------------------- class BloodSplatter : Actor { Default { Radius 2; Height 4; +NOBLOCKMAP +MISSILE +DROPOFF +NOTELEPORT +CANNOTPUSH +ALLOWPARTICLES Mass 5; } States { Spawn: BLUD CBA 8; Stop; Death: BLUD A 6; Stop; } } // Axe Blood ---------------------------------------------------------------- class AxeBlood : Actor { Default { Radius 2; Height 4; +NOBLOCKMAP +NOGRAVITY +DROPOFF +NOTELEPORT +CANNOTPUSH +ALLOWPARTICLES Mass 5; } States { Spawn: FAXE FGHIJ 3; Death: FAXE K 3; Stop; } } // Boost Armor Artifact (Dragonskin Bracers) -------------------------------- class ArtiBoostArmor : Inventory { Default { +COUNTITEM +FLOATBOB Inventory.DefMaxAmount; Inventory.PickupFlash "PickupFlash"; +INVENTORY.INVBAR +INVENTORY.FANCYPICKUPSOUND Inventory.Icon "ARTIBRAC"; Inventory.PickupSound "misc/p_pkup"; Inventory.PickupMessage "$TXT_ARTIBOOSTARMOR"; Tag "$TAG_ARTIBOOSTARMOR"; } States { Spawn: BRAC ABCDEFGH 4 Bright; Loop; } override bool Use (bool pickup) { int count = 0; if (gameinfo.gametype == GAME_Hexen) { HexenArmor armor; for (int i = 0; i < 4; ++i) { armor = HexenArmor(Spawn("HexenArmor")); armor.bDropped = true; armor.health = i; armor.Amount = 1; if (!armor.CallTryPickup (Owner)) { armor.Destroy (); } else { count++; } } return count != 0; } else { BasicArmorBonus armor = BasicArmorBonus(Spawn("BasicArmorBonus")); armor.bDropped = true; armor.SaveAmount = 50; armor.MaxSaveAmount = 300; if (!armor.CallTryPickup (Owner)) { armor.Destroy (); return false; } else { return true; } } } } //=========================================================================== // // Boss Brain // //=========================================================================== class BossBrain : Actor { Default { Health 250; Mass 10000000; PainChance 255; Radius 16; +SOLID +SHOOTABLE +NOICEDEATH +OLDRADIUSDMG PainSound "brain/pain"; DeathSound "brain/death"; } States { Spawn: BBRN A -1; Stop; Pain: BBRN B 36 A_BrainPain; Goto Spawn; Death: BBRN A 100 A_BrainScream; BBRN AA 10; BBRN A -1 A_BrainDie; Stop; } } //=========================================================================== // // Boss Eye // //=========================================================================== class BossEye : Actor { Default { Height 32; +NOBLOCKMAP +NOSECTOR } States { Spawn: SSWV A 10 A_Look; Loop; See: SSWV A 181 A_BrainAwake; SSWV A 150 A_BrainSpit; Wait; } } //=========================================================================== // // Boss Target // //=========================================================================== class BossTarget : SpecialSpot { Default { Height 32; +NOBLOCKMAP; +NOSECTOR; } } //=========================================================================== // // Spawn shot // //=========================================================================== class SpawnShot : Actor { Default { Radius 6; Height 32; Speed 10; Damage 3; Projectile; +NOCLIP -ACTIVATEPCROSS +RANDOMIZE SeeSound "brain/spit"; DeathSound "brain/cubeboom"; } States { Spawn: BOSF A 3 BRIGHT A_SpawnSound; BOSF BCD 3 BRIGHT A_SpawnFly; Loop; } } //=========================================================================== // // Spawn fire // //=========================================================================== class SpawnFire : Actor { Default { Height 78; +NOBLOCKMAP +NOGRAVITY +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: FIRE ABCDEFGH 4 Bright A_Fire; Stop; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== extend class Actor { void A_BrainAwake() { A_StartSound("brain/sight", CHAN_VOICE, CHANF_DEFAULT, 1, ATTN_NONE); } void A_BrainPain() { A_StartSound("brain/pain", CHAN_VOICE, CHANF_DEFAULT, 1, ATTN_NONE); } private static void BrainishExplosion(vector3 pos) { Actor boom = Actor.Spawn("Rocket", pos, NO_REPLACE); if (boom) { boom.DeathSound = "misc/brainexplode"; boom.Vel.z = random[BrainScream](0, 255)/128.; boom.SetStateLabel ("Brainexplode"); boom.bRocketTrail = false; boom.SetDamage(0); // disables collision detection which is not wanted here boom.tics -= random[BrainScream](0, 7); if (boom.tics < 1) boom.tics = 1; } } void A_BrainScream() { for (double x = -196; x < +320; x += 8) { // (1 / 512.) is actually what the original value of 128 did, even though it probably meant 128 map units. BrainishExplosion(Vec2OffsetZ(x, -320, (1 / 512.) + random[BrainExplode](0, 255) * 2)); } A_StartSound("brain/death", CHAN_VOICE, CHANF_DEFAULT, 1., ATTN_NONE); } void A_BrainExplode() { double x = random2[BrainExplode]() / 32.; Vector3 pos = Vec2OffsetZ(x, 0, 1 / 512. + random[BrainExplode]() * 2); BrainishExplosion(pos); } void A_BrainDie() { // [RH] If noexit, then don't end the level. if ((deathmatch || alwaysapplydmflags) && sv_noexit) return; // New dmflag: Kill all boss spawned monsters before ending the level. if (sv_killbossmonst) { int count; // Repeat until we have no more boss-spawned monsters. ThinkerIterator it = ThinkerIterator.Create("Actor"); do // (e.g. Pain Elementals can spawn more to kill upon death.) { Actor mo; it.Reinit(); count = 0; while (mo = Actor(it.Next())) { if (mo.health > 0 && mo.bBossSpawned) { mo.DamageMobj(self, self, mo.health, "None", DMG_NO_ARMOR|DMG_FORCED|DMG_THRUSTLESS|DMG_NO_FACTOR); // [Blue Shadow] If 'mo' is a RandomSpawner or another actor which can't be killed, // it could cause this code to loop indefinitely. So only let it trigger a loop if it // has been actually killed. if (mo.bKilled) count++; } } } while (count != 0); } Level.ExitLevel(0, false); } void A_BrainSpit(class spawntype = null) { SpotState spstate = Level.GetSpotState(); Actor targ; Actor spit; bool isdefault = false; // shoot a cube at current target targ = spstate.GetNextInList("BossTarget", G_SkillPropertyInt(SKILLP_EasyBossBrain)); if (targ) { if (spawntype == null) { spawntype = "SpawnShot"; isdefault = true; } // spawn brain missile spit = SpawnMissile (targ, spawntype); if (spit) { // Boss cubes should move freely to their destination so it's // probably best to disable all collision detection for them. spit.bNoInteraction = spit.bNoClip; spit.target = targ; spit.master = self; // [RH] Do this correctly for any trajectory. Doom would divide by 0 // if the target had the same y coordinate as the spitter. if (spit.Vel.xy == (0, 0)) { spit.special2 = 0; } else if (abs(spit.Vel.y) > abs(spit.Vel.x)) { spit.special2 = int((targ.pos.y - pos.y) / spit.Vel.y); } else { spit.special2 = int((targ.pos.x - pos.x) / spit.Vel.x); } // [GZ] Calculates when the projectile will have reached destination spit.special2 += level.maptime; spit.bBossCube = true; } if (!isdefault) { A_StartSound(self.AttackSound, CHAN_WEAPON, CHANF_DEFAULT, 1., ATTN_NONE); } else { // compatibility fallback A_StartSound("brain/spit", CHAN_WEAPON, CHANF_DEFAULT, 1., ATTN_NONE); } } } private void SpawnFly(class spawntype, sound snd) { Actor newmobj; Actor fog; Actor eye = master; // The eye is the spawnshot's master, not the target! Actor targ = target; // Unlike other projectiles, the target is the intended destination. int r; if (targ == null) { Destroy(); return; } // [GZ] Should be more viable than a countdown... if (special2 != 0) { if (special2 > level.maptime) return; // still flying } else { if (reactiontime == 0 || --reactiontime != 0) return; // still flying } if (spawntype) { fog = Spawn (spawntype, targ.pos, ALLOW_REPLACE); if (fog) A_StartSound(snd, CHAN_BODY); } class SpawnName = null; DropItem di; // di will be our drop item list iterator DropItem drop; // while drop stays as the reference point. int n = 0; // First see if this cube has its own actor list drop = GetDropItems(); // If not, then default back to its master's list if (drop == null && eye != null) drop = eye.GetDropItems(); if (drop != null) { for (di = drop; di != null; di = di.Next) { if (di.Name != 'None') { int amt = di.Amount; if (amt < 0) { amt = 1; // default value is -1, we need a positive value. } n += amt; // this is how we can weight the list. } } di = drop; n = random[pr_spawnfly](0, n); while (n >= 0) { if (di.Name != 'none') { int amt = di.Amount; if (amt < 0) { amt = 1; } n -= amt; } if ((di.Next != null) && (n >= 0)) { di = di.Next; } else { n = -1; } } SpawnName = di.Name; } if (SpawnName == null) { // Randomly select monster to spawn. r = random[pr_spawnfly](0, 255); // Probability distribution (kind of :), // decreasing likelihood. if (r < 50) SpawnName = "DoomImp"; else if (r < 90) SpawnName = "Demon"; else if (r < 120) SpawnName = "Spectre"; else if (r < 130) SpawnName = "PainElemental"; else if (r < 160) SpawnName = "Cacodemon"; else if (r < 162) SpawnName = "Archvile"; else if (r < 172) SpawnName = "Revenant"; else if (r < 192) SpawnName = "Arachnotron"; else if (r < 222) SpawnName = "Fatso"; else if (r < 246) SpawnName = "HellKnight"; else SpawnName = "BaronOfHell"; } if (spawnname != null) { newmobj = Spawn (spawnname, targ.pos, ALLOW_REPLACE); if (newmobj != null) { // Make the new monster hate what the boss eye hates if (eye != null) { newmobj.CopyFriendliness (eye, false); } // Make it act as if it was around when the player first made noise // (if the player has made noise). newmobj.LastHeard = newmobj.CurSector.SoundTarget; if (newmobj.SeeState != null && newmobj.LookForPlayers (true)) { newmobj.SetState (newmobj.SeeState); } if (!newmobj.bDestroyed) { // telefrag anything in this spot newmobj.TeleportMove (newmobj.pos, true); } newmobj.bBossSpawned = true; } } // remove self (i.e., cube). Destroy (); } void A_SpawnFly(class spawntype = null) { sound snd; if (spawntype != null) { snd = GetDefaultByType(spawntype).SeeSound; } else { spawntype = "SpawnFire"; snd = "brain/spawn"; } SpawnFly(spawntype, snd); } void A_SpawnSound() { // travelling cube sound A_StartSound("brain/cube", CHAN_BODY); SpawnFly("SpawnFire", "brain/spawn"); } } class CajunBodyNode : Actor { Default { +NOSECTOR +NOGRAVITY +INVISIBLE } } class CajunTrace : Actor { Default { Speed 12; Radius 6; Height 8; +NOBLOCKMAP +DROPOFF +MISSILE +NOGRAVITY +NOTELEPORT } } class Bot native { native Actor dest; } /* args[0]: Bridge radius, in mapunits args[1]: Bridge height, in mapunits args[2]: Amount of bridge balls (if 0: Doom bridge) args[3]: Rotation speed of bridge balls, in byte angle per seconds, sorta: Since an arg is only a byte, it can only go from 0 to 255, while ZDoom's BAM go from 0 to 65535. Plus, it needs to be able to go either way. So, up to 128, it goes counterclockwise; 129-255 is clockwise, substracting 256 from it to get the angle. A few example values: 0: Hexen default 11: 15° / seconds 21: 30° / seconds 32: 45° / seconds 64: 90° / seconds 128: 180° / seconds 192: -90° / seconds 223: -45° / seconds 233: -30° / seconds 244: -15° / seconds This value only matters if args[2] is not zero. args[4]: Rotation radius of bridge balls, in bridge radius %. If 0, use Hexen default: ORBIT_RADIUS, regardless of bridge radius. This value only matters if args[2] is not zero. */ // Bridge ball ------------------------------------------------------------- class BridgeBall : Actor { default { +NOBLOCKMAP +NOTELEPORT +NOGRAVITY } States { Spawn: TLGL A 2 Bright; TLGL A 1 Bright A_BridgeOrbit; Wait; } void A_BridgeOrbit() { if (target == NULL) { // Don't crash if somebody spawned this into the world // independently of a Bridge actor. return; } // Set default values // Every five tics, Hexen moved the ball 3/256th of a revolution. double rotationspeed = 45. / 32 * 3 / 5; double rotationradius = CustomBridge.ORBIT_RADIUS; // If the bridge is custom, set non-default values if any. // Set angular speed; 1--128: counterclockwise rotation ~=1--180°; 129--255: clockwise rotation ~= 180--1° if (target.args[3] > 128) rotationspeed = 45. / 32 * (target.args[3] - 256) / TICRATE; else if (target.args[3] > 0) rotationspeed = 45. / 32 * (target.args[3]) / TICRATE; // Set rotation radius if (target.args[4]) rotationradius = ((target.args[4] * target.radius) / 100); Angle += rotationspeed; SetOrigin(target.Vec3Angle(rotationradius, Angle, 0), true); floorz = target.floorz; ceilingz = target.ceilingz; } } // The bridge itself ------------------------------------------------------- class CustomBridge : Actor { const ORBIT_RADIUS = 15; default { +SOLID +NOGRAVITY +NOLIFTDROP +ACTLIKEBRIDGE Radius 32; Height 2; RenderStyle "None"; } states { Spawn: TLGL ABCDE 3 Bright; Loop; See: TLGL A 2; TLGL A 2 A_BridgeInit; TLGL A -1; Stop; Death: TLGL A 2; TLGL A 300; Stop; } override void BeginPlay () { if (args[2]) // Hexen bridge if there are balls { SetState(SeeState); A_SetSize(args[0] ? args[0] : 32, args[1] ? args[1] : 2); } else // No balls? Then a Doom bridge. { A_SetSize(args[0] ? args[0] : 36, args[1] ? args[1] : 4); A_SetRenderStyle(1., STYLE_Normal); } } override void OnDestroy() { // Hexen originally just set a flag to make the bridge balls remove themselves in A_BridgeOrbit. // But this is not safe with custom bridge balls that do not necessarily call that function. // So the best course of action is to look for all bridge balls here and destroy them ourselves. let it = ThinkerIterator.Create("Actor"); Actor thing; while ((thing = Actor(it.Next()))) { if (thing.target == self) { thing.Destroy(); } } Super.OnDestroy(); } void A_BridgeInit(class balltype = "BridgeBall") { if (balltype == NULL) { balltype = "BridgeBall"; } double startangle = random[orbit]() * (360./256.); // Spawn triad into world -- may be more than a triad now. int ballcount = args[2]==0 ? 3 : args[2]; for (int i = 0; i < ballcount; i++) { Actor ball = Spawn(balltype, Pos, ALLOW_REPLACE); ball.Angle = startangle + (45./32) * (256/ballcount) * i; ball.target = self; double rotationradius = ORBIT_RADIUS; if (args[4]) rotationradius = (args[4] * radius) / 100; ball.SetOrigin(Vec3Angle(rotationradius, ball.Angle, 0), true); ball.floorz = floorz; ball.ceilingz = ceilingz; } } } // The Hexen bridge ------------------------------------------------------- class Bridge : CustomBridge { default { RenderStyle "None"; Args 32, 2, 3, 0; } } // The ZDoom bridge ------------------------------------------------------- class ZBridge : CustomBridge { default { Args 36, 4, 0, 0; } } // Invisible bridge -------------------------------------------------------- class InvisibleBridge : Actor { default { RenderStyle "None"; Radius 32; RenderRadius -1; Height 4; +SOLID +NOGRAVITY +NOLIFTDROP +ACTLIKEBRIDGE } States { Spawn: TNT1 A -1; Stop; } override void BeginPlay () { Super.BeginPlay (); if (args[0] || args[1]) { A_SetSize(args[0]? args[0] : radius, args[1]? args[1] : height); } } } // And some invisible bridges from Skull Tag ------------------------------- class InvisibleBridge32 : InvisibleBridge { default { Radius 32; Height 8; } } class InvisibleBridge16 : InvisibleBridge { default { Radius 16; Height 8; } } class InvisibleBridge8 : InvisibleBridge { default { Radius 8; Height 8; } } //=========================================================================== // // Baron of Hell // //=========================================================================== class BaronOfHell : Actor { Default { Health 1000; Radius 24; Height 64; Mass 1000; Speed 8; PainChance 50; Monster; +FLOORCLIP +BOSSDEATH +E1M8BOSS SeeSound "baron/sight"; PainSound "baron/pain"; DeathSound "baron/death"; ActiveSound "baron/active"; Obituary "$OB_BARON"; HitObituary "$OB_BARONHIT"; Tag "$FN_BARON"; } States { Spawn: BOSS AB 10 A_Look ; Loop; See: BOSS AABBCCDD 3 A_Chase; Loop; Melee: Missile: BOSS EF 8 A_FaceTarget; BOSS G 8 A_BruisAttack; Goto See; Pain: BOSS H 2; BOSS H 2 A_Pain; Goto See; Death: BOSS I 8; BOSS J 8 A_Scream; BOSS K 8; BOSS L 8 A_NoBlocking; BOSS MN 8; BOSS O -1 A_BossDeath; Stop; Raise: BOSS O 8; BOSS NMLKJI 8; Goto See; } } //=========================================================================== // // Hell Knight // //=========================================================================== class HellKnight : BaronOfHell { Default { Health 500; -BOSSDEATH; SeeSound "knight/sight"; ActiveSound "knight/active"; PainSound "knight/pain"; DeathSound "knight/death"; HitObituary "$OB_KNIGHTHIT"; Obituary "$OB_KNIGHT"; Tag "$FN_HELL"; } States { Spawn: BOS2 AB 10 A_Look; Loop; See: BOS2 AABBCCDD 3 A_Chase; Loop; Melee: Missile: BOS2 EF 8 A_FaceTarget; BOS2 G 8 A_BruisAttack; Goto See; Pain: BOS2 H 2; BOS2 H 2 A_Pain; Goto See; Death: BOS2 I 8; BOS2 J 8 A_Scream; BOS2 K 8; BOS2 L 8 A_NoBlocking; BOS2 MN 8; BOS2 O -1; Stop; Raise: BOS2 O 8; BOS2 NMLKJI 8; Goto See; } } //=========================================================================== // // Baron slime ball // //=========================================================================== class BaronBall : Actor { Default { Radius 6; Height 16; Speed 15; FastSpeed 20; Damage 8; Projectile ; +RANDOMIZE +ZDOOMTRANS RenderStyle "Add"; Alpha 1; SeeSound "baron/attack"; DeathSound "baron/shotx"; Decal "BaronScorch"; } States { Spawn: BAL7 AB 4 BRIGHT; Loop; Death: BAL7 CDE 6 BRIGHT; Stop; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== extend class Actor { void A_BruisAttack() { let targ = target; if (targ) { if (CheckMeleeRange()) { int damage = random[pr_bruisattack](1, 8) * 10; A_StartSound ("baron/melee", CHAN_WEAPON); int newdam = target.DamageMobj (self, self, damage, "Melee"); targ.TraceBleed (newdam > 0 ? newdam : damage, self); } else { // launch a missile SpawnMissile (target, "BaronBall"); } } } } //=========================================================================== // // Cacodemon // //=========================================================================== class Cacodemon : Actor { Default { Health 400; Radius 31; Height 56; Mass 400; Speed 8; PainChance 128; Monster; +FLOAT +NOGRAVITY SeeSound "caco/sight"; PainSound "caco/pain"; DeathSound "caco/death"; ActiveSound "caco/active"; Obituary "$OB_CACO"; HitObituary "$OB_CACOHIT"; Tag "$FN_CACO"; } States { Spawn: HEAD A 10 A_Look; Loop; See: HEAD A 3 A_Chase; Loop; Missile: HEAD B 5 A_FaceTarget; HEAD C 5 A_FaceTarget; HEAD D 5 BRIGHT A_HeadAttack; Goto See; Pain: HEAD E 3; HEAD E 3 A_Pain; HEAD F 6; Goto See; Death: HEAD G 8; HEAD H 8 A_Scream; HEAD I 8; HEAD J 8; HEAD K 8 A_NoBlocking; HEAD L -1 A_SetFloorClip; Stop; Raise: HEAD L 8 A_UnSetFloorClip; HEAD KJIHG 8; Goto See; } } //=========================================================================== // // Cacodemon plasma ball // //=========================================================================== class CacodemonBall : Actor { Default { Radius 6; Height 8; Speed 10; FastSpeed 20; Damage 5; Projectile; +RANDOMIZE +ZDOOMTRANS RenderStyle "Add"; Alpha 1; SeeSound "caco/attack"; DeathSound "caco/shotx"; } States { Spawn: BAL2 AB 4 BRIGHT; Loop; Death: BAL2 CDE 6 BRIGHT; Stop; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== extend class Actor { void A_HeadAttack() { let targ = target; if (targ) { if (CheckMeleeRange()) { int damage = random[pr_headattack](1, 6) * 10; A_StartSound (AttackSound, CHAN_WEAPON); int newdam = target.DamageMobj (self, self, damage, "Melee"); targ.TraceBleed (newdam > 0 ? newdam : damage, self); } else { // launch a missile SpawnMissile (targ, "CacodemonBall"); } } } } class DoomBuilderCamera : Actor { States { Spawn: TNT1 A 1; Stop; } } class SecurityCamera : Actor { default { +NOBLOCKMAP +NOGRAVITY +DONTSPLASH RenderStyle "None"; CameraHeight 0; } double Center; double Acc; double Delta; double Range; override void PostBeginPlay () { Super.PostBeginPlay (); Center = Angle; if (args[2]) Delta = 360. / (args[2] * TICRATE / 8); else Delta = 0.; if (args[1]) Delta /= 2; Acc = 0.; int arg = (args[0] << 24) >> 24; // make sure the value has the intended sign. Pitch = clamp(arg, -89, 89); Range = args[1]; } override void Tick () { Acc += Delta; if (Range != 0) Angle = Center + Range * sin(Acc); else if (Delta != 0) Angle = Acc; } } class AimingCamera : SecurityCamera { double MaxPitchChange; override void PostBeginPlay () { int changepitch = args[2]; args[2] = 0; Super.PostBeginPlay (); MaxPitchChange = double(changepitch) / TICRATE; Range /= TICRATE; ActorIterator it = Level.CreateActorIterator(args[3]); tracer = it.Next (); if (tracer == NULL) { if (args[3] != 0) { console.Printf ("AimingCamera %d: Can't find TID %d\n", tid, args[3]); } } else { // Don't try for a new target upon losing this one. args[3] = 0; } } override void Tick () { if (tracer == NULL && args[3] != 0) { // Recheck, in case something with this TID was created since the last time. ActorIterator it = Level.CreateActorIterator(args[3]); tracer = it.Next (); } if (tracer != NULL) { double dir = deltaangle(angle, AngleTo(tracer)); double delta = abs(dir); if (delta > Range) { delta = Range; } if (dir > 0) { Angle += delta; } else { Angle -= delta; } if (MaxPitchChange != 0) { // Aim camera's pitch; use floats for precision Vector2 vect = tracer.Vec2To(self); double dz = pos.z - tracer.pos.z - tracer.Height/2; double dist = vect.Length(); double desiredPitch = dist != 0.f ? VectorAngle(dist, dz) : 0.; double diff = deltaangle(pitch, desiredPitch); if (abs (diff) < MaxPitchChange) { pitch = desiredPitch; } else if (diff < 0) { pitch -= MaxPitchChange; } else { pitch += MaxPitchChange; } } } } } // Centaur ------------------------------------------------------------------ class Centaur : Actor { Default { Health 200; Painchance 135; Speed 13; Height 64; Mass 120; Monster; +FLOORCLIP +TELESTOMP +SHIELDREFLECT SeeSound "CentaurSight"; AttackSound "CentaurAttack"; PainSound "CentaurPain"; DeathSound "CentaurDeath"; ActiveSound "CentaurActive"; HowlSound "PuppyBeat"; Obituary "$OB_CENTAUR"; DamageFactor "Electric", 3; Tag "$FN_CENTAUR"; } States { Spawn: CENT AB 10 A_Look; Loop; See: CENT ABCD 4 A_Chase; Loop; Pain: CENT G 6 A_Pain; CENT G 6 A_SetReflectiveInvulnerable; CENT EEE 15 A_CentaurDefend; CENT E 1 A_UnsetReflectiveInvulnerable; Goto See; Melee: CENT H 5 A_FaceTarget; CENT I 4 A_FaceTarget; CENT J 7 A_CustomMeleeAttack(random[CentaurAttack](3,9)); Goto See; Death: CENT K 4; CENT L 4 A_Scream; CENT MN 4; CENT O 4 A_NoBlocking; CENT PQ 4; CENT R 4 A_QueueCorpse; CENT S 4; CENT T -1; Stop; XDeath: CTXD A 4; CTXD B 4 A_NoBlocking; CTXD C 4 { A_SpawnItemEx("CentaurSword", 0, 0, 45, 1 + random[CentaurDrop](-128,127)*0.03125, 1 + random[CentaurDrop](-128,127)*0.03125, 8 + random[CentaurDrop](0,255)*0.015625, 270); A_SpawnItemEx("CentaurShield", 0, 0, 45, 1 + random[CentaurDrop](-128,127)*0.03125, 1 + random[CentaurDrop](-128,127)*0.03125, 8 + random[CentaurDrop](0,255)*0.015625, 90); } CTXD D 3 A_Scream; CTXD E 4 A_QueueCorpse; CTXD F 3; CTXD G 4; CTXD H 3; CTXD I 4; CTXD J 3; CTXD K -1; Ice: CENT U 5 A_FreezeDeath; CENT U 1 A_FreezeDeathChunks; Wait; } } extend class Actor { void A_CentaurDefend() { A_FaceTarget (); if (CheckMeleeRange() && random[CentaurDefend]() < 32) { // This should unset REFLECTIVE as well // (unless you want the Centaur to reflect projectiles forever!) bReflective = false; bInvulnerable = false; SetState(MeleeState); } } } // Centaur Leader ----------------------------------------------------------- class CentaurLeader : Centaur { Default { Health 250; PainChance 96; Speed 10; Obituary "$OB_SLAUGHTAUR"; HitObituary "$OB_SLAUGHTAURHIT"; Tag "$FN_SLAUGHTAUR"; } States { Missile: CENT E 10 A_FaceTarget; CENT F 8 Bright A_SpawnProjectile("CentaurFX", 45, 0, 0, CMF_AIMOFFSET); CENT E 10 A_FaceTarget; CENT F 8 Bright A_SpawnProjectile("CentaurFX", 45, 0, 0, CMF_AIMOFFSET); Goto See; } } // Mashed centaur ----------------------------------------------------------- // // The mashed centaur is only placed through ACS. Nowhere in the game source // is it ever referenced. class CentaurMash : Centaur { Default { +NOBLOOD +BLASTED -TELESTOMP +NOICEDEATH RenderStyle "Translucent"; Alpha 0.4; } States { Death: XDeath: Ice: Stop; } } // Centaur projectile ------------------------------------------------------- class CentaurFX : Actor { Default { Speed 20; Damage 4; Projectile; +SPAWNSOUNDSOURCE +ZDOOMTRANS RenderStyle "Add"; SeeSound "CentaurLeaderAttack"; DeathSound "CentaurMissileExplode"; } States { Spawn: CTFX A -1 Bright; Stop; Death: CTFX B 4 Bright; CTFX C 3 Bright; CTFX D 4 Bright; CTFX E 3 Bright; CTFX F 2 Bright; Stop; } } // Centaur shield (debris) -------------------------------------------------- class CentaurShield : Actor { Default { +DROPOFF +CORPSE +NOTELEPORT } States { Spawn: CTDP ABCDEF 3; Goto Spawn+2; Crash: CTDP G 4; CTDP H 4 A_QueueCorpse; CTDP I 4; CTDP J -1; Stop; } } // Centaur sword (debris) --------------------------------------------------- class CentaurSword : Actor { Default { +DROPOFF +CORPSE +NOTELEPORT } States { Spawn: CTDP KLMNOPQ 3; Goto Spawn+2; Crash: CTDP R 4; CTDP S 4 A_QueueCorpse; CTDP T -1; Stop; } } extend class Actor { //========================================================================== // // This file contains all the A_Jump* checker functions, all split up // into an actual checker and a simple wrapper around ResolveState. // //========================================================================== action state A_JumpIf(bool expression, statelabel label) { return expression? ResolveState(label) : null; } //========================================================================== // // // //========================================================================== action state A_JumpIfHealthLower(int health, statelabel label, int ptr_selector = AAPTR_DEFAULT) { Actor aptr = GetPointer(ptr_selector); return aptr && aptr.health < health? ResolveState(label) : null; } //========================================================================== // // // //========================================================================== bool CheckIfCloser(Actor targ, double dist, bool noz = false) { if (!targ) return false; return (Distance2D(targ) < dist && (noz || ((pos.z > targ.pos.z && pos.z - targ.pos.z - targ.height < dist) || (pos.z <= targ.pos.z && targ.pos.z - pos.z - height < dist) ) )); } action state A_JumpIfCloser(double distance, statelabel label, bool noz = false) { Actor targ; if (player == NULL) { targ = target; } else { // Does the player aim at something that can be shot? targ = AimTarget(); } return CheckIfCloser(targ, distance, noz)? ResolveState(label) : null; } action state A_JumpIfTracerCloser(double distance, statelabel label, bool noz = false) { return CheckIfCloser(tracer, distance, noz)? ResolveState(label) : null; } action state A_JumpIfMasterCloser(double distance, statelabel label, bool noz = false) { return CheckIfCloser(master, distance, noz)? ResolveState(label) : null; } //========================================================================== // // // //========================================================================== action state A_JumpIfTargetOutsideMeleeRange(statelabel label) { return CheckMeleeRange()? null : ResolveState(label); } action state A_JumpIfTargetInsideMeleeRange(statelabel label) { return CheckMeleeRange()? ResolveState(label) : null; } //========================================================================== // // // //========================================================================== action state A_JumpIfInventory(class itemtype, int itemamount, statelabel label, int owner = AAPTR_DEFAULT) { return CheckInventory(itemtype, itemamount, owner)? ResolveState(label) : null; } action state A_JumpIfInTargetInventory(class itemtype, int amount, statelabel label, int forward_ptr = AAPTR_DEFAULT) { if (target == null) return null; return target.CheckInventory(itemtype, amount, forward_ptr)? ResolveState(label) : null; } //========================================================================== // // rather pointless these days to do it this way. // //========================================================================== bool CheckArmorType(name Type, int amount = 1) { let myarmor = BasicArmor(FindInventory("BasicArmor")); return myarmor != null && myarmor.ArmorType == type && myarmor.Amount >= amount; } action state A_JumpIfArmorType(name Type, statelabel label, int amount = 1) { return CheckArmorType(Type, amount)? ResolveState(label) : null; } //========================================================================== // // // //========================================================================== native bool CheckIfSeen(); native bool CheckSightOrRange(double distance, bool two_dimension = false); native bool CheckRange(double distance, bool two_dimension = false); action state A_CheckSight(statelabel label) { return CheckIfSeen()? ResolveState(label) : null; } action state A_CheckSightOrRange(double distance, statelabel label, bool two_dimension = false) { return CheckSightOrRange(distance, two_dimension)? ResolveState(label) : null; } action state A_CheckRange(double distance, statelabel label, bool two_dimension = false) { return CheckRange(distance, two_dimension)? ResolveState(label) : null; } //========================================================================== // // // //========================================================================== action state A_CheckFloor(statelabel label) { return pos.z <= floorz? ResolveState(label) : null; } action state A_CheckCeiling(statelabel label) { return pos.z + height >= ceilingz? ResolveState(label) : null; } //========================================================================== // // since this is deprecated the checker is private. // //========================================================================== private native bool CheckFlag(string flagname, int check_pointer = AAPTR_DEFAULT); deprecated("2.3", "Use a combination of direct flag access and SetStateLabel()") action state A_CheckFlag(string flagname, statelabel label, int check_pointer = AAPTR_DEFAULT) { return CheckFlag(flagname, check_pointer)? ResolveState(label) : null; } //========================================================================== // // // //========================================================================== native bool PlayerSkinCheck(); action state A_PlayerSkinCheck(statelabel label) { return PlayerSkinCheck()? ResolveState(label) : null; } //========================================================================== // // // //========================================================================== action state A_CheckSpecies(statelabel label, name species = 'none', int ptr = AAPTR_DEFAULT) { Actor aptr = GetPointer(ptr); return aptr && aptr.GetSpecies() == species? ResolveState(label) : null; } //========================================================================== // // // //========================================================================== native bool CheckLOF(int flags = 0, double range = 0, double minrange = 0, double angle = 0, double pitch = 0, double offsetheight = 0, double offsetwidth = 0, int ptr_target = AAPTR_DEFAULT, double offsetforward = 0); native bool CheckIfTargetInLOS (double fov = 0, int flags = 0, double dist_max = 0, double dist_close = 0); native bool CheckIfInTargetLOS (double fov = 0, int flags = 0, double dist_max = 0, double dist_close = 0); native bool CheckProximity(class classname, double distance, int count = 1, int flags = 0, int ptr = AAPTR_DEFAULT); native bool CheckBlock(int flags = 0, int ptr = AAPTR_DEFAULT, double xofs = 0, double yofs = 0, double zofs = 0, double angle = 0); action state A_CheckLOF(statelabel label, int flags = 0, double range = 0, double minrange = 0, double angle = 0, double pitch = 0, double offsetheight = 0, double offsetwidth = 0, int ptr_target = AAPTR_DEFAULT, double offsetforward = 0) { return CheckLOF(flags, range, minrange, angle, pitch, offsetheight, offsetwidth, ptr_target, offsetforward)? ResolveState(label) : null; } action state A_JumpIfTargetInLOS (statelabel label, double fov = 0, int flags = 0, double dist_max = 0, double dist_close = 0) { return CheckIfTargetInLOS(fov, flags, dist_max, dist_close)? ResolveState(label) : null; } action state A_JumpIfInTargetLOS (statelabel label, double fov = 0, int flags = 0, double dist_max = 0, double dist_close = 0) { return CheckIfInTargetLOS(fov, flags, dist_max, dist_close)? ResolveState(label) : null; } action state A_CheckProximity(statelabel label, class classname, double distance, int count = 1, int flags = 0, int ptr = AAPTR_DEFAULT) { // This one was doing some weird stuff that needs to be preserved. state jumpto = ResolveState(label); if (!jumpto) { if (!(flags & (CPXF_SETTARGET | CPXF_SETMASTER | CPXF_SETTRACER))) { return null; } } return CheckProximity(classname, distance, count, flags, ptr)? jumpto : null; } action state A_CheckBlock(statelabel label, int flags = 0, int ptr = AAPTR_DEFAULT, double xofs = 0, double yofs = 0, double zofs = 0, double angle = 0) { return CheckBlock(flags, ptr, xofs, yofs, zofs, angle)? ResolveState(label) : null; } //=========================================================================== // A_JumpIfHigherOrLower // // Jumps if a target, master, or tracer is higher or lower than the calling // actor. Can also specify how much higher/lower the actor needs to be than // itself. Can also take into account the height of the actor in question, // depending on which it's checking. This means adding height of the // calling actor's self if the pointer is higher, or height of the pointer // if its lower. //=========================================================================== action state A_JumpIfHigherOrLower(statelabel high, statelabel low, double offsethigh = 0, double offsetlow = 0, bool includeHeight = true, int ptr = AAPTR_TARGET) { Actor mobj = GetPointer(ptr); if (mobj != null && mobj != self) //AAPTR_DEFAULT is completely useless in this regard. { if ((high) && (mobj.pos.z > ((includeHeight ? Height : 0) + pos.z + offsethigh))) { return ResolveState(high); } else if ((low) && (mobj.pos.z + (includeHeight ? mobj.Height : 0)) < (pos.z + offsetlow)) { return ResolveState(low); } } return null; } } // Renaming and changing messages // Mini Zorch ----------------------------------------------------------------- class MiniZorchRecharge : Clip { Default { inventory.pickupmessage "$GOTZORCHRECHARGE"; } } class MiniZorchPack : Clip { Default { Inventory.PickupMessage "$GOTMINIZORCHPACK"; Inventory.Amount 50; } States { Spawn: AMMO A -1; Stop; } } // Large Zorch ---------------------------------------------------------------- class LargeZorchRecharge : Shell { Default { inventory.pickupmessage "$GOTLARGEZORCHERRECHARGE"; } } class LargeZorchPack : Shell { Default { Inventory.PickupMessage "$GOTLARGEZORCHERPACK"; Inventory.Amount 20; } States { Spawn: SBOX A -1; Stop; } } // Zorch Propulsor ------------------------------------------------------------ class PropulsorZorch : RocketAmmo { Default { inventory.pickupmessage "$GOTPROPULSORRECHARGE"; } } class PropulsorZorchPack : RocketAmmo { Default { Inventory.PickupMessage "$GOTPROPULSORPACK"; Inventory.Amount 5; } States { Spawn: BROK A -1; Stop; } } // Phasing Zorch -------------------------------------------------------------- class PhasingZorch : Cell { Default { inventory.pickupmessage "$GOTPHASINGZORCHERRECHARGE"; } } class PhasingZorchPack : Cell { Default { Inventory.PickupMessage "$GOTPHASINGZORCHERPACK"; Inventory.Amount 100; } States { Spawn: CELP A -1; Stop; } } // Doom items renamed with height changes // Civilians ------------------------------------------------------------------ class ChexCivilian1 : GreenTorch { Default { height 54; } } class ChexCivilian2 : ShortGreenTorch { Default { height 54; } } class ChexCivilian3 : ShortRedTorch { Default { height 48; } } // Landing Zone --------------------------------------------------------------- class ChexLandingLight : Column { Default { height 35; } } class ChexSpaceship : TechPillar { Default { height 52; } } // Trees and Plants ----------------------------------------------------------- class ChexAppleTree : Stalagtite { Default { height 92; } } class ChexBananaTree : BigTree { Default { height 108; } } class ChexOrangeTree : TorchTree { Default { height 92; } } class ChexSubmergedPlant : ShortGreenColumn { Default { height 42; } } class ChexTallFlower : HeadsOnAStick { Default { height 25; } } class ChexTallFlower2 : DeadStick { Default { height 25; } } // Slime Fountain ------------------------------------------------------------- class ChexSlimeFountain : BlueTorch { Default { height 48; } States { Spawn: TBLU ABCD 4; Loop; } } // Cavern Decorations --------------------------------------------------------- class ChexCavernColumn : TallRedColumn { Default { height 128; } } class ChexCavernStalagmite : TallGreenColumn { Default { height 60; } } // Misc. Props ---------------------------------------------------------------- class ChexChemicalBurner : EvilEye { Default { height 25; } } class ChexChemicalFlask : Candlestick { Default { RenderStyle "Translucent"; alpha 0.75; } } class ChexFlagOnPole : SkullColumn { Default { height 128; } } class ChexGasTank : Candelabra { Default { height 36; } } class ChexLightColumn : ShortBlueTorch { Default { height 86; } } class ChexMineCart : ShortRedColumn { Default { height 30; } } // General Pickups ============================================================ // Health --------------------------------------------------------------------- class GlassOfWater : HealthBonus { Default { inventory.pickupmessage "$GOTWATER"; } } class BowlOfFruit : Stimpack { Default { inventory.pickupmessage "$GOTFRUIT"; } } class BowlOfVegetables : Medikit { Default { inventory.pickupmessage "$GOTVEGETABLES"; health.lowmessage 25, "$GOTVEGETABLESNEED"; } } class SuperchargeBreakfast : Soulsphere { Default { inventory.pickupmessage "$GOTBREAKFAST"; } } // Armor ---------------------------------------------------------------------- class SlimeRepellent : ArmorBonus { Default { inventory.pickupmessage "$GOTREPELLENT"; } } class ChexArmor : GreenArmor { Default { inventory.pickupmessage "$GOTCHEXARMOR"; } } class SuperChexArmor : BlueArmor { Default { inventory.pickupmessage "$GOTSUPERCHEXARMOR"; } } // Powerups =================================================================== class ComputerAreaMap : Allmap { Default { inventory.pickupmessage "$GOTCHEXMAP"; } } class SlimeProofSuit : RadSuit { Default { inventory.pickupmessage "$GOTSLIMESUIT"; } } class Zorchpack : Backpack { Default { inventory.pickupmessage "$GOTZORCHPACK"; } } // These are merely renames of the Doom cards class ChexBlueCard : BlueCard { Default { inventory.pickupmessage "$GOTCBLUEKEY"; } } class ChexYellowCard : YellowCard { Default { inventory.pickupmessage "$GOTCYELLOWKEY"; } } class ChexRedCard : RedCard { Default { inventory.pickupmessage "$GOTCREDKEY"; } } //=========================================================================== // // Flemoidus Commonus // //=========================================================================== class FlemoidusCommonus : ZombieMan { Default { DropItem ""; Obituary "$OB_COMMONUS"; } States { Missile: Stop; Melee: goto Super::Missile; } } //=========================================================================== // // Flemoidus Bipedicus // //=========================================================================== class FlemoidusBipedicus : ShotgunGuy { Default { DropItem ""; Obituary "$OB_BIPEDICUS"; } States { Missile: Stop; Melee: goto Super::Missile; } } //=========================================================================== // // Flemoidus Bipedicus w/ Armor // //=========================================================================== class ArmoredFlemoidusBipedicus : DoomImp { Default { Obituary "$OB_BIPEDICUS2"; HitObituary "$OB_BIPEDICUS2"; } } //=========================================================================== // // Flemoidus Cycloptis Commonus // //=========================================================================== class FlemoidusCycloptisCommonus : Demon { Default { Obituary "$OB_CYCLOPTIS"; } } //=========================================================================== // // The Flembrane // //=========================================================================== class Flembrane : BaronOfHell { Default { radius 44; height 100; speed 0; Obituary "$OB_FLEMBRANE"; } States { Missile: BOSS EF 3 A_FaceTarget; BOSS G 0 A_BruisAttack; goto See; } } //=========================================================================== class ChexSoul : LostSoul { Default { height 0; } } // Chex Warrior class ChexPlayer : DoomPlayer { Default { player.displayname "Chex Warrior"; player.crouchsprite ""; player.colorrange 192, 207; //Not perfect, but its better than everyone being blue. player.startitem "MiniZorcher"; player.startitem "Bootspoon"; player.startitem "MiniZorchRecharge", 50; player.damagescreencolor "60 b0 58"; player.WeaponSlot 1, "Bootspoon", "SuperBootspork"; player.WeaponSlot 2, "MiniZorcher"; player.WeaponSlot 3, "LargeZorcher", "SuperLargeZorcher"; player.WeaponSlot 4, "RapidZorcher"; player.WeaponSlot 5, "ZorchPropulsor"; player.WeaponSlot 6, "PhasingZorcher"; player.WeaponSlot 7, "LAZDevice"; Player.Colorset 0, "$TXT_COLOR_LIGHTBLUE", 0xC0, 0xCF, 0xC2; Player.Colorset 1, "$TXT_COLOR_GREEN", 0x70, 0x7F, 0x72; Player.Colorset 2, "$TXT_COLOR_GRAY", 0x60, 0x6F, 0x62; Player.Colorset 3, "$TXT_COLOR_BROWN", 0x40, 0x4F, 0x42; Player.Colorset 4, "$TXT_COLOR_RED", 0x20, 0x2F, 0x22; Player.Colorset 5, "$TXT_COLOR_LIGHTGRAY", 0x58, 0x67, 0x5A; Player.Colorset 6, "$TXT_COLOR_LIGHTBROWN", 0x38, 0x47, 0x3A; Player.Colorset 7, "$TXT_COLOR_LIGHTRED", 0xB0, 0xBF, 0xB2; } } // Same as Doom weapons, but the obituaries are removed. class Bootspoon : Fist { Default { obituary "$OB_MPSPOON"; Tag "$TAG_SPOON"; } } class SuperBootspork : Chainsaw { Default { obituary "$OB_MPBOOTSPORK"; Inventory.PickupMessage "$GOTSUPERBOOTSPORK"; Tag "$TAG_SPORK"; } } class MiniZorcher : Pistol { Default { obituary "$OB_MPZORCH"; inventory.pickupmessage "$GOTMINIZORCHER"; Tag "$TAG_MINIZORCHER"; } States { Spawn: MINZ A -1; Stop; } } class LargeZorcher : Shotgun { Default { obituary "$OB_MPZORCH"; inventory.pickupmessage "$GOTLARGEZORCHER"; Tag "$TAG_LARGEZORCHER"; } } class SuperLargeZorcher : SuperShotgun { Default { obituary "$OB_MPMEGAZORCH"; inventory.pickupmessage "$GOTSUPERLARGEZORCHER"; Tag "$TAG_SUPERLARGEZORCHER"; } } class RapidZorcher : Chaingun { Default { obituary "$OB_MPRAPIDZORCH"; inventory.pickupmessage "$GOTRAPIDZORCHER"; Tag "$TAG_RAPIDZORCHER"; } } class ZorchPropulsor : RocketLauncher { Default { obituary ""; inventory.pickupmessage "$GOTZORCHPROPULSOR"; Tag "$TAG_ZORCHPROPULSOR"; } States { Fire: MISG B 8 A_GunFlash; MISG B 12 A_FireProjectile("PropulsorMissile"); MISG B 0 A_ReFire; Goto Ready; } } class PropulsorMissile : Rocket { Default { -ROCKETTRAIL -DEHEXPLOSION RenderStyle "Translucent"; Obituary "$OB_MPPROPULSOR"; Alpha 0.75; } } class PhasingZorcher : PlasmaRifle { Default { obituary ""; inventory.pickupmessage "$GOTPHASINGZORCHER"; Tag "$TAG_PHASINGZORCHER"; } States { Fire: PLSG A 0 A_GunFlash('Flash', GFF_NOEXTCHANGE); PLSG A 3 A_FireProjectile("PhaseZorchMissile"); PLSG B 20 A_ReFire; Goto Ready; Flash: PLSF A 0 A_Jump(128, "Flash2"); PLSF A 3 Bright A_Light1; Goto LightDone; Flash2: PLSF B 3 Bright A_Light1; Goto LightDone; } } class PhaseZorchMissile : PlasmaBall { Default { RenderStyle "Translucent"; Obituary "$OB_MPPHASEZORCH"; Alpha 0.75; } } class LAZDevice : BFG9000 { Default { obituary ""; inventory.pickupmessage "$GOTLAZDEVICE"; Tag "$TAG_LAZDEVICE"; } States { Fire: BFGG A 20 A_BFGsound; BFGG B 10 A_GunFlash; BFGG B 10 A_FireProjectile("LAZBall"); BFGG B 20 A_ReFire; Goto Ready; } } class LAZBall : BFGBall { Default { RenderStyle "Translucent"; Obituary "$OB_MPLAZ_BOOM"; Alpha 0.75; } } // Beak puff ---------------------------------------------------------------- class BeakPuff : StaffPuff { Default { Mass 5; Renderstyle "Translucent"; Alpha 0.4; AttackSound "chicken/attack"; VSpeed 1; } } // Beak --------------------------------------------------------------------- class Beak : Weapon { Default { Weapon.SelectionOrder 10000; +WEAPON.DONTBOB +WEAPON.MELEEWEAPON Weapon.YAdjust 15; Weapon.SisterWeapon "BeakPowered"; } States { Ready: BEAK A 1 A_WeaponReady; Loop; Deselect: BEAK A 1 A_Lower; Loop; Select: BEAK A 1 A_BeakRaise; Loop; Fire: BEAK A 18 A_BeakAttackPL1; Goto Ready; } //--------------------------------------------------------------------------- // // PROC A_BeakRaise // //--------------------------------------------------------------------------- action void A_BeakRaise () { if (player == null) { return; } let psp = player.GetPSprite(PSP_WEAPON); if (psp) { psp.y = WEAPONTOP; ResetPSprite(psp); } player.SetPsprite(PSP_WEAPON, player.ReadyWeapon.GetReadyState()); } //---------------------------------------------------------------------------- // // PROC A_BeakAttackPL1 // //---------------------------------------------------------------------------- action void A_BeakAttackPL1() { FTranslatedLineTarget t; if (player == null) { return; } int damage = random[BeakAtk](1,3); double ang = angle; double slope = AimLineAttack (ang, DEFMELEERANGE); LineAttack (ang, DEFMELEERANGE, slope, damage, 'Melee', "BeakPuff", true, t); if (t.linetarget) { angle = t.angleFromSource; } A_StartSound ("chicken/peck", CHAN_VOICE); player.chickenPeck = 12; let psp = player.GetPSprite(PSP_WEAPON); if (psp) { psp.Tics -= random[BeakAtk](0,7); } } } // BeakPowered --------------------------------------------------------------------- class BeakPowered : Beak { Default { +WEAPON.POWERED_UP Weapon.SisterWeapon "Beak"; } States { Fire: BEAK A 12 A_BeakAttackPL2; Goto Ready; } //---------------------------------------------------------------------------- // // PROC A_BeakAttackPL2 // //---------------------------------------------------------------------------- action void A_BeakAttackPL2() { FTranslatedLineTarget t; if (player == null) { return; } int damage = random[BeakAtk](1,8) * 4; double ang = angle; double slope = AimLineAttack (ang, DEFMELEERANGE); LineAttack (ang, DEFMELEERANGE, slope, damage, 'Melee', "BeakPuff", true, t); if (t.linetarget) { angle = t.angleFromSource; } A_StartSound ("chicken/peck", CHAN_VOICE); player.chickenPeck = 12; let psp = player.GetPSprite(PSP_WEAPON); if (psp) { psp.Tics -= random[BeakAtk](0,3); } } } // Chicken player ----------------------------------------------------------- class ChickenPlayer : PlayerPawn { Default { Health 30; ReactionTime 0; PainChance 255; Radius 16; Height 24; Speed 1; Gravity 0.125; +NOSKIN +PLAYERPAWN.CANSUPERMORPH PainSound "chicken/pain"; DeathSound "chicken/death"; Player.JumpZ 1; Player.Viewheight 21; Player.ForwardMove 1.22, 1.22; Player.SideMove 1.22, 1.22; Player.SpawnClass "Chicken"; Player.SoundClass "Chicken"; Player.DisplayName "Chicken"; Player.MorphWeapon "Beak"; -PICKUP } States { Spawn: CHKN A -1; Stop; See: CHKN ABAB 3; Loop; Melee: Missile: CHKN C 12; Goto Spawn; Pain: CHKN D 4 A_Feathers; CHKN C 4 A_Pain; Goto Spawn; Death: CHKN E 6 A_Scream; CHKN F 6 A_Feathers; CHKN G 6; CHKN H 6 A_NoBlocking; CHKN IJK 6; CHKN L -1; Stop; } //--------------------------------------------------------------------------- // // PROC P_UpdateBeak // //--------------------------------------------------------------------------- override void MorphPlayerThink () { if (health > 0) { // Handle beak movement PSprite pspr; if (player != null && (pspr = player.FindPSprite(PSP_WEAPON)) != null) { pspr.y = WEAPONTOP + player.chickenPeck / 2; } } if (player.morphTics & 15) { return; } if (Vel.X == 0 && Vel.Y == 0 && random[ChickenPlayerThink]() < 160) { // Twitch view ang angle += Random2[ChickenPlayerThink]() * (360. / 256. / 32.); } if ((pos.z <= floorz) && (random[ChickenPlayerThink]() < 32)) { // Jump and noise Vel.Z += JumpZ; State painstate = FindState('Pain'); if (painstate != null) SetState (painstate); } if (random[ChickenPlayerThink]() < 48) { // Just noise A_StartSound ("chicken/active", CHAN_VOICE); } } } // Chicken (non-player) ----------------------------------------------------- class Chicken : MorphedMonster { Default { Health 10; Radius 9; Height 22; Mass 40; Speed 4; Painchance 200; Monster; -COUNTKILL +WINDTHRUST +DONTMORPH +FLOORCLIP SeeSound "chicken/pain"; AttackSound "chicken/attack"; PainSound "chicken/pain"; DeathSound "chicken/death"; ActiveSound "chicken/active"; Obituary "$OB_CHICKEN"; Tag "$FN_CHICKEN"; } States { Spawn: CHKN AB 10 A_Look; Loop; See: CHKN AB 3 A_Chase; Loop; Pain: CHKN D 5 A_Feathers; CHKN C 5 A_Pain; Goto See; Melee: CHKN A 8 A_FaceTarget; CHKN C 10 A_CustomMeleeAttack(random[ChicAttack](1,2)); Goto See; Death: CHKN E 6 A_Scream; CHKN F 6 A_Feathers; CHKN G 6; CHKN H 6 A_NoBlocking; CHKN IJK 6; CHKN L -1; Stop; } } // Feather ------------------------------------------------------------------ class Feather : Actor { Default { Radius 2; Height 4; +MISSILE +DROPOFF +NOTELEPORT +CANNOTPUSH +WINDTHRUST +DONTSPLASH Gravity 0.125; } States { Spawn: CHKN MNOPQPON 3; Loop; Death: CHKN N 6; Stop; } } extend class Actor { //---------------------------------------------------------------------------- // // PROC A_Feathers // This is used by both the chicken player and monster and must be in the // common base class to be accessible by both // //---------------------------------------------------------------------------- void A_Feathers() { int count; if (health > 0) { // Pain count = random[Feathers]() < 32 ? 2 : 1; } else { // Death count = 5 + (random[Feathers](0, 3)); } for (int i = 0; i < count; i++) { Actor mo = Spawn("Feather", pos + (0, 0, 20), NO_REPLACE); if (mo != null) { mo.target = self; mo.Vel.X = Random2[Feathers]() / 256.; mo.Vel.Y = Random2[Feathers]() / 256.; mo.Vel.Z = 1. + random[Feathers]() / 128.; mo.SetState (mo.SpawnState + (random[Feathers](0, 7))); } } } } // Cleric Boss (Traductus) -------------------------------------------------- class ClericBoss : Actor { Default { Health 800; PainChance 50; Speed 25; Radius 16; Height 64; Monster; +FLOORCLIP +TELESTOMP +DONTMORPH PainSound "PlayerClericPain"; DeathSound "PlayerClericCrazyDeath"; Obituary "$OB_CBOSS"; Tag "$FN_CBOSS"; } States { Spawn: CLER A 2; CLER A 3 A_ClassBossHealth; CLER A 5 A_Look; Wait; See: CLER ABCD 4 A_FastChase; Loop; Pain: CLER H 4; CLER H 4 A_Pain; Goto See; Melee: Missile: CLER EF 8 A_FaceTarget; CLER G 10 A_ClericAttack; Goto See; Death: CLER I 6; CLER K 6 A_Scream; CLER LL 6; CLER M 6 A_NoBlocking; CLER NOP 6; CLER Q -1; Stop; XDeath: CLER R 5 A_Scream; CLER S 5; CLER T 5 A_NoBlocking; CLER UVWXYZ 5; CLER [ -1; Stop; Ice: CLER \ 5 A_FreezeDeath; CLER \ 1 A_FreezeDeathChunks; Wait; Burn: CLER C 5 Bright A_StartSound("PlayerClericBurnDeath"); FDTH D 4 Bright ; FDTH G 5 Bright ; FDTH H 4 Bright A_Scream; FDTH I 5 Bright ; FDTH J 4 Bright ; FDTH K 5 Bright ; FDTH L 4 Bright ; FDTH M 5 Bright ; FDTH N 4 Bright ; FDTH O 5 Bright ; FDTH P 4 Bright ; FDTH Q 5 Bright ; FDTH R 4 Bright ; FDTH S 5 Bright A_NoBlocking; FDTH T 4 Bright ; FDTH U 5 Bright ; FDTH V 4 Bright ; Stop; } //============================================================================ // // A_ClericAttack // //============================================================================ void A_ClericAttack() { if (!target) return; Actor missile = SpawnMissileZ (pos.z + 40., target, "HolyMissile"); if (missile != null) missile.tracer = null; // No initial target A_StartSound ("HolySymbolFire", CHAN_WEAPON); } } // The Cleric's Flame Strike ------------------------------------------------ class CWeapFlame : ClericWeapon { Default { +NOGRAVITY Weapon.SelectionOrder 1000; Weapon.AmmoUse 4; Weapon.AmmoGive 25; Weapon.KickBack 150; Weapon.YAdjust 10; Weapon.AmmoType1 "Mana2"; Inventory.PickupMessage "$TXT_WEAPON_C3"; Tag "$TAG_CWEAPFLAME"; } States { Spawn: WCFM ABCDEFGH 4 Bright; Loop; Select: CFLM A 1 A_Raise; Loop; Deselect: CFLM A 1 A_Lower; Loop; Ready: CFLM AAAABBBBCCCC 1 A_WeaponReady; Loop; Fire: CFLM A 2 Offset (0, 40); CFLM D 2 Offset (0, 50); CFLM D 2 Offset (0, 36); CFLM E 4 Bright; CFLM F 4 Bright A_CFlameAttack; CFLM E 4 Bright; CFLM G 2 Offset (0, 40); CFLM G 2; Goto Ready; } //============================================================================ // // A_CFlameAttack // //============================================================================ action void A_CFlameAttack() { if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } SpawnPlayerMissile ("CFlameMissile"); A_StartSound ("ClericFlameFire", CHAN_WEAPON); } } // Floor Flame -------------------------------------------------------------- class CFlameFloor : Actor { Default { +NOBLOCKMAP +NOGRAVITY +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: CFFX N 5 Bright; CFFX O 4 Bright; CFFX P 3 Bright; Stop; } } // Flame Puff --------------------------------------------------------------- class FlamePuff : Actor { Default { Radius 1; Height 1; +NOBLOCKMAP +NOGRAVITY +ZDOOMTRANS RenderStyle "Add"; SeeSound "ClericFlameExplode"; AttackSound "ClericFlameExplode"; } States { Spawn: CFFX ABC 3 Bright; CFFX D 4 Bright; CFFX E 3 Bright; CFFX F 4 Bright; CFFX G 3 Bright; CFFX H 4 Bright; CFFX I 3 Bright; CFFX J 4 Bright; CFFX K 3 Bright; CFFX L 4 Bright; CFFX M 3 Bright; Stop; } } // Flame Puff 2 ------------------------------------------------------------- class FlamePuff2 : FlamePuff { States { Spawn: CFFX ABC 3 Bright; CFFX D 4 Bright; CFFX E 3 Bright; CFFX F 4 Bright; CFFX G 3 Bright; CFFX H 4 Bright; CFFX IC 3 Bright; CFFX D 4 Bright; CFFX E 3 Bright; CFFX F 4 Bright; CFFX G 3 Bright; CFFX H 4 Bright; CFFX I 3 Bright; CFFX J 4 Bright; CFFX K 3 Bright; CFFX L 4 Bright; CFFX M 3 Bright; Stop; } } // Circle Flame ------------------------------------------------------------- class CircleFlame : Actor { const FLAMESPEED = 0.45; const FLAMEROTSPEED = 2.; Default { Radius 6; Damage 2; DamageType "Fire"; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS +ZDOOMTRANS RenderStyle "Add"; DeathSound "ClericFlameCircle"; Obituary "$OB_MPCWEAPFLAME"; } States { Spawn: CFCF A 4 Bright; CFCF B 2 Bright A_CFlameRotate; CFCF C 2 Bright; CFCF D 1 Bright; CFCF E 2 Bright; CFCF F 2 Bright A_CFlameRotate; CFCF G 1 Bright; CFCF HI 2 Bright; CFCF J 1 Bright A_CFlameRotate; CFCF K 2 Bright; CFCF LM 3 Bright; CFCF N 2 Bright A_CFlameRotate; CFCF O 3 Bright; CFCF P 2 Bright; Stop; Death: CFCF QR 3 Bright; CFCF S 3 Bright A_Explode(20, 128, 0); CFCF TUVWXYZ 3 Bright; Stop; } //============================================================================ // // A_CFlameRotate // //============================================================================ void A_CFlameRotate() { double an = Angle + 90.; VelFromAngle(FLAMEROTSPEED, an); Vel.XY += (specialf1, specialf2); Angle += 6; } } // Flame Missile ------------------------------------------------------------ class CFlameMissile : FastProjectile { Default { Speed 200; Radius 14; Height 8; Damage 8; DamageType "Fire"; +INVISIBLE +ZDOOMTRANS RenderStyle "Add"; Obituary "$OB_MPCWEAPFLAME"; } States { Spawn: CFFX A 4 Bright; CFFX A 1 A_CFlamePuff; Goto Death + 1; Death: CFFX A 1 Bright A_CFlameMissile; CFFX ABC 3 Bright; CFFX D 4 Bright; CFFX E 3 Bright; CFFX F 4 Bright; CFFX G 3 Bright; CFFX H 4 Bright; CFFX I 3 Bright; CFFX J 4 Bright; CFFX K 3 Bright; CFFX L 4 Bright; CFFX M 3 Bright; Stop; } override void BeginPlay () { special1 = 2; } override void Effect () { if (!--special1) { special1 = 4; double newz = pos.z - 12; if (newz < floorz) { newz = floorz; } Actor mo = Spawn ("CFlameFloor", (pos.xy, newz), ALLOW_REPLACE); if (mo) { mo.angle = angle; } } } //============================================================================ // // A_CFlamePuff // //============================================================================ void A_CFlamePuff() { bInvisible = false; bMissile = false; Vel = (0,0,0); A_StartSound ("ClericFlameExplode", CHAN_BODY); } //============================================================================ // // A_CFlameMissile // //============================================================================ void A_CFlameMissile() { bInvisible = false; A_StartSound ("ClericFlameExplode", CHAN_BODY); if (BlockingMobj && BlockingMobj.bShootable) { // Hit something, so spawn the flame circle around the thing double dist = BlockingMobj.radius + 18; for (int i = 0; i < 4; i++) { double an = i*45.; Actor mo = Spawn ("CircleFlame", BlockingMobj.Vec3Angle(dist, an, 5), ALLOW_REPLACE); if (mo) { mo.angle = an; mo.target = target; mo.VelFromAngle(CircleFlame.FLAMESPEED); mo.specialf1 = mo.Vel.X; mo.specialf2 = mo.Vel.Y; mo.tics -= random[FlameMissile](0, 3); } an += 180; mo = Spawn("CircleFlame", BlockingMobj.Vec3Angle(dist, an, 5), ALLOW_REPLACE); if(mo) { mo.angle = an; mo.target = target; mo.VelFromAngle(-CircleFlame.FLAMESPEED); mo.specialf1 = mo.Vel.X; mo.specialf2 = mo.Vel.Y; mo.tics -= random[FlameMissile](0, 3); } } SetState (SpawnState); } } } // Cleric Weapon Piece ------------------------------------------------------ class ClericWeaponPiece : WeaponPiece { Default { Inventory.PickupSound "misc/w_pkup"; Inventory.PickupMessage "$TXT_WRAITHVERGE_PIECE"; Inventory.ForbiddenTo "FighterPlayer", "MagePlayer"; WeaponPiece.Weapon "CWeapWraithverge"; +FLOATBOB } } // Cleric Weapon Piece 1 ---------------------------------------------------- class CWeaponPiece1 : ClericWeaponPiece { Default { WeaponPiece.Number 1; } States { Spawn: WCH1 A -1; Stop; } } // Cleric Weapon Piece 2 ---------------------------------------------------- class CWeaponPiece2 : ClericWeaponPiece { Default { WeaponPiece.Number 2; } States { Spawn: WCH2 A -1; Stop; } } // Cleric Weapon Piece 3 ---------------------------------------------------- class CWeaponPiece3 : ClericWeaponPiece { Default { WeaponPiece.Number 3; } States { Spawn: WCH3 A -1; Stop; } } // Wraithverge Drop --------------------------------------------------------- class WraithvergeDrop : Actor { States { Spawn: TNT1 A 1; TNT1 A 1 A_DropWeaponPieces("CWeaponPiece1", "CWeaponPiece2", "CWeaponPiece3"); Stop; } } // Cleric's Wraithverge (Holy Symbol?) -------------------------------------- class CWeapWraithverge : ClericWeapon { int CHolyCount; Default { Health 3; Weapon.SelectionOrder 3000; +WEAPON.PRIMARY_USES_BOTH; +Inventory.NoAttenPickupSound Weapon.AmmoUse1 18; Weapon.AmmoUse2 18; Weapon.AmmoGive1 20; Weapon.AmmoGive2 20; Weapon.KickBack 150; Weapon.AmmoType1 "Mana1"; Weapon.AmmoType2 "Mana2"; Inventory.PickupMessage "$TXT_WEAPON_C4"; Tag "$TAG_CWEAPWRAITHVERGE"; Inventory.PickupSound "WeaponBuild"; } States { Spawn: TNT1 A -1; Stop; Ready: CHLY A 1 A_WeaponReady; Loop; Select: CHLY A 1 A_Raise; Loop; Deselect: CHLY A 1 A_Lower; Loop; Fire: CHLY AB 1 Bright Offset (0, 40); CHLY CD 2 Bright Offset (0, 43); CHLY E 2 Bright Offset (0, 45); CHLY F 6 Bright Offset (0, 48) A_CHolyAttack; CHLY GG 2 Bright Offset (0, 40) A_CHolyPalette; CHLY G 2 Offset (0, 36) A_CHolyPalette; Goto Ready; } override color GetBlend () { if (paletteflash & PF_HEXENWEAPONS) { if (CHolyCount == 3) return Color(128, 70, 70, 70); else if (CHolyCount == 2) return Color(128, 100, 100, 100); else if (CHolyCount == 1) return Color(128, 130, 130, 130); else return Color(0, 0, 0, 0); } else { return Color(CHolyCount * 128 / 3, 131, 131, 131); } } //============================================================================ // // A_CHolyAttack // //============================================================================ action void A_CHolyAttack() { FTranslatedLineTarget t; if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } Actor missile = SpawnPlayerMissile ("HolyMissile", angle, pLineTarget:t); if (missile != null && !t.unlinked) { missile.tracer = t.linetarget; } invoker.CHolyCount = 3; A_StartSound ("HolySymbolFire", CHAN_WEAPON); } //============================================================================ // // A_CHolyPalette // //============================================================================ action void A_CHolyPalette() { if (invoker.CHolyCount > 0) invoker.CHolyCount--; } } // Holy Missile ------------------------------------------------------------- class HolyMissile : Actor { Default { Speed 30; Radius 15; Height 8; Damage 4; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS +EXTREMEDEATH } States { Spawn: SPIR PPPP 3 Bright A_SpawnItemEx("HolyMissilePuff"); Death: SPIR P 1 Bright A_CHolyAttack2; Stop; } //============================================================================ // // A_CHolyAttack2 // // Spawns the spirits //============================================================================ void A_CHolyAttack2() { for (int j = 0; j < 4; j++) { Actor mo = Spawn("HolySpirit", Pos, ALLOW_REPLACE); if (!mo) { continue; } switch (j) { // float bob index case 0: mo.WeaveIndexZ = random[HolyAtk2](0, 7); // upper-left break; case 1: mo.WeaveIndexZ = random[HolyAtk2](32, 39); // upper-right break; case 2: mo.WeaveIndexXY = random[HolyAtk2](32, 39); // lower-left break; case 3: mo.WeaveIndexXY = random[HolyAtk2](32, 39); mo.WeaveIndexZ = random[HolyAtk2](32, 39); break; } mo.SetZ(pos.z); mo.angle = angle + 67.5 - 45.*j; mo.Thrust(); mo.target = target; mo.args[0] = 10; // initial turn value mo.args[1] = 0; // initial look angle if (deathmatch) { // Ghosts last slightly less longer in DeathMatch mo.health = 85; } if (tracer) { mo.tracer = tracer; mo.bNoClip = true; mo.bSkullFly = true; mo.bMissile = false; } HolyTail.SpawnSpiritTail (mo); } } } // Holy Missile Puff -------------------------------------------------------- class HolyMissilePuff : Actor { Default { Radius 4; Height 8; +NOBLOCKMAP +NOGRAVITY +DROPOFF +NOTELEPORT RenderStyle "Translucent"; Alpha 0.4; } States { Spawn: SPIR QRSTU 3; Stop; } } // Holy Puff ---------------------------------------------------------------- class HolyPuff : Actor { Default { +NOBLOCKMAP +NOGRAVITY RenderStyle "Translucent"; Alpha 0.6; } States { Spawn: SPIR KLMNO 3; Stop; } } // Holy Spirit -------------------------------------------------------------- class HolySpirit : Actor { Default { Health 105; Speed 12; Radius 10; Height 6; Damage 3; Projectile; +RIPPER +SEEKERMISSILE +FOILINVUL +SKYEXPLODE +NOEXPLODEFLOOR +CANBLAST +EXTREMEDEATH +NOSHIELDREFLECT RenderStyle "Translucent"; Alpha 0.4; DeathSound "SpiritDie"; Obituary "$OB_MPCWEAPWRAITHVERGE"; } States { Spawn: SPIR AAB 2 A_CHolySeek; SPIR B 2 A_CHolyCheckScream; Loop; Death: SPIR D 4; SPIR E 4 A_Scream; SPIR FGHI 4; Stop; } //============================================================================ // // // //============================================================================ override bool Slam(Actor thing) { if (thing.bShootable && thing != target) { if (multiplayer && !deathmatch && thing.player && target.player) { // don't attack other co-op players return true; } if (thing.bReflective && (thing.player || thing.bBoss)) { tracer = target; target = thing; return true; } if (thing.bIsMonster || thing.player) { tracer = thing; } if (random[SpiritSlam]() < 96) { int dam = 12; if (thing.player || thing.bBoss) { dam = 3; // ghost burns out faster when attacking players/bosses health -= 6; } thing.DamageMobj(self, target, dam, 'Melee'); if (random[SpiritSlam]() < 128) { Spawn("HolyPuff", Pos, ALLOW_REPLACE); A_StartSound("SpiritAttack", CHAN_WEAPON); if (thing.bIsMonster && random[SpiritSlam]() < 128) { thing.Howl(); } } } if (thing.health <= 0) { tracer = null; } } return true; } override bool SpecialBlastHandling (Actor source, double strength) { if (tracer == source) { tracer = target; target = source; } return true; } //============================================================================ // // CHolyFindTarget // //============================================================================ private void CHolyFindTarget () { Actor target; if ( (target = RoughMonsterSearch (6, true)) ) { tracer = target; bNoClip = true; bSkullFly = true; bMissile = false; } } //============================================================================ // // CHolySeekerMissile // // Similar to P_SeekerMissile, but seeks to a random Z on the target //============================================================================ private void CHolySeekerMissile (double thresh, double turnMax) { Actor target = tracer; if (target == NULL) { return; } if (!target.bShootable || (!target.bIsMonster && !target.player)) { // Target died/target isn't a player or creature tracer = null; bNoClip = false; bSkullFly = false; bMissile = true; CHolyFindTarget(); return; } double ang = deltaangle(angle, AngleTo(target)); double delta = abs(ang); if (delta > thresh) { delta /= 2; if (delta > turnMax) { delta = turnMax; } } if (ang > 0) { // Turn clockwise angle += delta; } else { // Turn counter clockwise angle -= delta; } VelFromAngle(); if (!(Level.maptime&15) || pos.z > target.pos.z + target.height || pos.z + height < target.pos.z) { double newZ = target.pos.z + ((random[HolySeeker]()*target.Height) / 256.); double deltaZ = newZ - pos.z; if (abs(deltaZ) > 15) { if (deltaZ > 0) { deltaZ = 15; } else { deltaZ = -15; } } Vel.Z = deltaZ / DistanceBySpeed(target, Speed); } } //============================================================================ // // A_CHolySeek // //============================================================================ void A_CHolySeek() { health--; if (health <= 0) { Vel.X /= 4; Vel.Y /= 4; Vel.Z = 0; SetStateLabel ("Death"); tics -= random[HolySeeker](0, 3); return; } if (tracer) { CHolySeekerMissile (args[0], args[0]*2.); if (!((Level.maptime+7)&15)) { args[0] = 5+(random[HolySeeker]()/20); } } int xyspeed = random[HolySeeker](0, 4); int zspeed = random[HolySeeker](0, 4); A_Weave(xyspeed, zspeed, 4., 2.); } //============================================================================ // // A_CHolyCheckScream // //============================================================================ void A_CHolyCheckScream() { A_CHolySeek(); if (random[HolyScream]() < 20) { A_StartSound ("SpiritActive", CHAN_VOICE); } if (!tracer) { CHolyFindTarget(); } } } // Holy Tail ---------------------------------------------------------------- class HolyTail : Actor { Default { Radius 1; Height 1; +NOBLOCKMAP +NOGRAVITY +DROPOFF +NOCLIP +NOTELEPORT RenderStyle "Translucent"; Alpha 0.6; } States { Spawn: SPIR C 1 A_CHolyTail; Loop; TailTrail: SPIR D -1; Stop; } //============================================================================ // // SpawnSpiritTail // //============================================================================ static void SpawnSpiritTail (Actor spirit) { Actor tail = Spawn ("HolyTail", spirit.Pos, ALLOW_REPLACE); if (tail != null) { tail.target = spirit; // parent for (int i = 1; i < 3; i++) { Actor next = Spawn ("HolyTailTrail", spirit.Pos, ALLOW_REPLACE); tail.tracer = next; tail = next; } tail.tracer = null; // last tail bit } } //============================================================================ // // CHolyTailFollow // //============================================================================ private void CHolyTailFollow(double dist) { Actor mo = self; while (mo) { Actor child = mo.tracer; if (child) { double an = mo.AngleTo(child); double oldDistance = child.Distance2D(mo); if (child.TryMove(mo.Pos.XY + AngleToVector(an, dist), true)) { double newDistance = child.Distance2D(mo) - 1; if (oldDistance < 1) { if (child.pos.z < mo.pos.z) { child.SetZ(mo.pos.z - dist); } else { child.SetZ(mo.pos.z + dist); } } else { child.SetZ(mo.pos.z + (newDistance * (child.pos.z - mo.pos.z) / oldDistance)); } } } mo = child; dist -= 1; } } //============================================================================ // // CHolyTailRemove // //============================================================================ private void CHolyTailRemove () { Actor mo = self; while (mo) { Actor next = mo.tracer; mo.Destroy (); mo = next; } } //============================================================================ // // A_CHolyTail // //============================================================================ void A_CHolyTail() { Actor parent = target; if (parent == null || parent.health <= 0) // better check for health than current state - it's safer! { // Ghost removed, so remove all tail parts CHolyTailRemove (); return; } else { if (TryMove(parent.Vec2Angle(14., parent.Angle, true), true)) { SetZ(parent.pos.z - 5.); } CHolyTailFollow(10); } } } // Holy Tail Trail --------------------------------------------------------- class HolyTailTrail : HolyTail { States { Spawn: Goto TailTrail; } } // The Cleric's Mace -------------------------------------------------------- class CWeapMace : ClericWeapon { Default { Weapon.SelectionOrder 3500; Weapon.KickBack 150; Weapon.YAdjust -8; +BLOODSPLATTER Obituary "$OB_MPCWEAPMACE"; Tag "$TAG_CWEAPMACE"; } States { Select: CMCE A 1 A_Raise; Loop; Deselect: CMCE A 1 A_Lower; Loop; Ready: CMCE A 1 A_WeaponReady; Loop; Fire: CMCE B 2 Offset (60, 20); CMCE B 1 Offset (30, 33); CMCE B 2 Offset (8, 45); CMCE C 1 Offset (8, 45); CMCE D 1 Offset (8, 45); CMCE E 1 Offset (8, 45); CMCE E 1 Offset (-11, 58) A_CMaceAttack; CMCE F 1 Offset (8, 45); CMCE F 2 Offset (-8, 74); CMCE F 1 Offset (-20, 96); CMCE F 8 Offset (-33, 160); CMCE A 2 Offset (8, 75) A_ReFire; CMCE A 1 Offset (8, 65); CMCE A 2 Offset (8, 60); CMCE A 1 Offset (8, 55); CMCE A 2 Offset (8, 50); CMCE A 1 Offset (8, 45); Goto Ready; } //=========================================================================== // // A_CMaceAttack // //=========================================================================== action void A_CMaceAttack() { FTranslatedLineTarget t; if (player == null) { return; } int damage = random[MaceAtk](25, 40); for (int i = 0; i < 16; i++) { for (int j = 1; j >= -1; j -= 2) { double ang = angle + j*i*(45. / 16); double slope = AimLineAttack(ang, 2 * DEFMELEERANGE, t, 0., ALF_CHECK3D); if (t.linetarget) { LineAttack(ang, 2 * DEFMELEERANGE, slope, damage, 'Melee', "HammerPuff", true, t); if (t.linetarget != null) { AdjustPlayerAngle(t); return; } } } } // didn't find any creatures, so try to strike any walls weaponspecial = 0; double slope = AimLineAttack (angle, DEFMELEERANGE, null, 0., ALF_CHECK3D); LineAttack (angle, DEFMELEERANGE, slope, damage, 'Melee', "HammerPuff"); } } // The cleric --------------------------------------------------------------- class ClericPlayer : PlayerPawn { Default { Health 100; ReactionTime 0; PainChance 255; Radius 16; Height 64; Speed 1; +NOSKIN +NODAMAGETHRUST +PLAYERPAWN.NOTHRUSTWHENINVUL PainSound "PlayerClericPain"; RadiusDamageFactor 0.25; Player.JumpZ 9; Player.Viewheight 48; Player.SpawnClass "Cleric"; Player.DisplayName "Cleric"; Player.SoundClass "cleric"; Player.ScoreIcon "CLERFACE"; Player.InvulnerabilityMode "Ghost"; Player.HealRadiusType "Health"; Player.Hexenarmor 10, 10, 25, 5, 20; Player.StartItem "CWeapMace"; Player.Portrait "P_CWALK1"; Player.WeaponSlot 1, "CWeapMace"; Player.WeaponSlot 2, "CWeapStaff"; Player.WeaponSlot 3, "CWeapFlame"; Player.WeaponSlot 4, "CWeapWraithverge"; Player.FlechetteType "ArtiPoisonBag1"; Player.ColorRange 146, 163; Player.Colorset 0, "$TXT_COLOR_BLUE", 146, 163, 161; Player.ColorsetFile 1, "$TXT_COLOR_RED", "TRANTBL7", 0xB3; Player.ColorsetFile 2, "$TXT_COLOR_GOLD", "TRANTBL8", 0x8C; Player.ColorsetFile 3, "$TXT_COLOR_DULLGREEN", "TRANTBL9", 0x41; Player.ColorsetFile 4, "$TXT_COLOR_GREEN", "TRANTBLA", 0xC9; Player.ColorsetFile 5, "$TXT_COLOR_GRAY", "TRANTBLB", 0x30; Player.ColorsetFile 6, "$TXT_COLOR_BROWN", "TRANTBLC", 0x72; Player.ColorsetFile 7, "$TXT_COLOR_PURPLE", "TRANTBLD", 0xEE; } States { Spawn: CLER A -1; Stop; See: CLER ABCD 4; Loop; Pain: CLER H 4; CLER H 4 A_Pain; Goto Spawn; Missile: Melee: CLER EFG 6; Goto Spawn; Death: CLER I 6; CLER J 6 A_PlayerScream; CLER KL 6; CLER M 6 A_NoBlocking; CLER NOP 6; CLER Q -1; Stop; XDeath: CLER R 5 A_PlayerScream; CLER S 5; CLER T 5 A_NoBlocking; CLER UVWXYZ 5; CLER [ -1; Stop; Ice: CLER \ 5 A_FreezeDeath; CLER \ 1 A_FreezeDeathChunks; Wait; Burn: FDTH C 5 BRIGHT A_StartSound("*burndeath"); FDTH D 4 BRIGHT; FDTH G 5 BRIGHT; FDTH H 4 BRIGHT A_PlayerScream; FDTH I 5 BRIGHT; FDTH J 4 BRIGHT; FDTH K 5 BRIGHT; FDTH L 4 BRIGHT; FDTH M 5 BRIGHT; FDTH N 4 BRIGHT; FDTH O 5 BRIGHT; FDTH P 4 BRIGHT; FDTH Q 5 BRIGHT; FDTH R 4 BRIGHT; FDTH S 5 BRIGHT A_NoBlocking; FDTH T 4 BRIGHT; FDTH U 5 BRIGHT; FDTH V 4 BRIGHT; ACLO E 35 A_CheckPlayerDone; Wait; ACLO E 8; Stop; } } // The Cleric's Serpent Staff ----------------------------------------------- class CWeapStaff : ClericWeapon { Default { Weapon.SelectionOrder 1600; Weapon.AmmoUse1 1; Weapon.AmmoGive1 25; Weapon.KickBack 150; Weapon.YAdjust 10; Weapon.AmmoType1 "Mana1"; Inventory.PickupMessage "$TXT_WEAPON_C2"; Obituary "$OB_MPCWEAPSTAFFM"; Tag "$TAG_CWEAPSTAFF"; } States { Spawn: WCSS A -1; Stop; Select: CSSF C 1 A_Raise; Loop; Deselect: CSSF B 3; CSSF C 4; CSSF C 1 A_Lower; Wait; Ready: CSSF C 4; CSSF B 3 A_CStaffInitBlink; CSSF AAAAAAA 1 A_WeaponReady; CSSF A 1 A_CStaffCheckBlink; Goto Ready + 2; Fire: CSSF A 1 Offset (0, 45) A_CStaffCheck; CSSF J 1 Offset (0, 50) A_CStaffAttack; CSSF J 2 Offset (0, 50); CSSF J 2 Offset (0, 45); CSSF A 2 Offset (0, 40); CSSF A 2 Offset (0, 36); Goto Ready + 2; Blink: CSSF BBBCCCCCBBB 1 A_WeaponReady; Goto Ready + 2; Drain: CSSF K 10 Offset (0, 36); Goto Ready + 2; } //============================================================================ // // A_CStaffCheck // //============================================================================ action void A_CStaffCheck() { FTranslatedLineTarget t; if (player == null) { return; } Weapon weapon = player.ReadyWeapon; int damage = random[StaffCheck](20, 35); int max = player.mo.GetMaxHealth(); for (int i = 0; i < 3; i++) { for (int j = 1; j >= -1; j -= 2) { double ang = angle + j*i*(45. / 16); double slope = AimLineAttack(ang, 1.5 * DEFMELEERANGE, t, 0., ALF_CHECK3D); if (t.linetarget) { LineAttack(ang, 1.5 * DEFMELEERANGE, slope, damage, 'Melee', "CStaffPuff", false, t); if (t.linetarget != null) { angle = t.angleFromSource; if (((t.linetarget.player && (!t.linetarget.IsTeammate(self) || level.teamdamage != 0)) || t.linetarget.bIsMonster) && (!t.linetarget.bDormant && !t.linetarget.bInvulnerable)) { int newLife = player.health + (damage >> 3); newLife = newLife > max ? max : newLife; if (newLife > player.health) { health = player.health = newLife; } if (weapon != null) { State newstate = weapon.FindState("Drain"); if (newstate != null) player.SetPsprite(PSP_WEAPON, newstate); } } if (weapon != null) { weapon.DepleteAmmo(weapon.bAltFire, false); } } return; } } } } //============================================================================ // // A_CStaffAttack // //============================================================================ action void A_CStaffAttack() { if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } Actor mo = SpawnPlayerMissile ("CStaffMissile", angle - 3.0); if (mo) { mo.WeaveIndexXY = 32; } mo = SpawnPlayerMissile ("CStaffMissile", angle + 3.0); if (mo) { mo.WeaveIndexXY = 0; } A_StartSound ("ClericCStaffFire", CHAN_WEAPON); } //============================================================================ // // A_CStaffInitBlink // //============================================================================ action void A_CStaffInitBlink() { weaponspecial = (random[CStaffBlink]() >> 1) + 20; } //============================================================================ // // A_CStaffCheckBlink // //============================================================================ action void A_CStaffCheckBlink() { if (player && player.ReadyWeapon) { if (!--weaponspecial) { player.SetPsprite(PSP_WEAPON, player.ReadyWeapon.FindState ("Blink")); weaponspecial = (random[CStaffBlink]() + 50) >> 2; } else { A_WeaponReady(); } } } } // Serpent Staff Missile ---------------------------------------------------- class CStaffMissile : Actor { Default { Speed 22; Radius 12; Height 10; Damage 5; RenderStyle "Add"; Projectile; DeathSound "ClericCStaffExplode"; Obituary "$OB_MPCWEAPSTAFFR"; } States { Spawn: CSSF DDEE 1 Bright A_CStaffMissileSlither; Loop; Death: CSSF FG 4 Bright; CSSF HI 3 Bright; Stop; } override int DoSpecialDamage (Actor target, int damage, Name damagetype) { // Cleric Serpent Staff does poison damage if (target.player) { target.player.PoisonPlayer (self, self.target, 20); damage >>= 1; } return damage; } } extend class Actor { //============================================================================ // // A_CStaffMissileSlither // //============================================================================ void A_CStaffMissileSlither() { A_Weave(3, 0, 1., 0.); } } // Serpent Staff Puff ------------------------------------------------------- class CStaffPuff : Actor { Default { +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS RenderStyle "Translucent"; Alpha 0.6; SeeSound "ClericCStaffHitThing"; } States { Spawn: FHFX STUVW 4; Stop; } } class Clink : Actor { Default { Health 150; Radius 20; Height 64; Mass 75; Speed 14; Painchance 32; Monster; +NOBLOOD +FLOORCLIP SeeSound "clink/sight"; AttackSound "clink/attack"; PainSound "clink/pain"; DeathSound "clink/death"; ActiveSound "clink/active"; Obituary "$OB_CLINK"; Tag "$FN_CLINK"; DropItem "SkullRodAmmo", 84, 20; } States { Spawn: CLNK AB 10 A_Look; Loop; See: CLNK ABCD 3 A_Chase; Loop; Melee: CLNK E 5 A_FaceTarget; CLNK F 4 A_FaceTarget; CLNK G 7 A_CustomMeleeAttack(random[ClinkAttack](3,9), "clink/attack", "clink/attack"); Goto See; Pain: CLNK H 3; CLNK H 3 A_Pain; Goto See; Death: CLNK IJ 6; CLNK K 5 A_Scream; CLNK L 5 A_NoBlocking; CLNK MN 5; CLNK O -1; Stop; } } // Coin --------------------------------------------------------------------- class Coin : Inventory { Default { +DROPPED +NOTDMATCH +FLOORCLIP Inventory.MaxAmount 0x7fffffff; +INVENTORY.INVBAR Tag "$TAG_COIN"; Inventory.Icon "I_COIN"; Inventory.PickupMessage "$TXT_COIN"; } States { Spawn: COIN A -1; Stop; } // Coin --------------------------------------------------------------------- override String PickupMessage () { if (Amount == 1) { return Super.PickupMessage(); } else { String msg = StringTable.Localize("$TXT_XGOLD"); msg.Replace("%d", "" .. Amount); return msg; } } override bool HandlePickup (Inventory item) { if (item is "Coin") { if (Amount < MaxAmount) { if (MaxAmount - Amount < item.Amount) { Amount = MaxAmount; } else { Amount += item.Amount; } item.bPickupGood = true; } return true; } return false; } override Inventory CreateCopy (Actor other) { if (GetClass() == "Coin") { return Super.CreateCopy (other); } Inventory copy = Inventory(Spawn("Coin")); copy.Amount = Amount; copy.BecomeItem (); GoAwayAndDie (); return copy; } //=========================================================================== // // ACoin :: CreateTossable // // Gold drops in increments of 50 if you have that much, less if you don't. // //=========================================================================== override Inventory CreateTossable (int amt) { Coin tossed; if (bUndroppable || Owner == NULL || Amount <= 0) { return NULL; } if (amt == -1) amt = Amount >= 50? 50 : Amount >= 25? 25 : Amount >= 10? 10 : 1; else if (amt > Amount) amt = Amount; if (amt > 25) { Amount -= amt; tossed = Coin(Spawn("Gold50")); tossed.Amount = amt; } else if (amt > 10) { Amount -= 25; tossed = Coin(Spawn("Gold25")); } else if (amt > 1) { Amount -= 10; tossed = Coin(Spawn("Gold10")); } else if (Amount > 1 || bKeepDepleted) { Amount -= 1; tossed = Coin(Spawn("Coin")); } else // Amount == 1 && !(ItemFlags & IF_KEEPDEPLETED) { BecomePickup (); tossed = self; } tossed.bSpecial = false; tossed.bSolid = false; tossed.DropTime = 30; if (tossed != self && Amount <= 0) { Destroy (); } return tossed; } } // 10 Gold ------------------------------------------------------------------ class Gold10 : Coin { Default { Inventory.Amount 10; Tag "$TAG_10GOLD"; Inventory.PickupMessage "$TXT_10GOLD"; } States { Spawn: CRED A -1; Stop; } } // 25 Gold ------------------------------------------------------------------ class Gold25 : Coin { Default { Inventory.Amount 25; Tag "$TAG_25GOLD"; Inventory.PickupMessage "$TXT_25GOLD"; } States { Spawn: SACK A -1; Stop; } } // 50 Gold ------------------------------------------------------------------ class Gold50 : Coin { Default { Inventory.Amount 50; Tag "$TAG_50GOLD"; Inventory.PickupMessage "$TXT_50GOLD"; } States { Spawn: CHST A -1; Stop; } } // 300 Gold ------------------------------------------------------------------ class Gold300 : Coin { Default { Inventory.Amount 300; Tag "$TAG_300GOLD"; Inventory.PickupMessage "$TXT_300GOLD"; Inventory.GiveQuest 3; +INVENTORY.ALWAYSPICKUP } States { Spawn: TOKN A -1; Stop; } } /* ** colorpickermenu.txt ** The color picker menu ** **--------------------------------------------------------------------------- ** Copyright 2010-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ //============================================================================= // // This is only used by the color picker // //============================================================================= class OptionMenuSliderVar : OptionMenuSliderBase { int mIndex; OptionMenuSliderVar Init(String label, int index, double min, double max, double step, int showval) { Super.Init(label, min, max, step, showval); mIndex = index; return self; } override double GetSliderValue() { return ColorpickerMenu(Menu.GetCurrentMenu()).GetColor(mIndex); } override void SetSliderValue(double val) { ColorpickerMenu(Menu.GetCurrentMenu()).setColor(mIndex, val); } } class ColorpickerMenu : OptionMenu { float mRed; float mGreen; float mBlue; int mGridPosX; int mGridPosY; int mStartItem; CVar mCVar; double GetColor(int index) { double v = index == 0? mRed : index == 1? mGreen : mBlue; return v; } void SetColor(int index, double val) { if (index == 0) mRed = val; else if (index == 1) mGreen = val; else mBlue = val; } //============================================================================= // // // //============================================================================= void Init(Menu parent, String name, OptionMenuDescriptor desc, CVar cv) { Super.Init(parent, desc); mStartItem = mDesc.mItems.Size(); mCVar = cv; ResetColor(); mGridPosX = 0; mGridPosY = 0; // This menu uses some features that are hard to implement in an external control lump // so it creates its own list of menu items. mDesc.mItems.Resize(mStartItem+8); mDesc.mItems[mStartItem+0] = new ("OptionMenuItemStaticText").Init(name, false); mDesc.mItems[mStartItem+1] = new ("OptionMenuItemStaticText").Init(" ", false); mDesc.mItems[mStartItem+2] = new ("OptionMenuSliderVar").Init("$TXT_COLOR_RED", 0, 0, 255, 15, 0); mDesc.mItems[mStartItem+3] = new ("OptionMenuSliderVar").Init("$TXT_COLOR_GREEN", 1, 0, 255, 15, 0); mDesc.mItems[mStartItem+4] = new ("OptionMenuSliderVar").Init("$TXT_COLOR_BLUE", 2, 0, 255, 15, 0); mDesc.mItems[mStartItem+5] = new ("OptionMenuItemStaticText").Init(" ", false); mDesc.mItems[mStartItem+6] = new ("OptionMenuItemCommand").Init("$TXT_UNDOCHANGES", "undocolorpic"); mDesc.mItems[mStartItem+7] = new ("OptionMenuItemStaticText").Init(" ", false); mDesc.mSelectedItem = mStartItem + 2; mDesc.mIndent = 0; mDesc.CalcIndent(); } //============================================================================= // // // //============================================================================= override bool MenuEvent (int mkey, bool fromcontroller) { switch (mkey) { case MKEY_Down: if (mDesc.mSelectedItem == mStartItem+6) // last valid item { MenuSound ("menu/cursor"); mGridPosY = 0; // let it point to the last static item so that the super class code still has a valid item mDesc.mSelectedItem = mStartItem+7; return true; } else if (mDesc.mSelectedItem == mStartItem+7) { if (mGridPosY < 15) { MenuSound ("menu/cursor"); mGridPosY++; } return true; } break; case MKEY_Up: if (mDesc.mSelectedItem == mStartItem+7) { if (mGridPosY > 0) { MenuSound ("menu/cursor"); mGridPosY--; } else { MenuSound ("menu/cursor"); mDesc.mSelectedItem = mStartItem+6; } return true; } break; case MKEY_Left: if (mDesc.mSelectedItem == mStartItem+7) { MenuSound ("menu/cursor"); if (--mGridPosX < 0) mGridPosX = 15; return true; } break; case MKEY_Right: if (mDesc.mSelectedItem == mStartItem+7) { MenuSound ("menu/cursor"); if (++mGridPosX > 15) mGridPosX = 0; return true; } break; case MKEY_Enter: if (mDesc.mSelectedItem == mStartItem+7) { // Choose selected palette entry int index = mGridPosX + mGridPosY * 16; color col = Screen.PaletteColor(index); mRed = col.r; mGreen = col.g; mBlue = col.b; MenuSound ("menu/choose"); return true; } break; } if (mDesc.mSelectedItem >= 0 && mDesc.mSelectedItem < mStartItem+7) { if (mDesc.mItems[mDesc.mSelectedItem].MenuEvent(mkey, fromcontroller)) return true; } return Super.MenuEvent(mkey, fromcontroller); } //============================================================================= // // // //============================================================================= override bool MouseEvent(int type, int mx, int my) { int olditem = mDesc.mSelectedItem; bool res = Super.MouseEvent(type, mx, my); if (mDesc.mSelectedItem == -1 || mDesc.mSelectedItem == mStartItem+7) { int y = (-mDesc.mPosition + BigFont.GetHeight() + mDesc.mItems.Size() * OptionMenuSettings.mLinespacing) * CleanYfac_1; int h = (screen.GetHeight() - y) / 16; int fh = OptionMenuSettings.mLinespacing * CleanYfac_1; int w = fh; int yy = y + 2 * CleanYfac_1; int indent = (screen.GetWidth() / 2); if (h > fh) h = fh; else if (h < 4) return res; // no space to draw it. int box_y = y - 2 * CleanYfac_1; int box_x = indent - 16*w; if (mx >= box_x && mx < box_x + 16*w && my >= box_y && my < box_y + 16*h) { int cell_x = (mx - box_x) / w; int cell_y = (my - box_y) / h; if (olditem != mStartItem+7 || cell_x != mGridPosX || cell_y != mGridPosY) { mGridPosX = cell_x; mGridPosY = cell_y; } mDesc.mSelectedItem = mStartItem+7; if (type == MOUSE_Release) { MenuEvent(MKEY_Enter, true); if (m_use_mouse == 2) mDesc.mSelectedItem = -1; } res = true; } } return res; } //============================================================================= // // // //============================================================================= override void Drawer() { Super.Drawer(); if (mCVar == null) return; int y = (-mDesc.mPosition + BigFont.GetHeight() + mDesc.mItems.Size() * OptionMenuSettings.mLinespacing) * CleanYfac_1; int fh = OptionMenuSettings.mLinespacing * CleanYfac_1; int h = (screen.GetHeight() - y) / 16; int w = fh; int yy = y; if (h > fh) h = fh; else if (h < 4) return; // no space to draw it. int indent = (screen.GetWidth() / 2); int p = 0; for(int i = 0; i < 16; i++) { int box_x, box_y; int x1; box_y = y - 2 * CleanYfac_1; box_x = indent - 16*w; for (x1 = 0; x1 < 16; ++x1) { screen.Clear (box_x, box_y, box_x + w, box_y + h, 0, p); if ((mDesc.mSelectedItem == mStartItem+7) && (/*p == CurrColorIndex ||*/ (i == mGridPosY && x1 == mGridPosX))) { int r, g, b; Color col; double blinky; if (i == mGridPosY && x1 == mGridPosX) { r = 255; g = 128; b = 0; } else { r = 200; g = 200; b = 255; } // Make sure the cursors stand out against similar colors // by pulsing them. blinky = abs(sin(MSTimeF()/1000.0)) * 0.5 + 0.5; col = Color(255, int(r*blinky), int(g*blinky), int(b*blinky)); screen.Clear (box_x, box_y, box_x + w, box_y + 1, col); screen.Clear (box_x, box_y + h-1, box_x + w, box_y + h, col); screen.Clear (box_x, box_y, box_x + 1, box_y + h, col); screen.Clear (box_x + w - 1, box_y, box_x + w, box_y + h, col); } box_x += w; p++; } y += h; } y = yy; color newColor = Color(255, int(mRed), int(mGreen), int(mBlue)); color oldColor = mCVar.GetInt() | 0xFF000000; int x = screen.GetWidth()*2/3; screen.Clear (x, y, x + 48*CleanXfac_1, y + 48*CleanYfac_1, oldColor); screen.Clear (x + 48*CleanXfac_1, y, x + 48*2*CleanXfac_1, y + 48*CleanYfac_1, newColor); y += 49*CleanYfac_1; screen.DrawText (SmallFont, Font.CR_GRAY, x+(48-SmallFont.StringWidth("---->")/2)*CleanXfac_1, y, "---->", DTA_CleanNoMove_1, true); } override void OnDestroy() { if (mStartItem >= 0) { mDesc.mItems.Resize(mStartItem); if (mCVar != null) { mCVar.SetInt(Color(int(mRed), int(mGreen), int(mBlue))); } mStartItem = -1; } } override void ResetColor() { if (mCVar != null) { Color clr = Color(mCVar.GetInt()); mRed = clr.r; mGreen = clr.g; mBlue = clr.b; } } } // This file contains compatibility wrappers for DECORATE functions with bad parameters or other things that were refactored since the first release. extend class Object { deprecated("2.4", "Use gameinfo.gametype instead") static int GameType() { return gameinfo.gametype; } deprecated("2.4", "Use Console.MidPrint() instead") static void C_MidPrint(string fontname, string textlabel, bool bold = false) { let f = Font.GetFont(fontname); if (f == null) return; Console.MidPrint(f, textlabel, bold); } } extend class Actor { //========================================================================== // // CheckClass // // NON-ACTION function to check a pointer's class. // deprecated because functionality is directly accessible. // //========================================================================== deprecated("3.7", "Use GetClass(), type cast, or 'is' operator instead") bool CheckClass(class checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false) { let check = GetPointer(ptr_select); if (check == null || checkclass == null) { return false; } else if (match_superclass) { return check is checkclass; } else { return check.GetClass() == checkclass; } } //========================================================================== // // GetDistance // // NON-ACTION function to get the distance in double. // deprecated because it requires AAPTR to work. // //========================================================================== deprecated("3.7", "Use Actor.Distance2D() or Actor.Distance3D() instead") double GetDistance(bool checkz, int ptr = AAPTR_TARGET) const { let target = GetPointer(ptr); if (!target || target == self) { return 0; } else { let diff = Vec3To(target); if (checkz) diff.Z += (target.Height - self.Height) / 2; else diff.Z = 0.; return diff.Length(); } } //========================================================================== // // GetAngle // // NON-ACTION function to get the angle in degrees (normalized to -180..180) // deprecated because it requires AAPTR to work. // //========================================================================== deprecated("3.7", "Use Actor.AngleTo() instead") double GetAngle(int flags, int ptr = AAPTR_TARGET) { let target = GetPointer(ptr); if (!target || target == self) { return 0; } else { let angto = (flags & GAF_SWITCH) ? target.AngleTo(self) : self.AngleTo(target); let yaw = (flags & GAF_SWITCH) ? target.Angle : self.Angle; if (flags & GAF_RELATIVE) angto = deltaangle(yaw, angto); return angto; } } //========================================================================== // // GetSpriteAngle // // NON-ACTION function returns the sprite angle of a pointer. // deprecated because direct access to the data is now possible. // //========================================================================== deprecated("3.7", "Use Actor.SpriteAngle instead") double GetSpriteAngle(int ptr = AAPTR_DEFAULT) { let target = GetPointer(ptr); return target? target.SpriteAngle : 0; } //========================================================================== // // GetSpriteRotation // // NON-ACTION function returns the sprite rotation of a pointer. // deprecated because direct access to the data is now possible. // //========================================================================== deprecated("3.7", "Use Actor.SpriteRotation instead") double GetSpriteRotation(int ptr = AAPTR_DEFAULT) { let target = GetPointer(ptr); return target? target.SpriteRotation : 0; } deprecated("2.3", "Use A_SpawnProjectile() instead") void A_CustomMissile(class missiletype, double spawnheight = 32, double spawnofs_xy = 0, double angle = 0, int flags = 0, double pitch = 0, int ptr = AAPTR_TARGET) { A_SpawnProjectile(missiletype, spawnheight, spawnofs_xy, angle, flags|CMF_BADPITCH, pitch, ptr); } } extend class StateProvider { deprecated("2.3", "Use A_FireProjectile() instead") action void A_FireCustomMissile(class missiletype, double angle = 0, bool useammo = true, double spawnofs_xy = 0, double spawnheight = 0, int flags = 0, double pitch = 0) { A_FireProjectile(missiletype, angle, useammo, spawnofs_xy, spawnheight, flags, -pitch); } } // for flag changer functions. const FLAG_NO_CHANGE = -1; const MAXPLAYERS = 8; enum EStateUseFlags { SUF_ACTOR = 1, SUF_OVERLAY = 2, SUF_WEAPON = 4, SUF_ITEM = 8, }; // Flags for A_PainAttack enum EPainAttackFlags { PAF_NOSKULLATTACK = 1, PAF_AIMFACING = 2, PAF_NOTARGET = 4, }; // Flags for A_VileAttack enum EVileAttackFlags { VAF_DMGTYPEAPPLYTODIRECT = 1, }; // Flags for A_Saw enum ESawFlags { SF_NORANDOM = 1, SF_RANDOMLIGHTMISS = 2, SF_RANDOMLIGHTHIT = 4, SF_RANDOMLIGHTBOTH = 6, SF_NOUSEAMMOMISS = 8, SF_NOUSEAMMO = 16, SF_NOPULLIN = 32, SF_NOTURN = 64, SF_STEALARMOR = 128, SF_NORANDOMPUFFZ = 256, }; // Flags for A_BFGSpray enum EBFGSprayFlags { BFGF_HURTSOURCE = 1, BFGF_MISSILEORIGIN = 2, }; // Flags for A_SpawnProjectile enum ECustomMissileFlags { CMF_AIMOFFSET = 1, CMF_AIMDIRECTION = 2, CMF_TRACKOWNER = 4, CMF_CHECKTARGETDEAD = 8, CMF_ABSOLUTEPITCH = 16, CMF_OFFSETPITCH = 32, CMF_SAVEPITCH = 64, CMF_ABSOLUTEANGLE = 128, CMF_BADPITCH = 256, // for compatibility handling only - avoid! }; // Flags for A_CustomBulletAttack enum ECustomBulletAttackFlags { CBAF_AIMFACING = 1, CBAF_NORANDOM = 2, CBAF_EXPLICITANGLE = 4, CBAF_NOPITCH = 8, CBAF_NORANDOMPUFFZ = 16, CBAF_PUFFTARGET = 32, CBAF_PUFFMASTER = 64, CBAF_PUFFTRACER = 128, }; // Flags for A_GunFlash enum EGunFlashFlags { GFF_NOEXTCHANGE = 1, }; // Flags for A_FireBullets enum EFireBulletsFlags { FBF_USEAMMO = 1, FBF_NORANDOM = 2, FBF_EXPLICITANGLE = 4, FBF_NOPITCH = 8, FBF_NOFLASH = 16, FBF_NORANDOMPUFFZ = 32, FBF_PUFFTARGET = 64, FBF_PUFFMASTER = 128, FBF_PUFFTRACER = 256, }; // Flags for A_SpawnItemEx enum ESpawnItemFlags { SXF_TRANSFERTRANSLATION = 1 << 0, SXF_ABSOLUTEPOSITION = 1 << 1, SXF_ABSOLUTEANGLE = 1 << 2, SXF_ABSOLUTEMOMENTUM = 1 << 3, //Since "momentum" is declared to be deprecated in the expressions, for compatibility SXF_ABSOLUTEVELOCITY = 1 << 3, //purposes, this was made. It does the same thing though. Do not change the value. SXF_SETMASTER = 1 << 4, SXF_NOCHECKPOSITION = 1 << 5, SXF_TELEFRAG = 1 << 6, SXF_CLIENTSIDE = 1 << 7, // only used by Skulltag SXF_TRANSFERAMBUSHFLAG = 1 << 8, SXF_TRANSFERPITCH = 1 << 9, SXF_TRANSFERPOINTERS = 1 << 10, SXF_USEBLOODCOLOR = 1 << 11, SXF_CLEARCALLERTID = 1 << 12, SXF_MULTIPLYSPEED = 1 << 13, SXF_TRANSFERSCALE = 1 << 14, SXF_TRANSFERSPECIAL = 1 << 15, SXF_CLEARCALLERSPECIAL = 1 << 16, SXF_TRANSFERSTENCILCOL = 1 << 17, SXF_TRANSFERALPHA = 1 << 18, SXF_TRANSFERRENDERSTYLE = 1 << 19, SXF_SETTARGET = 1 << 20, SXF_SETTRACER = 1 << 21, SXF_NOPOINTERS = 1 << 22, SXF_ORIGINATOR = 1 << 23, SXF_TRANSFERSPRITEFRAME = 1 << 24, SXF_TRANSFERROLL = 1 << 25, SXF_ISTARGET = 1 << 26, SXF_ISMASTER = 1 << 27, SXF_ISTRACER = 1 << 28, }; // Flags for A_Chase enum EChaseFlags { CHF_FASTCHASE = 1, CHF_NOPLAYACTIVE = 2, CHF_NIGHTMAREFAST = 4, CHF_RESURRECT = 8, CHF_DONTMOVE = 16, CHF_NORANDOMTURN = 32, CHF_NODIRECTIONTURN = 64, CHF_NOPOSTATTACKTURN = 128, CHF_STOPIFBLOCKED = 256, CHF_DONTIDLE = 512, CHF_DONTLOOKALLAROUND = 1024, CHF_DONTTURN = CHF_NORANDOMTURN | CHF_NOPOSTATTACKTURN | CHF_STOPIFBLOCKED }; // Flags for A_LookEx enum ELookFlags { LOF_NOSIGHTCHECK = 1, LOF_NOSOUNDCHECK = 2, LOF_DONTCHASEGOAL = 4, LOF_NOSEESOUND = 8, LOF_FULLVOLSEESOUND = 16, LOF_NOJUMP = 32, }; // Flags for A_Respawn enum ERespawnFlags { RSF_FOG = 1, RSF_KEEPTARGET = 2, RSF_TELEFRAG = 4, }; // Flags for A_JumpIfTargetInLOS and A_JumpIfInTargetLOS enum EJumpFlags { JLOSF_PROJECTILE = 1, JLOSF_NOSIGHT = 1 << 1, JLOSF_CLOSENOFOV = 1 << 2, JLOSF_CLOSENOSIGHT = 1 << 3, JLOSF_CLOSENOJUMP = 1 << 4, JLOSF_DEADNOJUMP = 1 << 5, JLOSF_CHECKMASTER = 1 << 6, JLOSF_TARGETLOS = 1 << 7, JLOSF_FLIPFOV = 1 << 8, JLOSF_ALLYNOJUMP = 1 << 9, JLOSF_COMBATANTONLY = 1 << 10, JLOSF_NOAUTOAIM = 1 << 11, JLOSF_CHECKTRACER = 1 << 12, }; // Flags for A_ChangeVelocity enum EChangeVelocityFlags { CVF_RELATIVE = 1, CVF_REPLACE = 2, }; // Flags for A_WeaponReady enum EWeaponReadyFlags { WRF_NOBOB = 1, WRF_NOSWITCH = 2, WRF_NOPRIMARY = 4, WRF_NOSECONDARY = 8, WRF_NOFIRE = WRF_NOPRIMARY | WRF_NOSECONDARY, WRF_ALLOWRELOAD = 16, WRF_ALLOWZOOM = 32, WRF_DISABLESWITCH = 64, WRF_ALLOWUSER1 = 128, WRF_ALLOWUSER2 = 256, WRF_ALLOWUSER3 = 512, WRF_ALLOWUSER4 = 1024, }; // Flags for A_SelectWeapon enum ESelectWeaponFlags { SWF_SELECTPRIORITY = 1, }; // Morph constants enum EMorphFlags { MRF_OLDEFFECTS = 0x00000000, MRF_ADDSTAMINA = 0x00000001, MRF_FULLHEALTH = 0x00000002, MRF_UNDOBYTOMEOFPOWER = 0x00000004, MRF_UNDOBYCHAOSDEVICE = 0x00000008, MRF_FAILNOTELEFRAG = 0x00000010, MRF_FAILNOLAUGH = 0x00000020, MRF_WHENINVULNERABLE = 0x00000040, MRF_LOSEACTUALWEAPON = 0x00000080, MRF_NEWTIDBEHAVIOUR = 0x00000100, MRF_UNDOBYDEATH = 0x00000200, MRF_UNDOBYDEATHFORCED = 0x00000400, MRF_UNDOBYDEATHSAVES = 0x00000800, MRF_UNDOBYTIMEOUT = 0x00001000, MRF_UNDOALWAYS = 0x00002000, MRF_TRANSFERTRANSLATION = 0x00004000, MRF_STANDARDUNDOING = MRF_UNDOBYTOMEOFPOWER | MRF_UNDOBYCHAOSDEVICE | MRF_UNDOBYTIMEOUT, }; // Flags for A_RailAttack and A_CustomRailgun enum ERailFlags { RGF_SILENT = 1, RGF_NOPIERCING = 2, RGF_EXPLICITANGLE = 4, RGF_FULLBRIGHT = 8, RGF_CENTERZ = 16, RGF_NORANDOMPUFFZ = 32, }; // Flags for A_Mushroom enum EMushroomFlags { MSF_Standard = 0, MSF_Classic = 1, MSF_DontHurt = 2, }; // Flags for A_Explode enum EExplodeFlags { XF_HURTSOURCE = 1, XF_NOTMISSILE = 4, XF_EXPLICITDAMAGETYPE = 8, XF_NOSPLASH = 16, XF_THRUSTZ = 32, XF_THRUSTLESS = 64, XF_NOALLIES = 128, XF_CIRCULAR = 256, }; // Flags for A_RadiusThrust enum ERadiusThrustFlags { RTF_AFFECTSOURCE = 1, RTF_NOIMPACTDAMAGE = 2, RTF_NOTMISSILE = 4, RTF_THRUSTZ = 16, }; // Flags for A_RadiusDamageSelf enum ERadiusDamageSelfFlags { RDSF_BFGDAMAGE = 1, }; // Flags for A_Blast enum EBlastFlags { BF_USEAMMO = 1, BF_DONTWARN = 2, BF_AFFECTBOSSES = 4, BF_NOIMPACTDAMAGE = 8, BF_ONLYVISIBLETHINGS = 16, }; // Flags for A_SeekerMissile enum ESeekerMissileFlags { SMF_LOOK = 1, SMF_PRECISE = 2, SMF_CURSPEED = 4, }; // Flags for A_CustomPunch enum ECustomPunchFlags { CPF_USEAMMO = 1, CPF_DAGGER = 2, CPF_PULLIN = 4, CPF_NORANDOMPUFFZ = 8, CPF_NOTURN = 16, CPF_STEALARMOR = 32, }; enum EFireCustomMissileFlags { FPF_AIMATANGLE = 1, FPF_TRANSFERTRANSLATION = 2, FPF_NOAUTOAIM = 4, }; // Flags for A_Teleport enum ETeleportFlags { TF_TELEFRAG = 0x00000001, // Allow telefrag in order to teleport. TF_RANDOMDECIDE = 0x00000002, // Randomly fail based on health. (A_Srcr2Decide) TF_FORCED = 0x00000004, // Forget what's in the way. TF_Telefrag takes precedence though. TF_KEEPVELOCITY = 0x00000008, // Preserve velocity. TF_KEEPANGLE = 0x00000010, // Keep angle. TF_USESPOTZ = 0x00000020, // Set the z to the spot's z, instead of the floor. TF_NOSRCFOG = 0x00000040, // Don't leave any fog behind when teleporting. TF_NODESTFOG = 0x00000080, // Don't spawn any fog at the arrival position. TF_USEACTORFOG = 0x00000100, // Use the actor's TeleFogSourceType and TeleFogDestType fogs. TF_NOJUMP = 0x00000200, // Don't jump after teleporting. TF_OVERRIDE = 0x00000400, // Ignore NOTELEPORT. TF_SENSITIVEZ = 0x00000800, // Fail if the actor wouldn't fit in the position (for Z). TF_KEEPORIENTATION = TF_KEEPVELOCITY|TF_KEEPANGLE, TF_NOFOG = TF_NOSRCFOG|TF_NODESTFOG, }; // Flags for A_WolfAttack enum EWolfAttackFlags { WAF_NORANDOM = 1, WAF_USEPUFF = 2 }; // Flags for A_RadiusGive enum ERadiusGiveFlags { RGF_GIVESELF = 1, RGF_PLAYERS = 1 << 1, RGF_MONSTERS = 1 << 2, RGF_OBJECTS = 1 << 3, RGF_VOODOO = 1 << 4, RGF_CORPSES = 1 << 5, RGF_NOTARGET = 1 << 6, RGF_NOTRACER = 1 << 7, RGF_NOMASTER = 1 << 8, RGF_CUBE = 1 << 9, RGF_NOSIGHT = 1 << 10, RGF_MISSILES = 1 << 11, RGF_INCLUSIVE = 1 << 12, RGF_ITEMS = 1 << 13, RGF_KILLED = 1 << 14, RGF_EXFILTER = 1 << 15, RGF_EXSPECIES = 1 << 16, RGF_EITHER = 1 << 17, }; // Change model flags enum ChangeModelFlags { CMDL_WEAPONTOPLAYER = 1, CMDL_HIDEMODEL = 1 << 1, CMDL_USESURFACESKIN = 1 << 2, }; // Activation flags enum EActivationFlags { THINGSPEC_Default = 0, THINGSPEC_ThingActs = 1, THINGSPEC_ThingTargets = 2, THINGSPEC_TriggerTargets = 4, THINGSPEC_MonsterTrigger = 8, THINGSPEC_MissileTrigger = 16, THINGSPEC_ClearSpecial = 32, THINGSPEC_NoDeathSpecial = 64, THINGSPEC_TriggerActs = 128, THINGSPEC_Activate = 1<<8, // The thing is activated when triggered THINGSPEC_Deactivate = 1<<9, // The thing is deactivated when triggered THINGSPEC_Switch = 1<<10, // The thing is alternatively activated and deactivated when triggered // Shorter aliases for same AF_Default = 0, AF_ThingActs = 1, AF_ThingTargets = 2, AF_TriggerTargets = 4, AF_MonsterTrigger = 8, AF_MissileTrigger = 16, AF_ClearSpecial = 32, AF_NoDeathSpecial = 64, AF_TriggerActs = 128, AF_Activate = 1<<8, // The thing is activated when triggered AF_Deactivate = 1<<9, // The thing is deactivated when triggered AF_Switch = 1<<10, // The thing is alternatively activated and deactivated when triggered }; // [MC] Flags for SetViewPos. enum EViewPosFlags { VPSF_ABSOLUTEOFFSET = 1 << 1, // Don't include angles. VPSF_ABSOLUTEPOS = 1 << 2, // Use absolute position. }; // Flags for A_TakeInventory and A_TakeFromTarget enum ETakeFlags { TIF_NOTAKEINFINITE = 1 }; // For SetPlayerProperty action special enum EPlayerProperties { PROP_FROZEN = 0, PROP_NOTARGET = 1, PROP_INSTANTWEAPONSWITCH = 2, PROP_FLY = 3, PROP_TOTALLYFROZEN = 4, PROP_INVULNERABILITY = 5, // (Deprecated) PROP_STRENGTH = 6, // (Deprecated) PROP_INVISIBILITY = 7, // (Deprecated) PROP_RADIATIONSUIT = 8, // (Deprecated) PROP_ALLMAP = 9, // (Deprecated) PROP_INFRARED = 10, // (Deprecated) PROP_WEAPONLEVEL2 = 11, // (Deprecated) PROP_FLIGHT = 12, // (Deprecated) PROP_SPEED = 15, // (Deprecated) PROP_BUDDHA = 16, PROP_BUDDHA2 = 17, PROP_FRIGHTENING = 18, PROP_NOCLIP = 19, PROP_NOCLIP2 = 20, PROP_GODMODE = 21, PROP_GODMODE2 = 22, } // Line_SetBlocking enum EBlockFlags { BLOCKF_CREATURES = 1, BLOCKF_MONSTERS = 2, BLOCKF_PLAYERS = 4, BLOCKF_FLOATERS = 8, BLOCKF_PROJECTILES = 16, BLOCKF_EVERYTHING = 32, BLOCKF_RAILING = 64, BLOCKF_USE = 128, BLOCKF_SIGHT = 256, BLOCKF_HITSCAN = 512, BLOCKF_SOUND = 1024, BLOCKF_LANDMONSTERS = 2048, }; // Pointer constants, bitfield-enabled enum EPointerFlags { AAPTR_DEFAULT = 0, AAPTR_NULL = 0x1, AAPTR_TARGET = 0x2, AAPTR_MASTER = 0x4, AAPTR_TRACER = 0x8, AAPTR_PLAYER_GETTARGET = 0x10, AAPTR_PLAYER_GETCONVERSATION = 0x20, AAPTR_PLAYER1 = 0x40, AAPTR_PLAYER2 = 0x80, AAPTR_PLAYER3 = 0x100, AAPTR_PLAYER4 = 0x200, AAPTR_PLAYER5 = 0x400, AAPTR_PLAYER6 = 0x800, AAPTR_PLAYER7 = 0x1000, AAPTR_PLAYER8 = 0x2000, AAPTR_FRIENDPLAYER = 0x4000, AAPTR_LINETARGET = 0x8000, }; // Pointer operation flags enum EPointerOperations { PTROP_UNSAFETARGET = 1, PTROP_UNSAFEMASTER = 2, PTROP_NOSAFEGUARDS = PTROP_UNSAFETARGET|PTROP_UNSAFEMASTER, }; // Flags for A_Warp enum EWarpFlags { WARPF_ABSOLUTEOFFSET = 0x1, WARPF_ABSOLUTEANGLE = 0x2, WARPF_USECALLERANGLE = 0x4, WARPF_NOCHECKPOSITION = 0x8, WARPF_INTERPOLATE = 0x10, WARPF_WARPINTERPOLATION = 0x20, WARPF_COPYINTERPOLATION = 0x40, WARPF_STOP = 0x80, WARPF_TOFLOOR = 0x100, WARPF_TESTONLY = 0x200, WAPRF_ABSOLUTEPOSITION = 0x400, WARPF_ABSOLUTEPOSITION = 0x400, WARPF_BOB = 0x800, WARPF_MOVEPTR = 0x1000, WARPF_USETID = 0x2000, WARPF_COPYVELOCITY = 0x4000, WARPF_COPYPITCH = 0x8000, }; // Flags for Actor.CheckMove() enum ECheckMoveFlags { PCM_DROPOFF = 1, PCM_NOACTORS = 1 << 1, PCM_NOLINES = 1 << 2, }; // flags for A_SetPitch/SetAngle/SetRoll enum EAngleFlags { SPF_FORCECLAMP = 1, SPF_INTERPOLATE = 2, SPF_SCALEDNOLERP = 4, }; // flags for A_CheckLOF enum ELOFFlags { CLOFF_NOAIM_VERT = 0x1, CLOFF_NOAIM_HORZ = 0x2, CLOFF_JUMPENEMY = 0x4, CLOFF_JUMPFRIEND = 0x8, CLOFF_JUMPOBJECT = 0x10, CLOFF_JUMPNONHOSTILE = 0x20, CLOFF_SKIPENEMY = 0x40, CLOFF_SKIPFRIEND = 0x80, CLOFF_SKIPOBJECT = 0x100, CLOFF_SKIPNONHOSTILE = 0x200, CLOFF_MUSTBESHOOTABLE = 0x400, CLOFF_SKIPTARGET = 0x800, CLOFF_ALLOWNULL = 0x1000, CLOFF_CHECKPARTIAL = 0x2000, CLOFF_MUSTBEGHOST = 0x4000, CLOFF_IGNOREGHOST = 0x8000, CLOFF_MUSTBESOLID = 0x10000, CLOFF_BEYONDTARGET = 0x20000, CLOFF_FROMBASE = 0x40000, CLOFF_MUL_HEIGHT = 0x80000, CLOFF_MUL_WIDTH = 0x100000, CLOFF_JUMP_ON_MISS = 0x200000, CLOFF_AIM_VERT_NOOFFSET = 0x400000, CLOFF_SETTARGET = 0x800000, CLOFF_SETMASTER = 0x1000000, CLOFF_SETTRACER = 0x2000000, CLOFF_SKIPOBSTACLES = CLOFF_SKIPENEMY|CLOFF_SKIPFRIEND|CLOFF_SKIPOBJECT|CLOFF_SKIPNONHOSTILE, CLOFF_NOAIM = CLOFF_NOAIM_VERT|CLOFF_NOAIM_HORZ }; // Flags for A_Kill (Master/Target/Tracer/Children/Siblings) series enum EKillFlags { KILS_FOILINVUL = 0x00000001, KILS_KILLMISSILES = 0x00000002, KILS_NOMONSTERS = 0x00000004, KILS_FOILBUDDHA = 0x00000008, KILS_EXFILTER = 0x00000010, KILS_EXSPECIES = 0x00000020, KILS_EITHER = 0x00000040, }; // Flags for A_Damage (Master/Target/Tracer/Children/Siblings/Self) series enum EDamageFlags { DMSS_FOILINVUL = 0x00000001, DMSS_AFFECTARMOR = 0x00000002, DMSS_KILL = 0x00000004, DMSS_NOFACTOR = 0x00000008, DMSS_FOILBUDDHA = 0x00000010, DMSS_NOPROTECT = 0x00000020, DMSS_EXFILTER = 0x00000040, DMSS_EXSPECIES = 0x00000080, DMSS_EITHER = 0x00000100, DMSS_INFLICTORDMGTYPE = 0x00000200, }; // Flags for A_AlertMonsters enum EAlertFlags { AMF_TARGETEMITTER = 1, AMF_TARGETNONPLAYER = 2, AMF_EMITFROMTARGET = 4, } // Flags for A_Remove* enum ERemoveFlags { RMVF_MISSILES = 0x00000001, RMVF_NOMONSTERS = 0x00000002, RMVF_MISC = 0x00000004, RMVF_EVERYTHING = 0x00000008, RMVF_EXFILTER = 0x00000010, RMVF_EXSPECIES = 0x00000020, RMVF_EITHER = 0x00000040, }; // Flags for A_Fade* enum EFadeFlags { FTF_REMOVE = 1 << 0, FTF_CLAMP = 1 << 1, }; // Flags for A_Face* enum EFaceFlags { FAF_BOTTOM = 1, FAF_MIDDLE = 2, FAF_TOP = 4, FAF_NODISTFACTOR = 8, }; // Flags for A_QuakeEx enum EQuakeFlags { QF_RELATIVE = 1, QF_SCALEDOWN = 1 << 1, QF_SCALEUP = 1 << 2, QF_MAX = 1 << 3, QF_FULLINTENSITY = 1 << 4, QF_WAVE = 1 << 5, QF_3D = 1 << 6, QF_GROUNDONLY = 1 << 7, QF_AFFECTACTORS = 1 << 8, QF_SHAKEONLY = 1 << 9, QF_DAMAGEFALLOFF = 1 << 10, }; // A_CheckProximity flags enum EProximityFlags { CPXF_ANCESTOR = 1, CPXF_LESSOREQUAL = 1 << 1, CPXF_NOZ = 1 << 2, CPXF_COUNTDEAD = 1 << 3, CPXF_DEADONLY = 1 << 4, CPXF_EXACT = 1 << 5, CPXF_SETTARGET = 1 << 6, CPXF_SETMASTER = 1 << 7, CPXF_SETTRACER = 1 << 8, CPXF_FARTHEST = 1 << 9, CPXF_CLOSEST = 1 << 10, CPXF_SETONPTR = 1 << 11, CPXF_CHECKSIGHT = 1 << 12, }; // Flags for A_CheckBlock // These flags only affect the calling actor('s pointer), not the ones being searched. enum ECheckBlockFlags { CBF_NOLINES = 1 << 0, //Don't check actors. CBF_SETTARGET = 1 << 1, //Sets the caller/pointer's target to the actor blocking it. Actors only. CBF_SETMASTER = 1 << 2, //^ but with master. CBF_SETTRACER = 1 << 3, //^ but with tracer. CBF_SETONPTR = 1 << 4, //Sets the pointer change on the actor doing the checking instead of self. CBF_DROPOFF = 1 << 5, //Check for dropoffs. CBF_NOACTORS = 1 << 6, //Don't check actors. CBF_ABSOLUTEPOS = 1 << 7, //Absolute position for offsets. CBF_ABSOLUTEANGLE = 1 << 8, //Absolute angle for offsets. }; enum EParticleFlags { SPF_FULLBRIGHT = 1, SPF_RELPOS = 1 << 1, SPF_RELVEL = 1 << 2, SPF_RELACCEL = 1 << 3, SPF_RELANG = 1 << 4, SPF_NOTIMEFREEZE = 1 << 5, SPF_ROLL = 1 << 6, SPF_REPLACE = 1 << 7, SPF_NO_XY_BILLBOARD = 1 << 8, SPF_RELATIVE = SPF_RELPOS|SPF_RELVEL|SPF_RELACCEL|SPF_RELANG }; //Flags for A_FaceMovementDirection enum EMovementFlags { FMDF_NOPITCH = 1 << 0, FMDF_INTERPOLATE = 1 << 1, FMDF_NOANGLE = 1 << 2, }; // Flags for GetZAt enum EZFlags { GZF_ABSOLUTEPOS = 1, // Use the absolute position instead of an offsetted one. GZF_ABSOLUTEANG = 1 << 1, // Don't add the actor's angle to the parameter. GZF_CEILING = 1 << 2, // Check the ceiling instead of the floor. GZF_3DRESTRICT = 1 << 3, // Ignore midtextures and 3D floors above the pointer's z. GZF_NOPORTALS = 1 << 4, // Don't pass through any portals. GZF_NO3DFLOOR = 1 << 5, // Pass all 3D floors. }; // Flags for A_WeaponOffset enum EWeaponOffsetFlags { WOF_KEEPX = 1, WOF_KEEPY = 1 << 1, WOF_ADD = 1 << 2, WOF_INTERPOLATE = 1 << 3, WOF_RELATIVE = 1 << 4, WOF_ZEROY = 1 << 5, }; // Flags for psprite layers enum EPSpriteFlags { PSPF_ADDWEAPON = 1 << 0, PSPF_ADDBOB = 1 << 1, PSPF_POWDOUBLE = 1 << 2, PSPF_CVARFAST = 1 << 3, PSPF_ALPHA = 1 << 4, PSPF_RENDERSTYLE = 1 << 5, PSPF_FLIP = 1 << 6, PSPF_FORCEALPHA = 1 << 7, PSPF_FORCESTYLE = 1 << 8, PSPF_MIRROR = 1 << 9, PSPF_PLAYERTRANSLATED = 1 << 10, PSPF_PIVOTPERCENT = 1 << 11, PSPF_INTERPOLATE = 1 << 12, }; // Alignment constants for A_OverlayPivotAlign enum EPSpriteAlign { PSPA_TOP = 0, PSPA_CENTER, PSPA_BOTTOM, PSPA_LEFT = PSPA_TOP, PSPA_RIGHT = 2 }; // Default psprite layers enum EPSPLayers { PSP_STRIFEHANDS = -1, PSP_WEAPON = 1, PSP_FLASH = 1000, PSP_TARGETCENTER = int.max - 2, PSP_TARGETLEFT, PSP_TARGETRIGHT }; enum EInputFlags { // These are the original inputs sent by the player. INPUT_OLDBUTTONS, INPUT_BUTTONS, INPUT_PITCH, INPUT_YAW, INPUT_ROLL, INPUT_FORWARDMOVE, INPUT_SIDEMOVE, INPUT_UPMOVE, // These are the inputs, as modified by P_PlayerThink(). // Most of the time, these will match the original inputs, but // they can be different if a player is frozen or using a // chainsaw. MODINPUT_OLDBUTTONS, MODINPUT_BUTTONS, MODINPUT_PITCH, MODINPUT_YAW, MODINPUT_ROLL, MODINPUT_FORWARDMOVE, MODINPUT_SIDEMOVE, MODINPUT_UPMOVE }; enum EButtons { BT_ATTACK = 1<<0, // Press "Fire". BT_USE = 1<<1, // Use button, to open doors, activate switches. BT_JUMP = 1<<2, BT_CROUCH = 1<<3, BT_TURN180 = 1<<4, BT_ALTATTACK = 1<<5, // Press your other "Fire". BT_RELOAD = 1<<6, // [XA] Reload key. Causes state jump in A_WeaponReady. BT_ZOOM = 1<<7, // [XA] Zoom key. Ditto. // The rest are all ignored by the play simulation and are for scripts. BT_SPEED = 1<<8, BT_STRAFE = 1<<9, BT_MOVERIGHT = 1<<10, BT_MOVELEFT = 1<<11, BT_BACK = 1<<12, BT_FORWARD = 1<<13, BT_RIGHT = 1<<14, BT_LEFT = 1<<15, BT_LOOKUP = 1<<16, BT_LOOKDOWN = 1<<17, BT_MOVEUP = 1<<18, BT_MOVEDOWN = 1<<19, BT_SHOWSCORES = 1<<20, BT_USER1 = 1<<21, BT_USER2 = 1<<22, BT_USER3 = 1<<23, BT_USER4 = 1<<24, BT_RUN = 1<<25, }; // Flags for GetAngle enum EGetAngleFlags { GAF_RELATIVE = 1, GAF_SWITCH = 1 << 1, }; //Flags for A_CopySpriteFrame enum ECopySpriteFrameFlags { CPSF_NOSPRITE = 1, CPSF_NOFRAME = 1 << 1, }; //Flags for A_SetMaskRotation enum EMaskRotationFlags { VRF_NOANGLESTART = 1, VRF_NOANGLEEND = 1 << 1, VRF_NOPITCHSTART = 1 << 2, VRF_NOPITCHEND = 1 << 3, VRF_NOANGLE = VRF_NOANGLESTART|VRF_NOANGLEEND, VRF_NOPITCH = VRF_NOPITCHSTART|VRF_NOPITCHEND, }; // Type definition for the implicit 'callingstate' parameter that gets passed to action functions. enum EStateType { STATE_Actor, STATE_Psprite, STATE_StateChain, } struct FStateParamInfo { state mCallingState; /*EStateType*/int mStateType; int mPSPIndex; } // returned by AimLineAttack. struct FTranslatedLineTarget { Actor linetarget; double angleFromSource; double attackAngleFromSource; bool unlinked; // found by a trace that went through an unlinked portal. native void TraceBleed(int damage, Actor missile); } enum EAimFlags { ALF_FORCENOSMART = 1, ALF_CHECK3D = 2, ALF_CHECKNONSHOOTABLE = 4, ALF_CHECKCONVERSATION = 8, ALF_NOFRIENDS = 16, ALF_PORTALRESTRICT = 32, // only work through portals with a global offset (to be used for stuff that cannot remember the calculated FTranslatedLineTarget info) ALF_NOWEAPONCHECK = 64, // ignore NOAUTOAIM flag on a player's weapon. } enum ELineAttackFlags { LAF_ISMELEEATTACK = 1, LAF_NORANDOMPUFFZ = 1 << 1, LAF_NOIMPACTDECAL = 1 << 2, LAF_NOINTERACT = 1 << 3, LAF_TARGETISSOURCE = 1 << 4, LAF_OVERRIDEZ = 1 << 5, LAF_ABSOFFSET = 1 << 6, LAF_ABSPOSITION = 1 << 7, } enum ELineTraceFlags { TRF_ABSPOSITION = 1, TRF_ABSOFFSET = 2, TRF_THRUSPECIES = 4, TRF_THRUACTORS = 8, TRF_THRUBLOCK = 16, TRF_THRUHITSCAN = 32, TRF_NOSKY = 64, TRF_ALLACTORS = 128, TRF_SOLIDACTORS = 256, TRF_BLOCKUSE = 512, TRF_BLOCKSELF = 1024, } const DEFMELEERANGE = 64; const SAWRANGE = (64.+(1./65536.)); // use meleerange + 1 so the puff doesn't skip the flash (i.e. plays all states) const MISSILERANGE = (32*64); const PLAYERMISSILERANGE = 8192; // [RH] New MISSILERANGE for players enum ESightFlags { SF_IGNOREVISIBILITY=1, SF_SEEPASTSHOOTABLELINES=2, SF_SEEPASTBLOCKEVERYTHING=4, SF_IGNOREWATERBOUNDARY=8 } enum EDmgFlags { DMG_NO_ARMOR = 1, DMG_INFLICTOR_IS_PUFF = 2, DMG_THRUSTLESS = 4, DMG_FORCED = 8, DMG_NO_FACTOR = 16, DMG_PLAYERATTACK = 32, DMG_FOILINVUL = 64, DMG_FOILBUDDHA = 128, DMG_NO_PROTECT = 256, DMG_USEANGLE = 512, DMG_NO_PAIN = 1024, DMG_EXPLOSION = 2048, DMG_NO_ENHANCE = 4096, } enum EReplace { NO_REPLACE = 0, ALLOW_REPLACE = 1 } // This translucency value produces the closest match to Heretic's TINTTAB. // ~40% of the value of the overlaid image shows through. const HR_SHADOW = (0x6800 / 65536.); // Hexen's TINTTAB is the same as Heretic's, just reversed. const HX_SHADOW = (0x9800 / 65536.); const HX_ALTSHADOW = (0x6800 / 65536.); enum EMapThingFlags { MTF_AMBUSH = 0x0008, // Thing is deaf MTF_DORMANT = 0x0010, // Thing is dormant (use Thing_Activate) MTF_SINGLE = 0x0100, // Thing appears in single-player games MTF_COOPERATIVE = 0x0200, // Thing appears in cooperative games MTF_DEATHMATCH = 0x0400, // Thing appears in deathmatch games MTF_SHADOW = 0x0800, MTF_ALTSHADOW = 0x1000, MTF_FRIENDLY = 0x2000, MTF_STANDSTILL = 0x4000, MTF_STRIFESOMETHING = 0x8000, MTF_SECRET = 0x080000, // Secret pickup MTF_NOINFIGHTING = 0x100000, MTF_NOCOUNT = 0x200000, // Removes COUNTKILL/COUNTITEM }; enum ESkillProperty { SKILLP_FastMonsters, SKILLP_Respawn, SKILLP_RespawnLimit, SKILLP_DisableCheats, SKILLP_AutoUseHealth, SKILLP_SpawnFilter, SKILLP_EasyBossBrain, SKILLP_ACSReturn, SKILLP_NoPain, SKILLP_EasyKey, SKILLP_SlowMonsters, SKILLP_Infight, SKILLP_PlayerRespawn, SKILLP_SpawnMulti, SKILLP_InstantReaction, }; enum EFSkillProperty // floating point properties { SKILLP_AmmoFactor, SKILLP_DropAmmoFactor, SKILLP_ArmorFactor, SKILLP_HealthFactor, SKILLP_DamageFactor, SKILLP_Aggressiveness, SKILLP_MonsterHealth, SKILLP_FriendlyHealth, SKILLP_KickbackFactor, }; enum EWeaponPos { WEAPONBOTTOM = 128, WEAPONTOP = 32 } enum ETranslationTable { TRANSLATION_Invalid, TRANSLATION_Players, TRANSLATION_PlayersExtra, TRANSLATION_Standard, TRANSLATION_LevelScripted, TRANSLATION_Decals, TRANSLATION_PlayerCorpses, TRANSLATION_Decorate, TRANSLATION_Blood, TRANSLATION_RainPillar, TRANSLATION_Custom, }; enum EFindFloorCeiling { FFCF_ONLYSPAWNPOS = 1, FFCF_SAMESECTOR = 2, FFCF_ONLY3DFLOORS = 4, // includes 3D midtexes FFCF_3DRESTRICT = 8, // ignore 3D midtexes and floors whose floorz are above thing's z FFCF_NOPORTALS = 16, // ignore portals (considers them impassable.) FFCF_NOFLOOR = 32, FFCF_NOCEILING = 64, FFCF_RESTRICTEDPORTAL = 128, // current values in the iterator's return are through a restricted portal type (i.e. some features are blocked.) FFCF_NODROPOFF = 256, // Caller does not need a dropoff (saves some time when checking portals) }; enum ERaise { RF_TRANSFERFRIENDLINESS = 1, RF_NOCHECKPOSITION = 2 } enum eFogParm { FOGP_DENSITY = 0, FOGP_OUTSIDEDENSITY = 1, FOGP_SKYFOG = 2, } enum ETeleport { TELF_DESTFOG = 1, TELF_SOURCEFOG = 2, TELF_KEEPORIENTATION = 4, TELF_KEEPVELOCITY = 8, TELF_KEEPHEIGHT = 16, TELF_ROTATEBOOM = 32, TELF_ROTATEBOOMINVERSE = 64, }; enum EGameType { GAME_Any = 0, GAME_Doom = 1, GAME_Heretic = 2, GAME_Hexen = 4, GAME_Strife = 8, GAME_Chex = 16, //Chex is basically Doom, but we need to have a different set of actors. GAME_Raven = GAME_Heretic|GAME_Hexen, GAME_DoomChex = GAME_Doom|GAME_Chex, GAME_DoomStrifeChex = GAME_Doom|GAME_Strife|GAME_Chex } enum PaletteFlashFlags { PF_HEXENWEAPONS = 1, PF_POISON = 2, PF_ICE = 4, PF_HAZARD = 8, }; enum EGameAction { ga_nothing, ga_loadlevel, ga_newgame, ga_newgame2, ga_recordgame, ga_loadgame, ga_loadgamehidecon, ga_loadgameplaydemo, ga_autoloadgame, ga_savegame, ga_autosave, ga_playdemo, ga_completed, ga_slideshow, ga_worlddone, ga_screenshot, ga_togglemap, ga_fullconsole, }; enum EPuffFlags { PF_HITTHING = 1, PF_MELEERANGE = 2, PF_TEMPORARY = 4, PF_HITTHINGBLEED = 8, PF_NORANDOMZ = 16, PF_HITSKY = 32 }; enum EPlayerCheats { CF_NOCLIP = 1 << 0, // No clipping, walk through barriers. CF_GODMODE = 1 << 1, // No damage, no health loss. CF_NOVELOCITY = 1 << 2, // Not really a cheat, just a debug aid. CF_NOTARGET = 1 << 3, // [RH] Monsters don't target CF_FLY = 1 << 4, // [RH] Flying player CF_CHASECAM = 1 << 5, // [RH] Put camera behind player CF_FROZEN = 1 << 6, // [RH] Don't let the player move CF_REVERTPLEASE = 1 << 7, // [RH] Stick camera in player's head if (s)he moves CF_STEPLEFT = 1 << 9, // [RH] Play left footstep sound next time CF_FRIGHTENING = 1 << 10, // [RH] Scare monsters away CF_INSTANTWEAPSWITCH= 1 << 11, // [RH] Switch weapons instantly CF_TOTALLYFROZEN = 1 << 12, // [RH] All players can do is press +use CF_PREDICTING = 1 << 13, // [RH] Player movement is being predicted CF_INTERPVIEW = 1 << 14, // [RH] view was changed outside of input, so interpolate one frame CF_INTERPVIEWANGLES = 1 << 15, // [MR] flag for interpolating view angles without interpolating the entire frame CF_SCALEDNOLERP = 1 << 15, // [MR] flag for applying angles changes in the ticrate without interpolating the frame CF_NOFOVINTERP = 1 << 16, // [B] Disable FOV interpolation when instantly zooming CF_EXTREMELYDEAD = 1 << 22, // [RH] Reliably let the status bar know about extreme deaths. CF_BUDDHA2 = 1 << 24, // [MC] Absolute buddha. No voodoo can kill it either. CF_GODMODE2 = 1 << 25, // [MC] Absolute godmode. No voodoo can kill it either. CF_BUDDHA = 1 << 27, // [SP] Buddha mode - take damage, but don't die CF_NOCLIP2 = 1 << 30, // [RH] More Quake-like noclip // These flags no longer exist, but keep the names for some stray mod that might have used them. CF_DRAIN = 0, CF_HIGHJUMP = 0, CF_REFLECTION = 0, CF_PROSPERITY = 0, CF_DOUBLEFIRINGSPEED= 0, CF_INFINITEAMMO = 0, }; enum EWeaponState { WF_WEAPONREADY = 1 << 0, // [RH] Weapon is in the ready state and can fire its primary attack WF_WEAPONBOBBING = 1 << 1, // [HW] Bob weapon while the player is moving WF_WEAPONREADYALT = 1 << 2, // Weapon can fire its secondary attack WF_WEAPONSWITCHOK = 1 << 3, // It is okay to switch away from this weapon WF_DISABLESWITCH = 1 << 4, // Disable weapon switching completely WF_WEAPONRELOADOK = 1 << 5, // [XA] Okay to reload this weapon. WF_WEAPONZOOMOK = 1 << 6, // [XA] Okay to use weapon zoom function. WF_REFIRESWITCHOK = 1 << 7, // Mirror WF_WEAPONSWITCHOK for A_ReFire WF_USER1OK = 1 << 8, // [MC] Allow pushing of custom state buttons 1-4 WF_USER2OK = 1 << 9, WF_USER3OK = 1 << 10, WF_USER4OK = 1 << 11, }; // these flags are for filtering actor visibility based on certain conditions of the renderer's feature support. // currently, no renderer supports every single one of these features. enum ActorRenderFeatureFlag { RFF_FLATSPRITES = 1<<0, // flat sprites RFF_MODELS = 1<<1, // 3d models RFF_SLOPE3DFLOORS = 1<<2, // sloped 3d floor support RFF_TILTPITCH = 1<<3, // full free-look RFF_ROLLSPRITES = 1<<4, // roll sprites RFF_UNCLIPPEDTEX = 1<<5, // midtex and sprite can render "into" flats and walls RFF_MATSHADER = 1<<6, // material shaders RFF_POSTSHADER = 1<<7, // post-process shaders (renderbuffers) RFF_BRIGHTMAP = 1<<8, // brightmaps RFF_COLORMAP = 1<<9, // custom colormaps (incl. ability to fullbright certain ranges, ala Strife) RFF_POLYGONAL = 1<<10, // uses polygons instead of wallscans/visplanes (i.e. softpoly and hardware opengl) RFF_TRUECOLOR = 1<<11, // renderer is currently truecolor RFF_VOXELS = 1<<12, // renderer is capable of voxels }; // Special activation types enum SPAC { SPAC_Cross = 1<<0, // when player crosses line SPAC_Use = 1<<1, // when player uses line SPAC_MCross = 1<<2, // when monster crosses line SPAC_Impact = 1<<3, // when projectile hits line SPAC_Push = 1<<4, // when player pushes line SPAC_PCross = 1<<5, // when projectile crosses line SPAC_UseThrough = 1<<6, // when player uses line (doesn't block) // SPAC_PTOUCH is mapped to SPAC_PCross|SPAC_Impact SPAC_AnyCross = 1<<7, // when anything without the MF2_TELEPORT flag crosses the line SPAC_MUse = 1<<8, // monsters can use SPAC_MPush = 1<<9, // monsters can push SPAC_UseBack = 1<<10, // Can be used from the backside SPAC_Damage = 1<<11, // [ZZ] when linedef receives damage SPAC_Death = 1<<12, // [ZZ] when linedef receives damage and has 0 health SPAC_PlayerActivate = (SPAC_Cross|SPAC_Use|SPAC_Impact|SPAC_Push|SPAC_AnyCross|SPAC_UseThrough|SPAC_UseBack), }; enum RadiusDamageFlags { RADF_HURTSOURCE = 1, RADF_NOIMPACTDAMAGE = 2, RADF_SOURCEISSPOT = 4, RADF_NODAMAGE = 8, RADF_THRUSTZ = 16, RADF_OLDRADIUSDAMAGE = 32, RADF_THRUSTLESS = 64, RADF_NOALLIES = 128, RADF_CIRCULAR = 256 }; enum IntermissionSequenceType { FSTATE_EndingGame = 0, FSTATE_ChangingLevel = 1, FSTATE_InLevel = 2 }; enum Bobbing { Bob_Normal, Bob_Inverse, Bob_Alpha, Bob_InverseAlpha, Bob_Smooth, Bob_InverseSmooth }; enum EFinishLevelType { FINISH_SameHub, FINISH_NextHub, FINISH_NoHub }; enum EChangeLevelFlags { CHANGELEVEL_KEEPFACING = 1, CHANGELEVEL_RESETINVENTORY = 2, CHANGELEVEL_NOMONSTERS = 4, CHANGELEVEL_CHANGESKILL = 8, CHANGELEVEL_NOINTERMISSION = 16, CHANGELEVEL_RESETHEALTH = 32, CHANGELEVEL_PRERAISEWEAPON = 64, }; enum ELevelFlags { LEVEL_NOINTERMISSION = 0x00000001, LEVEL_NOINVENTORYBAR = 0x00000002, // This effects Doom only, since it's the only one without a standard inventory bar. LEVEL_DOUBLESKY = 0x00000004, LEVEL_HASFADETABLE = 0x00000008, // Level uses Hexen's fadetable mapinfo to get fog LEVEL_MAP07SPECIAL = 0x00000010, LEVEL_BRUISERSPECIAL = 0x00000020, LEVEL_CYBORGSPECIAL = 0x00000040, LEVEL_SPIDERSPECIAL = 0x00000080, LEVEL_SPECLOWERFLOOR = 0x00000100, LEVEL_SPECOPENDOOR = 0x00000200, LEVEL_SPECLOWERFLOORTOHIGHEST=0x00000300, LEVEL_SPECACTIONSMASK = 0x00000300, LEVEL_MONSTERSTELEFRAG = 0x00000400, LEVEL_ACTOWNSPECIAL = 0x00000800, LEVEL_SNDSEQTOTALCTRL = 0x00001000, LEVEL_FORCETILEDSKY = 0x00002000, LEVEL_CROUCH_NO = 0x00004000, LEVEL_JUMP_NO = 0x00008000, LEVEL_FREELOOK_NO = 0x00010000, LEVEL_FREELOOK_YES = 0x00020000, // The absence of both of the following bits means that this level does not // use falling damage (though damage can be forced with dmflags,. LEVEL_FALLDMG_ZD = 0x00040000, // Level uses ZDoom's falling damage LEVEL_FALLDMG_HX = 0x00080000, // Level uses Hexen's falling damage LEVEL_HEADSPECIAL = 0x00100000, // Heretic episode 1/4 LEVEL_MINOTAURSPECIAL = 0x00200000, // Heretic episode 2/5 LEVEL_SORCERER2SPECIAL = 0x00400000, // Heretic episode 3 LEVEL_SPECKILLMONSTERS = 0x00800000, LEVEL_STARTLIGHTNING = 0x01000000, // Automatically start lightning LEVEL_FILTERSTARTS = 0x02000000, // Apply mapthing filtering to player starts LEVEL_LOOKUPLEVELNAME = 0x04000000, // Level name is the name of a language string LEVEL_USEPLAYERSTARTZ = 0x08000000, // Use the Z position of player starts LEVEL_SWAPSKIES = 0x10000000, // Used by lightning LEVEL_NOALLIES = 0x20000000, // i.e. Inside Strife's front base LEVEL_CHANGEMAPCHEAT = 0x40000000, // Don't display cluster messages LEVEL_VISITED = 0x80000000, // Used for intermission map // The flags uint64_t is now split into 2 DWORDs LEVEL2_RANDOMPLAYERSTARTS = 0x00000001, // Select single player starts randomnly (no voodoo dolls) LEVEL2_ALLMAP = 0x00000002, // The player picked up a map on this level LEVEL2_LAXMONSTERACTIVATION = 0x00000004, // Monsters can open doors depending on the door speed LEVEL2_LAXACTIVATIONMAPINFO = 0x00000008, // LEVEL_LAXMONSTERACTIVATION is not a default. LEVEL2_MISSILESACTIVATEIMPACT=0x00000010, // Missiles are the activators of SPAC_IMPACT events, not their shooters LEVEL2_NEEDCLUSTERTEXT = 0x00000020, // A map with this flag needs to retain its cluster intermission texts when being redefined in UMAPINFO LEVEL2_KEEPFULLINVENTORY = 0x00000040, // doesn't reduce the amount of inventory items to 1 LEVEL2_PRERAISEWEAPON = 0x00000080, // players should spawn with their weapons fully raised (but not when respawning it multiplayer) LEVEL2_MONSTERFALLINGDAMAGE = 0x00000100, LEVEL2_CLIPMIDTEX = 0x00000200, LEVEL2_WRAPMIDTEX = 0x00000400, LEVEL2_CHECKSWITCHRANGE = 0x00000800, LEVEL2_PAUSE_MUSIC_IN_MENUS = 0x00001000, LEVEL2_TOTALINFIGHTING = 0x00002000, LEVEL2_NOINFIGHTING = 0x00004000, LEVEL2_NOMONSTERS = 0x00008000, LEVEL2_INFINITE_FLIGHT = 0x00010000, LEVEL2_ALLOWRESPAWN = 0x00020000, LEVEL2_FORCETEAMPLAYON = 0x00040000, LEVEL2_FORCETEAMPLAYOFF = 0x00080000, LEVEL2_CONV_SINGLE_UNFREEZE = 0x00100000, LEVEL2_NOCLUSTERTEXT = 0x00200000, // ignore intermission texts fro clusters. This gets set when UMAPINFO is used to redefine its properties. LEVEL2_DUMMYSWITCHES = 0x00400000, LEVEL2_HEXENHACK = 0x00800000, // Level was defined in a Hexen style MAPINFO LEVEL2_SMOOTHLIGHTING = 0x01000000, // Level uses the smooth lighting feature. LEVEL2_POLYGRIND = 0x02000000, // Polyobjects grind corpses to gibs. LEVEL2_RESETINVENTORY = 0x04000000, // Resets player inventory when starting this level (unless in a hub) LEVEL2_RESETHEALTH = 0x08000000, // Resets player health when starting this level (unless in a hub) LEVEL2_NOSTATISTICS = 0x10000000, // This level should not have statistics collected LEVEL2_ENDGAME = 0x20000000, // This is an epilogue level that cannot be quit. LEVEL2_NOAUTOSAVEHINT = 0x40000000, // tell the game that an autosave for this level does not need to be kept LEVEL2_FORGETSTATE = 0x80000000, // forget this map's state in a hub // More flags! LEVEL3_FORCEFAKECONTRAST = 0x00000001, // forces fake contrast even with fog enabled LEVEL3_REMOVEITEMS = 0x00000002, // kills all INVBAR items on map change. LEVEL3_ATTENUATE = 0x00000004, // attenuate lights? LEVEL3_NOLIGHTFADE = 0x00000008, // no light fading to black. LEVEL3_NOCOLOREDSPRITELIGHTING = 0x00000010, // draw sprites only with color-less light LEVEL3_EXITNORMALUSED = 0x00000020, LEVEL3_EXITSECRETUSED = 0x00000040, LEVEL3_FORCEWORLDPANNING = 0x00000080, // Forces the world panning flag for all textures, even those without it explicitly set. LEVEL3_HIDEAUTHORNAME = 0x00000100, LEVEL3_PROPERMONSTERFALLINGDAMAGE = 0x00000200, // Properly apply falling damage to the monsters LEVEL3_SKYBOXAO = 0x00000400, // Apply SSAO to sector skies LEVEL3_E1M8SPECIAL = 0x00000800, LEVEL3_E2M8SPECIAL = 0x00001000, LEVEL3_E3M8SPECIAL = 0x00002000, LEVEL3_E4M8SPECIAL = 0x00004000, LEVEL3_E4M6SPECIAL = 0x00008000, LEVEL3_NOSHADOWMAP = 0x00010000, // disables shadowmaps for a given level. LEVEL3_AVOIDMELEE = 0x00020000, // global flag needed for proper MBF support. LEVEL3_NOJUMPDOWN = 0x00040000, // only for MBF21. Inverse of MBF's dog_jumping flag. LEVEL3_LIGHTCREATED = 0x00080000, // a light had been created in the last frame }; // [RH] Compatibility flags. enum ECompatFlags { COMPATF_SHORTTEX = 1 << 0, // Use Doom's shortest texture around behavior? COMPATF_STAIRINDEX = 1 << 1, // Don't fix loop index for stair building? COMPATF_LIMITPAIN = 1 << 2, // Pain elemental is limited to 20 lost souls? COMPATF_SILENTPICKUP = 1 << 3, // Pickups are only heard locally? COMPATF_NO_PASSMOBJ = 1 << 4, // Pretend every actor is infinitely tall? COMPATF_MAGICSILENCE = 1 << 5, // Limit actors to one sound at a time? COMPATF_WALLRUN = 1 << 6, // Enable buggier wall clipping so players can wallrun? COMPATF_NOTOSSDROPS = 1 << 7, // Spawn dropped items directly on the floor? COMPATF_USEBLOCKING = 1 << 8, // Any special line can block a use line COMPATF_NODOORLIGHT = 1 << 9, // Don't do the BOOM local door light effect COMPATF_RAVENSCROLL = 1 << 10, // Raven's scrollers use their original carrying speed COMPATF_SOUNDTARGET = 1 << 11, // Use sector based sound target code. COMPATF_DEHHEALTH = 1 << 12, // Limit deh.MaxHealth to the health bonus (as in Doom2.exe) COMPATF_TRACE = 1 << 13, // Trace ignores lines with the same sector on both sides COMPATF_DROPOFF = 1 << 14, // Monsters cannot move when hanging over a dropoff COMPATF_BOOMSCROLL = 1 << 15, // Scrolling sectors are additive like in Boom COMPATF_INVISIBILITY = 1 << 16, // Monsters can see semi-invisible players COMPATF_SILENT_INSTANT_FLOORS = 1<<17, // Instantly moving floors are not silent COMPATF_SECTORSOUNDS = 1 << 18, // Sector sounds use original method for sound origin. COMPATF_MISSILECLIP = 1 << 19, // Use original Doom heights for clipping against projectiles COMPATF_CROSSDROPOFF = 1 << 20, // monsters can't be pushed over dropoffs COMPATF_ANYBOSSDEATH = 1 << 21, // [GZ] Any monster which calls BOSSDEATH counts for level specials COMPATF_MINOTAUR = 1 << 22, // Minotaur's floor flame is exploded immediately when feet are clipped COMPATF_MUSHROOM = 1 << 23, // Force original velocity calculations for A_Mushroom in Dehacked mods. COMPATF_MBFMONSTERMOVE = 1 << 24, // Monsters are affected by friction and pushers/pullers. COMPATF_CORPSEGIBS = 1 << 25, // only needed for some hypothetical mod checking this flag. COMPATF_VILEGHOSTS = 1 << 25, // Crushed monsters are resurrected as ghosts. COMPATF_NOBLOCKFRIENDS = 1 << 26, // Friendly monsters aren't blocked by monster-blocking lines. COMPATF_SPRITESORT = 1 << 27, // Invert sprite sorting order for sprites of equal distance COMPATF_HITSCAN = 1 << 28, // Hitscans use original blockmap anf hit check code. COMPATF_LIGHT = 1 << 29, // Find neighboring light level like Doom COMPATF_POLYOBJ = 1 << 30, // Draw polyobjects the old fashioned way COMPATF_MASKEDMIDTEX = 1 << 31, // Ignore compositing when drawing masked midtextures COMPATF2_BADANGLES = 1 << 0, // It is impossible to face directly NSEW. COMPATF2_FLOORMOVE = 1 << 1, // Use the same floor motion behavior as Doom. COMPATF2_SOUNDCUTOFF = 1 << 2, // Cut off sounds when an actor vanishes instead of making it owner-less COMPATF2_POINTONLINE = 1 << 3, // Use original but buggy P_PointOnLineSide() and P_PointOnDivlineSideCompat() COMPATF2_MULTIEXIT = 1 << 4, // Level exit can be triggered multiple times (required by Daedalus's travel tubes, thanks to a faulty script) COMPATF2_TELEPORT = 1 << 5, // Don't let indirect teleports trigger sector actions COMPATF2_PUSHWINDOW = 1 << 6, // Disable the window check in CheckForPushSpecial() COMPATF2_CHECKSWITCHRANGE = 1 << 7, // Enable buggy CheckSwitchRange behavior COMPATF2_EXPLODE1 = 1 << 8, // No vertical explosion thrust COMPATF2_EXPLODE2 = 1 << 9, // Use original explosion code throughout. COMPATF2_RAILING = 1 << 10, // Bugged Strife railings. COMPATF2_SCRIPTWAIT = 1 << 11, // Use old scriptwait implementation where it doesn't wait on a non-running script. COMPATF2_AVOID_HAZARDS = 1 << 12, // another MBF thing. COMPATF2_STAYONLIFT = 1 << 13, // yet another MBF thing. COMPATF2_NOMBF21 = 1 << 14, // disable MBF21 features that may clash with certain maps COMPATF2_VOODOO_ZOMBIES = 1 << 15, // allow playerinfo, playerpawn, and voodoo health to all be different, and allow monster targetting of 'dead' players that have positive health }; const M_E = 2.7182818284590452354; // e const M_LOG2E = 1.4426950408889634074; // log_2 e const M_LOG10E = 0.43429448190325182765; // log_10 e const M_LN2 = 0.69314718055994530942; // log_e 2 const M_LN10 = 2.30258509299404568402; // log_e 10 const M_PI = 3.14159265358979323846; // pi const M_PI_2 = 1.57079632679489661923; // pi/2 const M_PI_4 = 0.78539816339744830962; // pi/4 const M_1_PI = 0.31830988618379067154; // 1/pi const M_2_PI = 0.63661977236758134308; // 2/pi const M_2_SQRTPI = 1.12837916709551257390; // 2/sqrt(pi) const M_SQRT2 = 1.41421356237309504880; // sqrt(2) const M_SQRT1_2 = 0.70710678118654752440; // 1/sqrt(2) // Used by Actor.FallAndSink const WATER_SINK_FACTOR = 0.125; const WATER_SINK_SMALL_FACTOR = 0.25; const WATER_SINK_SPEED = 0.5; const WATER_JUMP_SPEED = 3.5; /* ** conversationmenu.txt ** The Strife dialogue display ** **--------------------------------------------------------------------------- ** Copyright 2010-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ struct StrifeDialogueNode native version("2.4") { native Class DropType; native int ThisNodeNum; native int ItemCheckNode; native Class SpeakerType; native String SpeakerName; native Sound SpeakerVoice; native String Backdrop; native String Dialogue; native String Goodbye; native StrifeDialogueReply Children; native Name MenuClassName; native String UserData; } // FStrifeDialogueReply holds responses the player can give to the NPC struct StrifeDialogueReply native version("2.4") { native StrifeDialogueReply Next; native Class GiveType; native int ActionSpecial; native int Args[5]; native int PrintAmount; native String Reply; native String QuickYes; native String QuickNo; native String LogString; native int NextNode; // index into StrifeDialogues native int LogNumber; native bool NeedsGold; native bool ShouldSkipReply(PlayerInfo player); } class ConversationMenu : Menu { String mSpeaker; BrokenLines mDialogueLines; Array mResponseLines; Array mResponses; bool mShowGold; bool mHasBackdrop; bool mConfineTextToBackdrop; StrifeDialogueNode mCurNode; int mYpos; PlayerInfo mPlayer; int mSelection; int ConversationPauseTic; int LineHeight; int ReplyLineHeight; Font displayFont; int speechDisplayWidth; int displayWidth; int displayHeight; int fontScale; int refwidth; int refheight; Array ypositions; int SpeechWidth; int ReplyWidth; native static void SendConversationReply(int node, int reply); const NUM_RANDOM_LINES = 10; const NUM_RANDOM_GOODBYES = 3; //============================================================================= // // returns the y position of the replies box for positioning the terminal response. // //============================================================================= virtual int Init(StrifeDialogueNode CurNode, PlayerInfo player, int activereply) { mCurNode = CurNode; mPlayer = player; mShowGold = false; ConversationPauseTic = gametic + 20; DontDim = true; let tex = TexMan.CheckForTexture (CurNode.Backdrop, TexMan.Type_MiscPatch); mHasBackdrop = tex.isValid(); DontBlur = !mHasBackdrop; if (!generic_ui && !dlg_vgafont) { displayFont = SmallFont; displayWidth = CleanWidth; displayHeight = CleanHeight; fontScale = CleanXfac; refwidth = 320; refheight = 200; ReplyWidth = 320-50-10; SpeechWidth = screen.GetWidth()/CleanXfac - 24*2; ReplyLineHeight = LineHeight = displayFont.GetHeight(); mConfineTextToBackdrop = false; speechDisplayWidth = displayWidth; } else { displayFont = NewSmallFont; fontScale = (CleanXfac+1) / 2; refwidth = 640; refheight = 400; ReplyWidth = 640-100-20; displayWidth = screen.GetWidth() / fontScale; displayHeight = screen.GetHeight() / fontScale; let aspect = Screen.GetAspectRatio(); if (!mHasBackdrop || aspect <= 1.3334) { SpeechWidth = screen.GetWidth()/fontScale - (24*3 * CleanXfac / fontScale); mConfineTextToBackdrop = false; speechDisplayWidth = displayWidth; } else { speechDisplayWidth = int(Screen.GetHeight() * 1.3333 / fontScale); SpeechWidth = speechDisplayWidth - (24*3 * CleanXfac / fontScale); mConfineTextToBackdrop = true; } LineHeight = displayFont.GetHeight() + 2; ReplyLineHeight = LineHeight * fontScale / CleanYfac; } FormatSpeakerMessage(); return FormatReplies(activereply); } //============================================================================= // // // //============================================================================= virtual int FormatReplies(int activereply) { mSelection = -1; StrifeDialogueReply reply; int r = -1; int i = 1,j; for (reply = mCurNode.Children; reply != NULL; reply = reply.Next) { r++; if (reply.ShouldSkipReply(mPlayer)) { continue; } if (activereply == r) mSelection = i - 1; mShowGold |= reply.NeedsGold; let ReplyText = Stringtable.Localize(reply.Reply); if (reply.NeedsGold) { ReplyText.AppendFormat(" %s", Stringtable.Localize("$TXT_TRADE")); let amount = String.Format("%u", reply.PrintAmount); ReplyText.Replace("%u", amount); } let ReplyLines = displayFont.BreakLines (ReplyText, ReplyWidth); mResponses.Push(mResponseLines.Size()); for (j = 0; j < ReplyLines.Count(); ++j) { mResponseLines.Push(ReplyLines.StringAt(j)); } ++i; ReplyLines.Destroy(); } if (mSelection == -1) { mSelection = r < activereply ? r + 1 : 0; } let goodbyestr = mCurNode.Goodbye; if (goodbyestr.Length() == 0) { goodbyestr = String.Format("$TXT_RANDOMGOODBYE_%d", Random[RandomSpeech](1, NUM_RANDOM_GOODBYES)); } else if (goodbyestr.Left(7) == "RANDOM_") { goodbyestr = String.Format("$TXT_%s_%02d", goodbyestr, Random[RandomSpeech](1, NUM_RANDOM_LINES)); } goodbyestr = Stringtable.Localize(goodbyestr); if (goodbyestr.Length() == 0 || goodbyestr.Left(1) == "$") goodbyestr = "Bye."; mResponses.Push(mResponseLines.Size()); mResponseLines.Push(goodbyestr); // Determine where the top of the reply list should be positioned. mYpos = MIN (140, 192 - mResponseLines.Size() * ReplyLineHeight); i = 44 + mResponseLines.Size() * ReplyLineHeight; if (mYpos - 100 < i - screen.GetHeight() / CleanYfac / 2) { mYpos = i - screen.GetHeight() / CleanYfac / 2 + 100; } if (mSelection >= mResponses.Size()) { mSelection = mResponses.Size() - 1; } return mYpos; } //============================================================================= // // // //============================================================================= virtual void FormatSpeakerMessage() { // Format the speaker's message. String toSay = mCurNode.Dialogue; if (toSay.Left(7) == "RANDOM_") { let dlgtext = String.Format("$TXT_%s_%02d", toSay, random[RandomSpeech](1, NUM_RANDOM_LINES)); toSay = Stringtable.Localize(dlgtext); if (toSay.Left(1) == "$") toSay = Stringtable.Localize("$TXT_GOAWAY"); } else { // handle string table replacement toSay = Stringtable.Localize(toSay); } if (toSay.Length() == 0) { toSay = "."; } mDialogueLines = displayFont.BreakLines(toSay, SpeechWidth); } //============================================================================= // // // //============================================================================= override void OnDestroy() { if (mDialogueLines != null) mDialogueLines.Destroy(); SetMusicVolume (Level.MusicVolume); Super.OnDestroy(); } protected int GetReplyNum() { // This is needed because mSelection represents the replies currently being displayed which will // not match up with what's supposed to be selected if there are any hidden/skipped replies. [FishyClockwork] let reply = mCurNode.Children; int replynum = mSelection; for (int i = 0; i <= mSelection && reply != null; reply = reply.Next) { if (reply.ShouldSkipReply(mPlayer)) replynum++; else i++; } return replynum; } //============================================================================= // // // //============================================================================= override bool MenuEvent(int mkey, bool fromcontroller) { if (demoplayback) { // During demo playback, don't let the user do anything besides close this menu. if (mkey == MKEY_Back) { Close(); return true; } return false; } if (mkey == MKEY_Up) { if (--mSelection < 0) mSelection = mResponses.Size() - 1; return true; } else if (mkey == MKEY_Down) { if (++mSelection >= mResponses.Size()) mSelection = 0; return true; } else if (mkey == MKEY_Back) { SendConversationReply(-1, GetReplyNum()); Close(); return true; } else if (mkey == MKEY_Enter) { int replynum = GetReplyNum(); if (mSelection >= mResponses.Size()) { SendConversationReply(-2, replynum); } else { // Send dialogue and reply numbers across the wire. SendConversationReply(mCurNode.ThisNodeNum, replynum); } Close(); return true; } return false; } //============================================================================= // // // //============================================================================= override bool MouseEvent(int type, int x, int y) { int sel = -1; int fh = LineHeight; // convert x/y from screen to virtual coordinates, according to CleanX/Yfac use in DrawTexture x = ((x - (screen.GetWidth() / 2)) / fontScale) + refWidth/2; if (x >= 24 && x <= refWidth-24) { for (int i = 0; i < ypositions.Size()-1; i++) { if (y > ypositions[i] && y <= ypositions[i+1]) { sel = i; break; } } } mSelection = sel; if (type == MOUSE_Release) { return MenuEvent(MKEY_Enter, true); } return true; } //============================================================================= // // // //============================================================================= override bool OnUIEvent(UIEvent ev) { if (demoplayback) { // No interaction during demo playback return false; } if (ev.type == UIEvent.Type_Char && ev.KeyChar >= 48 && ev.KeyChar <= 57) { // Activate an item of type numberedmore (dialogue only) mSelection = ev.KeyChar == 48 ? 9 : ev.KeyChar - 49; return MenuEvent(MKEY_Enter, false); } return Super.OnUIEvent(ev); } //============================================================================ // // Draw the backdrop, returns true if the text background should be dimmed // //============================================================================ virtual bool DrawBackdrop() { let tex = TexMan.CheckForTexture (mCurNode.Backdrop, TexMan.Type_MiscPatch); if (tex.isValid()) { screen.DrawTexture(tex, false, 0, 0, DTA_320x200, true); return false; } return true; } //============================================================================ // // Draw the speaker text // //============================================================================ virtual void DrawSpeakerText(bool dimbg) { String speakerName; int linesize = LineHeight * fontScale; int cnt = mDialogueLines.Count(); // Who is talking to you? if (mCurNode.SpeakerName.Length() > 0) { speakerName = Stringtable.Localize(mCurNode.SpeakerName); } else { speakerName = players[consoleplayer].ConversationNPC.GetTag("$TXT_PERSON"); } // Dim the screen behind the dialogue (but only if there is no backdrop). if (dimbg) { int x = 14 * screen.GetWidth() / 320; int y = 13 * screen.GetHeight() / 200; int w = 294 * screen.GetWidth() / 320; int h = linesize * cnt + 6 * CleanYfac; if (speakerName.Length() > 0) h += linesize * 3 / 2; screen.Dim(0, 0.45f, x, y, w, h); } int x = 16 * screen.GetWidth() / 320; int y = 16 * screen.GetHeight() / 200; if (speakerName.Length() > 0) { screen.DrawText(displayFont, Font.CR_WHITE, x / fontScale, y / fontScale, speakerName, DTA_KeepRatio, !mConfineTextToBackdrop, DTA_VirtualWidth, speechDisplayWidth, DTA_VirtualHeight, displayHeight); y += linesize * 3 / 2; } x = 24 * screen.GetWidth() / 320; for (int i = 0; i < cnt; ++i) { screen.DrawText(displayFont, Font.CR_UNTRANSLATED, x / fontScale, y / fontScale, mDialogueLines.StringAt(i), DTA_KeepRatio, !mConfineTextToBackdrop, DTA_VirtualWidth, speechDisplayWidth, DTA_VirtualHeight, displayHeight); y += linesize; } } //============================================================================ // // Draw the replies // //============================================================================ virtual void DrawReplies() { // Dim the screen behind the PC's choices. screen.Dim(0, 0.45, (24 - 160) * CleanXfac + screen.GetWidth() / 2, (mYpos - 2 - 100) * CleanYfac + screen.GetHeight() / 2, 272 * CleanXfac, MIN(mResponseLines.Size() * ReplyLineHeight + 4, 200 - mYpos) * CleanYfac); int y = mYpos; int response = 0; ypositions.Clear(); for (int i = 0; i < mResponseLines.Size(); i++) { int width = displayFont.StringWidth(mResponseLines[i]); int x = 64; double sx = (x - 160.0) * CleanXfac + (screen.GetWidth() * 0.5); double sy = (y - 100.0) * CleanYfac + (screen.GetHeight() * 0.5); screen.DrawText(displayFont, Font.CR_GREEN, sx / fontScale, sy / fontScale, mResponseLines[i], DTA_KeepRatio, true, DTA_VirtualWidth, displayWidth, DTA_VirtualHeight, displayHeight); if (i == mResponses[response]) { String tbuf; ypositions.Push(sy); response++; tbuf = String.Format("%d.", response); x = 50 - displayFont.StringWidth(tbuf); sx = (x - 160.0) * CleanXfac + (screen.GetWidth() * 0.5); screen.DrawText(displayFont, Font.CR_GREY, sx / fontScale, sy / fontScale, tbuf, DTA_KeepRatio, true, DTA_VirtualWidth, displayWidth, DTA_VirtualHeight, displayHeight); if (response == mSelection + 1) { int colr = ((MenuTime() % 8) < 4) || GetCurrentMenu() != self ? Font.CR_RED : Font.CR_GREY; // custom graphic cursor color Color cursorTexColor; if (colr == Font.CR_RED) cursorTexColor = color(0xFF, 0x00, 0x00); else if (colr == Font.CR_GREY) cursorTexColor = color(0xCC, 0xCC, 0xCC); x = (50 + 3 - 160) * CleanXfac + screen.GetWidth() / 2; int yy = (y + ReplyLineHeight / 2 - 5 - 100) * CleanYfac + screen.GetHeight() / 2; // use a custom graphic (intentionally long-named to reduce collision with existing mods), with the ConFont version as the fallback let cursorTex = TexMan.CheckForTexture("graphics/DialogReplyCursor.png", TexMan.Type_MiscPatch); if (cursorTex.IsValid()) { screen.DrawTexture(cursorTex, true, x / fontScale, yy / fontScale, DTA_KeepRatio, true, DTA_VirtualWidth, displayWidth, DTA_VirtualHeight, displayHeight); screen.DrawTexture(cursorTex, true, x / fontScale, yy / fontScale, DTA_KeepRatio, true, DTA_VirtualWidth, displayWidth, DTA_VirtualHeight, displayHeight, DTA_FillColor, cursorTexColor, DTA_LegacyRenderStyle, STYLE_AddShaded); } else { screen.DrawText(ConFont, colr, x, yy, "\xd", DTA_CellX, 8 * CleanXfac, DTA_CellY, 8 * CleanYfac); } } } y += ReplyLineHeight; } double sy = (y - 100.0) * CleanYfac + (screen.GetHeight() * 0.5); ypositions.Push(sy); } virtual void DrawGold() { if (mShowGold) { let coin = players[consoleplayer].ConversationPC.FindInventory("Coin"); let icon = GetDefaultByType("Coin").Icon; let goldstr = String.Format("%d", coin != NULL ? coin.Amount : 0); screen.DrawText(SmallFont, Font.CR_GRAY, 21, 191, goldstr, DTA_320x200, true, DTA_FillColor, 0, DTA_Alpha, HR_SHADOW); screen.DrawTexture(icon, false, 3, 190, DTA_320x200, true, DTA_FillColor, 0, DTA_Alpha, HR_SHADOW); screen.DrawText(SmallFont, Font.CR_GRAY, 20, 190, goldstr, DTA_320x200, true); screen.DrawTexture(icon, false, 2, 189, DTA_320x200, true); } } //============================================================================ // // DrawConversationMenu // //============================================================================ override void Drawer() { if (mCurNode == NULL) { Close (); return; } bool dimbg = DrawBackdrop(); DrawSpeakerText(dimbg); DrawReplies(); DrawGold(); } //============================================================================ // // // //============================================================================ override void Ticker() { // [CW] Freeze the game depending on MAPINFO options. if (ConversationPauseTic < gametic && !multiplayer && !Level.no_dlg_freeze) { menuactive = Menu.On; } } } /*class Corona : Actor native { Default { RenderStyle "Add"; RenderRadius 1024.0; +NOINTERACTION +FORCEXYBILLBOARD } }*/ // Crusader ----------------------------------------------------------------- class Crusader : Actor { Default { Speed 8; Radius 40; Height 56; Mass 400; Health 400; Painchance 128; Monster; +FLOORCLIP +DONTMORPH +MISSILEMORE +INCOMBAT +NOICEDEATH +NOBLOOD MinMissileChance 120; MaxDropoffHeight 32; DropItem "EnergyPod", 256, 20; Tag "$TAG_CRUSADER"; SeeSound "crusader/sight"; PainSound "crusader/pain"; DeathSound "crusader/death"; ActiveSound "crusader/active"; Obituary "$OB_CRUSADER"; } States { Spawn: ROB2 Q 10 A_Look; Loop; See: ROB2 AABBCCDD 3 A_Chase; Loop; Missile: ROB2 E 3 Slow A_FaceTarget; ROB2 F 2 Slow Bright A_CrusaderChoose; ROB2 E 2 Slow Bright A_CrusaderSweepLeft; ROB2 F 3 Slow Bright A_CrusaderSweepLeft; ROB2 EF 2 Slow Bright A_CrusaderSweepLeft; ROB2 EFE 2 Slow Bright A_CrusaderSweepRight; ROB2 F 2 Slow A_CrusaderRefire; Loop; Pain: ROB2 D 1 Slow A_Pain; Goto See; Death: ROB2 G 3 A_Scream; ROB2 H 5 A_TossGib; ROB2 I 4 Bright A_TossGib; ROB2 J 4 Bright A_Explode(64, 64, alert:true); ROB2 K 4 Bright A_Fall; ROB2 L 4 A_Explode(64, 64, alert:true); ROB2 MN 4 A_TossGib; ROB2 O 4 A_Explode(64, 64, alert:true); ROB2 P -1 A_CrusaderDeath; Stop; } // Crusader ----------------------------------------------------------------- private bool CrusaderCheckRange () { if (reactiontime == 0 && CheckSight (target)) { return Distance2D (target) < 264.; } return false; } void A_CrusaderChoose () { if (target == null) return; if (CrusaderCheckRange ()) { A_FaceTarget (); angle -= 180./16; SpawnMissileZAimed (pos.z + 40, target, "FastFlameMissile"); } else { if (CheckMissileRange ()) { A_FaceTarget (); SpawnMissileZAimed (pos.z + 56, target, "CrusaderMissile"); angle -= 45./32; SpawnMissileZAimed (pos.z + 40, target, "CrusaderMissile"); angle += 45./16; SpawnMissileZAimed (pos.z + 40, target, "CrusaderMissile"); angle -= 45./16; reactiontime += 15; } SetState (SeeState); } } void A_CrusaderSweepLeft () { angle += 90./16; Actor misl = SpawnMissileZAimed (pos.z + 48, target, "FastFlameMissile"); if (misl != null) { misl.Vel.Z += 1; } } void A_CrusaderSweepRight () { angle -= 90./16; Actor misl = SpawnMissileZAimed (pos.z + 48, target, "FastFlameMissile"); if (misl != null) { misl.Vel.Z += 1; } } void A_CrusaderRefire () { if (target == null || target.health <= 0 || !CheckSight (target)) { SetState (SeeState); } } void A_CrusaderDeath () { if (CheckBossDeath ()) { Floor_LowerToLowest(667, 8); } } } // Fast Flame Projectile (used by Crusader) --------------------------------- class FastFlameMissile : FlameMissile { Default { Mass 50; Damage 1; Speed 35; } } // Crusader Missile --------------------------------------------------------- // This is just like the mini missile the player shoots, except it doesn't // explode when it dies, and it does slightly less damage for a direct hit. class CrusaderMissile : Actor { Default { Speed 20; Radius 10; Height 14; Damage 7; Projectile; +STRIFEDAMAGE MaxStepHeight 4; SeeSound "crusader/misl"; DeathSound "crusader/mislx"; } States { Spawn: MICR A 6 Bright A_RocketInFlight; Loop; Death: SMIS A 0 Bright A_SetRenderStyle(1, STYLE_Normal); SMIS A 5 Bright; SMIS B 5 Bright; SMIS C 4 Bright; SMIS DEFG 2 Bright; Stop; } } // Dead Crusader ------------------------------------------------------------ class DeadCrusader : Actor { States { Spawn: ROB2 N 4; ROB2 O 4; ROB2 P -1; Stop; } } /* ** **--------------------------------------------------------------------------- ** Copyright 2010-2017 Christoph Oelckers ** Copyright 2022 Ricardo Luis Vaz Silva ** ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ class CustomMessageBoxMenuBase : Menu abstract { BrokenLines mMessage; uint messageSelection; int mMouseLeft, mMouseRight, mMouseY; Font textFont, arrowFont; int destWidth, destHeight; String selector; abstract uint OptionCount(); abstract String OptionName(uint index); abstract int OptionXOffset(uint index); abstract int OptionForShortcut(int char_key, out bool activate); // -1 for no shortcut, activate = true if this executes the option immediately //============================================================================= // // // //============================================================================= virtual void Init(Menu parent, String message, bool playsound = false) { Super.Init(parent); messageSelection = 0; mMouseLeft = 140; mMouseY = 0x80000000; textFont = null; if (!generic_ui) { if (SmallFont && SmallFont.CanPrint(message) && SmallFont.CanPrint("$TXT_YES") && SmallFont.CanPrint("$TXT_NO")) textFont = SmallFont; else if (OriginalSmallFont && OriginalSmallFont.CanPrint(message) && OriginalSmallFont.CanPrint("$TXT_YES") && OriginalSmallFont.CanPrint("$TXT_NO")) textFont = OriginalSmallFont; } if (!textFont) { arrowFont = textFont = NewSmallFont; int factor = (CleanXfac+1) / 2; destWidth = screen.GetWidth() / factor; destHeight = screen.GetHeight() / factor; selector = "▶"; } else { arrowFont = ((textFont && textFont.GetGlyphHeight(0xd) > 0) ? textFont : ConFont); destWidth = CleanWidth; destHeight = CleanHeight; selector = "\xd"; } int mr1 = destWidth/2 + 10 + textFont.StringWidth(Stringtable.Localize("$TXT_YES")); int mr2 = destWidth/2 + 10 + textFont.StringWidth(Stringtable.Localize("$TXT_NO")); mMouseRight = MAX(mr1, mr2); mParentMenu = parent; mMessage = textFont.BreakLines(Stringtable.Localize(message), int(300/NotifyFontScale)); if (playsound) { MenuSound ("menu/prompt"); } } //============================================================================= // // // //============================================================================= override void Drawer () { int i; double y; let fontheight = textFont.GetHeight() * NotifyFontScale; y = destHeight / 2; int c = mMessage.Count(); y -= c * fontHeight / 2; for (i = 0; i < c; i++) { screen.DrawText (textFont, Font.CR_UNTRANSLATED, destWidth/2 - mMessage.StringWidth(i)*NotifyFontScale/2, y, mMessage.StringAt(i), DTA_VirtualWidth, destWidth, DTA_VirtualHeight, destHeight, DTA_KeepRatio, true, DTA_ScaleX, NotifyFontScale, DTA_ScaleY, NotifyFontScale); y += fontheight; } y += fontheight; mMouseY = int(y); let n = optionCount(); for(uint i = 0; i < n; i++) { screen.DrawText(textFont, messageSelection == i? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor, (destWidth / 2) + OptionXOffset(i), y + (fontheight * i), Stringtable.Localize(optionName(i)), DTA_VirtualWidth, destWidth, DTA_VirtualHeight, destHeight, DTA_KeepRatio, true, DTA_ScaleX, NotifyFontScale, DTA_ScaleY, NotifyFontScale); } if (messageSelection >= 0) { if ((MenuTime() % 8) < 6) { screen.DrawText(arrowFont, OptionMenuSettings.mFontColorSelection, (destWidth/2 - 3 - arrowFont.StringWidth(selector)) + OptionXOffset(messageSelection), y + fontheight * messageSelection, selector, DTA_VirtualWidth, destWidth, DTA_VirtualHeight, destHeight, DTA_KeepRatio, true); } } } //============================================================================= // // // //============================================================================= protected void CloseSound() { MenuSound (GetCurrentMenu() != NULL? "menu/backup" : "menu/dismiss"); } //============================================================================= // // // //============================================================================= abstract void HandleResult(int index); // -1 = escape //============================================================================= // // // //============================================================================= override bool OnUIEvent(UIEvent ev) { if (ev.type == UIEvent.Type_KeyDown) { // tolower int ch = ev.KeyChar; ch = ch >= 65 && ch <91? ch + 32 : ch; bool activate; int opt = optionForShortcut(ch,activate); if(opt >= 0){ if(activate || opt == messageSelection) { HandleResult(messageSelection); } else { messageSelection = opt; } return true; } return false; } return Super.OnUIEvent(ev); } override bool OnInputEvent(InputEvent ev) { if (ev.type == InputEvent.Type_KeyDown) { Close(); return true; } return Super.OnInputEvent(ev); } //============================================================================= // // // //============================================================================= override bool MenuEvent(int mkey, bool fromcontroller) { if (mkey == MKEY_Up) { MenuSound("menu/cursor"); if (messageSelection == 0) messageSelection = optionCount(); messageSelection--; return true; } else if (mkey == MKEY_Down) { MenuSound("menu/cursor"); messageSelection++; if (messageSelection == optionCount()) messageSelection = 0; return true; } else if (mkey == MKEY_Enter) { HandleResult(messageSelection); return true; } else if (mkey == MKEY_Back) { HandleResult(-1); return true; } return false; } //============================================================================= // // // //============================================================================= override bool MouseEvent(int type, int x, int y) { int fh = textFont.GetHeight() + 1; // convert x/y from screen to virtual coordinates, according to CleanX/Yfac use in DrawTexture x = x * destWidth / screen.GetWidth(); y = y * destHeight / screen.GetHeight(); int n = OptionCount(); if (x >= mMouseLeft && x <= mMouseRight && y >= mMouseY && y < mMouseY + (n * fh)) { messageSelection = (y - mMouseY) / fh; } if (type == MOUSE_Release) { return MenuEvent(MKEY_Enter, true); } return true; } } //=========================================================================== // // Cyberdemon // //=========================================================================== class Cyberdemon : Actor { Default { Health 4000; Radius 40; Height 110; Mass 1000; Speed 16; PainChance 20; Monster; MinMissileChance 160; +BOSS +MISSILEMORE +FLOORCLIP +NORADIUSDMG +DONTMORPH +BOSSDEATH +E2M8BOSS +E4M6BOSS SeeSound "cyber/sight"; PainSound "cyber/pain"; DeathSound "cyber/death"; ActiveSound "cyber/active"; Obituary "$OB_CYBORG"; Tag "$FN_CYBER"; } States { Spawn: CYBR AB 10 A_Look; Loop; See: CYBR A 3 A_Hoof; CYBR ABBCC 3 A_Chase; CYBR D 3 A_Metal; CYBR D 3 A_Chase; Loop; Missile: CYBR E 6 A_FaceTarget; CYBR F 12 A_CyberAttack; CYBR E 12 A_FaceTarget; CYBR F 12 A_CyberAttack; CYBR E 12 A_FaceTarget; CYBR F 12 A_CyberAttack; Goto See; Pain: CYBR G 10 A_Pain; Goto See; Death: CYBR H 10; CYBR I 10 A_Scream; CYBR JKL 10; CYBR M 10 A_NoBlocking; CYBR NO 10; CYBR P 30; CYBR P -1 A_BossDeath; Stop; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== extend class Actor { void A_CyberAttack() { if (target) { A_FaceTarget(); SpawnMissile (target, "Rocket"); } } void A_Hoof() { A_StartSound("cyber/hoof", CHAN_BODY, CHANF_DEFAULT, 1, ATTN_IDLE); A_Chase(); } } // Gibbed marine ----------------------------------------------------------- class GibbedMarine : Actor { States { Spawn: PLAY W -1; Stop; } } // Gibbed marine (extra copy) ---------------------------------------------- class GibbedMarineExtra : GibbedMarine { } // Dead marine ------------------------------------------------------------- class DeadMarine : Actor { States { Spawn: PLAY N -1; Stop; } } /* If it wasn't for Dehacked compatibility, the rest of these would be * better defined as single frame states. But since Doom reused the * dead state from the original monsters, we need to do the same. */ // Dead zombie man --------------------------------------------------------- class DeadZombieMan : ZombieMan { Default { Skip_Super; DropItem "None"; } States { Spawn: Goto Super::Death+4; } } // Dead shotgun guy -------------------------------------------------------- class DeadShotgunGuy : ShotgunGuy { Default { Skip_Super; DropItem "None"; } States { Spawn: Goto Super::Death+4; } } // Dead imp ---------------------------------------------------------------- class DeadDoomImp : DoomImp { Default { Skip_Super; } States { Spawn: Goto Super::Death+4; } } // Dead demon -------------------------------------------------------------- class DeadDemon : Demon { Default { Skip_Super; } States { Spawn: Goto Super::Death+5; } } // Dead cacodemon ---------------------------------------------------------- class DeadCacodemon : Cacodemon { Default { Skip_Super; } States { Spawn: Goto Super::Death+5; } } // Dead lost soul ---------------------------------------------------------- /* [RH] Considering that the lost soul removes itself when it dies, there * really wasn't much point in id including this thing, but they did anyway. * (There was probably a time when it stayed around after death, and this is * a holdover from that.) */ class DeadLostSoul : LostSoul { Default { Skip_Super; } States { Spawn: Goto Super::Death+5; } } // Rocks -------------------------------------------------------------------- class Rock1 : Actor { Default { +NOBLOCKMAP +DROPOFF +MISSILE +NOTELEPORT } States { Spawn: ROKK A 20; Loop; Death: ROKK A 10; Stop; } } class Rock2 : Actor { Default { +NOBLOCKMAP +DROPOFF +MISSILE +NOTELEPORT } States { Spawn: ROKK B 20; Loop; Death: ROKK B 10; Stop; } } class Rock3 : Actor { Default { +NOBLOCKMAP +DROPOFF +MISSILE +NOTELEPORT } States { Spawn: ROKK C 20; Loop; Death: ROKK C 10; Stop; } } // Dirt -------------------------------------------------------------------- class Dirt1 : Actor { Default { +NOBLOCKMAP +DROPOFF +MISSILE +NOTELEPORT } States { Spawn: ROKK D 20; Loop; Death: ROKK D 10; Stop; } } class Dirt2 : Actor { Default { +NOBLOCKMAP +DROPOFF +MISSILE +NOTELEPORT } States { Spawn: ROKK E 20; Loop; Death: ROKK E 10; Stop; } } class Dirt3 : Actor { Default { +NOBLOCKMAP +DROPOFF +MISSILE +NOTELEPORT } States { Spawn: ROKK F 20; Loop; Death: ROKK F 10; Stop; } } class Dirt4 : Actor { Default { +NOBLOCKMAP +DROPOFF +MISSILE +NOTELEPORT } States { Spawn: ROKK G 20; Loop; Death: ROKK G 10; Stop; } } class Dirt5 : Actor { Default { +NOBLOCKMAP +DROPOFF +MISSILE +NOTELEPORT } States { Spawn: ROKK H 20; Loop; Death: ROKK H 10; Stop; } } class Dirt6 : Actor { Default { +NOBLOCKMAP +DROPOFF +MISSILE +NOTELEPORT } States { Spawn: ROKK I 20; Loop; Death: ROKK I 10; Stop; } } // Stained glass ------------------------------------------------------------ class GlassShard : Actor { Default { Radius 5; Mass 5; Projectile; -ACTIVATEPCROSS -ACTIVATEIMPACT BounceType "HexenCompat"; BounceFactor 0.3; } override void Tick() { Super.Tick(); if (Vel.Z > 0 && Vel.Z < 0.5 && pos.z < floorz + 1) { Destroy (); } } } class SGShard1 : GlassShard { States { Spawn: SGSA ABCDE 4; Loop; Death: SGSA E 30; Stop; } } class SGShard2 : GlassShard { States { Spawn: SGSA FGHIJ 4; Loop; Death: SGSA J 30; Stop; } } class SGShard3 : GlassShard { States { Spawn: SGSA KLMNO 4; Loop; Death: SGSA O 30; Stop; } } class SGShard4 : GlassShard { States { Spawn: SGSA PQRST 4; Loop; Death: SGSA T 30; Stop; } } class SGShard5 : GlassShard { States { Spawn: SGSA UVWXY 4; Loop; Death: SGSA Y 30; Stop; } } class SGShard6 : GlassShard { States { Spawn: SGSB A 4; Loop; Death: SGSB A 30; Stop; } } class SGShard7 : GlassShard { States { Spawn: SGSB B 4; Loop; Death: SGSB B 30; Stop; } } class SGShard8 : GlassShard { States { Spawn: SGSB C 4; Loop; Death: SGSB C 30; Stop; } } class SGShard9 : GlassShard { States { Spawn: SGSB D 4; Loop; Death: SGSB D 30; Stop; } } class SGShard0 : GlassShard { States { Spawn: SGSB E 4; Loop; Death: SGSB E 30; Stop; } } class GlassJunk : Actor { Default { +NOCLIP +NOBLOCKMAP RenderStyle "Translucent"; Alpha 0.4; Health 3; // Number of different shards } States { // Are the first three frames used anywhere? SHAR A 128; Goto Death; SHAR B 128; Goto Death; SHAR C 128; Goto Death; Spawn: SHAR D 128; Goto Death; SHAR E 128; Goto Death; SHAR F 128; Goto Death; Death: "----" A 1 A_FadeOut(0.03); Wait; } } class Decal : Actor { native void SpawnDecal(); override void BeginPlay() { Super.BeginPlay(); SpawnDecal(); Destroy(); } } // This file defines all empty placeholder content for recent Dehacked extensions. class Deh_Actor_145 : Actor {} class Deh_Actor_146 : Actor {} class Deh_Actor_147 : Actor {} class Deh_Actor_148 : Actor {} class Deh_Actor_149 : Actor {} class Deh_Actor_150 : Actor {} class Deh_Actor_151 : Actor {} class Deh_Actor_152 : Actor {} class Deh_Actor_153 : Actor {} class Deh_Actor_154 : Actor {} class Deh_Actor_155 : Actor {} class Deh_Actor_156 : Actor {} class Deh_Actor_157 : Actor {} class Deh_Actor_158 : Actor {} class Deh_Actor_159 : Actor {} class Deh_Actor_160 : Actor {} class Deh_Actor_161 : Actor {} class Deh_Actor_162 : Actor {} class Deh_Actor_163 : Actor {} class Deh_Actor_164 : Actor {} class Deh_Actor_165 : Actor {} class Deh_Actor_166 : Actor {} class Deh_Actor_167 : Actor {} class Deh_Actor_168 : Actor {} class Deh_Actor_169 : Actor {} class Deh_Actor_170 : Actor {} class Deh_Actor_171 : Actor {} class Deh_Actor_172 : Actor {} class Deh_Actor_173 : Actor {} class Deh_Actor_174 : Actor {} class Deh_Actor_175 : Actor {} class Deh_Actor_176 : Actor {} class Deh_Actor_177 : Actor {} class Deh_Actor_178 : Actor {} class Deh_Actor_179 : Actor {} class Deh_Actor_180 : Actor {} class Deh_Actor_181 : Actor {} class Deh_Actor_182 : Actor {} class Deh_Actor_183 : Actor {} class Deh_Actor_184 : Actor {} class Deh_Actor_185 : Actor {} class Deh_Actor_186 : Actor {} class Deh_Actor_187 : Actor {} class Deh_Actor_188 : Actor {} class Deh_Actor_189 : Actor {} class Deh_Actor_190 : Actor {} class Deh_Actor_191 : Actor {} class Deh_Actor_192 : Actor {} class Deh_Actor_193 : Actor {} class Deh_Actor_194 : Actor {} class Deh_Actor_195 : Actor {} class Deh_Actor_196 : Actor {} class Deh_Actor_197 : Actor {} class Deh_Actor_198 : Actor {} class Deh_Actor_199 : Actor {} class Deh_Actor_200 : Actor {} class Deh_Actor_201 : Actor {} class Deh_Actor_202 : Actor {} class Deh_Actor_203 : Actor {} class Deh_Actor_204 : Actor {} class Deh_Actor_205 : Actor {} class Deh_Actor_206 : Actor {} class Deh_Actor_207 : Actor {} class Deh_Actor_208 : Actor {} class Deh_Actor_209 : Actor {} class Deh_Actor_210 : Actor {} class Deh_Actor_211 : Actor {} class Deh_Actor_212 : Actor {} class Deh_Actor_213 : Actor {} class Deh_Actor_214 : Actor {} class Deh_Actor_215 : Actor {} class Deh_Actor_216 : Actor {} class Deh_Actor_217 : Actor {} class Deh_Actor_218 : Actor {} class Deh_Actor_219 : Actor {} class Deh_Actor_220 : Actor {} class Deh_Actor_221 : Actor {} class Deh_Actor_222 : Actor {} class Deh_Actor_223 : Actor {} class Deh_Actor_224 : Actor {} class Deh_Actor_225 : Actor {} class Deh_Actor_226 : Actor {} class Deh_Actor_227 : Actor {} class Deh_Actor_228 : Actor {} class Deh_Actor_229 : Actor {} class Deh_Actor_230 : Actor {} class Deh_Actor_231 : Actor {} class Deh_Actor_232 : Actor {} class Deh_Actor_233 : Actor {} class Deh_Actor_234 : Actor {} class Deh_Actor_235 : Actor {} class Deh_Actor_236 : Actor {} class Deh_Actor_237 : Actor {} class Deh_Actor_238 : Actor {} class Deh_Actor_239 : Actor {} class Deh_Actor_240 : Actor {} class Deh_Actor_241 : Actor {} class Deh_Actor_242 : Actor {} class Deh_Actor_243 : Actor {} class Deh_Actor_244 : Actor {} class Deh_Actor_245 : Actor {} class Deh_Actor_246 : Actor {} class Deh_Actor_247 : Actor {} class Deh_Actor_248 : Actor {} class Deh_Actor_249 : Actor {} class Deh_Actor_250 : Actor { States { Deh: PLAY O 5; PLAY P 5 A_SkullPop; PLAY Q 5 A_Fall; PLAY RSTUV 5; PLAY W -1; // 1084 TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; // 1600 TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; // 2100 TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; // 2600 TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; // 3100 TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; // 3600 TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; TNT1 A -1; Wait; // 4000 DeclareSprites: SP00 A 0; SP01 A 0; SP02 A 0; SP03 A 0; SP04 A 0; SP05 A 0; SP06 A 0; SP07 A 0; SP08 A 0; SP09 A 0; SP10 A 0; SP11 A 0; SP12 A 0; SP13 A 0; SP14 A 0; SP15 A 0; SP16 A 0; SP17 A 0; SP18 A 0; SP19 A 0; SP20 A 0; SP21 A 0; SP22 A 0; SP23 A 0; SP24 A 0; SP25 A 0; SP26 A 0; SP27 A 0; SP28 A 0; SP29 A 0; SP30 A 0; SP31 A 0; SP32 A 0; SP33 A 0; SP34 A 0; SP35 A 0; SP36 A 0; SP37 A 0; SP38 A 0; SP39 A 0; SP40 A 0; SP41 A 0; SP42 A 0; SP43 A 0; SP44 A 0; SP45 A 0; SP46 A 0; SP47 A 0; SP48 A 0; SP49 A 0; SP50 A 0; SP51 A 0; SP52 A 0; SP53 A 0; SP54 A 0; SP55 A 0; SP56 A 0; SP57 A 0; SP58 A 0; SP59 A 0; SP60 A 0; SP61 A 0; SP62 A 0; SP63 A 0; SP64 A 0; SP65 A 0; SP66 A 0; SP67 A 0; SP68 A 0; SP69 A 0; SP70 A 0; SP71 A 0; SP72 A 0; SP73 A 0; SP74 A 0; SP75 A 0; SP76 A 0; SP77 A 0; SP78 A 0; SP79 A 0; SP80 A 0; SP81 A 0; SP82 A 0; SP83 A 0; SP84 A 0; SP85 A 0; SP86 A 0; SP87 A 0; SP88 A 0; SP89 A 0; SP90 A 0; SP91 A 0; SP92 A 0; SP93 A 0; SP94 A 0; SP95 A 0; SP96 A 0; SP97 A 0; SP98 A 0; SP99 A 0; Stop; } } //=========================================================================== // // Pink Demon // //=========================================================================== class Demon : Actor { Default { Health 150; PainChance 180; Speed 10; Radius 30; Height 56; Mass 400; Monster; +FLOORCLIP SeeSound "demon/sight"; AttackSound "demon/melee"; PainSound "demon/pain"; DeathSound "demon/death"; ActiveSound "demon/active"; Obituary "$OB_DEMONHIT"; Tag "$FN_DEMON"; } States { Spawn: SARG AB 10 A_Look; Loop; See: SARG AABBCCDD 2 Fast A_Chase; Loop; Melee: SARG EF 8 Fast A_FaceTarget; SARG G 8 Fast A_SargAttack; Goto See; Pain: SARG H 2 Fast; SARG H 2 Fast A_Pain; Goto See; Death: SARG I 8; SARG J 8 A_Scream; SARG K 4; SARG L 4 A_NoBlocking; SARG M 4; SARG N -1; Stop; Raise: SARG N 5; SARG MLKJI 5; Goto See; } } //=========================================================================== // // Spectre // //=========================================================================== class Spectre : Demon { Default { +SHADOW RenderStyle "OptFuzzy"; Alpha 0.5; SeeSound "spectre/sight"; AttackSound "spectre/melee"; PainSound "spectre/pain"; DeathSound "spectre/death"; ActiveSound "spectre/active"; Obituary "$OB_SPECTREHIT"; Tag "$FN_SPECTRE"; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== extend class Actor { void A_SargAttack() { let targ = target; if (targ && CheckMeleeRange()) { int damage = random[pr_sargattack](1, 10) * 4; int newdam = targ.DamageMobj (self, self, damage, "Melee"); targ.TraceBleed (newdam > 0 ? newdam : damage, self); } } } // Demon, type 1 (green, like D'Sparil's) ----------------------------------- class Demon1 : Actor { Default { Health 250; Painchance 50; Speed 13; Radius 32; Height 64; Mass 220; Monster; +TELESTOMP +FLOORCLIP SeeSound "DemonSight"; AttackSound "DemonAttack"; PainSound "DemonPain"; DeathSound "DemonDeath"; ActiveSound "DemonActive"; Obituary "$OB_DEMON1"; HitObituary "$OB_DEMON1HIT"; Tag "$FN_DEMON1"; } const ChunkFlags = SXF_TRANSFERTRANSLATION | SXF_ABSOLUTEVELOCITY; States { Spawn: DEMN AA 10 A_Look; Loop; See: DEMN ABCD 4 A_Chase; Loop; Pain: DEMN E 4; DEMN E 4 A_Pain; Goto See; Melee: DEMN E 6 A_FaceTarget; DEMN F 8 A_FaceTarget; DEMN G 6 A_CustomMeleeAttack(random[DemonAttack1](1,8)*2); Goto See; Missile: DEMN E 5 A_FaceTarget; DEMN F 6 A_FaceTarget; DEMN G 5 A_SpawnProjectile("Demon1FX1", 62, 0); Goto See; Death: DEMN HI 6; DEMN J 6 A_Scream; DEMN K 6 A_NoBlocking; DEMN L 6 A_QueueCorpse; DEMN MNO 6; DEMN P -1; Stop; XDeath: DEMN H 6; DEMN I 6 { static const class chunks[] = { "Demon1Chunk1", "Demon1Chunk2", "Demon1Chunk3", "Demon1Chunk4", "Demon1Chunk5" }; for(int i = 0; i < 5; i++) A_SpawnItemEx(chunks[i], 0,0,45, frandom[DemonChunks](1,4.984375)*cos(Angle+90), frandom[DemonChunks](1,4.984375)*sin(Angle+90), 8, 90, ChunkFlags); } Goto Death+2; Ice: DEMN Q 5 A_FreezeDeath; DEMN Q 1 A_FreezeDeathChunks; Wait; } } // Demon, type 1, mashed ---------------------------------------------------- class Demon1Mash : Demon1 { Default { +NOBLOOD +BLASTED -TELESTOMP +NOICEDEATH RenderStyle "Translucent"; Alpha 0.4; } States { Death: XDeath: Ice: Stop; } } // Demon chunk, base class -------------------------------------------------- class DemonChunk : Actor { Default { Radius 5; Height 5; +NOBLOCKMAP +DROPOFF +MISSILE +CORPSE +FLOORCLIP +NOTELEPORT } } // Demon, type 1, chunk 1 --------------------------------------------------- class Demon1Chunk1 : DemonChunk { States { Spawn: DEMA A 4; DEMA A 10 A_QueueCorpse; DEMA A 20; Wait; Death: DEMA A -1; Stop; } } // Demon, type 1, chunk 2 --------------------------------------------------- class Demon1Chunk2 : DemonChunk { States { Spawn: DEMB A 4; DEMB A 10 A_QueueCorpse; DEMB A 20; Wait; Death: DEMB A -1; Stop; } } class Demon1Chunk3 : DemonChunk { States { Spawn: DEMC A 4; DEMC A 10 A_QueueCorpse; DEMC A 20; Wait; Death: DEMC A -1; Stop; } } // Demon, type 1, chunk 4 --------------------------------------------------- class Demon1Chunk4 : DemonChunk { States { Spawn: DEMD A 4; DEMD A 10 A_QueueCorpse; DEMD A 20; Wait; Death: DEMD A -1; Stop; } } // Demon, type 1, chunk 5 --------------------------------------------------- class Demon1Chunk5 : DemonChunk { States { Spawn: DEME A 4; DEME A 10 A_QueueCorpse; DEME A 20; Wait; Death: DEME A -1; Stop; } } // Demon, type 1, projectile ------------------------------------------------ class Demon1FX1 : Actor { Default { Speed 15; Radius 10; Height 6; Damage 5; DamageType "Fire"; Projectile; +SPAWNSOUNDSOURCE +ZDOOMTRANS RenderStyle "Add"; SeeSound "DemonMissileFire"; DeathSound "DemonMissileExplode"; } States { Spawn: DMFX ABC 4 Bright; Loop; Death: DMFX DE 4 Bright; DMFX FGH 3 Bright; Stop; } } // Demon, type 2 (brown) ---------------------------------------------------- class Demon2 : Demon1 { Default { Obituary "$OB_DEMON2"; HitObituary "$OB_DEMON2HIT"; Species "Demon2"; } States { Spawn: DEM2 AA 10 A_Look; Loop; See: DEM2 ABCD 4 A_Chase; Loop; Pain: DEM2 E 4; DEM2 E 4 A_Pain; Goto See; Melee: DEM2 E 6 A_FaceTarget; DEM2 F 8 A_FaceTarget; DEM2 G 6 A_CustomMeleeAttack(random[DemonAttack1](1,8)*2); Goto See; Missile: DEM2 E 5 A_FaceTarget; DEM2 F 6 A_FaceTarget; DEM2 G 5 A_SpawnProjectile("Demon2FX1", 62, 0); Goto See; Death: DEM2 HI 6; DEM2 J 6 A_Scream; DEM2 K 6 A_NoBlocking; DEM2 L 6 A_QueueCorpse; DEM2 MNO 6; DEM2 P -1; Stop; XDeath: DEM2 H 6; DEM2 I 6 { static const class chunks[] = { "Demon2Chunk1", "Demon2Chunk2", "Demon2Chunk3", "Demon2Chunk4", "Demon2Chunk5" }; for(int i = 0; i < 5; i++) A_SpawnItemEx(chunks[i], 0,0,45, frandom[DemonChunks](1,4.984375)*cos(Angle+90), frandom[DemonChunks](1,4.984375)*sin(Angle+90), 8, 90, ChunkFlags); } Goto Death+2; } } // Demon, type 2, mashed ---------------------------------------------------- class Demon2Mash : Demon2 { Default { +NOBLOOD +BLASTED -TELESTOMP +NOICEDEATH RenderStyle "Translucent"; Alpha 0.4; } States { Death: XDeath: Ice: Stop; } } // Demon, type 2, chunk 1 --------------------------------------------------- class Demon2Chunk1 : DemonChunk { States { Spawn: DMBA A 4; DMBA A 10 A_QueueCorpse; DMBA A 20; Wait; Death: DMBA A -1; Stop; } } // Demon, type 2, chunk 2 --------------------------------------------------- class Demon2Chunk2 : DemonChunk { States { Spawn: DMBB A 4; DMBB A 10 A_QueueCorpse; DMBB A 20; Wait; Death: DMBB A -1; Stop; } } // Demon, type 2, chunk 3 --------------------------------------------------- class Demon2Chunk3 : DemonChunk { States { Spawn: DMBC A 4; DMBC A 10 A_QueueCorpse; DMBC A 20; Wait; Death: DMBC A -1; Stop; } } // Demon, type 2, chunk 4 --------------------------------------------------- class Demon2Chunk4 : DemonChunk { States { Spawn: DMBD A 4; DMBD A 10 A_QueueCorpse; DMBD A 20; Wait; Death: DMBD A -1; Stop; } } // Demon, type 2, chunk 5 --------------------------------------------------- class Demon2Chunk5 : DemonChunk { States { Spawn: DMBE A 4; DMBE A 10 A_QueueCorpse; DMBE A 20; Wait; Death: DMBE A -1; Stop; } } // Demon, type 2, projectile ------------------------------------------------ class Demon2FX1 : Actor { Default { Speed 15; Radius 10; Height 6; Damage 5; DamageType "Fire"; Projectile; +SPAWNSOUNDSOURCE +ZDOOMTRANS RenderStyle "Add"; SeeSound "DemonMissileFire"; DeathSound "DemonMissileExplode"; } States { Spawn: D2FX ABCDEF 4 Bright; Loop; Death: D2FX GHIJ 4 Bright; D2FX KL 3 Bright; Stop; } } struct HealthGroup native play { deprecated("3.8", "Use Level.FindHealthGroup() instead") static clearscope HealthGroup Find(int id) { return level.FindHealthGroup(id); } readonly int id; readonly int health; readonly Array sectors; readonly Array lines; native void SetHealth(int newhealth); } enum SectorPart { SECPART_None = -1, SECPART_Floor = 0, SECPART_Ceiling = 1, SECPART_3D = 2 } struct Destructible native play { static native void DamageSector(Sector sec, Actor source, int damage, Name damagetype, SectorPart part, vector3 position, bool isradius); static native void DamageLinedef(Line def, Actor source, int damage, Name damagetype, int side, vector3 position, bool isradius); static native void GeometryLineAttack(TraceResults trace, Actor thing, int damage, Name damagetype); static native void GeometryRadiusAttack(Actor bombspot, Actor bombsource, int bombdamage, int bombdistance, Name damagetype, int fulldamagedistance); static native bool ProjectileHitLinedef(Actor projectile, Line def); static native bool ProjectileHitPlane(Actor projectile, SectorPart part); static clearscope native bool CheckLinedefVulnerable(Line def, int side, SectorPart part); static clearscope native bool CheckSectorVulnerable(Sector sec, SectorPart part); } /** * Dictionary provides key-value storage. * * Both keys and values are strings. * * @note keys are case-sensitive. */ class Dictionary { native static Dictionary Create(); native void Insert(String key, String value); native void Remove(String key); /** * Returns the value for the specified key. */ native String At(String key) const; /** * Deserializes a dictionary from a string. * * @param s serialized string, must be either empty or returned from ToString(). */ native static Dictionary FromString(String s); /** * Serializes a dictionary to a string. */ native String ToString() const; } /** * Provides iterating over a Dictionary. * * Order is not specified. * * DictionaryIterator is not serializable. To make DictionaryIterator a class * member, use `transient` keyword. */ class DictionaryIterator { native static DictionaryIterator Create(Dictionary dict); /** * Returns false if there are no more entries in the dictionary. * Otherwise, returns true. * * While it returns true, get key and value for the current entry * with Key() and Value() functions. */ native bool Next(); /** * Returns the key for the current dictionary entry. * Do not call this function before calling Next(). */ native String Key() const; /** * Returns the value for the current dictionary entry. * Do not call this function before calling Next(). */ native String Value() const; } class MBFHelperDog : Actor { default { Health 500; Speed 10; PainChance 180; Radius 12; Height 28; Mass 100; Monster; +JUMPDOWN ActiveSound "dog/active"; AttackSound "dog/attack"; DeathSound "dog/death"; PainSound "dog/pain"; SeeSound "dog/sight"; Obituary "$OB_DOG"; Tag "$FN_DOG"; } States { Spawn: DOGS AB 10 A_Look; Loop; See: DOGS AABBCCDD 2 A_Chase; Loop; Melee: DOGS EF 8 A_FaceTarget; DOGS G 8 A_SargAttack; Goto See; Pain: DOGS H 2; DOGS H 2 A_Pain; Goto See; Death: DOGS I 8; DOGS J 8 A_Scream; DOGS K 4; DOGS L 4 A_Fall; DOGS M 4; DOGS N -1; Raise: DOGS NMLKJI 5; Goto See; } } // Clip -------------------------------------------------------------------- class Clip : Ammo { Default { Inventory.PickupMessage "$GOTCLIP"; Inventory.Amount 10; Inventory.MaxAmount 200; Ammo.BackpackAmount 10; Ammo.BackpackMaxAmount 400; Inventory.Icon "CLIPA0"; Tag "$AMMO_CLIP"; } States { Spawn: CLIP A -1; Stop; } } // Clip box ---------------------------------------------------------------- class ClipBox : Clip { Default { Inventory.PickupMessage "$GOTCLIPBOX"; Inventory.Amount 50; } States { Spawn: AMMO A -1; Stop; } } // Rocket ------------------------------------------------------------------ class RocketAmmo : Ammo { Default { Inventory.PickupMessage "$GOTROCKET"; Inventory.Amount 1; Inventory.MaxAmount 50; Ammo.BackpackAmount 1; Ammo.BackpackMaxAmount 100; Inventory.Icon "ROCKA0"; Tag "$AMMO_ROCKETS"; } States { Spawn: ROCK A -1; Stop; } } // Rocket box -------------------------------------------------------------- class RocketBox : RocketAmmo { Default { Inventory.PickupMessage "$GOTROCKBOX"; Inventory.Amount 5; } States { Spawn: BROK A -1; Stop; } } // Cell -------------------------------------------------------------------- class Cell : Ammo { Default { Inventory.PickupMessage "$GOTCELL"; Inventory.Amount 20; Inventory.MaxAmount 300; Ammo.BackpackAmount 20; Ammo.BackpackMaxAmount 600; Inventory.Icon "CELLA0"; Tag "$AMMO_CELLS"; } States { Spawn: CELL A -1; Stop; } } // Cell pack --------------------------------------------------------------- class CellPack : Cell { Default { Inventory.PickupMessage "$GOTCELLBOX"; Inventory.Amount 100; } States { Spawn: CELP A -1; Stop; } } // Shells ------------------------------------------------------------------ class Shell : Ammo { Default { Inventory.PickupMessage "$GOTSHELLS"; Inventory.Amount 4; Inventory.MaxAmount 50; Ammo.BackpackAmount 4; Ammo.BackpackMaxAmount 100; Inventory.Icon "SHELA0"; Tag "$AMMO_SHELLS"; } States { Spawn: SHEL A -1; Stop; } } // Shell box --------------------------------------------------------------- class ShellBox : Shell { Default { Inventory.PickupMessage "$GOTSHELLBOX"; Inventory.Amount 20; } States { Spawn: SBOX A -1; Stop; } } // Backpack --------------------------------------------------------------- class Backpack : BackpackItem { Default { Height 26; Inventory.PickupMessage "$GOTBACKPACK"; } States { Spawn: BPAK A -1; Stop; } } // Armor bonus -------------------------------------------------------------- class ArmorBonus : BasicArmorBonus { Default { Radius 20; Height 16; Inventory.Pickupmessage "$GOTARMBONUS"; Inventory.Icon "BON2A0"; Armor.Savepercent 33.335; Armor.Saveamount 1; Armor.Maxsaveamount 200; +COUNTITEM +INVENTORY.ALWAYSPICKUP } States { Spawn: BON2 ABCDCB 6; loop; } } // Green armor -------------------------------------------------------------- class GreenArmor : BasicArmorPickup { Default { Radius 20; Height 16; Inventory.Pickupmessage "$GOTARMOR"; Inventory.Icon "ARM1A0"; Armor.SavePercent 33.335; Armor.SaveAmount 100; } States { Spawn: ARM1 A 6; ARM1 B 7 bright; loop; } } // Blue armor --------------------------------------------------------------- class BlueArmor : BasicArmorPickup { Default { Radius 20; Height 16; Inventory.Pickupmessage "$GOTMEGA"; Inventory.Icon "ARM2A0"; Armor.Savepercent 50; Armor.Saveamount 200; } States { Spawn: ARM2 A 6; ARM2 B 6 bright; loop; } } // Invulnerability Sphere --------------------------------------------------- class InvulnerabilitySphere : PowerupGiver { Default { +COUNTITEM +INVENTORY.AUTOACTIVATE +INVENTORY.ALWAYSPICKUP +INVENTORY.BIGPOWERUP Inventory.MaxAmount 0; Powerup.Type "PowerInvulnerable"; Powerup.Color "InverseMap"; Inventory.PickupMessage "$GOTINVUL"; } States { Spawn: PINV ABCD 6 Bright; Loop; } } // Soulsphere -------------------------------------------------------------- class Soulsphere : Health { Default { +COUNTITEM; +INVENTORY.AUTOACTIVATE; +INVENTORY.ALWAYSPICKUP; +INVENTORY.FANCYPICKUPSOUND; Inventory.Amount 100; Inventory.MaxAmount 200; Inventory.PickupMessage "$GOTSUPER"; Inventory.PickupSound "misc/p_pkup"; } States { Spawn: SOUL ABCDCB 6 Bright; Loop; } } // Mega sphere -------------------------------------------------------------- class MegasphereHealth : Health // for manipulation by Dehacked { Default { Inventory.Amount 200; Inventory.MaxAmount 200; +INVENTORY.ALWAYSPICKUP } } // DeHackEd can only modify the blue armor's type, not the megasphere's. class BlueArmorForMegasphere : BlueArmor { Default { Armor.SavePercent 50; Armor.SaveAmount 200; } } class Megasphere : CustomInventory { Default { +COUNTITEM +INVENTORY.ALWAYSPICKUP +INVENTORY.ISHEALTH +INVENTORY.ISARMOR Inventory.PickupMessage "$GOTMSPHERE"; Inventory.PickupSound "misc/p_pkup"; } States { Spawn: MEGA ABCD 6 BRIGHT; Loop; Pickup: TNT1 A 0 A_GiveInventory("BlueArmorForMegasphere", 1); TNT1 A 0 A_GiveInventory("MegasphereHealth", 1); Stop; } } // Invisibility ------------------------------------------------------------- class BlurSphere : PowerupGiver { Default { +COUNTITEM +VISIBILITYPULSE +ZDOOMTRANS +INVENTORY.AUTOACTIVATE +INVENTORY.ALWAYSPICKUP +INVENTORY.BIGPOWERUP Inventory.MaxAmount 0; Powerup.Type "PowerInvisibility"; RenderStyle "Translucent"; Inventory.PickupMessage "$GOTINVIS"; } States { Spawn: PINS ABCD 6 Bright; Loop; } } // Radiation suit (aka iron feet) ------------------------------------------- class RadSuit : PowerupGiver { Default { Height 46; +INVENTORY.AUTOACTIVATE +INVENTORY.ALWAYSPICKUP Inventory.MaxAmount 0; Inventory.PickupMessage "$GOTSUIT"; Powerup.Type "PowerIronFeet"; } States { Spawn: SUIT A -1 Bright; Stop; } } // infrared ----------------------------------------------------------------- class Infrared : PowerupGiver { Default { +COUNTITEM +INVENTORY.AUTOACTIVATE +INVENTORY.ALWAYSPICKUP Inventory.MaxAmount 0; Powerup.Type "PowerLightAmp"; Inventory.PickupMessage "$GOTVISOR"; } States { Spawn: PVIS A 6 Bright; PVIS B 6; Loop; } } // Allmap ------------------------------------------------------------------- class Allmap : MapRevealer { Default { +COUNTITEM +INVENTORY.FANCYPICKUPSOUND +INVENTORY.ALWAYSPICKUP Inventory.MaxAmount 0; Inventory.PickupSound "misc/p_pkup"; Inventory.PickupMessage "$GOTMAP"; } States { Spawn: PMAP ABCDCB 6 Bright; Loop; } } // Berserk ------------------------------------------------------------------ class Berserk : CustomInventory { Default { +COUNTITEM +INVENTORY.ALWAYSPICKUP +INVENTORY.ISHEALTH Inventory.PickupMessage "$GOTBERSERK"; Inventory.PickupSound "misc/p_pkup"; } States { Spawn: PSTR A -1 Bright; Stop; Pickup: TNT1 A 0 A_GiveInventory("PowerStrength"); TNT1 A 0 HealThing(100, 0); TNT1 A 0 A_SelectWeapon("Fist"); Stop; } } extend struct _ { native readonly Array > AllActorClasses; native readonly Array<@PlayerClass> PlayerClasses; native readonly Array<@PlayerSkin> PlayerSkins; native readonly Array<@Team> Teams; native readonly Array<@TerrainDef> Terrains; native int validcount; native play @DehInfo deh; native readonly bool automapactive; native readonly TextureID skyflatnum; native readonly int gametic; native readonly int Net_Arbitrator; native ui BaseStatusBar StatusBar; native readonly Weapon WP_NOCHANGE; deprecated("3.8", "Use Actor.isFrozen() or Level.isFrozen() instead") native readonly bool globalfreeze; native int LocalViewPitch; // sandbox state in multi-level setups: native play @PlayerInfo players[MAXPLAYERS]; native readonly bool playeringame[MAXPLAYERS]; native play LevelLocals Level; } extend struct TexMan { native static void SetCameraToTexture(Actor viewpoint, String texture, double fov); native static void SetCameraTextureAspectRatio(String texture, double aspectScale, bool useTextureRatio = true); deprecated("3.8", "Use Level.ReplaceTextures() instead") static void ReplaceTextures(String from, String to, int flags) { level.ReplaceTextures(from, to, flags); } } extend struct Screen { native static void DrawFrame(int x, int y, int w, int h); // This is a leftover of the abandoned Inventory.DrawPowerup method. deprecated("2.5", "Use StatusBar.DrawTexture() instead") static ui void DrawHUDTexture(TextureID tex, double x, double y) { statusBar.DrawTexture(tex, (x, y), BaseStatusBar.DI_SCREEN_RIGHT_TOP, 1., (32, 32)); } } extend struct Console { native static void MidPrint(Font fontname, string textlabel, bool bold = false); } extend struct Translation { Color colors[256]; native int AddTranslation(); native static bool SetPlayerTranslation(int group, int num, int plrnum, PlayerClass pclass); native static int GetID(Name transname); } // This is needed because Actor contains a field named 'translation' which shadows the above. struct Translate version("4.5") { static int MakeID(int group, int num) { return (group << 16) + num; } static bool SetPlayerTranslation(int group, int num, int plrnum, PlayerClass pclass) { return Translation.SetPlayerTranslation(group, num, plrnum, pclass); } static int GetID(Name transname) { return Translation.GetID(transname); } } struct DamageTypeDefinition native { native static bool IgnoreArmor(Name type); } extend struct CVar { native static CVar GetCVar(Name name, PlayerInfo player = null); } extend struct GameInfoStruct { // will be extended as needed. native Name backpacktype; native double Armor2Percent; native String ArmorIcon1; native String ArmorIcon2; native bool norandomplayerclass; native Array infoPages; native GIFont mStatscreenMapNameFont; native GIFont mStatscreenEnteringFont; native GIFont mStatscreenFinishedFont; native GIFont mStatscreenContentFont; native GIFont mStatscreenAuthorFont; native double gibfactor; native bool intermissioncounter; native Color defaultbloodcolor; native double telefogheight; native int defKickback; native int defaultdropstyle; native TextureID healthpic; native TextureID berserkpic; native double normforwardmove[2]; native double normsidemove[2]; native bool mHideParTimes; } extend class Object { private native static Object BuiltinNewDoom(Class cls, int outerclass, int compatibility); private native static int BuiltinCallLineSpecial(int special, Actor activator, int arg1, int arg2, int arg3, int arg4, int arg5); // These really should be global functions... native static String G_SkillName(); native static int G_SkillPropertyInt(int p); native static double G_SkillPropertyFloat(int p); deprecated("3.8", "Use Level.PickDeathMatchStart() instead") static vector3, int G_PickDeathmatchStart() { let [a,b] = level.PickDeathmatchStart(); return a, b; } deprecated("3.8", "Use Level.PickPlayerStart() instead") static vector3, int G_PickPlayerStart(int pnum, int flags = 0) { let [a,b] = level.PickPlayerStart(pnum, flags); return a, b; } deprecated("4.3", "Use S_StartSound() instead") native static void S_Sound (Sound sound_id, int channel, float volume = 1, float attenuation = ATTN_NORM, float pitch = 0.0, float startTime = 0.0); native static void S_StartSound (Sound sound_id, int channel, int flags = 0, float volume = 1, float attenuation = ATTN_NORM, float pitch = 0.0, float startTime = 0.0); native static void S_PauseSound (bool notmusic, bool notsfx); native static void S_ResumeSound (bool notsfx); native static bool S_ChangeMusic(String music_name, int order = 0, bool looping = true, bool force = false); native static float S_GetLength(Sound sound_id); native static void MarkSound(Sound snd); native static uint BAM(double angle); native static void SetMusicVolume(float vol); } class Thinker : Object native play { enum EStatnums { // Thinkers that don't actually think STAT_INFO, // An info queue STAT_DECAL, // A decal STAT_AUTODECAL, // A decal that can be automatically deleted STAT_CORPSEPOINTER, // An entry in Hexen's corpse queue STAT_TRAVELLING, // An actor temporarily travelling to a new map STAT_STATIC, // Thinkers that do think STAT_FIRST_THINKING=32, STAT_SCROLLER=STAT_FIRST_THINKING, // A DScroller thinker STAT_PLAYER, // A player actor STAT_BOSSTARGET, // A boss brain target STAT_LIGHTNING, // The lightning thinker STAT_DECALTHINKER, // An object that thinks for a decal STAT_INVENTORY, // An inventory item STAT_LIGHT, // A sector light effect STAT_LIGHTTRANSFER, // A sector light transfer. These must be ticked after the light effects. STAT_EARTHQUAKE, // Earthquake actors STAT_MAPMARKER, // Map marker actors STAT_DLIGHT, // Dynamic lights STAT_USER = 70, STAT_USER_MAX = 90, STAT_DEFAULT = 100, // Thinkers go here unless specified otherwise. STAT_SECTOREFFECT, // All sector effects that cause floor and ceiling movement STAT_ACTORMOVER, // actor movers STAT_SCRIPTS, // The ACS thinker. This is to ensure that it can't tick before all actors called PostBeginPlay STAT_BOT, // Bot thinker MAX_STATNUM = 127 } native LevelLocals Level; virtual native void Tick(); virtual native void PostBeginPlay(); native void ChangeStatNum(int stat); static clearscope int Tics2Seconds(int tics) { return int(tics / TICRATE); } } class ThinkerIterator : Object native { native static ThinkerIterator Create(class type = "Actor", int statnum=Thinker.MAX_STATNUM+1); native Thinker Next(bool exact = false); native void Reinit(); } class ActorIterator : Object native { deprecated("3.8", "Use Level.CreateActorIterator() instead") static ActorIterator Create(int tid, class type = "Actor") { return level.CreateActorIterator(tid, type); } native Actor Next(); native void Reinit(); } class BlockThingsIterator : Object native { native Actor thing; native Vector3 position; native int portalflags; native static BlockThingsIterator Create(Actor origin, double checkradius = -1, bool ignorerestricted = false); native static BlockThingsIterator CreateFromPos(double checkx, double checky, double checkz, double checkh, double checkradius, bool ignorerestricted); native bool Next(); } class BlockLinesIterator : Object native { native Line CurLine; native Vector3 position; native int portalflags; native static BlockLinesIterator Create(Actor origin, double checkradius = -1); native static BlockLinesIterator CreateFromPos(Vector3 pos, double checkh, double checkradius, Sector sec = null); native bool Next(); } enum ETraceStatus { TRACE_Stop, // stop the trace, returning this hit TRACE_Continue, // continue the trace, returning this hit if there are none further along TRACE_Skip, // continue the trace; do not return this hit TRACE_Abort // stop the trace, returning no hits } enum ETraceFlags { TRACE_NoSky = 0x0001, // Hitting the sky returns TRACE_HitNone //TRACE_PCross = 0x0002, // Trigger SPAC_PCROSS lines //TRACE_Impact = 0x0004, // Trigger SPAC_IMPACT lines TRACE_PortalRestrict = 0x0008, // Cannot go through portals without a static link offset. TRACE_ReportPortals = 0x0010, // Report any portal crossing to the TraceCallback //TRACE_3DCallback = 0x0020, // [ZZ] use TraceCallback to determine whether we need to go through a line to do 3D floor check, or not. without this, only line flag mask is used TRACE_HitSky = 0x0040 // Hitting the sky returns TRACE_HasHitSky } enum ETraceResult { TRACE_HitNone, TRACE_HitFloor, TRACE_HitCeiling, TRACE_HitWall, TRACE_HitActor, TRACE_CrossingPortal, TRACE_HasHitSky } enum ELineTier { TIER_Middle, TIER_Upper, TIER_Lower, TIER_FFloor } struct TraceResults native { native Sector HitSector; // originally called "Sector". cannot be named like this in ZScript. native TextureID HitTexture; native vector3 HitPos; native vector3 HitVector; native vector3 SrcFromTarget; native double SrcAngleFromTarget; native double Distance; native double Fraction; native Actor HitActor; // valid if hit an actor. // originally called "Actor". native Line HitLine; // valid if hit a line // originally called "Line". native uint8 Side; native uint8 Tier; // see Tracer.ELineTier native bool unlinked; // passed through a portal without static offset. native ETraceResult HitType; native F3DFloor ffloor; native Sector CrossedWater; // For Boom-style, Transfer_Heights-based deep water native vector3 CrossedWaterPos; // remember the position so that we can use it for spawning the splash native F3DFloor Crossed3DWater; // For 3D floor-based deep water native vector3 Crossed3DWaterPos; } class LineTracer : Object native { native @TraceResults Results; native bool Trace(vector3 start, Sector sec, vector3 direction, double maxDist, ETraceFlags traceFlags, /* Line::ELineFlags */ uint wallMask = 0xFFFFFFFF, bool ignoreAllActors = false, Actor ignore = null); virtual ETraceStatus TraceCallback() { // Normally you would examine Results.HitType (for ETraceResult), and determine either: // - stop tracing and return the entity that was found (return TRACE_Stop) // - ignore some object, like noclip, e.g. only count solid walls and floors, and ignore actors (return TRACE_Skip) // - find last object of some type (return TRACE_Continue) // - stop tracing entirely and assume we found nothing (return TRACE_Abort) // TRACE_Abort and TRACE_Continue are of limited use in scripting. return TRACE_Stop; // default callback returns first hit, whatever it is. } } struct DropItem native { native readonly DropItem Next; native readonly name Name; native readonly int Probability; native readonly int Amount; } struct LevelInfo native { native readonly int levelnum; native readonly String MapName; native readonly String NextMap; native readonly String NextSecretMap; native readonly String SkyPic1; native readonly String SkyPic2; native readonly String F1Pic; native readonly int cluster; native readonly int partime; native readonly int sucktime; native readonly int flags; native readonly int flags2; native readonly int flags3; native readonly String Music; native readonly String LevelName; native readonly String AuthorName; native readonly int musicorder; native readonly float skyspeed1; native readonly float skyspeed2; native readonly int cdtrack; native readonly double gravity; native readonly double aircontrol; native readonly int airsupply; native readonly int compatflags; native readonly int compatflags2; native readonly name deathsequence; native readonly int fogdensity; native readonly int outsidefogdensity; native readonly int skyfog; native readonly float pixelstretch; native readonly name RedirectType; native readonly String RedirectMapName; native readonly double teamdamage; native bool isValid() const; native String LookupLevelName() const; native static int GetLevelInfoCount(); native static LevelInfo GetLevelInfo(int index); native static LevelInfo FindLevelInfo(String mapname); native static LevelInfo FindLevelByNum(int num); native static bool MapExists(String mapname); native static String MapChecksum(String mapname); } struct FSpawnParticleParams { native Color color1; native TextureID texture; native int style; native int flags; native int lifetime; native double size; native double sizestep; native Vector3 pos; native Vector3 vel; native Vector3 accel; native double startalpha; native double fadestep; native double startroll; native double rollvel; native double rollacc; }; struct LevelLocals native { enum EUDMF { UDMF_Line, UDMF_Side, UDMF_Sector, //UDMF_Thing // not implemented }; const CLUSTER_HUB = 0x00000001; // Cluster uses hub behavior native Array<@Sector> Sectors; native Array<@Line> Lines; native Array<@Side> Sides; native readonly Array<@Vertex> Vertexes; native readonly Array<@LinePortal> LinePortals; native internal Array<@SectorPortal> SectorPortals; native readonly int time; native readonly int maptime; native readonly int totaltime; native readonly int starttime; native readonly int partime; native readonly int sucktime; native readonly int cluster; native readonly int clusterflags; native readonly int levelnum; native readonly String LevelName; native readonly String MapName; native String NextMap; native String NextSecretMap; native readonly String F1Pic; native readonly int maptype; native readonly String AuthorName; native readonly String Music; native readonly int musicorder; native readonly TextureID skytexture1; native readonly TextureID skytexture2; native float skyspeed1; native float skyspeed2; native int total_secrets; native int found_secrets; native int total_items; native int found_items; native int total_monsters; native int killed_monsters; native play double gravity; native play double aircontrol; native play double airfriction; native play int airsupply; native readonly double teamdamage; native readonly bool noinventorybar; native readonly bool monsterstelefrag; native readonly bool actownspecial; native readonly bool sndseqtotalctrl; native bool allmap; native readonly bool missilesactivateimpact; native readonly bool monsterfallingdamage; native readonly bool checkswitchrange; native readonly bool polygrind; native readonly bool nomonsters; native readonly bool allowrespawn; deprecated("3.8", "Use Level.isFrozen() instead") native bool frozen; native readonly bool infinite_flight; native readonly bool no_dlg_freeze; native readonly bool keepfullinventory; native readonly bool removeitems; native readonly bool useplayerstartz; native readonly int fogdensity; native readonly int outsidefogdensity; native readonly int skyfog; native readonly float pixelstretch; native readonly float MusicVolume; native name deathsequence; native readonly int compatflags; native readonly int compatflags2; native readonly LevelInfo info; native String GetUDMFString(int type, int index, Name key); native int GetUDMFInt(int type, int index, Name key); native double GetUDMFFloat(int type, int index, Name key); native play int ExecuteSpecial(int special, Actor activator, line linedef, bool lineside, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0, int arg5 = 0); native void GiveSecret(Actor activator, bool printmsg = true, bool playsound = true); native void StartSlideshow(Name whichone = 'none'); native static void MakeScreenShot(); native static void MakeAutoSave(); native void WorldDone(); deprecated("3.8", "This function does nothing") static void RemoveAllBots(bool fromlist) { /* intentionally left as no-op. */ } native ui Vector2 GetAutomapPosition(); native void SetInterMusic(String nextmap); native String FormatMapName(int mapnamecolor); native bool IsJumpingAllowed() const; native bool IsCrouchingAllowed() const; native bool IsFreelookAllowed() const; native void StartIntermission(Name type, int state) const; native play SpotState GetSpotState(bool create = true); native int FindUniqueTid(int start = 0, int limit = 0); native uint GetSkyboxPortal(Actor actor); native void ReplaceTextures(String from, String to, int flags); clearscope native HealthGroup FindHealthGroup(int id); native vector3, int PickDeathmatchStart(); native vector3, int PickPlayerStart(int pnum, int flags = 0); native int isFrozen() const; native void setFrozen(bool on); native string LookupString(uint index); native clearscope Sector PointInSector(Vector2 pt) const; native clearscope bool IsPointInLevel(vector3 p) const; deprecated("3.8", "Use Level.IsPointInLevel() instead") clearscope static bool IsPointInMap(vector3 p) { return level.IsPointInLevel(p); } native clearscope vector2 Vec2Diff(vector2 v1, vector2 v2) const; native clearscope vector3 Vec3Diff(vector3 v1, vector3 v2) const; native clearscope vector3 SphericalCoords(vector3 viewpoint, vector3 targetPos, vector2 viewAngles = (0, 0), bool absolute = false) const; native clearscope vector2 Vec2Offset(vector2 pos, vector2 dir, bool absolute = false) const; native clearscope vector3 Vec2OffsetZ(vector2 pos, vector2 dir, double atz, bool absolute = false) const; native clearscope vector3 Vec3Offset(vector3 pos, vector3 dir, bool absolute = false) const; native clearscope Vector2 GetDisplacement(int pg1, int pg2) const; native clearscope int GetPortalGroupCount() const; native clearscope int PointOnLineSide(Vector2 pos, Line l, bool precise = false) const; native clearscope int ActorOnLineSide(Actor mo, Line l) const; native clearscope int BoxOnLineSide(Vector2 pos, double radius, Line l) const; native String GetChecksum() const; native void ChangeSky(TextureID sky1, TextureID sky2 ); native SectorTagIterator CreateSectorTagIterator(int tag, line defline = null); native LineIdIterator CreateLineIdIterator(int tag); native ActorIterator CreateActorIterator(int tid, class type = "Actor"); String TimeFormatted(bool totals = false) { int sec = Thinker.Tics2Seconds(totals? totaltime : time); return String.Format("%02d:%02d:%02d", sec / 3600, (sec % 3600) / 60, sec % 60); } native play bool CreateCeiling(sector sec, int type, line ln, double speed, double speed2, double height = 0, int crush = -1, int silent = 0, int change = 0, int crushmode = 0 /*Floor.crushDoom*/); native play bool CreateFloor(sector sec, int floortype, line ln, double speed, double height = 0, int crush = -1, int change = 0, bool crushmode = false, bool hereticlower = false); native void ExitLevel(int position, bool keepFacing); native void SecretExitLevel(int position); native void ChangeLevel(string levelname, int position = 0, int flags = 0, int skill = -1); native String GetClusterName(); native String GetEpisodeName(); native void SpawnParticle(FSpawnParticleParams p); } // a few values of this need to be readable by the play code. // Most are handled at load time and are omitted here. struct DehInfo native { native readonly int MaxSoulsphere; native readonly uint8 ExplosionStyle; native readonly double ExplosionAlpha; native readonly int NoAutofreeze; native readonly int BFGCells; native readonly int BlueAC; native readonly int MaxHealth; } struct State native { native readonly State NextState; native readonly int sprite; native readonly int16 Tics; native readonly uint16 TicRange; native readonly uint8 Frame; native readonly uint8 UseFlags; native readonly int Misc1; native readonly int Misc2; native readonly uint16 bSlow; native readonly uint16 bFast; native readonly bool bFullbright; native readonly bool bNoDelay; native readonly bool bSameFrame; native readonly bool bCanRaise; native readonly bool bDehacked; native int DistanceTo(state other); native bool ValidateSpriteFrame(); native TextureID, bool, Vector2 GetSpriteTexture(int rotation, int skin = 0, Vector2 scale = (0,0)); native bool InStateSequence(State base); } struct TerrainDef native { native Name TerrainName; native int Splash; native int DamageAmount; native Name DamageMOD; native int DamageTimeMask; native double FootClip; native float StepVolume; native int WalkStepTics; native int RunStepTics; native Sound LeftStepSound; native Sound RightStepSound; native bool IsLiquid; native bool AllowProtection; native bool DamageOnLand; native double Friction; native double MoveFactor; }; enum EPickStart { PPS_FORCERANDOM = 1, PPS_NOBLOCKINGCHECK = 2, } class SectorEffect : Thinker native { native protected Sector m_Sector; native Sector GetSector(); } class Mover : SectorEffect native {} class MovingFloor : Mover native {} class MovingCeiling : Mover native {} class Floor : MovingFloor native { // only here so that some constants and functions can be added. Not directly usable yet. enum EFloor { floorLowerToLowest, floorLowerToNearest, floorLowerToHighest, floorLowerByValue, floorRaiseByValue, floorRaiseToHighest, floorRaiseToNearest, floorRaiseAndCrush, floorRaiseAndCrushDoom, floorCrushStop, floorLowerInstant, floorRaiseInstant, floorMoveToValue, floorRaiseToLowestCeiling, floorRaiseByTexture, floorLowerAndChange, floorRaiseAndChange, floorRaiseToLowest, floorRaiseToCeiling, floorLowerToLowestCeiling, floorLowerByTexture, floorLowerToCeiling, donutRaise, buildStair, waitStair, resetStair, // Not to be used as parameters to DoFloor() genFloorChg0, genFloorChgT, genFloorChg }; deprecated("3.8", "Use Level.CreateFloor() instead") static bool CreateFloor(sector sec, int floortype, line ln, double speed, double height = 0, int crush = -1, int change = 0, bool crushmode = false, bool hereticlower = false) { return level.CreateFloor(sec, floortype, ln, speed, height, crush, change, crushmode, hereticlower); } } class Ceiling : MovingCeiling native { enum ECeiling { ceilLowerByValue, ceilRaiseByValue, ceilMoveToValue, ceilLowerToHighestFloor, ceilLowerInstant, ceilRaiseInstant, ceilCrushAndRaise, ceilLowerAndCrush, ceil_placeholder, ceilCrushRaiseAndStay, ceilRaiseToNearest, ceilLowerToLowest, ceilLowerToFloor, // The following are only used by Generic_Ceiling ceilRaiseToHighest, ceilLowerToHighest, ceilRaiseToLowest, ceilLowerToNearest, ceilRaiseToHighestFloor, ceilRaiseToFloor, ceilRaiseByTexture, ceilLowerByTexture, genCeilingChg0, genCeilingChgT, genCeilingChg } enum ECrushMode { crushDoom = 0, crushHexen = 1, crushSlowdown = 2 } deprecated("3.8", "Use Level.CreateCeiling() instead") static bool CreateCeiling(sector sec, int type, line ln, double speed, double speed2, double height = 0, int crush = -1, int silent = 0, int change = 0, int crushmode = crushDoom) { return level.CreateCeiling(sec, type, ln, speed, speed2, height, crush, silent, change, crushmode); } } struct LookExParams { double Fov; double minDist; double maxDist; double maxHeardist; int flags; State seestate; }; class Lighting : SectorEffect native { } struct Shader native { // This interface was deprecated for the pointless player dependency private static bool IsConsolePlayer(PlayerInfo player) { return player && player.mo && player == players[consoleplayer]; } deprecated("4.8", "Use PPShader.SetEnabled() instead") clearscope static void SetEnabled(PlayerInfo player, string shaderName, bool enable) { if (IsConsolePlayer(player)) PPShader.SetEnabled(shaderName, enable); } deprecated("4.8", "Use PPShader.SetUniform1f() instead") clearscope static void SetUniform1f(PlayerInfo player, string shaderName, string uniformName, float value) { if (IsConsolePlayer(player)) PPShader.SetUniform1f(shaderName, uniformName, value); } deprecated("4.8", "Use PPShader.SetUniform2f() instead") clearscope static void SetUniform2f(PlayerInfo player, string shaderName, string uniformName, vector2 value) { if (IsConsolePlayer(player)) PPShader.SetUniform2f(shaderName, uniformName, value); } deprecated("4.8", "Use PPShader.SetUniform3f() instead") clearscope static void SetUniform3f(PlayerInfo player, string shaderName, string uniformName, vector3 value) { if (IsConsolePlayer(player)) PPShader.SetUniform3f(shaderName, uniformName, value); } deprecated("4.8", "Use PPShader.SetUniform1i() instead") clearscope static void SetUniform1i(PlayerInfo player, string shaderName, string uniformName, int value) { if (IsConsolePlayer(player)) PPShader.SetUniform1i(shaderName, uniformName, value); } } struct FRailParams { native int damage; native double offset_xy; native double offset_z; native int color1, color2; native double maxdiff; native int flags; native Class puff; native double angleoffset; native double pitchoffset; native double distance; native int duration; native double sparsity; native double drift; native Class spawnclass; native int SpiralOffset; native int limit; }; // [RH] Shoot a railgun // Tech lamp --------------------------------------------------------------- class TechLamp : Actor { Default { Radius 16; Height 80; ProjectilePassHeight -16; +SOLID } States { Spawn: TLMP ABCD 4 BRIGHT; Loop; } } // Tech lamp 2 ------------------------------------------------------------- class TechLamp2 : Actor { Default { Radius 16; Height 60; ProjectilePassHeight -16; +SOLID } States { Spawn: TLP2 ABCD 4 BRIGHT; Loop; } } // Column ------------------------------------------------------------------ class Column : Actor { Default { Radius 16; Height 48; ProjectilePassHeight -16; +SOLID } States { Spawn: COLU A -1 BRIGHT; Stop; } } // Tall green column ------------------------------------------------------- class TallGreenColumn : Actor { Default { Radius 16; Height 52; ProjectilePassHeight -16; +SOLID } States { Spawn: COL1 A -1; Stop; } } // Short green column ------------------------------------------------------ class ShortGreenColumn : Actor { Default { Radius 16; Height 40; ProjectilePassHeight -16; +SOLID } States { Spawn: COL2 A -1; Stop; } } // Tall red column --------------------------------------------------------- class TallRedColumn : Actor { Default { Radius 16; Height 52; ProjectilePassHeight -16; +SOLID } States { Spawn: COL3 A -1; Stop; } } // Short red column -------------------------------------------------------- class ShortRedColumn : Actor { Default { Radius 16; Height 40; ProjectilePassHeight -16; +SOLID } States { Spawn: COL4 A -1; Stop; } } // Skull column ------------------------------------------------------------ class SkullColumn : Actor { Default { Radius 16; Height 40; ProjectilePassHeight -16; +SOLID } States { Spawn: COL6 A -1; Stop; } } // Heart column ------------------------------------------------------------ class HeartColumn : Actor { Default { Radius 16; Height 40; ProjectilePassHeight -16; +SOLID } States { Spawn: COL5 AB 14; Loop; } } // Evil eye ---------------------------------------------------------------- class EvilEye : Actor { Default { Radius 16; Height 54; ProjectilePassHeight -16; +SOLID } States { Spawn: CEYE ABCB 6 BRIGHT; Loop; } } // Floating skull ---------------------------------------------------------- class FloatingSkull : Actor { Default { Radius 16; Height 26; ProjectilePassHeight -16; +SOLID } States { Spawn: FSKU ABC 6 BRIGHT; Loop; } } // Torch tree -------------------------------------------------------------- class TorchTree : Actor { Default { Radius 16; Height 56; ProjectilePassHeight -16; +SOLID } States { Spawn: TRE1 A -1; Stop; } } // Blue torch -------------------------------------------------------------- class BlueTorch : Actor { Default { Radius 16; Height 68; ProjectilePassHeight -16; +SOLID } States { Spawn: TBLU ABCD 4 BRIGHT; Loop; } } // Green torch ------------------------------------------------------------- class GreenTorch : Actor { Default { Radius 16; Height 68; ProjectilePassHeight -16; +SOLID } States { Spawn: TGRN ABCD 4 BRIGHT; Loop; } } // Red torch --------------------------------------------------------------- class RedTorch : Actor { Default { Radius 16; Height 68; ProjectilePassHeight -16; +SOLID } States { Spawn: TRED ABCD 4 BRIGHT; Loop; } } // Short blue torch -------------------------------------------------------- class ShortBlueTorch : Actor { Default { Radius 16; Height 37; ProjectilePassHeight -16; +SOLID } States { Spawn: SMBT ABCD 4 BRIGHT; Loop; } } // Short green torch ------------------------------------------------------- class ShortGreenTorch : Actor { Default { Radius 16; Height 37; ProjectilePassHeight -16; +SOLID } States { Spawn: SMGT ABCD 4 BRIGHT; Loop; } } // Short red torch --------------------------------------------------------- class ShortRedTorch : Actor { Default { Radius 16; Height 37; ProjectilePassHeight -16; +SOLID } States { Spawn: SMRT ABCD 4 BRIGHT; Loop; } } // Stalagtite -------------------------------------------------------------- class Stalagtite : Actor { Default { Radius 16; Height 40; ProjectilePassHeight -16; +SOLID } States { Spawn: SMIT A -1; Stop; } } // Tech pillar ------------------------------------------------------------- class TechPillar : Actor { Default { Radius 16; Height 128; ProjectilePassHeight -16; +SOLID } States { Spawn: ELEC A -1; Stop; } } // Candle stick ------------------------------------------------------------ class Candlestick : Actor { Default { Radius 20; Height 14; ProjectilePassHeight -16; } States { Spawn: CAND A -1 BRIGHT; Stop; } } // Candelabra -------------------------------------------------------------- class Candelabra : Actor { Default { Radius 16; Height 60; ProjectilePassHeight -16; +SOLID } States { Spawn: CBRA A -1 BRIGHT; Stop; } } // Bloody twitch ----------------------------------------------------------- class BloodyTwitch : Actor { Default { Radius 16; Height 68; +SOLID +NOGRAVITY +SPAWNCEILING } States { Spawn: GOR1 A 10; GOR1 B 15; GOR1 C 8; GOR1 B 6; Loop; } } // Meat 2 ------------------------------------------------------------------ class Meat2 : Actor { Default { Radius 16; Height 84; +SOLID +NOGRAVITY +SPAWNCEILING } States { Spawn: GOR2 A -1; Stop; } } // Meat 3 ------------------------------------------------------------------ class Meat3 : Actor { Default { Radius 16; Height 84; +SOLID +NOGRAVITY +SPAWNCEILING } States { Spawn: GOR3 A -1; Stop; } } // Meat 4 ------------------------------------------------------------------ class Meat4 : Actor { Default { Radius 16; Height 68; +SOLID +NOGRAVITY +SPAWNCEILING } States { Spawn: GOR4 A -1; Stop; } } // Meat 5 ------------------------------------------------------------------ class Meat5 : Actor { Default { Radius 16; Height 52; +SOLID +NOGRAVITY +SPAWNCEILING } States { Spawn: GOR5 A -1; Stop; } } // Nonsolid meat ----------------------------------------------------------- class NonsolidMeat2 : Meat2 { Default { -SOLID Radius 20; } } class NonsolidMeat3 : Meat3 { Default { -SOLID Radius 20; } } class NonsolidMeat4 : Meat4 { Default { -SOLID Radius 20; } } class NonsolidMeat5 : Meat5 { Default { -SOLID Radius 20; } } // Nonsolid bloody twitch -------------------------------------------------- class NonsolidTwitch : BloodyTwitch { Default { -SOLID Radius 20; } } // Head on a stick --------------------------------------------------------- class HeadOnAStick : Actor { Default { Radius 16; Height 56; ProjectilePassHeight -16; +SOLID } States { Spawn: POL4 A -1; Stop; } } // Heads (plural!) on a stick ---------------------------------------------- class HeadsOnAStick : Actor { Default { Radius 16; Height 64; ProjectilePassHeight -16; +SOLID } States { Spawn: POL2 A -1; Stop; } } // Head candles ------------------------------------------------------------ class HeadCandles : Actor { Default { Radius 16; Height 42; ProjectilePassHeight -16; +SOLID } States { Spawn: POL3 AB 6 BRIGHT; Loop; } } // Dead on a stick --------------------------------------------------------- class DeadStick : Actor { Default { Radius 16; Height 64; ProjectilePassHeight -16; +SOLID } States { Spawn: POL1 A -1; Stop; } } // Still alive on a stick -------------------------------------------------- class LiveStick : Actor { Default { Radius 16; Height 64; ProjectilePassHeight -16; +SOLID } States { Spawn: POL6 A 6; POL6 B 8; Loop; } } // Big tree ---------------------------------------------------------------- class BigTree : Actor { Default { Radius 32; Height 108; ProjectilePassHeight -16; +SOLID } States { Spawn: TRE2 A -1; Stop; } } // Burning barrel ---------------------------------------------------------- class BurningBarrel : Actor { Default { Radius 16; Height 32; ProjectilePassHeight -16; +SOLID } States { Spawn: FCAN ABC 4 BRIGHT; Loop; } } // Hanging with no guts ---------------------------------------------------- class HangNoGuts : Actor { Default { Radius 16; Height 88; +SOLID +NOGRAVITY +SPAWNCEILING } States { Spawn: HDB1 A -1; Stop; } } // Hanging from bottom with no brain --------------------------------------- class HangBNoBrain : Actor { Default { Radius 16; Height 88; +SOLID +NOGRAVITY +SPAWNCEILING } States { Spawn: HDB2 A -1; Stop; } } // Hanging from top, looking down ------------------------------------------ class HangTLookingDown : Actor { Default { Radius 16; Height 64; +SOLID +NOGRAVITY +SPAWNCEILING } States { Spawn: HDB3 A -1; Stop; } } // Hanging from top, looking up -------------------------------------------- class HangTLookingUp : Actor { Default { Radius 16; Height 64; +SOLID +NOGRAVITY +SPAWNCEILING } States { Spawn: HDB5 A -1; Stop; } } // Hanging from top, skully ------------------------------------------------ class HangTSkull : Actor { Default { Radius 16; Height 64; +SOLID +NOGRAVITY +SPAWNCEILING } States { Spawn: HDB4 A -1; Stop; } } // Hanging from top without a brain ---------------------------------------- class HangTNoBrain : Actor { Default { Radius 16; Height 64; +SOLID +NOGRAVITY +SPAWNCEILING } States { Spawn: HDB6 A -1; Stop; } } // Colon gibs -------------------------------------------------------------- class ColonGibs : Actor { Default { Radius 20; Height 4; +NOBLOCKMAP +MOVEWITHSECTOR } States { Spawn: POB1 A -1; Stop; } } // Small pool o' blood ----------------------------------------------------- class SmallBloodPool : Actor { Default { Radius 20; Height 1; +NOBLOCKMAP +MOVEWITHSECTOR } States { Spawn: POB2 A -1; Stop; } } // brain stem lying on the ground ------------------------------------------ class BrainStem : Actor { Default { Radius 20; Height 4; +NOBLOCKMAP +MOVEWITHSECTOR } States { Spawn: BRS1 A -1; Stop; } } // Grey stalagmite (unused Doom sprite, definition taken from Skulltag ----- class Stalagmite : Actor { Default { Radius 16; Height 48; +SOLID } States { Spawn: SMT2 A -1; Stop; } } // Health bonus ------------------------------------------------------------- class HealthBonus : Health { Default { +COUNTITEM +INVENTORY.ALWAYSPICKUP Inventory.Amount 1; Inventory.MaxAmount 200; Inventory.PickupMessage "$GOTHTHBONUS"; } States { Spawn: BON1 ABCDCB 6; Loop; } } // Stimpack ----------------------------------------------------------------- class Stimpack : Health { Default { Inventory.Amount 10; Inventory.PickupMessage "$GOTSTIM"; } States { Spawn: STIM A -1; Stop; } } // Medikit ----------------------------------------------------------------- class Medikit : Health { Default { Inventory.Amount 25; Inventory.PickupMessage "$GOTMEDIKIT"; Health.LowMessage 25, "$GOTMEDINEED"; } States { Spawn: MEDI A -1; Stop; } } //=========================================================================== // // Imp // //=========================================================================== class DoomImp : Actor { Default { Health 60; Radius 20; Height 56; Mass 100; Speed 8; PainChance 200; Monster; +FLOORCLIP SeeSound "imp/sight"; PainSound "imp/pain"; DeathSound "imp/death"; ActiveSound "imp/active"; HitObituary "$OB_IMPHIT"; Obituary "$OB_IMP"; Tag "$FN_IMP"; } States { Spawn: TROO AB 10 A_Look; Loop; See: TROO AABBCCDD 3 A_Chase; Loop; Melee: Missile: TROO EF 8 A_FaceTarget; TROO G 6 A_TroopAttack ; Goto See; Pain: TROO H 2; TROO H 2 A_Pain; Goto See; Death: TROO I 8; TROO J 8 A_Scream; TROO K 6; TROO L 6 A_NoBlocking; TROO M -1; Stop; XDeath: TROO N 5; TROO O 5 A_XScream; TROO P 5; TROO Q 5 A_NoBlocking; TROO RST 5; TROO U -1; Stop; Raise: TROO ML 8; TROO KJI 6; Goto See; } } //=========================================================================== // // Imp fireball // //=========================================================================== class DoomImpBall : Actor { Default { Radius 6; Height 8; Speed 10; FastSpeed 20; Damage 3; Projectile; +RANDOMIZE +ZDOOMTRANS RenderStyle "Add"; Alpha 1; SeeSound "imp/attack"; DeathSound "imp/shotx"; } States { Spawn: BAL1 AB 4 BRIGHT; Loop; Death: BAL1 CDE 6 BRIGHT; Stop; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== extend class Actor { void A_TroopAttack() { let targ = target; if (targ) { if (CheckMeleeRange()) { int damage = random[pr_troopattack](1, 8) * 3; A_StartSound ("imp/melee", CHAN_WEAPON); int newdam = targ.DamageMobj (self, self, damage, "Melee"); targ.TraceBleed (newdam > 0 ? newdam : damage, self); } else { // launch a missile SpawnMissile (targ, "DoomImpBall"); } } } } class DoomKey : Key { Default { Radius 20; Height 16; +NOTDMATCH } } // Blue key card ------------------------------------------------------------ class BlueCard : DoomKey { Default { Inventory.Pickupmessage "$GOTBLUECARD"; Inventory.Icon "STKEYS0"; } States { Spawn: BKEY A 10; BKEY B 10 bright; loop; } } // Yellow key card ---------------------------------------------------------- class YellowCard : DoomKey { Default { Inventory.Pickupmessage "$GOTYELWCARD"; Inventory.Icon "STKEYS1"; } States { Spawn: YKEY A 10; YKEY B 10 bright; loop; } } // Red key card ------------------------------------------------------------- class RedCard : DoomKey { Default { Inventory.Pickupmessage "$GOTREDCARD"; Inventory.Icon "STKEYS2"; } States { Spawn: RKEY A 10; RKEY B 10 bright; loop; } } // Blue skull key ----------------------------------------------------------- class BlueSkull : DoomKey { Default { Inventory.Pickupmessage "$GOTBLUESKUL"; Inventory.Icon "STKEYS3"; } States { Spawn: BSKU A 10; BSKU B 10 bright; loop; } } // Yellow skull key --------------------------------------------------------- class YellowSkull : DoomKey { Default { Inventory.Pickupmessage "$GOTYELWSKUL"; Inventory.Icon "STKEYS4"; } States { Spawn: YSKU A 10; YSKU B 10 bright; loop; } } // Red skull key ------------------------------------------------------------ class RedSkull : DoomKey { Default { Inventory.Pickupmessage "$GOTREDSKUL"; Inventory.Icon "STKEYS5"; } States { Spawn: RSKU A 10; RSKU B 10 bright; loop; } } class GameplayMenu : OptionMenu { override void Drawer () { Super.Drawer(); String s = String.Format("dmflags = %d dmflags2 = %d dmflags3 = %d", dmflags, dmflags2, dmflags3); screen.DrawText (OptionFont(), OptionMenuSettings.mFontColorValue, (screen.GetWidth() - OptionWidth (s) * CleanXfac_1) / 2, 35 * CleanXfac_1, s, DTA_CleanNoMove_1, true); } } class CompatibilityMenu : OptionMenu { override void Drawer () { Super.Drawer(); String s = String.Format("compatflags = %d compatflags2 = %d", compatflags, compatflags2); screen.DrawText (OptionFont(), OptionMenuSettings.mFontColorValue, (screen.GetWidth() - OptionWidth (s) * CleanXfac_1) / 2, 35 * CleanXfac_1, s, DTA_CleanNoMove_1, true); } } //============================================================================= // // Placeholder classes for overhauled video mode menu. Do not use! // Their sole purpose is to support mods with full copy of embedded MENUDEF // //============================================================================= class OptionMenuItemScreenResolution : OptionMenuItem { String mResTexts[3]; int mSelection; int mHighlight; int mMaxValid; enum EValues { SRL_INDEX = 0x30000, SRL_SELECTION = 0x30003, SRL_HIGHLIGHT = 0x30004, }; OptionMenuItemScreenResolution Init(String command) { return self; } override bool Selectable() { return false; } } class VideoModeMenu : OptionMenu { static bool SetSelectedSize() { return false; } } class DoomMenuDelegate : MenuDelegateBase { override void PlaySound(Name snd) { String s = snd; S_StartSound (s, CHAN_VOICE, CHANF_UI, snd_menuvolume); } } // The barrel of green goop ------------------------------------------------ class ExplosiveBarrel : Actor { Default { Health 20; Radius 10; Height 42; +SOLID +SHOOTABLE +NOBLOOD +ACTIVATEMCROSS +DONTGIB +NOICEDEATH +OLDRADIUSDMG DeathSound "world/barrelx"; Obituary "$OB_BARREL"; } States { Spawn: BAR1 AB 6; Loop; Death: BEXP A 5 BRIGHT; BEXP B 5 BRIGHT A_Scream; BEXP C 5 BRIGHT; BEXP D 10 BRIGHT A_Explode; BEXP E 10 BRIGHT; TNT1 A 1050 BRIGHT A_BarrelDestroy; TNT1 A 5 A_Respawn; Wait; } } extend class Actor { void A_BarrelDestroy() { if (sv_barrelrespawn) { Height = Default.Height; bInvisible = true; bSolid = false; } else { Destroy(); } } } // Bullet puff ------------------------------------------------------------- class BulletPuff : Actor { Default { +NOBLOCKMAP +NOGRAVITY +ALLOWPARTICLES +RANDOMIZE +ZDOOMTRANS RenderStyle "Translucent"; Alpha 0.5; VSpeed 1; Mass 5; } States { Spawn: PUFF A 4 Bright; PUFF B 4; Melee: PUFF CD 4; Stop; } } // Container for an unused state ------------------------------------------- /* Doom defined the states S_STALAG, S_DEADTORSO, and S_DEADBOTTOM but never * actually used them. For compatibility with DeHackEd patches, they still * need to be kept around. This class serves that purpose. */ class DoomUnusedStates : Actor { States { Label1: SMT2 A -1; stop; Label2: PLAY N -1; stop; PLAY S -1; stop; TNT: // MBF compatibility TNT1 A -1; Loop; } } // MBF Beta emulation items class EvilSceptre : ScoreItem { Default { Inventory.PickupMessage "$BETA_BONUS3"; } States { Spawn: BON3 A 6; Loop; } } class UnholyBible : ScoreItem { Default { Inventory.PickupMessage "$BETA_BONUS4"; } States { Spawn: BON4 A 6; Loop; } } //=========================================================================== // // Player // //=========================================================================== class DoomPlayer : PlayerPawn { Default { Speed 1; Health 100; Radius 16; Height 56; Mass 100; PainChance 255; Player.DisplayName "Marine"; Player.CrouchSprite "PLYC"; Player.StartItem "Pistol"; Player.StartItem "Fist"; Player.StartItem "Clip", 50; Player.WeaponSlot 1, "Fist", "Chainsaw"; Player.WeaponSlot 2, "Pistol"; Player.WeaponSlot 3, "Shotgun", "SuperShotgun"; Player.WeaponSlot 4, "Chaingun"; Player.WeaponSlot 5, "RocketLauncher"; Player.WeaponSlot 6, "PlasmaRifle"; Player.WeaponSlot 7, "BFG9000"; Player.ColorRange 112, 127; Player.Colorset 0, "$TXT_COLOR_GREEN", 0x70, 0x7F, 0x72; Player.Colorset 1, "$TXT_COLOR_GRAY", 0x60, 0x6F, 0x62; Player.Colorset 2, "$TXT_COLOR_BROWN", 0x40, 0x4F, 0x42; Player.Colorset 3, "$TXT_COLOR_RED", 0x20, 0x2F, 0x22; // Doom Legacy additions Player.Colorset 4, "$TXT_COLOR_LIGHTGRAY", 0x58, 0x67, 0x5A; Player.Colorset 5, "$TXT_COLOR_LIGHTBROWN", 0x38, 0x47, 0x3A; Player.Colorset 6, "$TXT_COLOR_LIGHTRED", 0xB0, 0xBF, 0xB2; Player.Colorset 7, "$TXT_COLOR_LIGHTBLUE", 0xC0, 0xCF, 0xC2; } States { Spawn: PLAY A -1; Loop; See: PLAY ABCD 4; Loop; Missile: PLAY E 12; Goto Spawn; Melee: PLAY F 6 BRIGHT; Goto Missile; Pain: PLAY G 4; PLAY G 4 A_Pain; Goto Spawn; Death: PLAY H 0 A_PlayerSkinCheck("AltSkinDeath"); Death1: PLAY H 10; PLAY I 10 A_PlayerScream; PLAY J 10 A_NoBlocking; PLAY KLM 10; PLAY N -1; Stop; XDeath: PLAY O 0 A_PlayerSkinCheck("AltSkinXDeath"); XDeath1: PLAY O 5; PLAY P 5 A_XScream; PLAY Q 5 A_NoBlocking; PLAY RSTUV 5; PLAY W -1; Stop; AltSkinDeath: PLAY H 6; PLAY I 6 A_PlayerScream; PLAY JK 6; PLAY L 6 A_NoBlocking; PLAY MNO 6; PLAY P -1; Stop; AltSkinXDeath: PLAY Q 5 A_PlayerScream; PLAY R 0 A_NoBlocking; PLAY R 5 A_SkullPop; PLAY STUVWX 5; PLAY Y -1; Stop; } } // -------------------------------------------------------------------------- // // Doom weap base class // // -------------------------------------------------------------------------- class DoomWeapon : Weapon { Default { Weapon.Kickback 100; } } extend class StateProvider { // // [RH] A_FireRailgun // [TP] This now takes a puff type to retain Skulltag's railgun's ability to pierce armor. // action void A_FireRailgun(class puffType = "BulletPuff", int offset_xy = 0) { if (player == null) { return; } Weapon weap = player.ReadyWeapon; if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { if (!weap.DepleteAmmo (weap.bAltFire, true, 1)) return; State flash = weap.FindState('Flash'); if (flash != null) { player.SetSafeFlash(weap, flash, random[FireRail](0, 1)); } } int damage = deathmatch ? 100 : 150; A_RailAttack(damage, offset_xy, false, pufftype: puffType); // note that this function handles ammo depletion itself for Dehacked compatibility purposes. } action void A_FireRailgunLeft() { A_FireRailgun(offset_xy: -10); } action void A_FireRailgunRight() { A_FireRailgun(offset_xy: 10); } action void A_RailWait() { // only here to satisfy old Dehacked patches. } } class DoomStatusBar : BaseStatusBar { HUDFont mHUDFont; HUDFont mIndexFont; HUDFont mAmountFont; InventoryBarState diparms; override void Init() { Super.Init(); SetSize(32, 320, 200); // Create the font used for the fullscreen HUD Font fnt = "HUDFONT_DOOM"; mHUDFont = HUDFont.Create(fnt, fnt.GetCharWidth("0"), Mono_CellLeft, 1, 1); fnt = "INDEXFONT_DOOM"; mIndexFont = HUDFont.Create(fnt, fnt.GetCharWidth("0"), Mono_CellLeft); mAmountFont = HUDFont.Create("INDEXFONT"); diparms = InventoryBarState.Create(); } override void Draw (int state, double TicFrac) { Super.Draw (state, TicFrac); if (state == HUD_StatusBar) { BeginStatusBar(); DrawMainBar (TicFrac); } else if (state == HUD_Fullscreen) { BeginHUD(); DrawFullScreenStuff (); } } protected void DrawMainBar (double TicFrac) { DrawImage("STBAR", (0, 168), DI_ITEM_OFFSETS); DrawImage("STTPRCNT", (90, 171), DI_ITEM_OFFSETS); DrawImage("STTPRCNT", (221, 171), DI_ITEM_OFFSETS); Inventory a1 = GetCurrentAmmo(); if (a1 != null) DrawString(mHUDFont, FormatNumber(a1.Amount, 3), (44, 171), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW); DrawString(mHUDFont, FormatNumber(CPlayer.health, 3), (90, 171), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW); DrawString(mHUDFont, FormatNumber(GetArmorAmount(), 3), (221, 171), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW); DrawBarKeys(); DrawBarAmmo(); if (deathmatch || teamplay) { DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (138, 171), DI_TEXT_ALIGN_RIGHT); } else { DrawBarWeapons(); } if (multiplayer) { DrawImage("STFBANY", (143, 168), DI_ITEM_OFFSETS|DI_TRANSLATABLE); } if (CPlayer.mo.InvSel != null && !Level.NoInventoryBar) { DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198), DI_DIMDEPLETED); if (CPlayer.mo.InvSel.Amount > 1) { DrawString(mAmountFont, FormatNumber(CPlayer.mo.InvSel.Amount), (175, 198-mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD); } } else { DrawTexture(GetMugShot(5), (143, 168), DI_ITEM_OFFSETS); } if (isInventoryBarVisible()) { DrawInventoryBar(diparms, (48, 169), 7, DI_ITEM_LEFT_TOP); } } protected virtual void DrawBarKeys() { bool locks[6]; String image; for(int i = 0; i < 6; i++) locks[i] = CPlayer.mo.CheckKeys(i + 1, false, true); // key 1 if (locks[1] && locks[4]) image = "STKEYS6"; else if (locks[1]) image = "STKEYS0"; else if (locks[4]) image = "STKEYS3"; DrawImage(image, (239, 171), DI_ITEM_OFFSETS); // key 2 if (locks[2] && locks[5]) image = "STKEYS7"; else if (locks[2]) image = "STKEYS1"; else if (locks[5]) image = "STKEYS4"; else image = ""; DrawImage(image, (239, 181), DI_ITEM_OFFSETS); // key 3 if (locks[0] && locks[3]) image = "STKEYS8"; else if (locks[0]) image = "STKEYS2"; else if (locks[3]) image = "STKEYS5"; else image = ""; DrawImage(image, (239, 191), DI_ITEM_OFFSETS); } protected virtual void DrawBarAmmo() { int amt1, maxamt; [amt1, maxamt] = GetAmount("Clip"); DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 173), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 173), DI_TEXT_ALIGN_RIGHT); [amt1, maxamt] = GetAmount("Shell"); DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 179), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 179), DI_TEXT_ALIGN_RIGHT); [amt1, maxamt] = GetAmount("RocketAmmo"); DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 185), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 185), DI_TEXT_ALIGN_RIGHT); [amt1, maxamt] = GetAmount("Cell"); DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 191), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 191), DI_TEXT_ALIGN_RIGHT); } protected virtual void DrawBarWeapons() { DrawImage("STARMS", (104, 168), DI_ITEM_OFFSETS); DrawImage(CPlayer.HasWeaponsInSlot(2)? "STYSNUM2" : "STGNUM2", (111, 172), DI_ITEM_OFFSETS); DrawImage(CPlayer.HasWeaponsInSlot(3)? "STYSNUM3" : "STGNUM3", (123, 172), DI_ITEM_OFFSETS); DrawImage(CPlayer.HasWeaponsInSlot(4)? "STYSNUM4" : "STGNUM4", (135, 172), DI_ITEM_OFFSETS); DrawImage(CPlayer.HasWeaponsInSlot(5)? "STYSNUM5" : "STGNUM5", (111, 182), DI_ITEM_OFFSETS); DrawImage(CPlayer.HasWeaponsInSlot(6)? "STYSNUM6" : "STGNUM6", (123, 182), DI_ITEM_OFFSETS); DrawImage(CPlayer.HasWeaponsInSlot(7)? "STYSNUM7" : "STGNUM7", (135, 182), DI_ITEM_OFFSETS); } protected void DrawFullScreenStuff () { Vector2 iconbox = (40, 20); // Draw health let berserk = CPlayer.mo.FindInventory("PowerStrength"); DrawImage(berserk? "PSTRA0" : "MEDIA0", (20, -2)); DrawString(mHUDFont, FormatNumber(CPlayer.health, 3), (44, -20)); let armor = CPlayer.mo.FindInventory("BasicArmor"); if (armor != null && armor.Amount > 0) { DrawInventoryIcon(armor, (20, -22)); DrawString(mHUDFont, FormatNumber(armor.Amount, 3), (44, -40)); } Inventory ammotype1, ammotype2; [ammotype1, ammotype2] = GetCurrentAmmo(); int invY = -20; if (ammotype1 != null) { DrawInventoryIcon(ammotype1, (-14, -4)); DrawString(mHUDFont, FormatNumber(ammotype1.Amount, 3), (-30, -20), DI_TEXT_ALIGN_RIGHT); invY -= 20; } if (ammotype2 != null && ammotype2 != ammotype1) { DrawInventoryIcon(ammotype2, (-14, invY + 17)); DrawString(mHUDFont, FormatNumber(ammotype2.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT); invY -= 20; } if (!isInventoryBarVisible() && !Level.NoInventoryBar && CPlayer.mo.InvSel != null) { DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17), DI_DIMDEPLETED); DrawString(mHUDFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT); } if (deathmatch) { DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (-3, 1), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD); } else { DrawFullscreenKeys(); } if (isInventoryBarVisible()) { DrawInventoryBar(diparms, (0, 0), 7, DI_SCREEN_CENTER_BOTTOM, HX_SHADOW); } } protected virtual void DrawFullscreenKeys() { // Draw the keys. This does not use a special draw function like SBARINFO because the specifics will be different for each mod // so it's easier to copy or reimplement the following piece of code instead of trying to write a complicated all-encompassing solution. Vector2 keypos = (-10, 2); int rowc = 0; double roww = 0; for(let i = CPlayer.mo.Inv; i != null; i = i.Inv) { if (i is "Key" && i.Icon.IsValid()) { DrawTexture(i.Icon, keypos, DI_SCREEN_RIGHT_TOP|DI_ITEM_LEFT_TOP); Vector2 size = TexMan.GetScaledSize(i.Icon); keypos.Y += size.Y + 2; roww = max(roww, size.X); if (++rowc == 3) { keypos.Y = 2; keypos.X -= roww + 2; roww = 0; rowc = 0; } } } } } // Dragon ------------------------------------------------------------------- class Dragon : Actor { Default { Health 640; PainChance 128; Speed 10; Height 65; Mass 0x7fffffff; Monster; +NOGRAVITY +FLOAT +NOBLOOD +BOSS +DONTMORPH +NOTARGET +NOICEDEATH SeeSound "DragonSight"; AttackSound "DragonAttack"; PainSound "DragonPain"; DeathSound "DragonDeath"; ActiveSound "DragonActive"; Obituary "$OB_DRAGON"; Tag "$FN_DRAGON"; } States { Spawn: DRAG D 10 A_Look; Loop; See: DRAG CB 5; DRAG A 5 A_DragonInitFlight; DRAG B 3 A_DragonFlap; DRAG BCCDDCCBBAA 3 A_DragonFlight; Goto See + 3; Pain: DRAG F 10 A_DragonPain; Goto See + 3; Missile: DRAG E 8 A_DragonAttack; Goto See + 3; Death: DRAG G 5 A_Scream; DRAG H 4 A_NoBlocking; DRAG I 4; DRAG J 4 A_DragonCheckCrash; Wait; Crash: DRAG KL 5; DRAG M -1; Stop; } //============================================================================ // // DragonSeek // //============================================================================ private void DragonSeek (double thresh, double turnMax) { double dist; double delta; Actor targ; int i; double bestAngle; double angleToSpot, angleToTarget; Actor mo; targ = tracer; if(targ == null) { return; } double diff = deltaangle(angle, AngleTo(targ)); delta = abs(diff); if (delta > thresh) { delta /= 2; if (delta > turnMax) { delta = turnMax; } } if (diff > 0) { // Turn clockwise angle = angle + delta; } else { // Turn counter clockwise angle = angle - delta; } VelFromAngle(); dist = DistanceBySpeed(targ, Speed); if (pos.z + height < targ.pos.z || targ.pos.z + targ.height < pos.z) { Vel.Z = (targ.pos.z - pos.z) / dist; } if (targ.bShootable && random[DragonSeek]() < 64) { // attack the destination mobj if it's attackable Actor oldTarget; if (absangle(angle, AngleTo(targ)) < 22.5) { oldTarget = target; target = targ; if (CheckMeleeRange ()) { int damage = random[DragonSeek](1, 8) * 10; int newdam = targ.DamageMobj (self, self, damage, 'Melee'); targ.TraceBleed (newdam > 0 ? newdam : damage, self); A_StartSound (AttackSound, CHAN_WEAPON); } else if (random[DragonSeek]() < 128 && CheckMissileRange()) { SpawnMissile(targ, "DragonFireball"); A_StartSound (AttackSound, CHAN_WEAPON); } target = oldTarget; } } if (dist < 4) { // Hit the target thing if (target && random[DragonSeek]() < 200) { Actor bestActor = null; bestAngle = 360.; angleToTarget = AngleTo(target); for (i = 0; i < 5; i++) { if (!targ.args[i]) { continue; } ActorIterator iter = Level.CreateActorIterator(targ.args[i]); mo = iter.Next (); if (mo == null) { continue; } angleToSpot = AngleTo(mo); double diff = absangle(angleToSpot, angleToTarget); if (diff < bestAngle) { bestAngle = diff; bestActor = mo; } } if (bestActor != null) { tracer = bestActor; } } else { // [RH] Don't lock up if the dragon doesn't have any // targs defined for (i = 0; i < 5; ++i) { if (targ.args[i] != 0) { break; } } if (i < 5) { do { i = (random[DragonSeek]() >> 2) % 5; } while(!targ.args[i]); ActorIterator iter = Level.CreateActorIterator(targ.args[i]); tracer = iter.Next (); } } } } //============================================================================ // // A_DragonInitFlight // //============================================================================ void A_DragonInitFlight() { ActorIterator iter = Level.CreateActorIterator(tid); do { // find the first tid identical to the dragon's tid tracer = iter.Next (); if (tracer == null) { SetState (SpawnState); return; } } while (tracer == self); RemoveFromHash (); } //============================================================================ // // A_DragonFlight // //============================================================================ void A_DragonFlight() { double ang; DragonSeek (4., 8.); let targ = target; if (targ) { if(!target.bShootable) { // target died target = null; return; } ang = absangle(angle, AngleTo(target)); if (ang <22.5 && CheckMeleeRange()) { int damage = random[DragonFlight](1, 8) * 8; int newdam = targ.DamageMobj (self, self, damage, 'Melee'); targ.TraceBleed (newdam > 0 ? newdam : damage, self); A_StartSound (AttackSound, CHAN_WEAPON); } else if (ang <= 20) { SetState (MissileState); A_StartSound (AttackSound, CHAN_WEAPON); } } else { LookForPlayers (true); } } //============================================================================ // // A_DragonFlap // //============================================================================ void A_DragonFlap() { A_DragonFlight(); if (random[DragonFlight]() < 240) { A_StartSound ("DragonWingflap", CHAN_BODY); } else { PlayActiveSound (); } } //============================================================================ // // A_DragonAttack // //============================================================================ void A_DragonAttack() { SpawnMissile (target, "DragonFireball"); } //============================================================================ // // A_DragonPain // //============================================================================ void A_DragonPain() { A_Pain(); if (!tracer) { // no destination spot yet SetState (SeeState); } } //============================================================================ // // A_DragonCheckCrash // //============================================================================ void A_DragonCheckCrash() { if (pos.z <= floorz) { SetStateLabel ("Crash"); } } } // Dragon Fireball ---------------------------------------------------------- class DragonFireball : Actor { Default { Speed 24; Radius 12; Height 10; Damage 6; DamageType "Fire"; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS +ZDOOMTRANS RenderStyle "Add"; DeathSound "DragonFireballExplode"; } States { Spawn: DRFX ABCDEF 4 Bright; Loop; Death: DRFX GHI 4 Bright; DRFX J 4 Bright A_DragonFX2; DRFX KL 3 Bright; Stop; } //============================================================================ // // A_DragonFX2 // //============================================================================ void A_DragonFX2() { int delay = 16+(random[DragonFX2]()>>3); for (int i = random[DragonFX2](1, 4); i; i--) { double xo = (random[DragonFX2]() - 128) / 4.; double yo = (random[DragonFX2]() - 128) / 4.; double zo = (random[DragonFX2]() - 128) / 16.; Actor mo = Spawn ("DragonExplosion", Vec3Offset(xo, yo, zo), ALLOW_REPLACE); if (mo) { mo.tics = delay + (random[DragonFX2](0, 3)) * i*2; mo.target = target; } } } } // Dragon Fireball Secondary Explosion -------------------------------------- class DragonExplosion : Actor { Default { Radius 8; Height 8; DamageType "Fire"; +NOBLOCKMAP +NOTELEPORT +INVISIBLE +ZDOOMTRANS RenderStyle "Add"; DeathSound "DragonFireballExplode"; } States { Spawn: CFCF Q 1 Bright; CFCF Q 4 Bright A_UnHideThing; CFCF R 3 Bright A_Scream; CFCF S 4 Bright; CFCF T 3 Bright A_Explode (80, 128, 0); CFCF U 4 Bright; CFCF V 3 Bright; CFCF W 4 Bright; CFCF X 3 Bright; CFCF Y 4 Bright; CFCF Z 3 Bright; Stop; } } // Boss spot ---------------------------------------------------------------- class BossSpot : SpecialSpot { Default { +INVISIBLE } } // Sorcerer (D'Sparil on his serpent) --------------------------------------- class Sorcerer1 : Actor { Default { Health 2000; Radius 28; Height 100; Mass 800; Speed 16; PainChance 56; Monster; +BOSS +DONTMORPH +NORADIUSDMG +NOTARGET +NOICEDEATH +FLOORCLIP +DONTGIB SeeSound "dsparilserpent/sight"; AttackSound "dsparilserpent/attack"; PainSound "dsparilserpent/pain"; DeathSound "dsparilserpent/death"; ActiveSound "dsparilserpent/active"; Obituary "$OB_DSPARIL1"; HitObituary "$OB_DSPARIL1HIT"; Tag "$FN_DSPARIL"; } States { Spawn: SRCR AB 10 A_Look; Loop; See: SRCR ABCD 5 A_Sor1Chase; Loop; Pain: SRCR Q 6 A_Sor1Pain; Goto See; Missile: SRCR Q 7 A_FaceTarget; SRCR R 6 A_FaceTarget; SRCR S 10 A_Srcr1Attack; Goto See; Missile2: SRCR S 10 A_FaceTarget; SRCR Q 7 A_FaceTarget; SRCR R 6 A_FaceTarget; SRCR S 10 A_Srcr1Attack; Goto See; Death: SRCR E 7; SRCR F 7 A_Scream; SRCR G 7; SRCR HIJK 6; SRCR L 25 A_StartSound("dsparil/zap", CHAN_BODY, CHANF_DEFAULT, 1., ATTN_NONE); SRCR MN 5; SRCR O 4; SRCR L 20 A_StartSound("dsparil/zap", CHAN_BODY, CHANF_DEFAULT, 1., ATTN_NONE); SRCR MN 5; SRCR O 4; SRCR L 12; SRCR P -1 A_SorcererRise; } //---------------------------------------------------------------------------- // // PROC A_Sor1Pain // //---------------------------------------------------------------------------- void A_Sor1Pain () { special1 = 20; // Number of steps to walk fast A_Pain(); } //---------------------------------------------------------------------------- // // PROC A_Sor1Chase // //---------------------------------------------------------------------------- void A_Sor1Chase () { if (special1) { special1--; tics -= 3; } A_Chase(); } //---------------------------------------------------------------------------- // // PROC A_Srcr1Attack // // Sorcerer demon attack. // //---------------------------------------------------------------------------- void A_Srcr1Attack () { let targ = target; if (!targ) { return; } A_StartSound (AttackSound, CHAN_BODY); if (CheckMeleeRange ()) { int damage = random[Srcr1Attack](1,8) * 8; int newdam = targ.DamageMobj (self, self, damage, 'Melee'); targ.TraceBleed (newdam > 0 ? newdam : damage, self); return; } if (health > (SpawnHealth()/3)*2) { // Spit one fireball SpawnMissileZ (pos.z + 48, targ, "SorcererFX1"); } else { // Spit three fireballs Actor mo = SpawnMissileZ (pos.z + 48, targ, "SorcererFX1"); if (mo != null) { double ang = mo.angle; SpawnMissileAngleZ(pos.z + 48, "SorcererFX1", ang - 3, mo.Vel.Z); SpawnMissileAngleZ(pos.z + 48, "SorcererFX1", ang + 3, mo.Vel.Z); } if (health < SpawnHealth()/3) { // Maybe attack again if (special1) { // Just attacked, so don't attack again special1 = 0; } else { // Set state to attack again special1 = 1; SetStateLabel("Missile2"); } } } } //---------------------------------------------------------------------------- // // PROC A_SorcererRise // //---------------------------------------------------------------------------- void A_SorcererRise () { bSolid = false; Actor mo = Spawn("Sorcerer2", Pos, ALLOW_REPLACE); if (mo != null) { mo.Translation = Translation; mo.SetStateLabel("Rise"); mo.angle = angle; mo.CopyFriendliness (self, true); } } } // Sorcerer FX 1 ------------------------------------------------------------ class SorcererFX1 : Actor { Default { Radius 10; Height 10; Speed 20; FastSpeed 28; Damage 10; DamageType "Fire"; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: FX14 ABC 6 BRIGHT; Loop; Death: FX14 DEFGH 5 BRIGHT; Stop; } } // Sorcerer 2 (D'Sparil without his serpent) -------------------------------- class Sorcerer2 : Actor { Default { Health 3500; Radius 16; Height 70; Mass 300; Speed 14; Painchance 32; Monster; +DROPOFF +BOSS +DONTMORPH +FULLVOLACTIVE +NORADIUSDMG +NOTARGET +NOICEDEATH +FLOORCLIP +BOSSDEATH SeeSound "dsparil/sight"; AttackSound "dsparil/attack"; PainSound "dsparil/pain"; ActiveSound "dsparil/active"; Obituary "$OB_DSPARIL2"; HitObituary "$OB_DSPARIL2HIT"; Tag "$FN_DSPARIL"; } States { Spawn: SOR2 MN 10 A_Look; Loop; See: SOR2 MNOP 4 A_Chase; Loop; Rise: SOR2 AB 4; SOR2 C 4 A_StartSound("dsparil/rise", CHAN_BODY, CHANF_DEFAULT, 1., ATTN_NONE); SOR2 DEF 4; SOR2 G 12 A_StartSound("dsparil/sight", CHAN_BODY, CHANF_DEFAULT, 1., ATTN_NONE); Goto See; Pain: SOR2 Q 3; SOR2 Q 6 A_Pain; Goto See; Missile: SOR2 R 9 A_Srcr2Decide; SOR2 S 9 A_FaceTarget; SOR2 T 20 A_Srcr2Attack; Goto See; Teleport: SOR2 LKJIHG 6; Goto See; Death: SDTH A 8 A_Sor2DthInit; SDTH B 8; SDTH C 8 A_StartSound("dsparil/scream", CHAN_BODY, CHANF_DEFAULT, 1., ATTN_NONE); DeathLoop: SDTH DE 7; SDTH F 7 A_Sor2DthLoop; SDTH G 6 A_StartSound("dsparil/explode", CHAN_BODY, CHANF_DEFAULT, 1., ATTN_NONE); SDTH H 6; SDTH I 18; SDTH J 6 A_NoBlocking; SDTH K 6 A_StartSound("dsparil/bones", CHAN_BODY, CHANF_DEFAULT, 1., ATTN_NONE); SDTH LMN 6; SDTH O -1 A_BossDeath; Stop; } //---------------------------------------------------------------------------- // // PROC P_DSparilTeleport // //---------------------------------------------------------------------------- void DSparilTeleport () { SpotState state = Level.GetSpotState(); if (state == null) return; Actor spot = state.GetSpotWithMinMaxDistance("BossSpot", pos.x, pos.y, 128, 0); if (spot == null) return; Vector3 prev = Pos; if (TeleportMove (spot.Pos, false)) { Actor mo = Spawn("Sorcerer2Telefade", prev, ALLOW_REPLACE); if (mo) { mo.Translation = Translation; mo.A_StartSound("misc/teleport", CHAN_BODY); } SetStateLabel ("Teleport"); A_StartSound ("misc/teleport", CHAN_BODY); SetZ(floorz); angle = spot.angle; vel = (0,0,0); } } //---------------------------------------------------------------------------- // // PROC A_Srcr2Decide // //---------------------------------------------------------------------------- void A_Srcr2Decide () { static const int chance[] = { 192, 120, 120, 120, 64, 64, 32, 16, 0 }; int health8 = max(1, SpawnHealth() / 8); int chanceindex = min(8, health / health8); if (random[Srcr2Decide]() < chance[chanceindex]) { DSparilTeleport (); } } //---------------------------------------------------------------------------- // // PROC A_Srcr2Attack // //---------------------------------------------------------------------------- void A_Srcr2Attack () { let targ = target; if (!targ) { return; } A_StartSound (AttackSound, CHAN_BODY, CHANF_DEFAULT, 1., ATTN_NONE); if (CheckMeleeRange()) { int damage = random[Srcr2Atk](1, 8) * 20; int newdam = targ.DamageMobj (self, self, damage, 'Melee'); targ.TraceBleed (newdam > 0 ? newdam : damage, self); return; } int chance = health < SpawnHealth()/2 ? 96 : 48; if (random[Srcr2Atk]() < chance) { // Wizard spawners SpawnMissileAngle("Sorcerer2FX2", Angle - 45, 0.5); SpawnMissileAngle("Sorcerer2FX2", Angle + 45, 0.5); } else { // Blue bolt SpawnMissile (targ, "Sorcerer2FX1"); } } //---------------------------------------------------------------------------- // // PROC A_Sor2DthInit // //---------------------------------------------------------------------------- void A_Sor2DthInit () { special1 = 7; // Animation loop counter Thing_Destroy(0); // Kill monsters early } //---------------------------------------------------------------------------- // // PROC A_Sor2DthLoop // //---------------------------------------------------------------------------- void A_Sor2DthLoop () { if (--special1) { // Need to loop SetStateLabel("DeathLoop"); } } } // Sorcerer 2 FX 1 ---------------------------------------------------------- class Sorcerer2FX1 : Actor { Default { Radius 10; Height 6; Speed 20; FastSpeed 28; Damage 1; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: FX16 ABC 3 BRIGHT A_BlueSpark; Loop; Death: FX16 G 5 BRIGHT A_Explode(random[S2FX1](80,111)); FX16 HIJKL 5 BRIGHT; Stop; } //---------------------------------------------------------------------------- // // PROC A_BlueSpark // //---------------------------------------------------------------------------- void A_BlueSpark () { for (int i = 0; i < 2; i++) { Actor mo = Spawn("Sorcerer2FXSpark", pos, ALLOW_REPLACE); if (mo != null) { mo.Vel.X = Random2[BlueSpark]() / 128.; mo.Vel.Y = Random2[BlueSpark]() / 128.; mo.Vel.Z = 1. + Random[BlueSpark]() / 256.; } } } } // Sorcerer 2 FX Spark ------------------------------------------------------ class Sorcerer2FXSpark : Actor { Default { Radius 20; Height 16; +NOBLOCKMAP +NOGRAVITY +NOTELEPORT +CANNOTPUSH +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: FX16 DEF 12 BRIGHT; Stop; } } // Sorcerer 2 FX 2 ---------------------------------------------------------- class Sorcerer2FX2 : Actor { Default { Radius 10; Height 6; Speed 6; Damage 10; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: FX11 A 35 BRIGHT; FX11 A 5 BRIGHT A_GenWizard; FX11 B 5 BRIGHT; Goto Spawn+1; Death: FX11 CDEFG 5 BRIGHT; Stop; } //---------------------------------------------------------------------------- // // PROC A_GenWizard // //---------------------------------------------------------------------------- void A_GenWizard () { Actor mo = Spawn("Wizard", pos, ALLOW_REPLACE); if (mo != null) { mo.AddZ(-mo.Default.Height / 2, false); if (!mo.TestMobjLocation ()) { // Didn't fit mo.ClearCounters(); mo.Destroy (); } else { // [RH] Make the new wizards inherit D'Sparil's target mo.CopyFriendliness (self.target, true); Vel = (0,0,0); SetStateLabel('Death'); bMissile = false; mo.master = target; SpawnTeleportFog(pos, false, true); } } } } // Sorcerer 2 Telefade ------------------------------------------------------ class Sorcerer2Telefade : Actor { Default { +NOBLOCKMAP } States { Spawn: SOR2 GHIJKL 6; Stop; } } // The VM uses 7 integral data types, so for dynamic array support we need one specific set of functions for each of these types. // Do not use these structs directly, they are incomplete and only needed to create prototypes for the needed functions. struct DynArray_I8 native { native readonly int Size; native void Copy(DynArray_I8 other); native void Move(DynArray_I8 other); native void Append (DynArray_I8 other); native int Find(int item) const; native int Push(int item); native bool Pop (); native void Delete (uint index, int deletecount = 1); native void Insert (uint index, int item); native void ShrinkToFit (); native void Grow (uint amount); native void Resize (uint amount); native int Reserve(uint amount); native int Max() const; native void Clear (); } struct DynArray_I16 native { native readonly int Size; native void Copy(DynArray_I16 other); native void Move(DynArray_I16 other); native void Append (DynArray_I16 other); native int Find(int item) const; native int Push(int item); native bool Pop (); native void Delete (uint index, int deletecount = 1); native void Insert (uint index, int item); native void ShrinkToFit (); native void Grow (uint amount); native void Resize (uint amount); native int Reserve(uint amount); native int Max() const; native void Clear (); } struct DynArray_I32 native { native readonly int Size; native void Copy(DynArray_I32 other); native void Move(DynArray_I32 other); native void Append (DynArray_I32 other); native int Find(int item) const; native int Push(int item); native vararg uint PushV (int item, ...); native bool Pop (); native void Delete (uint index, int deletecount = 1); native void Insert (uint index, int item); native void ShrinkToFit (); native void Grow (uint amount); native void Resize (uint amount); native int Reserve(uint amount); native int Max() const; native void Clear (); } struct DynArray_F32 native { native readonly int Size; native void Copy(DynArray_F32 other); native void Move(DynArray_F32 other); native void Append (DynArray_F32 other); native int Find(double item) const; native int Push(double item); native bool Pop (); native void Delete (uint index, int deletecount = 1); native void Insert (uint index, double item); native void ShrinkToFit (); native void Grow (uint amount); native void Resize (uint amount); native int Reserve(uint amount); native int Max() const; native void Clear (); } struct DynArray_F64 native { native readonly int Size; native void Copy(DynArray_F64 other); native void Move(DynArray_F64 other); native void Append (DynArray_F64 other); native int Find(double item) const; native int Push(double item); native bool Pop (); native void Delete (uint index, int deletecount = 1); native void Insert (uint index, double item); native void ShrinkToFit (); native void Grow (uint amount); native void Resize (uint amount); native int Reserve(uint amount); native int Max() const; native void Clear (); } struct DynArray_Ptr native { native readonly int Size; native void Copy(DynArray_Ptr other); native void Move(DynArray_Ptr other); native void Append (DynArray_Ptr other); native int Find(voidptr item) const; native int Push(voidptr item); native bool Pop (); native void Delete (uint index, int deletecount = 1); native void Insert (uint index, voidptr item); native void ShrinkToFit (); native void Grow (uint amount); native void Resize (uint amount); native int Reserve(uint amount); native int Max() const; native void Clear (); } struct DynArray_Obj native { native readonly int Size; native void Copy(DynArray_Obj other); native void Move(DynArray_Obj other); native void Append (DynArray_Obj other); native int Find(Object item) const; native int Push(Object item); native bool Pop (); native void Delete (uint index, int deletecount = 1); native void Insert (uint index, Object item); native void ShrinkToFit (); native void Grow (uint amount); native void Resize (uint amount); native int Reserve(uint amount); native int Max() const; native void Clear (); } struct DynArray_String native { native readonly int Size; native void Copy(DynArray_String other); native void Move(DynArray_String other); native void Append (DynArray_String other); native int Find(String item) const; native int Push(String item); native vararg uint PushV(String item, ...); native bool Pop (); native void Delete (uint index, int deletecount = 1); native void Insert (uint index, String item); native void ShrinkToFit (); native void Grow (uint amount); native void Resize (uint amount); native int Reserve(uint amount); native int Max() const; native void Clear (); } class DynamicLight : Actor { double SpotInnerAngle; double SpotOuterAngle; private int lighttype; private int lightflags; property SpotInnerAngle: SpotInnerAngle; property SpotOuterAngle: SpotOuterAngle; flagdef subtractive: lightflags, 0; flagdef additive: lightflags, 1; flagdef dontlightself: lightflags, 2; flagdef attenuate: lightflags, 3; flagdef noshadowmap: lightflags, 4; flagdef dontlightactors: lightflags, 5; flagdef spot: lightflags, 6; flagdef dontlightothers: lightflags, 7; flagdef dontlightmap: lightflags, 8; enum EArgs { LIGHT_RED = 0, LIGHT_GREEN = 1, LIGHT_BLUE = 2, LIGHT_INTENSITY = 3, LIGHT_SECONDARY_INTENSITY = 4, LIGHT_SCALE = 3, }; // These are for use in A_AttachLight calls. enum LightFlag { LF_SUBTRACTIVE = 1, LF_ADDITIVE = 2, LF_DONTLIGHTSELF = 4, LF_ATTENUATE = 8, LF_NOSHADOWMAP = 16, LF_DONTLIGHTACTORS = 32, LF_SPOT = 64, LF_DONTLIGHTOTHERS = 128, LF_DONTLIGHTMAP = 256, }; enum ELightType { PointLight, PulseLight, FlickerLight, RandomFlickerLight, SectorLight, DummyLight, ColorPulseLight, ColorFlickerLight, RandomColorFlickerLight }; native void SetOffset(Vector3 offset); private native void AttachLight(); private native void ActivateLight(); private native void DeactivateLight(); Default { Height 0; Radius 0.1; FloatBobPhase 0; RenderRadius -1; DynamicLight.SpotInnerAngle 10; DynamicLight.SpotOuterAngle 25; +NOBLOCKMAP +NOGRAVITY +FIXMAPTHINGPOS +INVISIBLE +NOTONAUTOMAP } //========================================================================== // // // //========================================================================== override void Tick() { // Lights do not call the super method. } override void BeginPlay() { ChangeStatNum(STAT_DLIGHT); } override void PostBeginPlay() { Super.PostBeginPlay(); AttachLight(); if (!(SpawnFlags & MTF_DORMANT)) { Activate(self); } } override void Activate(Actor activator) { bDormant = false; ActivateLight(); } override void Deactivate(Actor activator) { bDormant = true; DeactivateLight(); } } class PointLight : DynamicLight { Default { DynamicLight.Type "Point"; } } class PointLightPulse : PointLight { Default { DynamicLight.Type "Pulse"; } } class PointLightFlicker : PointLight { Default { DynamicLight.Type "Flicker"; } } class SectorPointLight : PointLight { Default { DynamicLight.Type "Sector"; } } class PointLightFlickerRandom : PointLight { Default { DynamicLight.Type "RandomFlicker"; } } // DYNAMICLIGHT.ADDITIVE and DYNAMICLIGHT.SUBTRACTIVE are used by the lights for additive and subtractive lights class PointLightAdditive : PointLight { Default { +DYNAMICLIGHT.ADDITIVE } } class PointLightPulseAdditive : PointLightPulse { Default { +DYNAMICLIGHT.ADDITIVE } } class PointLightFlickerAdditive : PointLightFlicker { Default { +DYNAMICLIGHT.ADDITIVE } } class SectorPointLightAdditive : SectorPointLight { Default { +DYNAMICLIGHT.ADDITIVE } } class PointLightFlickerRandomAdditive :PointLightFlickerRandom { Default { +DYNAMICLIGHT.ADDITIVE } } class PointLightSubtractive : PointLight { Default { +DYNAMICLIGHT.SUBTRACTIVE } } class PointLightPulseSubtractive : PointLightPulse { Default { +DYNAMICLIGHT.SUBTRACTIVE } } class PointLightFlickerSubtractive : PointLightFlicker { Default { +DYNAMICLIGHT.SUBTRACTIVE } } class SectorPointLightSubtractive : SectorPointLight { Default { +DYNAMICLIGHT.SUBTRACTIVE } } class PointLightFlickerRandomSubtractive : PointLightFlickerRandom { Default { +DYNAMICLIGHT.SUBTRACTIVE } } class PointLightAttenuated : PointLight { Default { +DYNAMICLIGHT.ATTENUATE } } class PointLightPulseAttenuated : PointLightPulse { Default { +DYNAMICLIGHT.ATTENUATE } } class PointLightFlickerAttenuated : PointLightFlicker { Default { +DYNAMICLIGHT.ATTENUATE } } class SectorPointLightAttenuated : SectorPointLight { Default { +DYNAMICLIGHT.ATTENUATE } } class PointLightFlickerRandomAttenuated :PointLightFlickerRandom { Default { +DYNAMICLIGHT.ATTENUATE } } class SpotLight : DynamicLight { Default { DynamicLight.Type "Point"; +DYNAMICLIGHT.SPOT } } class SpotLightPulse : SpotLight { Default { DynamicLight.Type "Pulse"; } } class SpotLightFlicker : SpotLight { Default { DynamicLight.Type "Flicker"; } } class SectorSpotLight : SpotLight { Default { DynamicLight.Type "Sector"; } } class SpotLightFlickerRandom : SpotLight { Default { DynamicLight.Type "RandomFlicker"; } } class SpotLightAdditive : SpotLight { Default { +DYNAMICLIGHT.ADDITIVE } } class SpotLightPulseAdditive : SpotLightPulse { Default { +DYNAMICLIGHT.ADDITIVE } } class SpotLightFlickerAdditive : SpotLightFlicker { Default { +DYNAMICLIGHT.ADDITIVE } } class SectorSpotLightAdditive : SectorSpotLight { Default { +DYNAMICLIGHT.ADDITIVE } } class SpotLightFlickerRandomAdditive : SpotLightFlickerRandom { Default { +DYNAMICLIGHT.ADDITIVE } } class SpotLightSubtractive : SpotLight { Default { +DYNAMICLIGHT.SUBTRACTIVE } } class SpotLightPulseSubtractive : SpotLightPulse { Default { +DYNAMICLIGHT.SUBTRACTIVE } } class SpotLightFlickerSubtractive : SpotLightFlicker { Default { +DYNAMICLIGHT.SUBTRACTIVE } } class SectorSpotLightSubtractive : SectorSpotLight { Default { +DYNAMICLIGHT.SUBTRACTIVE } } class SpotLightFlickerRandomSubtractive : SpotLightFlickerRandom { Default { +DYNAMICLIGHT.SUBTRACTIVE } } class SpotLightAttenuated : SpotLight { Default { +DYNAMICLIGHT.ATTENUATE } } class SpotLightPulseAttenuated : SpotLightPulse { Default { +DYNAMICLIGHT.ATTENUATE } } class SpotLightFlickerAttenuated : SpotLightFlicker { Default { +DYNAMICLIGHT.ATTENUATE } } class SectorSpotLightAttenuated : SectorSpotLight { Default { +DYNAMICLIGHT.ATTENUATE } } class SpotLightFlickerRandomAttenuated : SpotLightFlickerRandom { Default { +DYNAMICLIGHT.ATTENUATE } } class VavoomLight : DynamicLight { Default { DynamicLight.Type "Point"; } override void BeginPlay () { if (CurSector) AddZ(-CurSector.floorplane.ZatPoint(pos.XY), false); // z is absolute for Vavoom lights Super.BeginPlay(); } } class VavoomLightWhite : VavoomLight { override void BeginPlay () { args[LIGHT_INTENSITY] = args[0] * 4; args[LIGHT_RED] = 128; args[LIGHT_GREEN] = 128; args[LIGHT_BLUE] = 128; Super.BeginPlay(); } } class VavoomLightColor : VavoomLight { override void BeginPlay () { int radius = args[0] * 4; args[LIGHT_RED] = args[1] >> 1; args[LIGHT_GREEN] = args[2] >> 1; args[LIGHT_BLUE] = args[3] >> 1; args[LIGHT_INTENSITY] = radius; Super.BeginPlay(); } } // Entity Nest -------------------------------------------------------------- class EntityNest : Actor { Default { Radius 84; Height 47; +SOLID +NOTDMATCH +FLOORCLIP } States { Spawn: NEST A -1; Stop; } } // Entity Pod --------------------------------------------------------------- class EntityPod : Actor { Default { Radius 25; Height 91; +SOLID +NOTDMATCH SeeSound "misc/gibbed"; } States { Spawn: PODD A 60 A_Look; Loop; See: PODD A 360; PODD B 9 A_NoBlocking; PODD C 9; PODD D 9 A_SpawnEntity; PODD E -1; Stop; } void A_SpawnEntity () { Actor entity = Spawn("EntityBoss", pos + (0,0,70), ALLOW_REPLACE); if (entity != null) { entity.Angle = self.Angle; entity.CopyFriendliness(self, true); entity.Vel.Z = 5; entity.tracer = self; } } } // -------------------------------------------------------------- class EntityBoss : SpectralMonster { Default { Health 2500; Painchance 255; Speed 13; Radius 130; Height 200; FloatSpeed 5; Mass 1000; Monster; +SPECIAL +NOGRAVITY +FLOAT +SHADOW +NOTDMATCH +DONTMORPH +NOTARGET +NOBLOCKMONST +INCOMBAT +LOOKALLAROUND +SPECTRAL +NOICEDEATH MinMissileChance 150; RenderStyle "Translucent"; Alpha 0.5; Tag "$TAG_ENTITY"; SeeSound "entity/sight"; AttackSound "entity/melee"; PainSound "entity/pain"; DeathSound "entity/death"; ActiveSound "entity/active"; Obituary "$OB_ENTITY"; } States { Spawn: MNAM A 100; MNAM B 60 Bright; MNAM CDEFGHIJKL 4 Bright; MNAL A 4 Bright A_Look; MNAL B 4 Bright A_SentinelBob; Goto Spawn+12; See: MNAL AB 4 Bright A_Chase; MNAL C 4 Bright A_SentinelBob; MNAL DEF 4 Bright A_Chase; MNAL G 4 Bright A_SentinelBob; MNAL HIJ 4 Bright A_Chase; MNAL K 4 Bright A_SentinelBob; Loop; Melee: MNAL J 4 Bright A_FaceTarget; MNAL I 4 Bright A_CustomMeleeAttack((random[SpectreMelee](0,255)&9)*5); MNAL C 4 Bright; Goto See+2; Missile: MNAL F 4 Bright A_FaceTarget; MNAL I 4 Bright A_EntityAttack; MNAL E 4 Bright; Goto See+10; Pain: MNAL J 2 Bright A_Pain; Goto See+6; Death: MNAL L 7 Bright A_SpectreChunkSmall; MNAL M 7 Bright A_Scream; MNAL NO 7 Bright A_SpectreChunkSmall; MNAL P 7 Bright A_SpectreChunkLarge; MNAL Q 64 Bright A_SpectreChunkSmall; MNAL Q 6 Bright A_EntityDeath; Stop; } // -------------------------------------------------------------- private void A_SpectralMissile (class missilename) { if (target != null) { Actor missile = SpawnMissileXYZ (Pos + (0,0,32), target, missilename, false); if (missile != null) { missile.tracer = target; missile.CheckMissileSpawn(radius); } } } // -------------------------------------------------------------- void A_EntityAttack() { // Apparent Strife bug: Case 5 was unreachable because they used % 5 instead of % 6. // I've fixed that by making case 1 duplicate it, since case 1 did nothing. switch (random[Entity](0, 4)) { case 0: A_SpotLightning(); break; case 2: A_SpectralMissile ("SpectralLightningH3"); break; case 3: A_Spectre3Attack(); break; case 4: A_SpectralMissile ("SpectralLightningBigV2"); break; default: A_SpectralMissile ("SpectralLightningBigBall2"); break; } } // -------------------------------------------------------------- void A_EntityDeath() { Actor second; double secondRadius = GetDefaultByType("EntitySecond").radius * 2; static const double turns[] = { 0, 90, -90 }; Actor spot = tracer; if (spot == null) spot = self; for (int i = 0; i < 3; i++) { double an = Angle + turns[i]; Vector3 pos = spot.Vec3Angle(secondRadius, an, tracer ? 70. : 0.); second = Spawn("EntitySecond", pos, ALLOW_REPLACE); if (second != null) { second.CopyFriendliness(self, true); second.A_FaceTarget(); second.VelFromAngle(i == 0? 4.8828125 : secondRadius * 4., an); } } } } // Second Entity Boss ------------------------------------------------------- class EntitySecond : SpectralMonster { Default { Health 990; Painchance 255; Speed 14; Radius 130; Height 200; FloatSpeed 5; Mass 1000; Monster; +SPECIAL +NOGRAVITY +FLOAT +SHADOW +NOTDMATCH +DONTMORPH +NOBLOCKMONST +INCOMBAT +LOOKALLAROUND +SPECTRAL +NOICEDEATH MinMissileChance 150; RenderStyle "Translucent"; Alpha 0.25; Tag "$TAG_ENTITY"; SeeSound "alienspectre/sight"; AttackSound "alienspectre/blade"; PainSound "alienspectre/pain"; DeathSound "alienspectre/death"; ActiveSound "alienspectre/active"; Obituary "$OB_ENTITY"; } States { Spawn: MNAL R 10 Bright A_Look; Loop; See: MNAL R 5 Bright A_SentinelBob; MNAL ST 5 Bright A_Chase; MNAL U 5 Bright A_SentinelBob; MNAL V 5 Bright A_Chase; MNAL W 5 Bright A_SentinelBob; Loop; Melee: MNAL S 4 Bright A_FaceTarget; MNAL R 4 Bright A_CustomMeleeAttack((random[SpectreMelee](0,255)&9)*5); MNAL T 4 Bright A_SentinelBob; Goto See+1; Missile: MNAL W 4 Bright A_FaceTarget; MNAL U 4 Bright A_SpawnProjectile("SpectralLightningH3",32,0); MNAL V 4 Bright A_SentinelBob; Goto See+4; Pain: MNAL R 2 Bright A_Pain; Goto See; Death: MDTH A 3 Bright A_Scream; MDTH B 3 Bright A_TossGib; MDTH C 3 Bright A_NoBlocking; MDTH DEFGHIJKLMN 3 Bright A_TossGib; MDTH O 3 Bright A_SubEntityDeath; Stop; } // -------------------------------------------------------------- void A_SubEntityDeath () { if (CheckBossDeath ()) { Level.ExitLevel(0, false); } } } // Ettin -------------------------------------------------------------------- class Ettin : Actor { Default { Health 175; Radius 25; Height 68; Mass 175; Speed 13; Damage 3; Painchance 60; Monster; +FLOORCLIP +TELESTOMP SeeSound "EttinSight"; AttackSound "EttinAttack"; PainSound "EttinPain"; DeathSound "EttinDeath"; ActiveSound "EttinActive"; HowlSound "PuppyBeat"; Obituary "$OB_ETTIN"; Tag "$FN_ETTIN"; } States { Spawn: ETTN AA 10 A_Look; Loop; See: ETTN ABCD 5 A_Chase; Loop; Pain: ETTN H 7 A_Pain; Goto See; Melee: ETTN EF 6 A_FaceTarget; ETTN G 8 A_CustomMeleeAttack(random[EttinAttack](1,8)*2); Goto See; Death: ETTN IJ 4; ETTN K 4 A_Scream; ETTN L 4 A_NoBlocking; ETTN M 4 A_QueueCorpse; ETTN NOP 4; ETTN Q -1; Stop; XDeath: ETTB A 4; ETTB B 4 A_NoBlocking; ETTB C 4 A_SpawnItemEx("EttinMace", 0,0,8.5, random[DropMace](-128,127) * 0.03125, random[DropMace](-128,127) * 0.03125, 10 + random[DropMace](0,255) * 0.015625, 0, SXF_ABSOLUTEVELOCITY); ETTB D 4 A_Scream; ETTB E 4 A_QueueCorpse; ETTB FGHIJK 4; ETTB L -1; Stop; Ice: ETTN R 5 A_FreezeDeath; ETTN R 1 A_FreezeDeathChunks; Wait; } } // Ettin mace --------------------------------------------------------------- class EttinMace : Actor { Default { Radius 5; Height 5; +DROPOFF +CORPSE +NOTELEPORT +FLOORCLIP } States { Spawn: ETTB MNOP 5; Loop; Crash: ETTB Q 5; ETTB R 5 A_QueueCorpse; ETTB S -1; Stop; } } // Ettin mash --------------------------------------------------------------- class EttinMash : Ettin { Default { +NOBLOOD +NOICEDEATH RenderStyle "Translucent"; Alpha 0.4; } States { Death: XDeath: Ice: Stop; } } struct RenderEvent native ui version("2.4") { native readonly Vector3 ViewPos; native readonly double ViewAngle; native readonly double ViewPitch; native readonly double ViewRoll; native readonly double FracTic; native readonly Actor Camera; } struct WorldEvent native play version("2.4") { // for loaded/unloaded native readonly bool IsSaveGame; // this will be true if we are re-entering the hub level. native readonly bool IsReopen; // for unloaded, name of next map (if any) native readonly String NextMap; // for thingspawned/thingdied/thingdestroyed/thingground native readonly Actor Thing; // for thingdied. can be null native readonly Actor Inflictor; // for thingdamaged, line/sector damaged native readonly int Damage; native readonly Actor DamageSource; native readonly Name DamageType; native readonly EDmgFlags DamageFlags; native readonly double DamageAngle; // for line(pre)activated native readonly Line ActivatedLine; native readonly int ActivationType; native bool ShouldActivate; // for line/sector damaged native readonly SectorPart DamageSectorPart; native readonly Line DamageLine; native readonly Sector DamageSector; native readonly int DamageLineSide; native readonly vector3 DamagePosition; native readonly bool DamageIsRadius; native int NewDamage; native readonly State CrushedState; } struct PlayerEvent native play version("2.4") { // this is the player number that caused the event. // note: you can get player struct from this by using players[e.PlayerNumber] native readonly int PlayerNumber; // this will be true if we are re-entering the hub level. native readonly bool IsReturn; } struct ConsoleEvent native version("2.4") { // for net events, this will be the activator. // for UI events, this is always -1, and you need to check if level is loaded and use players[consoleplayer]. native readonly int Player; // this is the name and args as specified in SendNetworkEvent or event/netevent CCMDs native readonly String Name; native readonly int Args[3]; // this will be true if the event is fired from the console by event/netevent CCMD native readonly bool IsManual; } struct ReplaceEvent native version("2.4") { native readonly Class Replacee; native Class Replacement; native bool IsFinal; } struct ReplacedEvent native version("3.7") { native Class Replacee; native readonly Class Replacement; native bool IsFinal; } class StaticEventHandler : Object native play version("2.4") { // static event handlers CAN register other static event handlers. // unlike EventHandler.Create that will not create them. clearscope static native StaticEventHandler Find(Class type); // just for convenience. who knows. // these are called when the handler gets registered or unregistered // you can set Order/IsUiProcessor here. virtual void OnRegister() {} virtual void OnUnregister() {} // actual handlers are here virtual void OnEngineInitialize() {} virtual void WorldLoaded(WorldEvent e) {} virtual void WorldUnloaded(WorldEvent e) {} virtual void WorldThingSpawned(WorldEvent e) {} virtual void WorldThingDied(WorldEvent e) {} virtual void WorldThingGround(WorldEvent e) {} virtual void WorldThingRevived(WorldEvent e) {} virtual void WorldThingDamaged(WorldEvent e) {} virtual void WorldThingDestroyed(WorldEvent e) {} virtual void WorldLinePreActivated(WorldEvent e) {} virtual void WorldLineActivated(WorldEvent e) {} virtual void WorldSectorDamaged(WorldEvent e) {} virtual void WorldLineDamaged(WorldEvent e) {} virtual void WorldLightning(WorldEvent e) {} // for the sake of completeness. virtual void WorldTick() {} // //virtual ui void RenderFrame(RenderEvent e) {} virtual ui void RenderOverlay(RenderEvent e) {} virtual ui void RenderUnderlay(RenderEvent e) {} // virtual void PlayerEntered(PlayerEvent e) {} virtual void PlayerSpawned(PlayerEvent e) {} virtual void PlayerRespawned(PlayerEvent e) {} virtual void PlayerDied(PlayerEvent e) {} virtual void PlayerDisconnected(PlayerEvent e) {} // virtual ui bool UiProcess(UiEvent e) { return false; } virtual ui bool InputProcess(InputEvent e) { return false; } virtual ui void UiTick() {} virtual ui void PostUiTick() {} // virtual ui void ConsoleProcess(ConsoleEvent e) {} virtual ui void InterfaceProcess(ConsoleEvent e) {} virtual void NetworkProcess(ConsoleEvent e) {} // virtual void CheckReplacement(ReplaceEvent e) {} virtual void CheckReplacee(ReplacedEvent e) {} // virtual void NewGame() {} // this value will be queried on Register() to decide the relative order of this handler to every other. // this is most useful in UI systems. // default is 0. native readonly int Order; native void SetOrder(int order); // this value will be queried on user input to decide whether to send UiProcess to this handler. native bool IsUiProcessor; // this value determines whether mouse input is required. native bool RequireMouse; } class EventHandler : StaticEventHandler native version("2.4") { clearscope static native StaticEventHandler Find(class type); clearscope static native void SendNetworkEvent(String name, int arg1 = 0, int arg2 = 0, int arg3 = 0); clearscope static native void SendInterfaceEvent(int playerNum, string name, int arg1 = 0, int arg2 = 0, int arg3 = 0); } // Fast projectiles -------------------------------------------------------- class FastProjectile : Actor { Default { Projectile; MissileHeight 0; } virtual void Effect() { class trail = MissileName; if (trail != null) { double hitz = pos.z - 8; if (hitz < floorz) { hitz = floorz; } // Do not clip this offset to the floor. hitz += MissileHeight; Actor act = Spawn (trail, (pos.xy, hitz), ALLOW_REPLACE); if (act != null) { if (bGetOwner && target != null) act.target = target; else act.target = self; act.angle = angle; act.pitch = pitch; } } } //---------------------------------------------------------------------------- // // AFastProjectile :: Tick // // Thinker for the ultra-fast projectiles used by Heretic and Hexen // //---------------------------------------------------------------------------- override void Tick () { ClearInterpolation(); double oldz = pos.Z; if (isFrozen()) return; // [RH] Ripping is a little different than it was in Hexen FCheckPosition tm; tm.DoRipping = bRipper; int count = 8; if (radius > 0) { while (abs(Vel.X) >= radius * count || abs(Vel.Y) >= radius * count) { // we need to take smaller steps. count += count; } } if (height > 0) { while (abs(Vel.Z) >= height * count) { count += count; } } // Handle movement bool ismoved = Vel != (0, 0, 0) // Check Z position set during previous tick. // It should be strictly equal to the argument of SetZ() function. || ( (pos.Z != floorz ) /* Did it hit the floor? */ && (pos.Z != ceilingz - Height) /* Did it hit the ceiling? */ ); if (ismoved) { // force some lateral movement so that collision detection works as intended. if (bMissile && Vel.X == 0 && Vel.Y == 0 && !IsZeroDamage()) { VelFromAngle(MinVel); } Vector3 frac = Vel / count; int changexy = frac.X != 0 || frac.Y != 0; int ripcount = count / 8; for (int i = 0; i < count; i++) { if (changexy) { if (--ripcount <= 0) { tm.ClearLastRipped(); // [RH] Do rip damage each step, like Hexen } if (!TryMove (Pos.XY + frac.XY, true, false, tm)) { // Blocked move if (!bSkyExplode) { let l = tm.ceilingline; if (l && l.backsector && l.backsector.GetTexture(sector.ceiling) == skyflatnum) { let posr = PosRelative(l.backsector); if (pos.Z >= l.backsector.ceilingplane.ZatPoint(posr.XY)) { // Hack to prevent missiles exploding against the sky. // Does not handle sky floors. Destroy (); return; } } // [RH] Don't explode on horizon lines. if (BlockingLine != NULL && BlockingLine.special == Line_Horizon) { Destroy (); return; } } ExplodeMissile (BlockingLine, BlockingMobj); return; } } AddZ(frac.Z); UpdateWaterLevel (); oldz = pos.Z; if (oldz <= floorz) { // Hit the floor if (floorpic == skyflatnum && !bSkyExplode) { // [RH] Just remove the missile without exploding it // if this is a sky floor. Destroy (); return; } SetZ(floorz); HitFloor (); Destructible.ProjectileHitPlane(self, SECPART_Floor); ExplodeMissile (NULL, NULL); return; } if (pos.Z + height > ceilingz) { // Hit the ceiling if (ceilingpic == skyflatnum && !bSkyExplode) { Destroy (); return; } SetZ(ceilingz - Height); Destructible.ProjectileHitPlane(self, SECPART_Ceiling); ExplodeMissile (NULL, NULL); return; } CheckPortalTransition(); if (changexy && ripcount <= 0) { ripcount = count >> 3; // call the 'Effect' method. Effect(); } } } if (!CheckNoDelay()) return; // freed itself // Advance the state if (tics != -1) { if (tics > 0) tics--; while (!tics) { if (!SetState (CurState.NextState)) { // mobj was removed return; } } } } } //=========================================================================== // // Mancubus // //=========================================================================== class Fatso : Actor { Default { Health 600; Radius 48; Height 64; Mass 1000; Speed 8; PainChance 80; Monster; +FLOORCLIP +BOSSDEATH +MAP07BOSS1 SeeSound "fatso/sight"; PainSound "fatso/pain"; DeathSound "fatso/death"; ActiveSound "fatso/active"; Obituary "$OB_FATSO"; Tag "$FN_MANCU"; } States { Spawn: FATT AB 15 A_Look; Loop; See: FATT AABBCCDDEEFF 4 A_Chase; Loop; Missile: FATT G 20 A_FatRaise; FATT H 10 BRIGHT A_FatAttack1; FATT IG 5 A_FaceTarget; FATT H 10 BRIGHT A_FatAttack2; FATT IG 5 A_FaceTarget; FATT H 10 BRIGHT A_FatAttack3; FATT IG 5 A_FaceTarget; Goto See; Pain: FATT J 3; FATT J 3 A_Pain; Goto See; Death: FATT K 6; FATT L 6 A_Scream; FATT M 6 A_NoBlocking; FATT NOPQRS 6; FATT T -1 A_BossDeath; Stop; Raise: FATT R 5; FATT QPONMLK 5; Goto See; } } //=========================================================================== // // Mancubus fireball // //=========================================================================== class FatShot : Actor { Default { Radius 6; Height 8; Speed 20; Damage 8; Projectile; +RANDOMIZE +ZDOOMTRANS RenderStyle "Add"; Alpha 1; SeeSound "fatso/attack"; DeathSound "fatso/shotx"; } States { Spawn: MANF AB 4 BRIGHT; Loop; Death: MISL B 8 BRIGHT; MISL C 6 BRIGHT; MISL D 4 BRIGHT; Stop; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== extend class Actor { const FATSPREAD = 90./8; void A_FatRaise() { A_FaceTarget(); A_StartSound("fatso/raiseguns", CHAN_WEAPON); } // // Mancubus attack, // firing three missiles in three different directions? // Doesn't look like it. // void A_FatAttack1(class spawntype = "FatShot") { if (target) { A_FaceTarget (); // Change direction to ... Angle += FATSPREAD; SpawnMissile (target, spawntype); Actor missile = SpawnMissile (target, spawntype); if (missile) { missile.Angle += FATSPREAD; missile.VelFromAngle(); } } } void A_FatAttack2(class spawntype = "FatShot") { if (target) { A_FaceTarget (); // Now here choose opposite deviation. Angle -= FATSPREAD; SpawnMissile (target, spawntype); Actor missile = SpawnMissile (target, spawntype); if (missile) { missile.Angle -= FATSPREAD; missile.VelFromAngle(); } } } void A_FatAttack3(class spawntype = "FatShot") { if (target) { A_FaceTarget (); Actor missile = SpawnMissile (target, spawntype); if (missile) { missile.Angle -= FATSPREAD/2; missile.VelFromAngle(); } missile = SpawnMissile (target, spawntype); if (missile) { missile.Angle += FATSPREAD/2; missile.VelFromAngle(); } } } // // killough 9/98: a mushroom explosion effect, sorta :) // Original idea: Linguica // void A_Mushroom(class spawntype = "FatShot", int numspawns = 0, int flags = 0, double vrange = 4.0, double hrange = 0.5) { int i, j; if (numspawns == 0) { numspawns = GetMissileDamage(0, 1); } A_Explode(128, 128, (flags & MSF_DontHurt) ? 0 : XF_HURTSOURCE); // Now launch mushroom cloud Actor aimtarget = Spawn("Mapspot", pos, NO_REPLACE); // We need something to aim at. if (aimtarget == null) return; Actor owner = (flags & MSF_DontHurt) ? target : self; aimtarget.Height = Height; bool shootmode = ((flags & MSF_Classic) || // Flag explicitly set, or no flags and compat options (flags == 0 && CurState.bDehacked && (Level.compatflags & COMPATF_MUSHROOM))); for (i = -numspawns; i <= numspawns; i += 8) { for (j = -numspawns; j <= numspawns; j += 8) { Actor mo; aimtarget.SetXYZ(pos + (i, j, (i, j).Length() * vrange)); // Aim up fairly high if (shootmode) { // Use old function for MBF compatibility mo = OldSpawnMissile(aimtarget, spawntype, owner); } else // Use normal function { mo = SpawnMissile(aimtarget, spawntype, owner); } if (mo) { // Slow it down a bit mo.Vel *= hrange; mo.bNoGravity = false; // Make debris fall under gravity } } } aimtarget.Destroy(); } } // The Fighter's Axe -------------------------------------------------------- class FWeapAxe : FighterWeapon { const AXERANGE = (2.25 * DEFMELEERANGE); Default { Weapon.SelectionOrder 1500; +WEAPON.AXEBLOOD +WEAPON.AMMO_OPTIONAL +WEAPON.MELEEWEAPON Weapon.AmmoUse1 2; Weapon.AmmoGive1 25; Weapon.KickBack 150; Weapon.YAdjust -12; Weapon.AmmoType1 "Mana1"; Inventory.PickupMessage "$TXT_WEAPON_F2"; Obituary "$OB_MPFWEAPAXE"; Tag "$TAG_FWEAPAXE"; } States { Spawn: WFAX A -1; Stop; Select: FAXE A 1 A_FAxeCheckUp; Loop; Deselect: FAXE A 1 A_Lower; Loop; Ready: FAXE A 1 A_FAxeCheckReady; Loop; Fire: FAXE B 4 Offset (15, 32) A_FAxeCheckAtk; FAXE C 3 Offset (15, 32); FAXE D 2 Offset (15, 32); FAXE D 1 Offset (-5, 70) A_FAxeAttack; EndAttack: FAXE D 2 Offset (-25, 90); FAXE E 1 Offset (15, 32); FAXE E 2 Offset (10, 54); FAXE E 7 Offset (10, 150); FAXE A 1 Offset (0, 60) A_ReFire; FAXE A 1 Offset (0, 52); FAXE A 1 Offset (0, 44); FAXE A 1 Offset (0, 36); FAXE A 1; Goto Ready; SelectGlow: FAXE L 1 A_FAxeCheckUpG; Loop; DeselectGlow: FAXE L 1 A_Lower; Loop; ReadyGlow: FAXE LLL 1 A_FAxeCheckReadyG; FAXE MMM 1 A_FAxeCheckReadyG; Loop; FireGlow: FAXE N 4 Offset (15, 32); FAXE O 3 Offset (15, 32); FAXE P 2 Offset (15, 32); FAXE P 1 Offset (-5, 70) A_FAxeAttack; FAXE P 2 Offset (-25, 90); FAXE Q 1 Offset (15, 32); FAXE Q 2 Offset (10, 54); FAXE Q 7 Offset (10, 150); FAXE A 1 Offset (0, 60) A_ReFire; FAXE A 1 Offset (0, 52); FAXE A 1 Offset (0, 44); FAXE A 1 Offset (0, 36); FAXE A 1; Goto ReadyGlow; } override State GetUpState () { return Ammo1.Amount ? FindState ("SelectGlow") : Super.GetUpState(); } override State GetDownState () { return Ammo1.Amount ? FindState ("DeselectGlow") : Super.GetDownState(); } override State GetReadyState () { return Ammo1.Amount ? FindState ("ReadyGlow") : Super.GetReadyState(); } override State GetAtkState (bool hold) { return Ammo1.Amount ? FindState ("FireGlow") : Super.GetAtkState(hold); } //============================================================================ // // A_FAxeCheckReady // //============================================================================ action void A_FAxeCheckReady() { if (player == null) { return; } Weapon w = player.ReadyWeapon; if (w.Ammo1 && w.Ammo1.Amount > 0) { player.SetPsprite(PSP_WEAPON, w.FindState("ReadyGlow")); } else { A_WeaponReady(); } } //============================================================================ // // A_FAxeCheckReadyG // //============================================================================ action void A_FAxeCheckReadyG() { if (player == null) { return; } Weapon w = player.ReadyWeapon; if (!w.Ammo1 || w.Ammo1.Amount <= 0) { player.SetPsprite(PSP_WEAPON, w.FindState("Ready")); } else { A_WeaponReady(); } } //============================================================================ // // A_FAxeCheckUp // //============================================================================ action void A_FAxeCheckUp() { if (player == null) { return; } Weapon w = player.ReadyWeapon; if (w.Ammo1 && w.Ammo1.Amount > 0) { player.SetPsprite(PSP_WEAPON, w.FindState("SelectGlow")); } else { A_Raise(); } } //============================================================================ // // A_FAxeCheckUpG // //============================================================================ action void A_FAxeCheckUpG() { if (player == null) { return; } Weapon w = player.ReadyWeapon; if (!w.Ammo1 || w.Ammo1.Amount <= 0) { player.SetPsprite(PSP_WEAPON, w.FindState("Select")); } else { A_Raise(); } } //============================================================================ // // A_FAxeCheckAtk // //============================================================================ action void A_FAxeCheckAtk() { if (player == null) { return; } Weapon w = player.ReadyWeapon; if (w.Ammo1 && w.Ammo1.Amount > 0) { player.SetPsprite(PSP_WEAPON, w.FindState("FireGlow")); } } //============================================================================ // // A_FAxeAttack // //============================================================================ action void A_FAxeAttack() { FTranslatedLineTarget t; if (player == null) { return; } int damage = random[AxeAtk](40, 55); damage += random[AxeAtk](0, 7); int power = 0; Weapon weapon = player.ReadyWeapon; class pufftype; int usemana; if ((usemana = (weapon.Ammo1 && weapon.Ammo1.Amount > 0))) { damage <<= 1; power = 6; pufftype = "AxePuffGlow"; } else { pufftype = "AxePuff"; } for (int i = 0; i < 16; i++) { for (int j = 1; j >= -1; j -= 2) { double ang = angle + j*i*(45. / 16); double slope = AimLineAttack(ang, AXERANGE, t, 0., ALF_CHECK3D); if (t.linetarget) { LineAttack(ang, AXERANGE, slope, damage, 'Melee', pufftype, true, t); if (t.linetarget != null) { if (t.linetarget.bIsMonster || t.linetarget.player) { t.linetarget.Thrust(power, t.attackAngleFromSource); } AdjustPlayerAngle(t); weapon.DepleteAmmo (weapon.bAltFire, false); if ((weapon.Ammo1 == null || weapon.Ammo1.Amount == 0) && (!(weapon.bPrimary_Uses_Both) || weapon.Ammo2 == null || weapon.Ammo2.Amount == 0)) { player.SetPsprite(PSP_WEAPON, weapon.FindState("EndAttack")); } return; } } } } // didn't find any creatures, so try to strike any walls self.weaponspecial = 0; double slope = AimLineAttack (angle, DEFMELEERANGE, null, 0., ALF_CHECK3D); LineAttack (angle, DEFMELEERANGE, slope, damage, 'Melee', pufftype, true); } } // Axe Puff ----------------------------------------------------------------- class AxePuff : Actor { Default { +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS RenderStyle "Translucent"; Alpha 0.6; SeeSound "FighterAxeHitThing"; AttackSound "FighterHammerHitWall"; ActiveSound "FighterHammerMiss"; } States { Spawn: FHFX STUVW 4; Stop; } } // Glowing Axe Puff --------------------------------------------------------- class AxePuffGlow : AxePuff { Default { +PUFFONACTORS +ZDOOMTRANS RenderStyle "Add"; Alpha 1; } States { Spawn: FAXE RSTUVWX 4 Bright; Stop; } } // Fighter Boss (Zedek) ----------------------------------------------------- class FighterBoss : Actor { Default { health 800; PainChance 50; Speed 25; Radius 16; Height 64; Monster; +FLOORCLIP +TELESTOMP +DONTMORPH PainSound "PlayerFighterPain"; DeathSound "PlayerFighterCrazyDeath"; Obituary "$OB_FBOSS"; Tag "$FN_FBOSS"; } States { Spawn: PLAY A 2; PLAY A 3 A_ClassBossHealth; PLAY A 5 A_Look; Wait; See: PLAY ABCD 4 A_FastChase; Loop; Pain: PLAY G 4; PLAY G 4 A_Pain; Goto See; Melee: Missile: PLAY E 8 A_FaceTarget; PLAY F 8 A_FighterAttack; Goto See; Death: PLAY H 6; PLAY I 6 A_Scream; PLAY JK 6; PLAY L 6 A_NoBlocking; PLAY M 6; PLAY N -1; Stop; XDeath: PLAY O 5 A_Scream; PLAY P 5 A_SkullPop; PLAY R 5 A_NoBlocking; PLAY STUV 5; PLAY W -1; Stop; Ice: PLAY X 5 A_FreezeDeath; PLAY X 1 A_FreezeDeathChunks; Wait; Burn: FDTH A 5 Bright A_StartSound("PlayerFighterBurnDeath"); FDTH B 4 Bright; FDTH G 5 Bright; FDTH H 4 Bright A_Scream; FDTH I 5 Bright; FDTH J 4 Bright; FDTH K 5 Bright; FDTH L 4 Bright; FDTH M 5 Bright; FDTH N 4 Bright; FDTH O 5 Bright; FDTH P 4 Bright; FDTH Q 5 Bright; FDTH R 4 Bright; FDTH S 5 Bright A_NoBlocking; FDTH T 4 Bright; FDTH U 5 Bright; FDTH V 4 Bright; Stop; } //============================================================================ // // A_FighterAttack // //============================================================================ void A_FighterAttack() { if (!target) return; SpawnMissileAngle("FSwordMissile", Angle + (45. / 4), 0); SpawnMissileAngle("FSwordMissile", Angle + (45. / 8), 0); SpawnMissileAngle("FSwordMissile", Angle, 0); SpawnMissileAngle("FSwordMissile", Angle - (45. / 8), 0); SpawnMissileAngle("FSwordMissile", Angle - (45. / 4), 0); A_StartSound ("FighterSwordFire", CHAN_WEAPON); } } // Fist (first weapon) ------------------------------------------------------ class FWeapFist : FighterWeapon { Default { +BLOODSPLATTER Weapon.SelectionOrder 3400; +WEAPON.MELEEWEAPON Weapon.KickBack 150; Obituary "$OB_MPFWEAPFIST"; Tag "$TAG_FWEAPFIST"; } States { Select: FPCH A 1 A_Raise; Loop; Deselect: FPCH A 1 A_Lower; Loop; Ready: FPCH A 1 A_WeaponReady; Loop; Fire: FPCH B 5 Offset (5, 40); FPCH C 4 Offset (5, 40); FPCH D 4 Offset (5, 40) A_FPunchAttack; FPCH C 4 Offset (5, 40); FPCH B 5 Offset (5, 40) A_ReFire; Goto Ready; Fire2: FPCH DE 4 Offset (5, 40); FPCH E 1 Offset (15, 50); FPCH E 1 Offset (25, 60); FPCH E 1 Offset (35, 70); FPCH E 1 Offset (45, 80); FPCH E 1 Offset (55, 90); FPCH E 1 Offset (65, 100); FPCH E 10 Offset (0, 150); Goto Ready; } //============================================================================ // // TryPunch // // Returns true if an actor was punched, false if not. // //============================================================================ private action bool TryPunch(double angle, int damage, int power) { Class pufftype; FTranslatedLineTarget t; double slope = AimLineAttack (angle, 2*DEFMELEERANGE, t, 0., ALF_CHECK3D); if (t.linetarget != null) { if (++weaponspecial >= 3) { damage <<= 1; power *= 3; pufftype = "HammerPuff"; } else { pufftype = "PunchPuff"; } LineAttack (angle, 2*DEFMELEERANGE, slope, damage, 'Melee', pufftype, true, t); if (t.linetarget != null) { // The mass threshold has been changed to CommanderKeen's value which has been used most often for 'unmovable' stuff. if (t.linetarget.player != null || (t.linetarget.Mass < 10000000 && (t.linetarget.bIsMonster))) { if (!t.linetarget.bDontThrust) t.linetarget.Thrust(power, t.attackAngleFromSource); } AdjustPlayerAngle(t); return true; } } return false; } //============================================================================ // // A_FPunchAttack // //============================================================================ action void A_FPunchAttack() { if (player == null) { return; } int damage = random[FighterAtk](40, 55); for (int i = 0; i < 16; i++) { if (TryPunch(angle + i*(45./16), damage, 2) || TryPunch(angle - i*(45./16), damage, 2)) { // hit something if (weaponspecial >= 3) { weaponspecial = 0; player.SetPsprite(PSP_WEAPON, player.ReadyWeapon.FindState("Fire2")); A_StartSound ("*fistgrunt", CHAN_VOICE); } return; } } // didn't find any creatures, so try to strike any walls weaponspecial = 0; double slope = AimLineAttack (angle, DEFMELEERANGE, null, 0., ALF_CHECK3D); LineAttack (angle, DEFMELEERANGE, slope, damage, 'Melee', "PunchPuff", true); } } // Punch puff --------------------------------------------------------------- class PunchPuff : Actor { Default { +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS RenderStyle "Translucent"; Alpha 0.6; SeeSound "FighterPunchHitThing"; AttackSound "FighterPunchHitWall"; ActiveSound "FighterPunchMiss"; VSpeed 1; } States { Spawn: FHFX STUVW 4; Stop; } } // The Fighter's Hammer ----------------------------------------------------- class FWeapHammer : FighterWeapon { const HAMMER_RANGE = 1.5 * DEFMELEERANGE; Default { +BLOODSPLATTER Weapon.SelectionOrder 900; +WEAPON.AMMO_OPTIONAL Weapon.AmmoUse1 3; Weapon.AmmoGive1 25; Weapon.KickBack 150; Weapon.YAdjust -10; Weapon.AmmoType1 "Mana2"; Inventory.PickupMessage "$TXT_WEAPON_F3"; Obituary "$OB_MPFWEAPHAMMERM"; Tag "$TAG_FWEAPHAMMER"; } States { Spawn: WFHM A -1; Stop; Select: FHMR A 1 A_Raise; Loop; Deselect: FHMR A 1 A_Lower; Loop; Ready: FHMR A 1 A_WeaponReady; Loop; Fire: FHMR B 6 Offset (5, 0); FHMR C 3 Offset (5, 0) A_FHammerAttack; FHMR D 3 Offset (5, 0); FHMR E 2 Offset (5, 0); FHMR E 10 Offset (5, 150) A_FHammerThrow; FHMR A 1 Offset (0, 60); FHMR A 1 Offset (0, 55); FHMR A 1 Offset (0, 50); FHMR A 1 Offset (0, 45); FHMR A 1 Offset (0, 40); FHMR A 1 Offset (0, 35); FHMR A 1; Goto Ready; } //============================================================================ // // A_FHammerAttack // //============================================================================ action void A_FHammerAttack() { FTranslatedLineTarget t; if (player == null) { return; } int damage = random[HammerAtk](60, 123); for (int i = 0; i < 16; i++) { for (int j = 1; j >= -1; j -= 2) { double ang = angle + j*i*(45. / 32); double slope = AimLineAttack(ang, HAMMER_RANGE, t, 0., ALF_CHECK3D); if (t.linetarget != null) { LineAttack(ang, HAMMER_RANGE, slope, damage, 'Melee', "HammerPuff", true, t); if (t.linetarget != null) { AdjustPlayerAngle(t); if (t.linetarget.bIsMonster || t.linetarget.player) { t.linetarget.Thrust(10, t.attackAngleFromSource); } weaponspecial = false; // Don't throw a hammer return; } } } } // didn't find any targets in meleerange, so set to throw out a hammer double slope = AimLineAttack (angle, HAMMER_RANGE, null, 0., ALF_CHECK3D); weaponspecial = (LineAttack (angle, HAMMER_RANGE, slope, damage, 'Melee', "HammerPuff", true) == null); // Don't spawn a hammer if the player doesn't have enough mana if (player.ReadyWeapon == null || !player.ReadyWeapon.CheckAmmo (player.ReadyWeapon.bAltFire ? Weapon.AltFire : Weapon.PrimaryFire, false, true)) { weaponspecial = false; } } //============================================================================ // // A_FHammerThrow // //============================================================================ action void A_FHammerThrow() { if (player == null) { return; } if (!weaponspecial) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire, false)) return; } Actor mo = SpawnPlayerMissile ("HammerMissile"); if (mo) { mo.special1 = 0; } } } // Hammer Missile ----------------------------------------------------------- class HammerMissile : Actor { Default { Speed 25; Radius 14; Height 20; Damage 10; DamageType "Fire"; Projectile; DeathSound "FighterHammerExplode"; Obituary "$OB_MPFWEAPHAMMERR"; } States { Spawn: FHFX A 2 Bright; FHFX B 2 Bright A_StartSound ("FighterHammerContinuous"); FHFX CDEFGH 2 Bright; Loop; Death: FHFX I 3 Bright A_SetRenderStyle(1, STYLE_Add); FHFX J 3 Bright; FHFX K 3 Bright A_Explode (128, 128, 0); FHFX LM 3 Bright; FHFX N 3; FHFX OPQR 3 Bright; Stop; } } // Hammer Puff (also used by fist) ------------------------------------------ class HammerPuff : Actor { Default { +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS RenderStyle "Translucent"; Alpha 0.6; VSpeed 0.8; SeeSound "FighterHammerHitThing"; AttackSound "FighterHammerHitWall"; ActiveSound "FighterHammerMiss"; } States { Spawn: FHFX STUVW 4; Stop; } } // The fighter -------------------------------------------------------------- class FighterPlayer : PlayerPawn { Default { Health 100; PainChance 255; Radius 16; Height 64; Speed 1; +NOSKIN +NODAMAGETHRUST +PLAYERPAWN.NOTHRUSTWHENINVUL PainSound "PlayerFighterPain"; RadiusDamageFactor 0.25; Player.JumpZ 9; Player.Viewheight 48; Player.SpawnClass "Fighter"; Player.DisplayName "Fighter"; Player.SoundClass "fighter"; Player.ScoreIcon "FITEFACE"; Player.HealRadiusType "Armor"; Player.Hexenarmor 15, 25, 20, 15, 5; Player.StartItem "FWeapFist"; Player.ForwardMove 1.08, 1.2; Player.SideMove 1.125, 1.475; Player.Portrait "P_FWALK1"; Player.WeaponSlot 1, "FWeapFist"; Player.WeaponSlot 2, "FWeapAxe"; Player.WeaponSlot 3, "FWeapHammer"; Player.WeaponSlot 4, "FWeapQuietus"; Player.ColorRange 246, 254; Player.Colorset 0, "$TXT_COLOR_GOLD", 246, 254, 253; Player.ColorsetFile 1, "$TXT_COLOR_RED", "TRANTBL0", 0xAC; Player.ColorsetFile 2, "$TXT_COLOR_BLUE", "TRANTBL1", 0x9D; Player.ColorsetFile 3, "$TXT_COLOR_DULLGREEN", "TRANTBL2", 0x3E; Player.ColorsetFile 4, "$TXT_COLOR_GREEN", "TRANTBL3", 0xC8; Player.ColorsetFile 5, "$TXT_COLOR_GRAY", "TRANTBL4", 0x2D; Player.ColorsetFile 6, "$TXT_COLOR_BROWN", "TRANTBL5", 0x6F; Player.ColorsetFile 7, "$TXT_COLOR_PURPLE", "TRANTBL6", 0xEE; } States { Spawn: PLAY A -1; Stop; See: PLAY ABCD 4; Loop; Missile: Melee: PLAY EF 8; Goto Spawn; Pain: PLAY G 4; PLAY G 4 A_Pain; Goto Spawn; Death: PLAY H 6; PLAY I 6 A_PlayerScream; PLAY JK 6; PLAY L 6 A_NoBlocking; PLAY M 6; PLAY N -1; Stop; XDeath: PLAY O 5 A_PlayerScream; PLAY P 5 A_SkullPop("BloodyFighterSkull"); PLAY R 5 A_NoBlocking; PLAY STUV 5; PLAY W -1; Stop; Ice: PLAY X 5 A_FreezeDeath; PLAY X 1 A_FreezeDeathChunks; Wait; Burn: FDTH A 5 BRIGHT A_StartSound("*burndeath"); FDTH B 4 BRIGHT; FDTH G 5 BRIGHT; FDTH H 4 BRIGHT A_PlayerScream; FDTH I 5 BRIGHT; FDTH J 4 BRIGHT; FDTH K 5 BRIGHT; FDTH L 4 BRIGHT; FDTH M 5 BRIGHT; FDTH N 4 BRIGHT; FDTH O 5 BRIGHT; FDTH P 4 BRIGHT; FDTH Q 5 BRIGHT; FDTH R 4 BRIGHT; FDTH S 5 BRIGHT A_NoBlocking; FDTH T 4 BRIGHT; FDTH U 5 BRIGHT; FDTH V 4 BRIGHT; ACLO E 35 A_CheckPlayerDone; Wait; ACLO E 8; Stop; } } // The fighter's bloody skull -------------------------------------------------------------- class BloodyFighterSkull : PlayerChunk { Default { Radius 4; Height 4; Gravity 0.125; +NOBLOCKMAP +DROPOFF +CANNOTPUSH +SKYEXPLODE +NOBLOCKMONST +NOSKIN } States { Spawn: BSKL A 0; BSKL ABCDFGH 5 A_CheckFloor("Hit"); Goto Spawn+1; Hit: BSKL I 16 A_CheckPlayerDone; Wait; } } // Fighter Weapon Piece ----------------------------------------------------- class FighterWeaponPiece : WeaponPiece { Default { Inventory.PickupSound "misc/w_pkup"; Inventory.PickupMessage "$TXT_QUIETUS_PIECE"; Inventory.ForbiddenTo "ClericPlayer", "MagePlayer"; WeaponPiece.Weapon "FWeapQuietus"; +FLOATBOB } } // Fighter Weapon Piece 1 --------------------------------------------------- class FWeaponPiece1 : FighterWeaponPiece { Default { WeaponPiece.Number 1; } States { Spawn: WFR1 A -1 Bright; Stop; } } // Fighter Weapon Piece 2 --------------------------------------------------- class FWeaponPiece2 : FighterWeaponPiece { Default { WeaponPiece.Number 2; } States { Spawn: WFR2 A -1 Bright; Stop; } } // Fighter Weapon Piece 3 --------------------------------------------------- class FWeaponPiece3 : FighterWeaponPiece { Default { WeaponPiece.Number 3; } States { Spawn: WFR3 A -1 Bright; Stop; } } // Quietus Drop ------------------------------------------------------------- class QuietusDrop : Actor { States { Spawn: TNT1 A 1; TNT1 A 1 A_DropWeaponPieces("FWeaponPiece1", "FWeaponPiece2", "FWeaponPiece3"); Stop; } } // The Fighter's Sword (Quietus) -------------------------------------------- class FWeapQuietus : FighterWeapon { Default { Health 3; Weapon.SelectionOrder 2900; +WEAPON.PRIMARY_USES_BOTH; +Inventory.NoAttenPickupSound Weapon.AmmoUse1 14; Weapon.AmmoUse2 14; Weapon.AmmoGive1 20; Weapon.AmmoGive2 20; Weapon.KickBack 150; Weapon.YAdjust 10; Weapon.AmmoType1 "Mana1"; Weapon.AmmoType2 "Mana2"; Inventory.PickupMessage "$TXT_WEAPON_F4"; Inventory.PickupSound "WeaponBuild"; Tag "$TAG_FWEAPQUIETUS"; } States { Spawn: TNT1 A -1; Stop; Select: FSRD A 1 Bright A_Raise; Loop; Deselect: FSRD A 1 Bright A_Lower; Loop; Ready: FSRD AAAABBBBCCCC 1 Bright A_WeaponReady; Loop; Fire: FSRD DE 3 Bright Offset (5, 36); FSRD F 2 Bright Offset (5, 36); FSRD G 3 Bright Offset (5, 36) A_FSwordAttack; FSRD H 2 Bright Offset (5, 36); FSRD I 2 Bright Offset (5, 36); FSRD I 10 Bright Offset (5, 150); FSRD A 1 Bright Offset (5, 60); FSRD B 1 Bright Offset (5, 55); FSRD C 1 Bright Offset (5, 50); FSRD A 1 Bright Offset (5, 45); FSRD B 1 Bright Offset (5, 40); Goto Ready; } //============================================================================ // // A_FSwordAttack // //============================================================================ action void A_FSwordAttack() { if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } SpawnPlayerMissile ("FSwordMissile", Angle + (45./4),0, 0, -10); SpawnPlayerMissile ("FSwordMissile", Angle + (45./8),0, 0, -5); SpawnPlayerMissile ("FSwordMissile", Angle ,0, 0, 0); SpawnPlayerMissile ("FSwordMissile", Angle - (45./8),0, 0, 5); SpawnPlayerMissile ("FSwordMissile", Angle - (45./4),0, 0, 10); A_StartSound ("FighterSwordFire", CHAN_WEAPON); } } // Fighter Sword Missile ---------------------------------------------------- class FSwordMissile : Actor { Default { Speed 30; Radius 16; Height 8; Damage 8; Projectile; +EXTREMEDEATH +ZDOOMTRANS RenderStyle "Add"; DeathSound "FighterSwordExplode"; Obituary "$OB_MPFWEAPQUIETUS"; } States { Spawn: FSFX ABC 3 Bright; Loop; Death: FSFX D 4 Bright; FSFX E 3 Bright A_FSwordFlames; FSFX F 4 Bright A_Explode (64, 128, 0); FSFX G 3 Bright; FSFX H 4 Bright; FSFX I 3 Bright; FSFX J 4 Bright; FSFX KLM 3 Bright; Stop; } override int DoSpecialDamage(Actor victim, int damage, Name damagetype) { if (victim.player) { damage -= damage >> 2; } return damage; } //============================================================================ // // A_FSwordFlames // //============================================================================ void A_FSwordFlames() { for (int i = random[FSwordFlame](1, 4); i; i--) { double xo = (random[FSwordFlame]() - 128) / 16.; double yo = (random[FSwordFlame]() - 128) / 16.; double zo = (random[FSwordFlame]() - 128) / 8.; Spawn ("FSwordFlame", Vec3Offset(xo, yo, zo), ALLOW_REPLACE); } } } // Fighter Sword Flame ------------------------------------------------------ class FSwordFlame : Actor { Default { +NOBLOCKMAP +NOGRAVITY RenderStyle "Translucent"; Alpha 0.6; } States { Spawn: FSFX NOPQRSTUVW 3 Bright; Stop; } } // FireDemon ---------------------------------------------------------------- class FireDemon : Actor { const FIREDEMON_ATTACK_RANGE = 64*8.; int fdstrafecount; Default { Health 80; ReactionTime 8; PainChance 1; Speed 13; Radius 20; Height 68; Mass 75; Damage 1; Monster; +DROPOFF +NOGRAVITY +FLOAT +FLOORCLIP +INVULNERABLE +TELESTOMP SeeSound "FireDemonSpawn"; PainSound "FireDemonPain"; DeathSound "FireDemonDeath"; ActiveSound "FireDemonActive"; Obituary "$OB_FIREDEMON"; Tag "$FN_FIREDEMON"; } States { Spawn: FDMN X 5 Bright; FDMN EFG 10 Bright A_Look; Goto Spawn + 1; See: FDMN E 8 Bright; FDMN F 6 Bright; FDMN G 5 Bright; FDMN F 8 Bright; FDMN E 6 Bright; FDMN G 7 Bright A_FiredRocks; FDMN HI 5 Bright; FDMN J 5 Bright A_UnSetInvulnerable; Chase: FDMN ABC 5 Bright A_FiredChase; Loop; Pain: FDMN D 0 Bright A_UnSetInvulnerable; FDMN D 6 Bright A_Pain; Goto Chase; Missile: FDMN K 3 Bright A_FaceTarget; FDMN KKK 5 Bright A_FiredAttack; Goto Chase; Crash: XDeath: FDMN M 5 A_FaceTarget; FDMN N 5 A_NoBlocking; FDMN O 5 A_FiredSplotch; Stop; Death: FDMN D 4 Bright A_FaceTarget; FDMN L 4 Bright A_Scream; FDMN L 4 Bright A_NoBlocking; FDMN L 200 Bright; Stop; Ice: FDMN R 5 A_FreezeDeath; FDMN R 1 A_FreezeDeathChunks; Wait; } //============================================================================ // Fire Demon AI // // special1 index into floatbob // fdstrafecount whether strafing or not //============================================================================ //============================================================================ // // A_FiredSpawnRock // //============================================================================ private void A_FiredSpawnRock () { Actor mo; class rtype; switch (random[FireDemonRock](0, 4)) { case 0: rtype = "FireDemonRock1"; break; case 1: rtype = "FireDemonRock2"; break; case 2: rtype = "FireDemonRock3"; break; case 3: rtype = "FireDemonRock4"; break; case 4: default: rtype = "FireDemonRock5"; break; } double xo = (random[FireDemonRock]() - 128) / 16.; double yo = (random[FireDemonRock]() - 128) / 16.; double zo = random[FireDemonRock]() / 32.; mo = Spawn (rtype, Vec3Offset(xo, yo, zo), ALLOW_REPLACE); if (mo) { mo.target = self; mo.Vel.X = (random[FireDemonRock]() - 128) / 64.; mo.Vel.Y = (random[FireDemonRock]() - 128) / 64.; mo.Vel.Z = (random[FireDemonRock]() / 64.); mo.special1 = 2; // Number bounces } // Initialize fire demon fdstrafecount = 0; bJustAttacked = false; } //============================================================================ // // A_FiredRocks // //============================================================================ void A_FiredRocks() { A_FiredSpawnRock (); A_FiredSpawnRock (); A_FiredSpawnRock (); A_FiredSpawnRock (); A_FiredSpawnRock (); } //============================================================================ // // A_FiredAttack // //============================================================================ void A_FiredAttack() { if (target == null) return; Actor mo = SpawnMissile (target, "FireDemonMissile"); if (mo) A_StartSound ("FireDemonAttack", CHAN_BODY); } //============================================================================ // // A_FiredChase // //============================================================================ void A_FiredChase() { int weaveindex = special1; double ang; double dist; if (reactiontime) reactiontime--; if (threshold) threshold--; // Float up and down AddZ(BobSin(weaveindex)); special1 = (weaveindex + 2) & 63; // Ensure it stays above certain height if (pos.Z < floorz + 64) { AddZ(2); } if(!target || !target.bShootable) { // Invalid target LookForPlayers (true); return; } // Strafe if (fdstrafecount > 0) { fdstrafecount--; } else { fdstrafecount = 0; Vel.X = Vel.Y = 0; dist = Distance2D(target); if (dist < FIREDEMON_ATTACK_RANGE) { if (random[FiredChase]() < 30) { ang = AngleTo(target); if (random[FiredChase]() < 128) ang += 90; else ang -= 90; Thrust(8, ang); fdstrafecount = 3; // strafe time } } } FaceMovementDirection (); // Normal movement if (!fdstrafecount) { if (--movecount<0 || !MonsterMove ()) { NewChaseDir (); } } // Do missile attack if (!bJustAttacked) { if (CheckMissileRange () && (random[FiredChase]() < 20)) { SetState (MissileState); bJustAttacked = true; return; } } else { bJustAttacked = false; } // make active sound if (random[FiredChase]() < 3) { PlayActiveSound (); } } //============================================================================ // // A_FiredSplotch // //============================================================================ void A_FiredSplotch() { Actor mo; mo = Spawn ("FireDemonSplotch1", Pos, ALLOW_REPLACE); if (mo) { mo.Vel.X = (random[FireDemonSplotch]() - 128) / 32.; mo.Vel.Y = (random[FireDemonSplotch]() - 128) / 32.; mo.Vel.Z = (random[FireDemonSplotch]() / 64.) + 3; } mo = Spawn ("FireDemonSplotch2", Pos, ALLOW_REPLACE); if (mo) { mo.Vel.X = (random[FireDemonSplotch]() - 128) / 32.; mo.Vel.Y = (random[FireDemonSplotch]() - 128) / 32.; mo.Vel.Z = (random[FireDemonSplotch]() / 64.) + 3; } } } // FireDemonSplotch1 ------------------------------------------------------- class FireDemonSplotch1 : Actor { Default { ReactionTime 8; Radius 3; Height 16; Mass 100; +DROPOFF +CORPSE +NOTELEPORT +FLOORCLIP } States { Spawn: FDMN P 3; FDMN P 6 A_QueueCorpse; FDMN Y -1; Stop; } } // FireDemonSplotch2 ------------------------------------------------------- class FireDemonSplotch2 : FireDemonSplotch1 { States { Spawn: FDMN Q 3; FDMN Q 6 A_QueueCorpse; FDMN Z -1; Stop; } } // FireDemonRock1 ------------------------------------------------------------ class FireDemonRock1 : Actor { Default { ReactionTime 8; Radius 3; Height 5; Mass 16; +NOBLOCKMAP +DROPOFF +MISSILE +NOTELEPORT } States { Spawn: FDMN S 4; Loop; Death: FDMN S 5 A_SmBounce; XDeath: FDMN S 200; Stop; } //============================================================================ // // A_SmBounce // //============================================================================ void A_SmBounce() { // give some more velocity (x,y,&z) SetZ(floorz + 1); Vel.Z = 2. + random[SMBounce]() / 64.; Vel.X = random[SMBounce](0, 2); Vel.Y = random[SMBounce](0, 2); } } // FireDemonRock2 ------------------------------------------------------------ class FireDemonRock2 : FireDemonRock1 { States { Spawn: FDMN T 4; Loop; Death: FDMN T 5 A_SmBounce; XDeath: FDMN T 200; Stop; } } // FireDemonRock3 ------------------------------------------------------------ class FireDemonRock3 : FireDemonRock1 { States { Spawn: FDMN U 4; Loop; Death: FDMN U 5 A_SmBounce; XDeath: FDMN U 200; Stop; } } // FireDemonRock4 ------------------------------------------------------------ class FireDemonRock4 : FireDemonRock1 { States { Spawn: FDMN V 4; Loop; Death: FDMN V 5 A_SmBounce; XDeath: FDMN V 200; Stop; } } // FireDemonRock5 ------------------------------------------------------------ class FireDemonRock5 : FireDemonRock1 { States { Spawn: FDMN W 4; Loop; Death: FDMN W 5 A_SmBounce; XDeath: FDMN W 200; Stop; } } // FireDemonMissile ----------------------------------------------------------- class FireDemonMissile : Actor { Default { ReactionTime 8; Speed 10; Radius 10; Height 6; Mass 5; Damage 1; DamageType "Fire"; Projectile; RenderStyle "Add"; DeathSound "FireDemonMissileHit"; +ZDOOMTRANS } States { Spawn: FDMB A 5 Bright; Loop; Death: FDMB BCDE 5 Bright; Stop; } } // Temp Small Flame -------------------------------------------------------- class FlameSmallTemp : Actor { Default { +NOTELEPORT +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: FFSM AB 3 Bright; FFSM C 2 Bright A_CountdownArg(0); FFSM C 2 Bright; FFSM D 3 Bright; FFSM E 3 Bright A_CountdownArg(0); Loop; } } // Temp Large Flame --------------------------------------------------------- class FlameLargeTemp : Actor { Default { +NOTELEPORT +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: FFLG A 4 Bright; FFLG B 4 Bright A_CountdownArg(0); FFLG C 4 Bright; FFLG D 4 Bright A_CountdownArg(0); FFLG E 4 Bright; FFLG F 4 Bright A_CountdownArg(0); FFLG G 4 Bright; FFLG H 4 Bright A_CountdownArg(0); FFLG I 4 Bright; FFLG J 4 Bright A_CountdownArg(0); FFLG K 4 Bright; FFLG L 4 Bright A_CountdownArg(0); FFLG M 4 Bright; FFLG N 4 Bright A_CountdownArg(0); FFLG O 4 Bright; FFLG P 4 Bright A_CountdownArg(0); Goto Spawn+4; } } // Small Flame -------------------------------------------------------------- class FlameSmall : SwitchableDecoration { Default { +NOTELEPORT +INVISIBLE +ZDOOMTRANS Radius 15; RenderStyle "Add"; } States { Active: FFSM A 0 Bright A_StartSound("Ignite"); Spawn: FFSM A 3 Bright; FFSM A 3 Bright A_UnHideThing; FFSM ABCDE 3 Bright; Goto Spawn+2; Inactive: FFSM A 2; FFSM B 2 A_HideThing; FFSM C 200; Wait; } } class FlameSmall2 : FlameSmall { } // Large Flame -------------------------------------------------------------- class FlameLarge : SwitchableDecoration { Default { +NOTELEPORT +INVISIBLE +ZDOOMTRANS Radius 15; RenderStyle "Add"; } States { Active: FFLG A 0 Bright A_StartSound("Ignite"); Spawn: FFLG A 2 Bright; FFLG A 2 Bright A_UnHideThing; FFLG ABCDEFGHIJKLMNOP 4 Bright; Goto Spawn+6; Inactive: FFLG DCB 2; FFLG A 2 A_HideThing; FFLG A 200; Wait; } } class FlameLarge2 : FlameLarge { } // Poison Bag (Flechette used by Cleric) ------------------------------------ class PoisonBag : Actor { Default { Radius 5; Height 5; +NOBLOCKMAP +NOGRAVITY } States { Spawn: PSBG A 18 Bright; PSBG B 4 Bright; PSBG C 3; PSBG C 1 A_PoisonBagInit; Stop; } //=========================================================================== // // A_PoisonBagInit // //=========================================================================== void A_PoisonBagInit() { Actor mo = Spawn("PoisonCloud", pos + (0, 0, 28), ALLOW_REPLACE); if (mo) { mo.target = target; } } } // Fire Bomb (Flechette used by Mage) --------------------------------------- class FireBomb : Actor { Default { DamageType "Fire"; +NOGRAVITY +FOILINVUL RenderStyle "Translucent"; Alpha 0.6; DeathSound "FlechetteExplode"; } States { Spawn: PSBG A 20; PSBG AA 10; PSBG B 4; PSBG C 4 A_Scream; XPL1 A 4 Bright A_TimeBomb; XPL1 BCDEF 4 Bright; Stop; } void A_TimeBomb() { AddZ(32, false); A_SetRenderStyle(1., STYLE_Add); A_Explode(); } } // Throwing Bomb (Flechette used by Fighter) -------------------------------- class ThrowingBomb : Actor { Default { Health 48; Speed 12; Radius 8; Height 10; DamageType "Fire"; +NOBLOCKMAP +DROPOFF +MISSILE BounceType "HexenCompat"; SeeSound "FlechetteBounce"; DeathSound "FlechetteExplode"; } States { Spawn: THRW A 4 A_CheckThrowBomb; THRW BCDE 3 A_CheckThrowBomb; THRW F 3 A_CheckThrowBomb2; Loop; Tail: THRW G 6 A_CheckThrowBomb; THRW F 4 A_CheckThrowBomb; THRW H 6 A_CheckThrowBomb; THRW F 4 A_CheckThrowBomb; THRW G 6 A_CheckThrowBomb; THRW F 3 A_CheckThrowBomb; Wait; Death: CFCF Q 4 Bright A_NoGravity; CFCF R 3 Bright A_Scream; CFCF S 4 Bright A_Explode; CFCF T 3 Bright; CFCF U 4 Bright; CFCF W 3 Bright; CFCF X 4 Bright; CFCF Z 3 Bright; Stop; } //=========================================================================== // // A_CheckThrowBomb // //=========================================================================== void A_CheckThrowBomb() { if (--health <= 0) { SetStateLabel("Death"); } } //=========================================================================== // // A_CheckThrowBomb2 // //=========================================================================== void A_CheckThrowBomb2() { // [RH] Check using actual velocity, although the vel.z < 2 check still stands if (Vel.Z < 2 && Vel.Length() < 1.5) { SetStateLabel("Tail"); SetZ(floorz); Vel.Z = 0; ClearBounce(); bMissile = false; } A_CheckThrowBomb(); } } // Poison Bag Artifact (Flechette) ------------------------------------------ class ArtiPoisonBag : Inventory { Default { +FLOATBOB Inventory.DefMaxAmount; Inventory.PickupFlash "PickupFlash"; +INVENTORY.INVBAR +INVENTORY.FANCYPICKUPSOUND Inventory.Icon "ARTIPSBG"; Inventory.PickupSound "misc/p_pkup"; Inventory.PickupMessage "$TXT_ARTIPOISONBAG"; Tag "$TAG_ARTIPOISONBAG"; } States { Spawn: PSBG A -1; Stop; } //============================================================================ // // AArtiPoisonBag :: BeginPlay // //============================================================================ override void BeginPlay () { Super.BeginPlay (); // If a subclass's specific icon is not defined, let it use the base class's. if (!Icon.isValid()) { Icon = GetDefaultByType("ArtiPoisonBag").Icon; } } //============================================================================ // // GetFlechetteType // //============================================================================ private class GetFlechetteType(Actor other) { class spawntype = null; PlayerPawn pp = PlayerPawn(other); if (pp) { spawntype = pp.FlechetteType; } if (spawntype == null) { // default fallback if nothing valid defined. spawntype = "ArtiPoisonBag3"; } return spawntype; } //============================================================================ // // AArtiPoisonBag :: HandlePickup // //============================================================================ override bool HandlePickup (Inventory item) { // Only do special handling when picking up the base class if (item.GetClass() != "ArtiPoisonBag") { return Super.HandlePickup (item); } if (GetClass() == GetFlechetteType(Owner)) { if (Amount < MaxAmount || sv_unlimited_pickup) { Amount += item.Amount; if (Amount > MaxAmount && !sv_unlimited_pickup) { Amount = MaxAmount; } item.bPickupGood = true; } return true; } return false; } //============================================================================ // // AArtiPoisonBag :: CreateCopy // //============================================================================ override Inventory CreateCopy (Actor other) { // Only the base class gets special handling if (GetClass() != "ArtiPoisonBag") { return Super.CreateCopy (other); } class spawntype = GetFlechetteType(other); let copy = Inventory(Spawn (spawntype)); if (copy != null) { copy.Amount = Amount; copy.MaxAmount = MaxAmount; GoAwayAndDie (); } return copy; } } // Poison Bag 1 (The Cleric's) ---------------------------------------------- class ArtiPoisonBag1 : ArtiPoisonBag { Default { Inventory.Icon "ARTIPSB1"; Tag "$TAG_ARTIPOISONBAG1"; } override bool Use (bool pickup) { Actor mo = Spawn("PoisonBag", Owner.Vec3Offset( 16 * cos(Owner.angle), 24 * sin(Owner.angle), -Owner.Floorclip + 8), ALLOW_REPLACE); if (mo) { mo.target = Owner; return true; } return false; } } // Poison Bag 2 (The Mage's) ------------------------------------------------ class ArtiPoisonBag2 : ArtiPoisonBag { Default { Inventory.Icon "ARTIPSB2"; Tag "$TAG_ARTIPOISONBAG2"; } override bool Use (bool pickup) { Actor mo = Spawn("FireBomb", Owner.Vec3Offset( 16 * cos(Owner.angle), 24 * sin(Owner.angle), -Owner.Floorclip + 8), ALLOW_REPLACE); if (mo) { mo.target = Owner; return true; } return false; } } // Poison Bag 3 (The Fighter's) --------------------------------------------- class ArtiPoisonBag3 : ArtiPoisonBag { Default { Inventory.Icon "ARTIPSB3"; Tag "$TAG_ARTIPOISONBAG3"; } override bool Use (bool pickup) { Actor mo = Spawn("ThrowingBomb", Owner.Pos + (0,0,35. - Owner.Floorclip + (Owner.player? Owner.player.crouchoffset : 0)), ALLOW_REPLACE); if (mo) { mo.angle = Owner.angle + (random[PoisonBag](-4, 3) * (360./256.)); /* Original flight code from Hexen * mo.momz = 4*F.RACUNIT+((player.lookdir)<<(F.RACBITS-4)); * mo.z += player.lookdir<<(F.RACBITS-4); * P_ThrustMobj(mo, mo.ang, mo.info.speed); * mo.momx += player.mo.momx>>1; * mo.momy += player.mo.momy>>1; */ // When looking straight ahead, it uses a z velocity of 4 while the xy velocity // is as set by the projectile. To accommodate self with a proper trajectory, we // aim the projectile ~20 degrees higher than we're looking at and increase the // speed we fire at accordingly. double modpitch = clamp(-Owner.Pitch + 20, -89., 89.); double ang = mo.angle; double speed = (mo.Speed, 4.).Length(); double xyscale = speed * cos(modpitch); mo.Vel.Z = speed * sin(modpitch); mo.Vel.X = xyscale * cos(ang) + Owner.Vel.X / 2; mo.Vel.Y = xyscale * sin(ang) + Owner.Vel.Y / 2; mo.AddZ(mo.Speed * sin(modpitch)); mo.target = Owner; mo.tics -= random[PoisonBag](0, 3); mo.CheckMissileSpawn(Owner.radius); return true; } return false; } } // Poison Bag 4 (Custom Giver) ---------------------------------------------- class ArtiPoisonBagGiver : ArtiPoisonBag { Default { Inventory.Icon "ARTIPSB4"; } override bool Use (bool pickup) { Class missiletype = MissileName; if (missiletype != null) { Actor mo = Spawn (missiletype, Owner.Pos, ALLOW_REPLACE); if (mo != null) { Inventory inv = Inventory(mo); if (inv && inv.CallTryPickup(Owner)) return true; mo.Destroy(); // Destroy if not inventory or couldn't be picked up } } return false; } } // Poison Bag 5 (Custom Thrower) -------------------------------------------- class ArtiPoisonBagShooter : ArtiPoisonBag { Default { Inventory.Icon "ARTIPSB5"; } override bool Use (bool pickup) { Class missiletype = MissileName; if (missiletype != null) { Actor mo = Owner.SpawnPlayerMissile(missiletype); if (mo != null) { // automatic handling of seeker missiles if (mo.bSeekerMissile) { mo.tracer = Owner.target; } return true; } } return false; } } // Poison Cloud ------------------------------------------------------------- class PoisonCloud : Actor { Default { Radius 20; Height 30; Mass 0x7fffffff; +NOBLOCKMAP +NOGRAVITY +DROPOFF +NODAMAGETHRUST +DONTSPLASH +FOILINVUL +CANBLAST +BLOODLESSIMPACT +BLOCKEDBYSOLIDACTORS +FORCEZERORADIUSDMG +OLDRADIUSDMG RenderStyle "Translucent"; Alpha 0.6; DeathSound "PoisonShroomDeath"; DamageType "PoisonCloud"; } States { Spawn: PSBG D 1; PSBG D 1 A_Scream; PSBG DEEEFFFGGGHHHII 2 A_PoisonBagDamage; PSBG I 2 A_PoisonBagDamage; PSBG I 1 A_PoisonBagCheck; Goto Spawn + 3; Death: PSBG HG 7; PSBG FD 6; Stop; } //=========================================================================== // // // //=========================================================================== override void BeginPlay () { Vel.X = MinVel; // missile objects must move to impact other objects special1 = random[PoisonCloud](24, 31); special2 = 0; } //=========================================================================== // // // //=========================================================================== override int DoSpecialDamage (Actor victim, int damage, Name damagetype) { if (victim.player) { bool mate = (target != null && victim.player != target.player && victim.IsTeammate (target)); bool dopoison; if (!mate) { dopoison = victim.player.poisoncount < 4; } else { dopoison = victim.player.poisoncount < (int)(4. * level.teamdamage); } if (dopoison) { damage = random[PoisonCloud](15, 30); if (mate) { damage = (int)(damage * level.teamdamage); } // Handle passive damage modifiers (e.g. PowerProtection) damage = victim.GetModifiedDamage(damagetype, damage, true); // Modify with damage factors damage = victim.ApplyDamageFactor(damagetype, damage); if (damage > 0) { victim.player.PoisonDamage (self, random[PoisonCloud](15, 30), false); // Don't play painsound // If successful, play the poison sound. if (victim.player.PoisonPlayer (self, self.target, 50)) victim.A_StartSound ("*poison", CHAN_VOICE); } } return -1; } else if (!victim.bIsMonster) { // only damage monsters/players with the poison cloud return -1; } return damage; } //=========================================================================== // // A_PoisonBagCheck // //=========================================================================== void A_PoisonBagCheck() { if (--special1 <= 0) { SetStateLabel("Death"); } } //=========================================================================== // // A_PoisonBagDamage // //=========================================================================== void A_PoisonBagDamage() { A_Explode(4, 40); AddZ(BobSin(special2) / 16); special2 = (special2 + 1) & 63; } } // Poison Shroom ------------------------------------------------------------ class ZPoisonShroom : PoisonBag { Default { Radius 6; Height 20; PainChance 255; Health 30; Mass 0x7fffffff; +SHOOTABLE +SOLID +NOBLOOD +NOICEDEATH -NOBLOCKMAP -NOGRAVITY PainSound "PoisonShroomPain"; DeathSound "PoisonShroomDeath"; } States { Spawn: SHRM A 5 A_PoisonShroom; Goto Pain+1; Pain: SHRM A 6; SHRM B 8 A_Pain; Goto Spawn; Death: SHRM CD 5; SHRM E 5 A_PoisonBagInit; SHRM F -1; Stop; } //=========================================================================== // // A_PoisonShroom // //=========================================================================== void A_PoisonShroom() { tics = 128 + (random[PoisonShroom]() << 1); } } // Buzzy fly ---------------------------------------------------------------- class LittleFly : Actor { Default { +NOBLOCKMAP +NOGRAVITY +CANPASS Speed 6; Radius 5; Height 5; Mass 2; ActiveSound "FlyBuzz"; } States { Spawn: TNT1 A 20 A_FlySearch; // [RH] Invisible when not flying Loop; Buzz: AFLY ABCD 3 A_FlyBuzz; Loop; } //=========================================================================== // // FindCorpse // // Finds a corpse to buzz around. We can't use a blockmap check because // corpses generally aren't linked into the blockmap. // //=========================================================================== private Actor FindCorpse(sector sec, int recurselimit) { Actor fallback = null; sec.validcount = validcount; // Search the current sector for (Actor check = sec.thinglist; check != null; check = check.snext) { if (check == self) continue; if (!check.bCorpse) continue; if (!CheckSight(check)) continue; fallback = check; if (random[Fly](0,1)) // 50% chance to try to pick a different corpse continue; return check; } if (--recurselimit <= 0 || (fallback != null && random[Fly](0,1))) { return fallback; } // Try neighboring sectors for (int i = 0; i < sec.lines.Size(); ++i) { line ln = sec.lines[i]; sector sec2 = (ln.frontsector == sec) ? ln.backsector : ln.frontsector; if (sec2 != null && sec2.validcount != validcount) { Actor neighbor = FindCorpse(sec2, recurselimit); if (neighbor != null) { return neighbor; } } } return fallback; } void A_FlySearch() { // The version from the retail beta is not so great for general use: // 1. Pick one of the first fifty thinkers at random. // 2. Starting from that thinker, find one that is an actor, not itself, // and within sight. Give up after 100 sequential thinkers. // It's effectively useless if there are more than 150 thinkers on a map. // // So search the sectors instead. We can't potentially find something all // the way on the other side of the map and we can't find invisible corpses, // but at least we aren't crippled on maps with lots of stuff going on. validcount++; Actor other = FindCorpse(CurSector, 5); if (other != null) { target = other; SetStateLabel("Buzz"); } } void A_FlyBuzz() { Actor targ = target; if (targ == null || !targ.bCorpse || random[Fly]() < 5) { SetIdle(); return; } Angle = AngleTo(targ); args[0]++; if (!TryMove(Pos.XY + AngleToVector(angle, 6), true)) { SetIdle(true); return; } if (args[0] & 2) { Vel.X += (random[Fly]() - 128) / 512.; Vel.Y += (random[Fly]() - 128) / 512.; } int zrand = random[Fly](); if (targ.pos.Z + 5. < pos.z && zrand > 150) { zrand = -zrand; } Vel.Z = zrand / 512.; if (random[Fly]() < 40) { A_StartSound(ActiveSound, CHAN_VOICE, CHANF_DEFAULT, 0.5f, ATTN_STATIC); } } } //========================================================================== // Fog Variables: // // args[0] Speed (0..10) of fog // args[1] Angle of spread (0..128) // args[2] Frequency of spawn (1..10) // args[3] Lifetime countdown // args[4] Boolean: fog moving? // special1 Internal: Counter for spawn frequency // WeaveIndexZ Internal: Index into floatbob table // //========================================================================== // Fog Spawner -------------------------------------------------------------- class FogSpawner : Actor { Default { +NOSECTOR +NOBLOCKMAP +FLOATBOB +NOGRAVITY +INVISIBLE } States { Spawn: TNT1 A 20 A_FogSpawn; Loop; } //========================================================================== // // A_FogSpawn // //========================================================================== void A_FogSpawn() { if (special1-- > 0) { return; } special1 = args[2]; // Reset frequency count class fog; switch (random[FogSpawn](0,2)) { default: case 0: fog = "FogPatchSmall"; break; case 1: fog = "FogPatchMedium"; break; case 2: fog = "FogPatchLarge"; break; } Actor mo = Spawn (fog, Pos, ALLOW_REPLACE); if (mo) { int delta = args[1]; if (delta == 0) delta = 1; mo.angle = angle + ((random[FogSpawn](0, delta-1) - (delta >> 1)) * (360 / 256.)); mo.target = self; if (args[0] < 1) args[0] = 1; mo.args[0] = random[FogSpawn](1, args[0]); // Random speed mo.args[3] = args[3]; // Set lifetime mo.args[4] = 1; // Set to moving mo.WeaveIndexZ = random[FogSpawn](0, 63); } } } // Small Fog Patch ---------------------------------------------------------- class FogPatchSmall : Actor { Default { Speed 1; +NOBLOCKMAP +NOGRAVITY +NOCLIP +FLOAT +NOTELEPORT RenderStyle "Translucent"; Alpha 0.6; } States { Spawn: FOGS ABCDE 7 A_FogMove; Loop; Death: FOGS E 5; Stop; } //========================================================================== // // A_FogMove // //========================================================================== void A_FogMove() { double speed = args[0]; int weaveindex; if (!args[4]) { return; } if (args[3]-- <= 0) { SetStateLabel ('Death', true); return; } if ((args[3] % 4) == 0) { weaveindex = WeaveIndexZ; AddZ(BobSin(weaveindex) / 2); WeaveIndexZ = (weaveindex + 1) & 63; } VelFromAngle(speed); } } // Medium Fog Patch --------------------------------------------------------- class FogPatchMedium : FogPatchSmall { States { Spawn: FOGM ABCDE 7 A_FogMove; Loop; Death: FOGS ABCDE 5; Goto Super::Death; } } // Large Fog Patch ---------------------------------------------------------- class FogPatchLarge : FogPatchMedium { States { Spawn: FOGL ABCDE 7 A_FogMove; Loop; Death: FOGM ABCDEF 4; Goto Super::Death; } } class ParticleFountain : Actor { enum EColor { REDFOUNTAIN = 1, GREENFOUNTAIN = 2, BLUEFOUNTAIN = 3, YELLOWFOUNTAIN = 4, PURPLEFOUNTAIN = 5, BLACKFOUNTAIN = 6, WHITEFOUNTAIN = 7 } default { Height 0; +NOBLOCKMAP +NOGRAVITY +INVISIBLE } override void PostBeginPlay () { Super.PostBeginPlay (); if (!(SpawnFlags & MTF_DORMANT)) Activate (null); } override void Activate (Actor activator) { Super.Activate (activator); fountaincolor = health; } override void Deactivate (Actor activator) { Super.Deactivate (activator); fountaincolor = 0; } } class RedParticleFountain : ParticleFountain { default { Health REDFOUNTAIN; } } class GreenParticleFountain : ParticleFountain { default { Health GREENFOUNTAIN; } } class BlueParticleFountain : ParticleFountain { default { Health BLUEFOUNTAIN; } } class YellowParticleFountain : ParticleFountain { default { Health YELLOWFOUNTAIN; } } class PurpleParticleFountain : ParticleFountain { default { Health PURPLEFOUNTAIN; } } class BlackParticleFountain : ParticleFountain { default { Health BLACKFOUNTAIN; } } class WhiteParticleFountain : ParticleFountain { default { Health WHITEFOUNTAIN; } } // Hate Target -------------------------------------------------------------- class HateTarget : Actor { default { Radius 20; Height 56; +SHOOTABLE +NOGRAVITY +NOBLOOD +DONTSPLASH Mass 0x7fffffff; } States { Spawn: TNT1 A -1; } override void BeginPlay() { Super.BeginPlay(); if (SpawnAngle != 0) { // Each degree translates into 10 units of health health = SpawnAngle * 10; } else { special2 = 1; health = 1000001; } } override int TakeSpecialDamage(Actor inflictor, Actor source, int damage, Name damagetype) { if (special2 != 0) { return 0; } else { return damage; } } } // Healing Radius Artifact -------------------------------------------------- class ArtiHealingRadius : Inventory { const HEAL_RADIUS_DIST = 255.; Default { +COUNTITEM +FLOATBOB Inventory.DefMaxAmount; +INVENTORY.INVBAR +INVENTORY.FANCYPICKUPSOUND Inventory.PickupFlash "PickupFlash"; Inventory.Icon "ARTIHRAD"; Inventory.PickupSound "misc/p_pkup"; Inventory.PickupMessage "$TXT_ARTIHEALINGRADIUS"; Tag "$TAG_ARTIHEALINGRADIUS"; } States { Spawn: HRAD ABCDEFGHIJKLMNOP 4 Bright; Loop; } override bool Use (bool pickup) { bool effective = false; Name mode = 'Health'; PlayerPawn pp = PlayerPawn(Owner); if (pp) mode = pp.HealingRadiusType; for (int i = 0; i < MAXPLAYERS; ++i) { if (!playeringame[i]) { continue; } PlayerPawn mo = players[i].mo; if (mo != null && mo.health > 0 && mo.Distance2D (Owner) <= HEAL_RADIUS_DIST) { // Q: Is it worth it to make this selectable as a player property? // A: Probably not - but it sure doesn't hurt. bool gotsome=false; switch (mode) { case 'Armor': for (int j = 0; j < 4; ++j) { HexenArmor armor = HexenArmor(Spawn("HexenArmor")); armor.health = j; armor.Amount = 1; if (!armor.CallTryPickup (mo)) { armor.Destroy (); } else { gotsome = true; } } break; case 'Mana': { int amount = random[HealRadius](50, 99); if (mo.GiveAmmo ("Mana1", amount) || mo.GiveAmmo ("Mana2", amount)) { gotsome = true; } break; } default: //case NAME_Health: gotsome = mo.GiveBody (random[HealRadius](50, 99)); break; } if (gotsome) { mo.A_StartSound ("MysticIncant", CHAN_AUTO); effective=true; } } } return effective; } } /* ** a_health.cpp ** All health items ** **--------------------------------------------------------------------------- ** Copyright 2000-2016 Randy Heit ** Copyright 2006-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ class Health : Inventory { transient int PrevHealth; meta int LowHealth; meta String LowHealthMessage; property LowMessage: LowHealth, LowHealthMessage; Default { +INVENTORY.ISHEALTH Inventory.Amount 1; Inventory.MaxAmount 0; Inventory.PickupSound "misc/health_pkup"; } //=========================================================================== // // AHealth :: PickupMessage // //=========================================================================== override String PickupMessage () { if (PrevHealth < LowHealth) { String message = LowHealthMessage; if (message.Length() != 0) { return message; } } return Super.PickupMessage(); } //=========================================================================== // // TryPickup // //=========================================================================== override bool TryPickup (in out Actor other) { PrevHealth = other.player != NULL ? other.player.health : other.health; // P_GiveBody adds one new feature, applied only if it is possible to pick up negative health: // Negative values are treated as positive percentages, ie Amount -100 means 100% health, ignoring max amount. if (other.GiveBody(Amount, MaxAmount)) { GoAwayAndDie(); return true; } return false; } } class MaxHealth : Health { //=========================================================================== // // TryPickup // //=========================================================================== override bool TryPickup (in out Actor other) { bool success = false; let player = PlayerPawn(other); if (player) { if (player.BonusHealth < MaxAmount) { player.BonusHealth = min(player.BonusHealth + Amount, MaxAmount); success = true; } } success |= Super.TryPickup(other); if (success) GoAwayAndDie(); return success; } } class HealthPickup : Inventory { int autousemode; property AutoUse: autousemode; Default { Inventory.DefMaxAmount; +INVENTORY.INVBAR +INVENTORY.ISHEALTH } //=========================================================================== // // CreateCopy // //=========================================================================== override Inventory CreateCopy (Actor other) { Inventory copy = Super.CreateCopy (other); copy.health = health; return copy; } //=========================================================================== // // CreateTossable // //=========================================================================== override Inventory CreateTossable (int amount) { Inventory copy = Super.CreateTossable (-1); if (copy != NULL) { copy.health = health; } return copy; } //=========================================================================== // // HandlePickup // //=========================================================================== override bool HandlePickup (Inventory item) { // HealthPickups that are the same type but have different health amounts // do not count as the same item. if (item.health == health) { return Super.HandlePickup (item); } return false; } //=========================================================================== // // Use // //=========================================================================== override bool Use (bool pickup) { return Owner.GiveBody (health, 0); } } // The Heresiarch him/itself ------------------------------------------------ //============================================================================ // // Sorcerer stuff // // Sorcerer Variables // specialf1 Angle of ball 1 (all others relative to that) // StopBall which ball to stop at in stop mode (MT_???) // args[0] Defense time // args[1] Number of full rotations since stopping mode // args[2] Target orbit speed for acceleration/deceleration // args[3] Movement mode (see SORC_ macros) // args[4] Current ball orbit speed // Sorcerer Ball Variables // specialf1 Previous angle of ball (for woosh) // special2 Countdown of rapid fire (FX4) //============================================================================ class Heresiarch : Actor { const SORCBALL_INITIAL_SPEED = 7; const SORCBALL_TERMINAL_SPEED = 25; const SORCBALL_SPEED_ROTATIONS = 5; const SORC_DEFENSE_TIME = 255; const SORC_DEFENSE_HEIGHT = 45; const BOUNCE_TIME_UNIT = (35/2); const SORCFX4_RAPIDFIRE_TIME = (6*3); // 3 seconds const SORCFX4_SPREAD_ANGLE = 20; enum ESorc { SORC_DECELERATE, SORC_ACCELERATE, SORC_STOPPING, SORC_FIRESPELL, SORC_STOPPED, SORC_NORMAL, SORC_FIRING_SPELL } const BALL1_ANGLEOFFSET = 0.; const BALL2_ANGLEOFFSET = 120.; const BALL3_ANGLEOFFSET = 240.; double BallAngle; class StopBall; Default { Health 5000; Painchance 10; Speed 16; Radius 40; Height 110; Mass 500; Damage 9; Monster; +FLOORCLIP +BOSS +DONTMORPH +NOTARGET +NOICEDEATH +DEFLECT +NOBLOOD SeeSound "SorcererSight"; PainSound "SorcererPain"; DeathSound "SorcererDeathScream"; ActiveSound "SorcererActive"; Obituary "$OB_HERESIARCH"; Tag "$FN_HERESIARCH"; } States { Spawn: SORC A 3; SORC A 2 A_SorcSpinBalls; Idle: SORC A 10 A_Look; Wait; See: SORC ABCD 5 A_Chase; Loop; Pain: SORC G 8; SORC G 8 A_Pain; Goto See; Missile: SORC F 6 Bright A_FaceTarget; SORC F 6 Bright A_SpeedBalls; SORC F 6 Bright A_FaceTarget; Wait; Attack1: SORC E 6 Bright; SORC E 6 Bright A_SpawnFizzle; SORC E 5 Bright A_FaceTarget; Goto Attack1+1; Attack2: SORC E 2 Bright; SORC E 2 Bright A_SorcBossAttack; Goto See; Death: SORC H 5 Bright; SORC I 5 Bright A_FaceTarget; SORC J 5 Bright A_Scream; SORC KLMNOPQRST 5 Bright; SORC U 5 Bright A_NoBlocking; SORC VWXY 5 Bright; SORC Z -1 Bright; Stop; } override void Die (Actor source, Actor inflictor, int dmgflags, Name MeansOfDeath) { // The heresiarch just executes a script instead of a special upon death int script = special; special = 0; Super.Die (source, inflictor, dmgflags, MeansOfDeath); if (script != 0) { ACS_Execute(script, 0); } } //============================================================================ // // A_StopBalls // // Instant stop when rotation gets to ball in special2 // self is sorcerer // //============================================================================ void A_StopBalls() { int chance = random[Heresiarch](); args[3] = SORC_STOPPING; // stopping mode args[1] = 0; // Reset rotation counter if ((args[0] <= 0) && (chance < 200)) { StopBall = "SorcBall2"; // Blue } else if((health < (SpawnHealth() >> 1)) && (chance < 200)) { StopBall = "SorcBall3"; // Green } else { StopBall = "SorcBall1"; // Yellow } } //============================================================================ // // A_SorcSpinBalls // // Spawn spinning balls above head - actor is sorcerer //============================================================================ void A_SorcSpinBalls() { A_SlowBalls(); args[0] = 0; // Currently no defense args[3] = SORC_NORMAL; args[4] = SORCBALL_INITIAL_SPEED; // Initial orbit speed BallAngle = 1.; Vector3 ballpos = (pos.xy, -Floorclip + Height); Actor mo = Spawn("SorcBall1", pos, NO_REPLACE); if (mo) { mo.target = self; mo.special2 = SORCFX4_RAPIDFIRE_TIME; } mo = Spawn("SorcBall2", pos, NO_REPLACE); if (mo) mo.target = self; mo = Spawn("SorcBall3", pos, NO_REPLACE); if (mo) mo.target = self; } //============================================================================ // // A_SpeedBalls // // Set balls to speed mode - self is sorcerer // //============================================================================ void A_SpeedBalls() { args[3] = SORC_ACCELERATE; // speed mode args[2] = SORCBALL_TERMINAL_SPEED; // target speed } //============================================================================ // // A_SlowBalls // // Set balls to slow mode - actor is sorcerer // //============================================================================ void A_SlowBalls() { args[3] = SORC_DECELERATE; // slow mode args[2] = SORCBALL_INITIAL_SPEED; // target speed } //============================================================================ // // A_SorcBossAttack // // Resume ball spinning // //============================================================================ void A_SorcBossAttack() { args[3] = SORC_ACCELERATE; args[2] = SORCBALL_INITIAL_SPEED; } //============================================================================ // // A_SpawnFizzle // // spell cast magic fizzle // //============================================================================ void A_SpawnFizzle() { Vector3 pos = Vec3Angle(5., Angle, -Floorclip + Height / 2. ); for (int ix=0; ix<5; ix++) { Actor mo = Spawn("SorcSpark1", pos, ALLOW_REPLACE); if (mo) { double rangle = Angle + random[Heresiarch](0, 4) * (4096 / 360.); mo.Vel.X = random[Heresiarch](0, int(speed) - 1) * cos(rangle); mo.Vel.Y = random[Heresiarch](0, int(speed) - 1) * sin(rangle); mo.Vel.Z = 2; } } } } // Base class for the balls flying around the Heresiarch's head ------------- class SorcBall : Actor { Default { Speed 10; Radius 5; Height 5; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS +FULLVOLDEATH +CANBOUNCEWATER +NOWALLBOUNCESND BounceType "HexenCompat"; SeeSound "SorcererBallBounce"; DeathSound "SorcererBigBallExplode"; } double OldAngle, AngleOffset; //============================================================================ // // SorcBall::DoFireSpell // //============================================================================ virtual void DoFireSpell () { CastSorcererSpell (); target.args[3] = Heresiarch.SORC_STOPPED; } virtual void SorcUpdateBallAngle () { } override bool SpecialBlastHandling (Actor source, double strength) { // don't blast sorcerer balls return false; } //============================================================================ // // ASorcBall::CastSorcererSpell // // Make noise and change the parent sorcerer's animation // //============================================================================ virtual void CastSorcererSpell () { target.A_StartSound ("SorcererSpellCast", CHAN_VOICE); // Put sorcerer into throw spell animation if (target.health > 0) target.SetStateLabel ("Attack2"); } //============================================================================ // // A_SorcBallOrbit // // - actor is ball //============================================================================ void A_SorcBallOrbit() { // [RH] If no parent, then die instead of crashing if (target == null || target.health <= 0) { SetStateLabel ("Pain"); return; } int mode = target.args[3]; Heresiarch parent = Heresiarch(target); double dist = parent.radius - (radius*2); double prevangle = OldAngle; double baseangle = parent.BallAngle; double curangle = baseangle + AngleOffset; angle = curangle; switch (mode) { case Heresiarch.SORC_NORMAL: // Balls rotating normally SorcUpdateBallAngle (); break; case Heresiarch.SORC_DECELERATE: // Balls decelerating A_DecelBalls(); SorcUpdateBallAngle (); break; case Heresiarch.SORC_ACCELERATE: // Balls accelerating A_AccelBalls(); SorcUpdateBallAngle (); break; case Heresiarch.SORC_STOPPING: // Balls stopping if ((parent.StopBall == GetClass()) && (parent.args[1] > Heresiarch.SORCBALL_SPEED_ROTATIONS) && absangle(curangle, parent.angle) < 42.1875) { // Can stop now target.args[3] = Heresiarch.SORC_FIRESPELL; target.args[4] = 0; // Set angle so self angle == sorcerer angle parent.BallAngle = parent.angle - AngleOffset; } else { SorcUpdateBallAngle (); } break; case Heresiarch.SORC_FIRESPELL: // Casting spell if (parent.StopBall == GetClass()) { // Put sorcerer into special throw spell anim if (parent.health > 0) parent.SetStateLabel("Attack1"); DoFireSpell (); } break; case Heresiarch.SORC_FIRING_SPELL: if (parent.StopBall == GetClass()) { if (special2-- <= 0) { // Done rapid firing parent.args[3] = Heresiarch.SORC_STOPPED; // Back to orbit balls if (parent.health > 0) parent.SetStateLabel("Attack2"); } else { // Do rapid fire spell A_SorcOffense2(); } } break; default: break; } // The comparison here depends on binary angle semantics and cannot be done in floating point. // It also requires very exact conversion that must be done natively. if (BAM(curangle) < BAM(prevangle) && (parent.args[4] == Heresiarch.SORCBALL_TERMINAL_SPEED)) { parent.args[1]++; // Bump rotation counter // Completed full rotation - make woosh sound A_StartSound ("SorcererBallWoosh", CHAN_BODY); } OldAngle = curangle; // Set previous angle Vector3 pos = parent.Vec3Angle(dist, curangle, -parent.Floorclip + parent.Height); SetOrigin (pos, true); floorz = parent.floorz; ceilingz = parent.ceilingz; } //============================================================================ // // A_SorcOffense2 // // Actor is ball // //============================================================================ void A_SorcOffense2() { Actor parent = target; Actor dest = parent.target; // [RH] If no enemy, then don't try to shoot. if (dest == null) { return; } int index = args[4]; args[4] = (args[4] + 15) & 255; double delta = sin(index * (360 / 256.f)) * Heresiarch.SORCFX4_SPREAD_ANGLE; double ang1 = Angle + delta; Actor mo = parent.SpawnMissileAngle("SorcFX4", ang1, 0); if (mo) { mo.special2 = 35*5/2; // 5 seconds double dist = mo.DistanceBySpeed(dest, mo.Speed); mo.Vel.Z = (dest.pos.z - mo.pos.z) / dist; } } //============================================================================ // // A_AccelBalls // // Increase ball orbit speed - actor is ball // //============================================================================ void A_AccelBalls() { Heresiarch sorc = Heresiarch(target); if (sorc.args[4] < sorc.args[2]) { sorc.args[4]++; } else { sorc.args[3] = Heresiarch.SORC_NORMAL; if (sorc.args[4] >= Heresiarch.SORCBALL_TERMINAL_SPEED) { // Reached terminal velocity - stop balls sorc.A_StopBalls(); } } } //============================================================================ // // A_DecelBalls // // Decrease ball orbit speed - actor is ball // //============================================================================ void A_DecelBalls() { Actor sorc = target; if (sorc.args[4] > sorc.args[2]) { sorc.args[4]--; } else { sorc.args[3] = Heresiarch.SORC_NORMAL; } } void A_SorcBallExplode() { bNoBounceSound = true; A_Explode(255, 255); } //============================================================================ // // A_SorcBallPop // // Ball death - bounce away in a random direction // //============================================================================ void A_SorcBallPop() { A_StartSound ("SorcererBallPop", CHAN_BODY, CHANF_DEFAULT, 1., ATTN_NONE); bNoGravity = false; Gravity = 1. / 8; Vel.X = random[Heresiarch](-5, 4); Vel.Y = random[Heresiarch](-5, 4); Vel.Z = random[Heresiarch](2, 4); args[4] = Heresiarch.BOUNCE_TIME_UNIT; // Bounce time unit args[3] = 5; // Bounce time in seconds } //============================================================================ // // A_BounceCheck // //============================================================================ void A_BounceCheck () { if (args[4]-- <= 0) { if (args[3]-- <= 0) { SetStateLabel("Death"); A_StartSound ("SorcererBigBallExplode", CHAN_BODY, CHANF_DEFAULT, 1., ATTN_NONE); } else { args[4] = Heresiarch.BOUNCE_TIME_UNIT; } } } } // First ball (purple) - fires projectiles ---------------------------------- class SorcBall1 : SorcBall { States { Spawn: SBMP ABCDEFGHIJKLMNOP 2 A_SorcBallOrbit; Loop; Pain: SBMP A 5 A_SorcBallPop; SBMP B 2 A_BounceCheck; Wait; Death: SBS4 D 5 A_SorcBallExplode; SBS4 E 5; SBS4 FGH 6; Stop; } override void BeginPlay () { Super.BeginPlay (); AngleOffset = Heresiarch.BALL1_ANGLEOFFSET; } //============================================================================ // // SorcBall1::CastSorcererSpell // // Offensive // //============================================================================ override void CastSorcererSpell () { Super.CastSorcererSpell (); Actor parent = target; double ang1 = Angle + 70; double ang2 = Angle - 70; Class cls = "SorcFX1"; Actor mo = parent.SpawnMissileAngle (cls, ang1, 0); if (mo) { mo.target = parent; mo.tracer = parent.target; mo.args[4] = Heresiarch.BOUNCE_TIME_UNIT; mo.args[3] = 15; // Bounce time in seconds } mo = parent.SpawnMissileAngle (cls, ang2, 0); if (mo) { mo.target = parent; mo.tracer = parent.target; mo.args[4] = Heresiarch.BOUNCE_TIME_UNIT; mo.args[3] = 15; // Bounce time in seconds } } //============================================================================ // // ASorcBall1::SorcUpdateBallAngle // // Update angle if first ball //============================================================================ override void SorcUpdateBallAngle () { (Heresiarch(target)).BallAngle += target.args[4]; } //============================================================================ // // SorcBall1::DoFireSpell // //============================================================================ override void DoFireSpell () { if (random[Heresiarch]() < 200) { target.A_StartSound ("SorcererSpellCast", CHAN_VOICE, CHANF_DEFAULT, 1., ATTN_NONE); special2 = Heresiarch.SORCFX4_RAPIDFIRE_TIME; args[4] = 128; target.args[3] = Heresiarch.SORC_FIRING_SPELL; } else { Super.DoFireSpell (); } } } // Second ball (blue) - generates the shield -------------------------------- class SorcBall2 : SorcBall { States { Spawn: SBMB ABCDEFGHIJKLMNOP 2 A_SorcBallOrbit; Loop; Pain: SBMB A 5 A_SorcBallPop; SBMB B 2 A_BounceCheck; Wait; Death: SBS3 D 5 A_SorcBallExplode; SBS3 E 5; SBS3 FGH 6; Stop; } override void BeginPlay () { Super.BeginPlay (); AngleOffset = Heresiarch.BALL2_ANGLEOFFSET; } //============================================================================ // // ASorcBall2::CastSorcererSpell // // Defensive // //============================================================================ override void CastSorcererSpell () { Super.CastSorcererSpell (); Actor parent = target; Actor mo = Spawn("SorcFX2", Pos + (0, 0, parent.Floorclip + Heresiarch.SORC_DEFENSE_HEIGHT), ALLOW_REPLACE); parent.bReflective = true; parent.bInvulnerable = true; parent.args[0] = Heresiarch.SORC_DEFENSE_TIME; if (mo) mo.target = parent; } } // Third ball (green) - summons Bishops ------------------------------------- class SorcBall3 : SorcBall { States { Spawn: SBMG ABCDEFGHIJKLMNOP 2 A_SorcBallOrbit; Loop; Pain: SBMG A 5 A_SorcBallPop; SBMG B 2 A_BounceCheck; Wait; Death: SBS3 D 5 A_SorcBallExplode; SBS3 E 5; SBS3 FGH 6; Stop; } override void BeginPlay () { Super.BeginPlay (); AngleOffset = Heresiarch.BALL3_ANGLEOFFSET; } //============================================================================ // // ASorcBall3::CastSorcererSpell // // Reinforcements // //============================================================================ override void CastSorcererSpell () { Actor mo; Super.CastSorcererSpell (); Actor parent = target; double ang1 = Angle - 45; double ang2 = Angle + 45; Class cls = "SorcFX3"; if (health < (SpawnHealth()/3)) { // Spawn 2 at a time mo = parent.SpawnMissileAngle(cls, ang1, 4.); if (mo) mo.target = parent; mo = parent.SpawnMissileAngle(cls, ang2, 4.); if (mo) mo.target = parent; } else { if (random[Heresiarch]() < 128) ang1 = ang2; mo = parent.SpawnMissileAngle(cls, ang1, 4.); if (mo) mo.target = parent; } } } // Sorcerer spell 1 (The burning, bouncing head thing) ---------------------- class SorcFX1 : Actor { Default { Speed 7; Radius 5; Height 5; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS -NOGRAVITY +FULLVOLDEATH +CANBOUNCEWATER +NOWALLBOUNCESND BounceFactor 1.0; BounceType "HexenCompat"; SeeSound "SorcererBallBounce"; DeathSound "SorcererHeadScream"; } States { Spawn: SBS1 A 2 Bright; SBS1 BCD 3 Bright A_SorcFX1Seek; Loop; Death: FHFX S 2 Bright A_Explode(30, 128); FHFX SS 6 Bright; Stop; } //============================================================================ // // A_SorcFX1Seek // // Yellow spell - offense // //============================================================================ void A_SorcFX1Seek() { if (args[4]-- <= 0) { if (args[3]-- <= 0) { SetStateLabel("Death"); A_StartSound ("SorcererHeadScream", CHAN_BODY, CHANF_DEFAULT, 1., ATTN_NONE); } else { args[4] = Heresiarch.BOUNCE_TIME_UNIT; } } A_SeekerMissile(2, 6); } } // Sorcerer spell 2 (The visible part of the shield) ------------------------ class SorcFX2 : Actor { Default { Speed 15; Radius 5; Height 5; +NOBLOCKMAP +NOGRAVITY +NOTELEPORT } states { Spawn: SBS2 A 3 Bright A_SorcFX2Split; Loop; Orbit: SBS2 A 2 Bright; SBS2 BCDEFGHIJKLMNOPA 2 Bright A_SorcFX2Orbit; Goto Orbit+1; Death: SBS2 A 10; Stop; } //============================================================================ // // A_SorcFX2Split // // Blue spell - defense // //============================================================================ // // FX2 Variables // specialf1 current angle // special2 // args[0] 0 = CW, 1 = CCW // args[1] //============================================================================ // Split ball in two void A_SorcFX2Split() { Actor mo = Spawn(GetClass(), Pos, NO_REPLACE); if (mo) { mo.target = target; mo.args[0] = 0; // CW mo.specialf1 = Angle; // Set angle mo.SetStateLabel("Orbit"); } mo = Spawn(GetClass(), Pos, NO_REPLACE); if (mo) { mo.target = target; mo.args[0] = 1; // CCW mo.specialf1 = Angle; // Set angle mo.SetStateLabel("Orbit"); } Destroy (); } //============================================================================ // // A_SorcFX2Orbit // // Orbit FX2 about sorcerer // //============================================================================ void A_SorcFX2Orbit () { Actor parent = target; // [RH] If no parent, then disappear if (parent == null) { Destroy(); return; } double dist = parent.radius; if ((parent.health <= 0) || // Sorcerer is dead (!parent.args[0])) // Time expired { SetStateLabel("Death"); parent.args[0] = 0; parent.bReflective = false; parent.bInvulnerable = false; } if (args[0] && (parent.args[0]-- <= 0)) // Time expired { SetStateLabel("Death"); parent.args[0] = 0; parent.bReflective = false; } Vector3 posi; // Move to new position based on angle if (args[0]) // Counter clock-wise { specialf1 += 10; angle = specialf1; posi = parent.Vec3Angle(dist, angle, parent.Floorclip + Heresiarch.SORC_DEFENSE_HEIGHT); posi.Z += 15 * cos(angle); // Spawn trailer Spawn("SorcFX2T1", pos, ALLOW_REPLACE); } else // Clock wise { specialf1 -= 10; angle = specialf1; posi = parent.Vec3Angle(dist, angle, parent.Floorclip + Heresiarch.SORC_DEFENSE_HEIGHT); posi.Z += 20 * sin(angle); // Spawn trailer Spawn("SorcFX2T1", pos, ALLOW_REPLACE); } SetOrigin (posi, true); floorz = parent.floorz; ceilingz = parent.ceilingz; } } // The translucent trail behind SorcFX2 ------------------------------------- class SorcFX2T1 : SorcFX2 { Default { RenderStyle "Translucent"; Alpha 0.4; } States { Spawn: Goto Death; } } // Sorcerer spell 3 (The Bishop spawner) ------------------------------------ class SorcFX3 : Actor { Default { Speed 15; Radius 22; Height 65; +NOBLOCKMAP +MISSILE +NOTELEPORT SeeSound "SorcererBishopSpawn"; } States { Spawn: SBS3 ABC 2 Bright; Loop; Death: SBS3 A 4 Bright; BISH P 4 A_SorcererBishopEntry; BISH ON 4; BISH MLKJIH 3; BISH G 3 A_SpawnBishop; Stop; } //============================================================================ // // A_SorcererBishopEntry // //============================================================================ void A_SorcererBishopEntry() { Spawn("SorcFX3Explosion", Pos, ALLOW_REPLACE); A_StartSound (SeeSound, CHAN_VOICE); } //============================================================================ // // A_SpawnBishop // // Green spell - spawn bishops // //============================================================================ void A_SpawnBishop() { Actor mo = Spawn("Bishop", Pos, ALLOW_REPLACE); if (mo) { if (!mo.TestMobjLocation()) { mo.ClearCounters(); mo.Destroy (); } else if (target != null) { // [RH] Make the new bishops inherit the Heresiarch's target mo.CopyFriendliness (target, true); mo.master = target; } } Destroy (); } } // The Bishop spawner's explosion animation --------------------------------- class SorcFX3Explosion : Actor { Default { +NOBLOCKMAP +NOGRAVITY +NOTELEPORT RenderStyle "Translucent"; Alpha 0.4; } States { Spawn: SBS3 DEFGH 3; Stop; } } // Sorcerer spell 4 (The purple projectile) --------------------------------- class SorcFX4 : Actor { Default { Speed 12; Radius 10; Height 10; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS DeathSound "SorcererBallExplode"; } States { Spawn: SBS4 ABC 2 Bright A_SorcFX4Check; Loop; Death: SBS4 D 2 Bright; SBS4 E 2 Bright A_Explode(20, 128); SBS4 FGH 2 Bright; Stop; } //============================================================================ // // A_SorcFX4Check // // FX4 - rapid fire balls // //============================================================================ void A_SorcFX4Check() { if (special2-- <= 0) { SetStateLabel ("Death"); } } } // Spark that appears when shooting SorcFX4 --------------------------------- class SorcSpark1 : Actor { Default { Radius 5; Height 5; Gravity 0.125; +NOBLOCKMAP +DROPOFF +NOTELEPORT +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: SBFX ABCDEFG 4 Bright; Stop; } } // Wimpy ammo --------------------------------------------------------------- Class GoldWandAmmo : Ammo { Default { Inventory.PickupMessage "$TXT_AMMOGOLDWAND1"; Inventory.Amount 10; Inventory.MaxAmount 100; Ammo.BackpackAmount 10; Ammo.BackpackMaxAmount 200; Inventory.Icon "INAMGLD"; Tag "$AMMO_GOLDWAND"; } States { Spawn: AMG1 A -1; Stop; } } // Hefty ammo --------------------------------------------------------------- Class GoldWandHefty : GoldWandAmmo { Default { Inventory.PickupMessage "$TXT_AMMOGOLDWAND2"; Inventory.Amount 50; } States { Spawn: AMG2 ABC 4; Loop; } } // Wimpy ammo --------------------------------------------------------------- Class CrossbowAmmo : Ammo { Default { Inventory.PickupMessage "$TXT_AMMOCROSSBOW1"; Inventory.Amount 5; Inventory.MaxAmount 50; Ammo.BackpackAmount 5; Ammo.BackpackMaxAmount 100; Inventory.Icon "INAMBOW"; Tag "$AMMO_CROSSBOW"; } States { Spawn: AMC1 A -1; Stop; } } // Hefty ammo --------------------------------------------------------------- Class CrossbowHefty : CrossbowAmmo { Default { Inventory.PickupMessage "$TXT_AMMOCROSSBOW2"; Inventory.Amount 20; } States { Spawn: AMC2 ABC 5; Loop; } } // Wimpy ammo --------------------------------------------------------------- Class MaceAmmo : Ammo { Default { Inventory.PickupMessage "$TXT_AMMOMACE1"; Inventory.Amount 20; Inventory.MaxAmount 150; Ammo.BackpackAmount 0; Ammo.BackpackMaxAmount 300; Inventory.Icon "INAMLOB"; Tag "$AMMO_MACE"; } States { Spawn: AMM1 A -1; Stop; } } // Hefty ammo --------------------------------------------------------------- Class MaceHefty : MaceAmmo { Default { Inventory.PickupMessage "$TXT_AMMOMACE2"; Inventory.Amount 100; } States { Spawn: AMM2 A -1; Stop; } } // Wimpy ammo --------------------------------------------------------------- Class BlasterAmmo : Ammo { Default { Inventory.PickupMessage "$TXT_AMMOBLASTER1"; Inventory.Amount 10; Inventory.MaxAmount 200; Ammo.BackpackAmount 10; Ammo.BackpackMaxAmount 400; Inventory.Icon "INAMBST"; Tag "$AMMO_BLASTER"; } States { Spawn: AMB1 ABC 4; Loop; } } // Hefty ammo --------------------------------------------------------------- Class BlasterHefty : BlasterAmmo { Default { Inventory.PickupMessage "$TXT_AMMOBLASTER2"; Inventory.Amount 25; } States { Spawn: AMB2 ABC 4; Loop; } } // Wimpy ammo --------------------------------------------------------------- Class SkullRodAmmo : Ammo { Default { Inventory.PickupMessage "$TXT_AMMOSKULLROD1"; Inventory.Amount 20; Inventory.MaxAmount 200; Ammo.BackpackAmount 20; Ammo.BackpackMaxAmount 400; Inventory.Icon "INAMRAM"; Tag "$AMMO_SKULLROD"; } States { Spawn: AMS1 AB 5; Loop; } } // Hefty ammo --------------------------------------------------------------- Class SkullRodHefty : SkullRodAmmo { Default { Inventory.PickupMessage "$TXT_AMMOSKULLROD2"; Inventory.Amount 100; } States { Spawn: AMS2 AB 5; Loop; } } // Wimpy ammo --------------------------------------------------------------- Class PhoenixRodAmmo : Ammo { Default { Inventory.PickupMessage "$TXT_AMMOPHOENIXROD1"; Inventory.Amount 1; Inventory.MaxAmount 20; Ammo.BackpackAmount 1; Ammo.BackpackMaxAmount 40; Inventory.Icon "INAMPNX"; Tag "$AMMO_PHOENIXROD"; } States { Spawn: AMP1 ABC 4; Loop; } } // Hefty ammo --------------------------------------------------------------- Class PhoenixRodHefty : PhoenixRodAmmo { Default { Inventory.PickupMessage "$TXT_AMMOPHOENIXROD2"; Inventory.Amount 10; } States { Spawn: AMP2 ABC 4; Loop; } } // --- Bag of holding ------------------------------------------------------- Class BagOfHolding : BackpackItem { Default { Inventory.PickupMessage "$TXT_ITEMBAGOFHOLDING"; +COUNTITEM +FLOATBOB } States { Spawn: BAGH A -1; Stop; } } // Silver Shield (Shield1) -------------------------------------------------- Class SilverShield : BasicArmorPickup { Default { +FLOATBOB Inventory.Pickupmessage "$TXT_ITEMSHIELD1"; Inventory.Icon "SHLDA0"; Armor.Savepercent 50; Armor.Saveamount 100; } States { Spawn: SHLD A -1; stop; } } // Enchanted shield (Shield2) ----------------------------------------------- Class EnchantedShield : BasicArmorPickup { Default { +FLOATBOB Inventory.Pickupmessage "$TXT_ITEMSHIELD2"; Inventory.Icon "SHD2A0"; Armor.Savepercent 75; Armor.Saveamount 200; } States { Spawn: SHD2 A -1; stop; } } // Super map ---------------------------------------------------------------- Class SuperMap : MapRevealer { Default { +COUNTITEM +INVENTORY.ALWAYSPICKUP +FLOATBOB Inventory.MaxAmount 0; Inventory.PickupMessage "$TXT_ITEMSUPERMAP"; } States { Spawn: SPMP A -1; Stop; } } // Invisibility ------------------------------------------------------------- Class ArtiInvisibility : PowerupGiver { Default { +COUNTITEM +FLOATBOB Inventory.PickupFlash "PickupFlash"; RenderStyle "Translucent"; Alpha 0.4; Inventory.RespawnTics 4230; Inventory.Icon "ARTIINVS"; Powerup.Type "PowerGhost"; Inventory.PickupMessage "$TXT_ARTIINVISIBILITY"; Tag "$TAG_ARTIINVISIBILITY"; } States { Spawn: INVS A 350 Bright; Loop; } } // Tome of power ------------------------------------------------------------ Class ArtiTomeOfPower : PowerupGiver { Default { +COUNTITEM +FLOATBOB Inventory.PickupFlash "PickupFlash"; Inventory.Icon "ARTIPWBK"; Powerup.Type "PowerWeaponlevel2"; Inventory.PickupMessage "$TXT_ARTITOMEOFPOWER"; Tag "$TAG_ARTITOMEOFPOWER"; } States { Spawn: PWBK A 350; Loop; } override bool Use (bool pickup) { Playerinfo p = Owner.player; if (p && p.morphTics && (p.MorphStyle & MRF_UNDOBYTOMEOFPOWER)) { // Attempt to undo chicken if (!p.mo.UndoPlayerMorph (p, MRF_UNDOBYTOMEOFPOWER)) { // Failed if (!(p.MorphStyle & MRF_FAILNOTELEFRAG)) { Owner.DamageMobj (null, null, TELEFRAG_DAMAGE, 'Telefrag'); } } else { // Succeeded Owner.A_StartSound ("*evillaugh", CHAN_VOICE); } return true; } else { return Super.Use (pickup); } } } // Time bomb ---------------------------------------------------------------- Class ActivatedTimeBomb : Actor { Default { +NOGRAVITY RenderStyle "Translucent"; Alpha 0.4; DeathSound "misc/timebomb"; } States { Spawn: FBMB ABCD 10; FBMB E 6 A_Scream; XPL1 A 4 BRIGHT A_Timebomb; XPL1 BCDEF 4 BRIGHT; Stop; } void A_TimeBomb() { AddZ(32, false); A_SetRenderStyle(1., STYLE_Add); A_Explode(); } } Class ArtiTimeBomb : Inventory { Default { +COUNTITEM +FLOATBOB Inventory.PickupFlash "PickupFlash"; +INVENTORY.INVBAR +INVENTORY.FANCYPICKUPSOUND Inventory.Icon "ARTIFBMB"; Inventory.PickupSound "misc/p_pkup"; Inventory.PickupMessage "$TXT_ARTIFIREBOMB"; Tag "$TAG_ARTIFIREBOMB"; Inventory.DefMaxAmount; } States { Spawn: FBMB E 350; Loop; } override bool Use (bool pickup) { Actor mo = Spawn("ActivatedTimeBomb", Owner.Vec3Angle(24., Owner.angle, - Owner.Floorclip), ALLOW_REPLACE); if (mo != null) mo.target = Owner; return true; } } Class SkullHang70 : Actor { Default { Radius 20; Height 70; +SPAWNCEILING +NOGRAVITY } States { Spawn: SKH1 A -1; Stop; } } Class SkullHang60 : Actor { Default { Radius 20; Height 60; +SPAWNCEILING +NOGRAVITY } States { Spawn: SKH2 A -1; Stop; } } Class SkullHang45 : Actor { Default { Radius 20; Height 45; +SPAWNCEILING +NOGRAVITY } States { Spawn: SKH3 A -1; Stop; } } Class SkullHang35 : Actor { Default { Radius 20; Height 35; +SPAWNCEILING +NOGRAVITY } States { Spawn: SKH4 A -1; Stop; } } Class Chandelier : Actor { Default { Radius 20; Height 60; +SPAWNCEILING +NOGRAVITY } States { Spawn: CHDL ABC 4; Loop; } } Class SerpentTorch : Actor { Default { Radius 12; Height 54; +SOLID } States { Spawn: SRTC ABC 4; Loop; } } Class SmallPillar : Actor { Default { Radius 16; Height 34; +SOLID } States { Spawn: SMPL A -1; Stop; } } Class StalagmiteSmall : Actor { Default { Radius 8; Height 32; +SOLID } States { Spawn: STGS A -1; Stop; } } Class StalagmiteLarge : Actor { Default { Radius 12; Height 64; +SOLID } States { Spawn: STGL A -1; Stop; } } Class StalactiteSmall : Actor { Default { Radius 8; Height 36; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: STCS A -1; Stop; } } Class StalactiteLarge : Actor { Default { Radius 12; Height 68; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: STCL A -1; Stop; } } Class FireBrazier : Actor { Default { Radius 16; Height 44; +SOLID } States { Spawn: KFR1 ABCDEFGH 3 Bright; Loop; } } Class Barrel : Actor { Default { Radius 12; Height 32; +SOLID } States { Spawn: BARL A -1; Stop; } } Class BrownPillar : Actor { Default { Radius 14; Height 128; +SOLID } States { Spawn: BRPL A -1; Stop; } } Class Moss1 : Actor { Default { Radius 20; Height 23; +SPAWNCEILING +NOGRAVITY } States { Spawn: MOS1 A -1; Stop; } } Class Moss2 : Actor { Default { Radius 20; Height 27; +SPAWNCEILING +NOGRAVITY } States { Spawn: MOS2 A -1; Stop; } } Class WallTorch : Actor { Default { Radius 6; Height 16; +NOGRAVITY +FIXMAPTHINGPOS } States { Spawn: WTRH ABC 6 Bright; Loop; } } Class HangingCorpse : Actor { Default { Radius 8; Height 104; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: HCOR A -1; Stop; } } // Heretic imp (as opposed to the Doom variety) ----------------------------- class HereticImp : Actor { bool extremecrash; Default { Health 40; Radius 16; Height 36; Mass 50; Speed 10; Painchance 200; Monster; +FLOAT +NOGRAVITY +SPAWNFLOAT +DONTOVERLAP +MISSILEMORE SeeSound "himp/sight"; AttackSound "himp/attack"; PainSound "himp/pain"; DeathSound "himp/death"; ActiveSound "himp/active"; Obituary "$OB_HERETICIMP"; HitObituary "$OB_HERETICIMPHIT"; Tag "$FN_HERETICIMP"; } States { Spawn: IMPX ABCB 10 A_Look; Loop; See: IMPX AABBCCBB 3 A_Chase; Loop; Melee: IMPX DE 6 A_FaceTarget; IMPX F 6 A_CustomMeleeAttack(random[ImpMeAttack](5,12), "himp/attack", "himp/attack"); Goto See; Missile: IMPX A 10 A_FaceTarget; IMPX B 6 A_ImpMsAttack; IMPX CBAB 6; Goto Missile+2; Pain: IMPX G 3; IMPX G 3 A_Pain; Goto See; Death: IMPX G 4 A_ImpDeath; IMPX H 5; Wait; XDeath: IMPX S 5 A_ImpXDeath1; IMPX TU 5; IMPX V 5 A_Gravity; IMPX W 5; Wait; Crash: IMPX I 7 A_ImpExplode; IMPX J 7 A_Scream; IMPX K 7; IMPX L -1; Stop; XCrash: IMPX X 7; IMPX Y 7; IMPX Z -1; Stop; } //---------------------------------------------------------------------------- // // PROC A_ImpMsAttack // //---------------------------------------------------------------------------- void A_ImpMsAttack() { if (!target || random[ImpMSAtk]() > 64) { SetState (SeeState); return; } A_SkullAttack(12); } //---------------------------------------------------------------------------- // // PROC A_ImpExplode // //---------------------------------------------------------------------------- void A_ImpExplode() { Actor chunk; bNoGravity = false; chunk = Spawn("HereticImpChunk1", pos, ALLOW_REPLACE); if (chunk != null) { chunk.vel.x = random2[ImpExplode]() / 64.; chunk.vel.y = random2[ImpExplode]() / 64.; chunk.vel.z = 9; } chunk = Spawn("HereticImpChunk2", pos, ALLOW_REPLACE); if (chunk != null) { chunk.vel.x = random2[ImpExplode]() / 64.; chunk.vel.y = random2[ImpExplode]() / 64.; chunk.vel.z = 9; } if (extremecrash) { SetStateLabel ("XCrash"); } } //---------------------------------------------------------------------------- // // PROC A_ImpDeath // //---------------------------------------------------------------------------- void A_ImpDeath() { bSolid = false; bFloorClip = true; } //---------------------------------------------------------------------------- // // PROC A_ImpXDeath1 // //---------------------------------------------------------------------------- void A_ImpXDeath1() { bSolid = false; bFloorClip = true; bNoGravity = true; extremecrash = true; } } // Heretic imp leader ------------------------------------------------------- class HereticImpLeader : HereticImp { Default { Species "HereticImpLeader"; Health 80; -MISSILEMORE AttackSound "himp/leaderattack"; } States { Melee: Stop; Missile: IMPX DE 6 A_FaceTarget; IMPX F 6 A_CustomComboAttack("HereticImpBall", 32, random[ImpMsAttack2](5,12), "himp/leaderattack"); Goto See; } } // Heretic imp chunk 1 ------------------------------------------------------ class HereticImpChunk1 : Actor { Default { Mass 5; Radius 4; +NOBLOCKMAP +MOVEWITHSECTOR } States { Spawn: IMPX M 5; IMPX NO 700; Stop; } } // Heretic imp chunk 2 ------------------------------------------------------ class HereticImpChunk2 : Actor { Default { Mass 5; Radius 4; +NOBLOCKMAP +MOVEWITHSECTOR } States { Spawn: IMPX P 5; IMPX QR 700; Stop; } } // Heretic imp ball --------------------------------------------------------- class HereticImpBall : Actor { Default { Radius 8; Height 8; Speed 10; FastSpeed 20; Damage 1; Projectile; SeeSound "himp/leaderattack"; +SPAWNSOUNDSOURCE -ACTIVATEPCROSS -ACTIVATEIMPACT +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: FX10 ABC 6 Bright; Loop; Death: FX10 DEFG 5 Bright; Stop; } } Class HereticKey : Key { Default { +NOTDMATCH Radius 20; Height 16; } } // Green key ------------------------------------------------------------ Class KeyGreen : HereticKey { Default { Inventory.PickupMessage "$TXT_GOTGREENKEY"; Inventory.Icon "GKEYICON"; } States { Spawn: AKYY ABCDEFGHIJ 3 Bright; Loop; } } // Blue key ----------------------------------------------------------------- Class KeyBlue : HereticKey { Default { Inventory.PickupMessage "$TXT_GOTBLUEKEY"; Inventory.Icon "BKEYICON"; } States { Spawn: BKYY ABCDEFGHIJ 3 Bright; Loop; } } // Yellow key --------------------------------------------------------------- Class KeyYellow : HereticKey { Default { Inventory.PickupMessage "$TXT_GOTYELLOWKEY"; Inventory.Icon "YKEYICON"; } States { Spawn: CKYY ABCDEFGHI 3 Bright; Loop; } } // --- Blue Key gizmo ----------------------------------------------------------- Class KeyGizmoBlue : Actor { Default { Radius 16; Height 50; +SOLID } States { Spawn: KGZ1 A 1; KGZ1 A 1 A_SpawnItemEx("KeyGizmoFloatBlue", 0, 0, 60); KGZ1 A -1; Stop; } } Class KeyGizmoFloatBlue : Actor { Default { Radius 16; Height 16; +SOLID +NOGRAVITY } States { Spawn: KGZB A -1 Bright; Stop; } } // --- Green Key gizmo ----------------------------------------------------------- Class KeyGizmoGreen : Actor { Default { Radius 16; Height 50; +SOLID } States { Spawn: KGZ1 A 1; KGZ1 A 1 A_SpawnItemEx("KeyGizmoFloatGreen", 0, 0, 60); KGZ1 A -1; Stop; } } Class KeyGizmoFloatGreen : Actor { Default { Radius 16; Height 16; +SOLID +NOGRAVITY } States { Spawn: KGZG A -1 Bright; Stop; } } // --- Yellow Key gizmo ----------------------------------------------------------- Class KeyGizmoYellow : Actor { Default { Radius 16; Height 50; +SOLID } States { Spawn: KGZ1 A 1; KGZ1 A 1 A_SpawnItemEx("KeyGizmoFloatYellow", 0, 0, 60); KGZ1 A -1; Stop; } } Class KeyGizmoFloatYellow : Actor { Default { Radius 16; Height 16; +SOLID +NOGRAVITY } States { Spawn: KGZY A -1 Bright; Stop; } } class HereticWeapon : Weapon { Default { Weapon.Kickback 150; } } // Pod ---------------------------------------------------------------------- class Pod : Actor { Default { Health 45; Radius 16; Height 54; Painchance 255; +SOLID +NOBLOOD +SHOOTABLE +DROPOFF +WINDTHRUST +PUSHABLE +SLIDESONWALLS +CANPASS +TELESTOMP +DONTMORPH +NOBLOCKMONST +DONTGIB +OLDRADIUSDMG DeathSound "world/podexplode"; PushFactor 0.5; } States { Spawn: PPOD A 10; Loop; Pain: PPOD B 14 A_PodPain; Goto Spawn; Death: PPOD C 5 BRIGHT A_RemovePod; PPOD D 5 BRIGHT A_Scream; PPOD E 5 BRIGHT A_Explode; PPOD F 10 BRIGHT; Stop; Grow: PPOD IJKLMNOP 3; Goto Spawn; } //---------------------------------------------------------------------------- // // PROC A_PodPain // //---------------------------------------------------------------------------- void A_PodPain (class gootype = "PodGoo") { int chance = Random[PodPain](); if (chance < 128) { return; } for (int count = chance > 240 ? 2 : 1; count; count--) { Actor goo = Spawn(gootype, pos + (0, 0, 48), ALLOW_REPLACE); if (goo != null) { goo.target = self; goo.Vel.X = Random2[PodPain]() / 128.; goo.Vel.Y = Random2[PodPain]() / 128.; goo.Vel.Z = 0.5 + random[PodPain]() / 128.; } } } //---------------------------------------------------------------------------- // // PROC A_RemovePod // //---------------------------------------------------------------------------- void A_RemovePod () { if (master && master.special1 > 0) { master.special1--; } } } // Pod goo (falls from pod when damaged) ------------------------------------ class PodGoo : Actor { Default { Radius 2; Height 4; Gravity 0.125; +NOBLOCKMAP +MISSILE +DROPOFF +NOTELEPORT +CANNOTPUSH } States { Spawn: PPOD GH 8; Loop; Death: PPOD G 10; Stop; } } // Pod generator ------------------------------------------------------------ class PodGenerator : Actor { Default { +NOBLOCKMAP +NOSECTOR +DONTSPLASH AttackSound "world/podgrow"; } States { Spawn: TNT1 A 35 A_MakePod; Loop; } //---------------------------------------------------------------------------- // // PROC A_MakePod // //---------------------------------------------------------------------------- const MAX_GEN_PODS = 16; void A_MakePod (class podtype = "Pod") { if (special1 >= MAX_GEN_PODS) { // Too many generated pods return; } Actor mo = Spawn(podtype, (pos.xy, ONFLOORZ), ALLOW_REPLACE); if (!mo) return; if (!mo.CheckPosition (mo.Pos.xy)) { // Didn't fit mo.Destroy (); return; } mo.SetStateLabel("Grow"); mo.Thrust(4.5, random[MakePod]() * (360. / 256)); A_StartSound (AttackSound, CHAN_BODY); special1++; // Increment generated pod count mo.master = self; // Link the generator to the pod } } // Teleglitter generator 1 -------------------------------------------------- class TeleGlitterGenerator1 : Actor { Default { +NOBLOCKMAP +NOGRAVITY +DONTSPLASH +MOVEWITHSECTOR } States { Spawn: TNT1 A 8 A_SpawnItemEx("TeleGlitter1", random[TeleGlitter](0,31)-16, random[TeleGlitter](0,31)-16, 0, 0,0,0.25); Loop; } } // Teleglitter generator 2 -------------------------------------------------- class TeleGlitterGenerator2 : Actor { Default { +NOBLOCKMAP +NOGRAVITY +DONTSPLASH +MOVEWITHSECTOR } States { Spawn: TNT1 A 8 A_SpawnItemEx("TeleGlitter2", random[TeleGlitter2](0,31)-16, random[TeleGlitter2](0,31)-16, 0, 0,0,0.25); Loop; } } // Teleglitter 1 ------------------------------------------------------------ class TeleGlitter1 : Actor { Default { +NOBLOCKMAP +NOGRAVITY +MISSILE +ZDOOMTRANS RenderStyle "Add"; Damage 0; } States { Spawn: TGLT A 2 BRIGHT; TGLT B 2 BRIGHT A_AccTeleGlitter; TGLT C 2 BRIGHT; TGLT D 2 BRIGHT A_AccTeleGlitter; TGLT E 2 BRIGHT; Loop; } //---------------------------------------------------------------------------- // // PROC A_AccTeleGlitter // //---------------------------------------------------------------------------- void A_AccTeleGlitter () { if (++health > 35) { Vel.Z *= 1.5; } } } // Teleglitter 2 ------------------------------------------------------------ class TeleGlitter2 : TeleGlitter1 { States { Spawn: TGLT F 2 BRIGHT; TGLT G 2 BRIGHT A_AccTeleGlitter; TGLT H 2 BRIGHT; TGLT I 2 BRIGHT A_AccTeleGlitter; TGLT J 2 BRIGHT; Loop; } } // --- Volcano -------------------------------------------------------------- class Volcano : Actor { Default { Radius 12; Height 20; +SOLID } States { Spawn: VLCO A 350; VLCO A 35 A_VolcanoSet; VLCO BCDBCD 3; VLCO E 10 A_VolcanoBlast; Goto Spawn+1; } //---------------------------------------------------------------------------- // // PROC A_VolcanoSet // //---------------------------------------------------------------------------- void A_VolcanoSet () { tics = random[VolcanoSet](105, 232); } //---------------------------------------------------------------------------- // // PROC A_VolcanoBlast // //---------------------------------------------------------------------------- void A_VolcanoBlast () { int count = random[VolcanoBlast](1,3); for (int i = 0; i < count; i++) { Actor blast = Spawn("VolcanoBlast", pos + (0, 0, 44), ALLOW_REPLACE); if (blast != null) { blast.target = self; blast.Angle = random[VolcanoBlast]() * (360 / 256.); blast.VelFromAngle(1.); blast.Vel.Z = 2.5 + random[VolcanoBlast]() / 64.; blast.A_StartSound ("world/volcano/shoot", CHAN_BODY); blast.CheckMissileSpawn (radius); } } } } // Volcano blast ------------------------------------------------------------ class VolcanoBlast : Actor { Default { Radius 8; Height 8; Speed 2; Damage 2; DamageType "Fire"; Gravity 0.125; +NOBLOCKMAP +MISSILE +DROPOFF +NOTELEPORT DeathSound "world/volcano/blast"; } States { Spawn: VFBL AB 4 BRIGHT A_SpawnItemEx("Puffy", random2[BeastPuff]()*0.015625, random2[BeastPuff]()*0.015625, random2[BeastPuff]()*0.015625, 0,0,0,0,SXF_ABSOLUTEPOSITION, 64); Loop; Death: XPL1 A 4 BRIGHT A_VolcBallImpact; XPL1 BCDEF 4 BRIGHT; Stop; } //---------------------------------------------------------------------------- // // PROC A_VolcBallImpact // //---------------------------------------------------------------------------- void A_VolcBallImpact () { if (pos.Z <= floorz) { bNoGravity = true; Gravity = 1; AddZ(28); } A_Explode(25, 25, XF_NOSPLASH|XF_HURTSOURCE, false, 0, 0, 0, "BulletPuff", 'Fire'); for (int i = 0; i < 4; i++) { Actor tiny = Spawn("VolcanoTBlast", Pos, ALLOW_REPLACE); if (tiny) { tiny.target = self; tiny.Angle = 90.*i; tiny.VelFromAngle(0.7); tiny.Vel.Z = 1. + random[VolcBallImpact]() / 128.; tiny.CheckMissileSpawn (radius); } } } } // Volcano T Blast ---------------------------------------------------------- class VolcanoTBlast : Actor { Default { Radius 8; Height 6; Speed 2; Damage 1; DamageType "Fire"; Gravity 0.125; +NOBLOCKMAP +MISSILE +DROPOFF +NOTELEPORT } States { Spawn: VTFB AB 4 BRIGHT; Loop; Death: SFFI CBABCDE 4 BRIGHT; Stop; } } class HereticPlayer : PlayerPawn { Default { Health 100; Radius 16; Height 56; Mass 100; Painchance 255; Speed 1; Player.DisplayName "Corvus"; Player.StartItem "GoldWand"; Player.StartItem "Staff"; Player.StartItem "GoldWandAmmo", 50; Player.WeaponSlot 1, "Staff", "Gauntlets"; Player.WeaponSlot 2, "GoldWand"; Player.WeaponSlot 3, "Crossbow"; Player.WeaponSlot 4, "Blaster"; Player.WeaponSlot 5, "SkullRod"; Player.WeaponSlot 6, "PhoenixRod"; Player.WeaponSlot 7, "Mace"; Player.ColorRange 225, 240; Player.Colorset 0, "$TXT_COLOR_GREEN", 225, 240, 238; Player.Colorset 1, "$TXT_COLOR_YELLOW", 114, 129, 127; Player.Colorset 2, "$TXT_COLOR_RED", 145, 160, 158; Player.Colorset 3, "$TXT_COLOR_BLUE", 190, 205, 203; // Doom Legacy additions Player.Colorset 4, "$TXT_COLOR_BROWN", 67, 82, 80; Player.Colorset 5, "$TXT_COLOR_LIGHTGRAY", 9, 24, 22; Player.Colorset 6, "$TXT_COLOR_LIGHTBROWN", 74, 89, 87; Player.Colorset 7, "$TXT_COLOR_LIGHTRED", 150, 165, 163; Player.Colorset 8, "$TXT_COLOR_LIGHTBLUE", 192, 207, 205; Player.Colorset 9, "$TXT_COLOR_BEIGE", 95, 110, 108; } States { Spawn: PLAY A -1; Stop; See: PLAY ABCD 4; Loop; Melee: Missile: PLAY F 6 BRIGHT; PLAY E 12; Goto Spawn; Pain: PLAY G 4; PLAY G 4 A_Pain; Goto Spawn; Death: PLAY H 6 A_PlayerSkinCheck("AltSkinDeath"); PLAY I 6 A_PlayerScream; PLAY JK 6; PLAY L 6 A_NoBlocking; PLAY MNO 6; PLAY P -1; Stop; XDeath: PLAY Q 0 A_PlayerSkinCheck("AltSkinXDeath"); PLAY Q 5 A_PlayerScream; PLAY R 0 A_NoBlocking; PLAY R 5 A_SkullPop; PLAY STUVWX 5; PLAY Y -1; Stop; Burn: FDTH A 5 BRIGHT A_StartSound("*burndeath"); FDTH B 4 BRIGHT; FDTH C 5 BRIGHT; FDTH D 4 BRIGHT A_PlayerScream; FDTH E 5 BRIGHT; FDTH F 4 BRIGHT; FDTH G 5 BRIGHT A_StartSound("*burndeath"); FDTH H 4 BRIGHT; FDTH I 5 BRIGHT; FDTH J 4 BRIGHT; FDTH K 5 BRIGHT; FDTH L 4 BRIGHT; FDTH M 5 BRIGHT; FDTH N 4 BRIGHT; FDTH O 5 BRIGHT A_NoBlocking; FDTH P 4 BRIGHT; FDTH Q 5 BRIGHT; FDTH R 4 BRIGHT; ACLO E 35 A_CheckPlayerDone; Wait; AltSkinDeath: PLAY H 10; PLAY I 10 A_PlayerScream; PLAY J 10 A_NoBlocking; PLAY KLM 10; PLAY N -1; Stop; AltSkinXDeath: PLAY O 5; PLAY P 5 A_XScream; PLAY Q 5 A_NoBlocking; PLAY RSTUV 5; PLAY W -1; Stop; } } // The player's skull ------------------------------------------------------- class BloodySkull : PlayerChunk { Default { Radius 4; Height 4; Gravity 0.125; +NOBLOCKMAP +DROPOFF +CANNOTPUSH +SKYEXPLODE +NOBLOCKMONST +NOSKIN } States { Spawn: BSKL A 0; BSKL ABCDE 5 A_CheckFloor("Hit"); Goto Spawn+1; Hit: BSKL F 16 A_CheckPlayerDone; Wait; } } class HereticStatusBar : BaseStatusBar { DynamicValueInterpolator mHealthInterpolator; HUDFont mHUDFont; HUDFont mIndexFont; HUDFont mBigFont; InventoryBarState diparms; InventoryBarState diparms_sbar; private int wiggle; override void Init() { Super.Init(); SetSize(42, 320, 200); // Create the font used for the fullscreen HUD Font fnt = "HUDFONT_RAVEN"; mHUDFont = HUDFont.Create(fnt, fnt.GetCharWidth("0") + 1, Mono_CellLeft, 1, 1); fnt = "INDEXFONT_RAVEN"; mIndexFont = HUDFont.Create(fnt, fnt.GetCharWidth("0"), Mono_CellLeft); fnt = "BIGFONT"; mBigFont = HUDFont.Create(fnt, fnt.GetCharWidth("0"), Mono_CellLeft, 2, 2); diparms = InventoryBarState.Create(mIndexFont); diparms_sbar = InventoryBarState.CreateNoBox(mIndexFont, boxsize:(31, 31), arrowoffs:(0,-10)); mHealthInterpolator = DynamicValueInterpolator.Create(0, 0.25, 1, 8); } override int GetProtrusion(double scaleratio) const { return scaleratio > 0.7? 8 : 0; } override void NewGame () { Super.NewGame(); mHealthInterpolator.Reset (0); } override void Tick() { Super.Tick(); mHealthInterpolator.Update(CPlayer.health); // wiggle the chain if it moves if (Level.time & 1) { wiggle = (mHealthInterpolator.GetValue() != CPlayer.health) && Random[ChainWiggle](0, 1); } } override void Draw (int state, double TicFrac) { Super.Draw (state, TicFrac); if (state == HUD_StatusBar) { BeginStatusBar(); DrawMainBar (TicFrac); } else if (state == HUD_Fullscreen) { BeginHUD(); DrawFullScreenStuff (); } } protected void DrawMainBar (double TicFrac) { DrawImage("BARBACK", (0, 158), DI_ITEM_OFFSETS); DrawImage("LTFCTOP", (0, 148), DI_ITEM_OFFSETS); DrawImage("RTFCTOP", (290, 148), DI_ITEM_OFFSETS); if (isInvulnerable()) { //god mode DrawImage("GOD1", (16, 167), DI_ITEM_OFFSETS); DrawImage("GOD2", (287, 167), DI_ITEM_OFFSETS); } //health DrawImage("CHAINBAC", (0, 190), DI_ITEM_OFFSETS); // wiggle the chain if it moves int inthealth = mHealthInterpolator.GetValue(); DrawGem("CHAIN", "LIFEGEM2",inthealth, CPlayer.mo.GetMaxHealth(true), (2, 191 + wiggle), 15, 25, 16, (multiplayer? DI_TRANSLATABLE : 0) | DI_ITEM_LEFT_TOP); DrawImage("LTFACE", (0, 190), DI_ITEM_OFFSETS); DrawImage("RTFACE", (276, 190), DI_ITEM_OFFSETS); DrawShader(SHADER_HORZ, (19, 190), (16, 10)); DrawShader(SHADER_HORZ|SHADER_REVERSE, (278, 190), (16, 10)); if (!isInventoryBarVisible()) { //statbar if (!deathmatch) { DrawImage("LIFEBAR", (34, 160), DI_ITEM_OFFSETS); DrawImage("ARMCLEAR", (57, 171), DI_ITEM_OFFSETS); DrawString(mHUDFont, FormatNumber(mHealthInterpolator.GetValue(), 3), (88, 170), DI_TEXT_ALIGN_RIGHT); } else { DrawImage("STATBAR", (34, 160), DI_ITEM_OFFSETS); DrawImage("ARMCLEAR", (57, 171), DI_ITEM_OFFSETS); DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (88, 170), DI_TEXT_ALIGN_RIGHT); } DrawString(mHUDFont, FormatNumber(GetArmorAmount(), 3), (255, 170), DI_TEXT_ALIGN_RIGHT); //ammo Ammo ammo1, ammo2; [ammo1, ammo2] = GetCurrentAmmo(); if (ammo1 != null && ammo2 == null) { DrawString(mHUDFont, FormatNumber(ammo1.Amount, 3), (136, 162), DI_TEXT_ALIGN_RIGHT); DrawTexture(ammo1.icon, (123, 180), DI_ITEM_CENTER); } else if (ammo2 != null) { DrawString(mIndexFont, FormatNumber(ammo1.Amount, 3), (137, 165), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(ammo2.Amount, 3), (137, 177), DI_TEXT_ALIGN_RIGHT); DrawTexture(ammo1.icon, (115, 169), DI_ITEM_CENTER); DrawTexture(ammo2.icon, (115, 180), DI_ITEM_CENTER); } //keys if (CPlayer.mo.CheckKeys(3, false, true)) DrawImage("YKEYICON", (153, 164), DI_ITEM_OFFSETS); if (CPlayer.mo.CheckKeys(1, false, true)) DrawImage("GKEYICON", (153, 172), DI_ITEM_OFFSETS); if (CPlayer.mo.CheckKeys(2, false, true)) DrawImage("BKEYICON", (153, 180), DI_ITEM_OFFSETS); //inventory box if (CPlayer.mo.InvSel != null) { DrawInventoryIcon(CPlayer.mo.InvSel, (194, 175), DI_ARTIFLASH|DI_ITEM_CENTER|DI_DIMDEPLETED, boxsize:(28, 28)); if (CPlayer.mo.InvSel.Amount > 1) { DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (209, 182), DI_TEXT_ALIGN_RIGHT); } } } else { DrawImage("INVBAR", (34, 160), DI_ITEM_OFFSETS); DrawInventoryBar(diparms_sbar, (49, 160), 7, DI_ITEM_LEFT_TOP, HX_SHADOW); } } protected void DrawFullScreenStuff () { //health DrawImage("PTN1A0", (51, -3)); DrawString(mBigFont, FormatNumber(mHealthInterpolator.GetValue()), (41, -21), DI_TEXT_ALIGN_RIGHT); //armor let armor = CPlayer.mo.FindInventory("BasicArmor"); if (armor != null && armor.Amount > 0) { DrawInventoryIcon(armor, (58, -24)); DrawString(mBigFont, FormatNumber(armor.Amount, 3), (41, -43), DI_TEXT_ALIGN_RIGHT); } //frags/keys if (deathmatch) { DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (70, -16)); } else { Vector2 keypos = (60, -1); int rowc = 0; double roww = 0; for(let i = CPlayer.mo.Inv; i != null; i = i.Inv) { if (i is "Key" && i.Icon.IsValid()) { DrawTexture(i.Icon, keypos, DI_ITEM_LEFT_BOTTOM); Vector2 size = TexMan.GetScaledSize(i.Icon); keypos.Y -= size.Y + 2; roww = max(roww, size.X); if (++rowc == 3) { keypos.Y = -1; keypos.X += roww + 2; roww = 0; rowc = 0; } } } } //ammo Ammo ammo1, ammo2; [ammo1, ammo2] = GetCurrentAmmo(); int y = -22; if (ammo1 != null) { DrawTexture(ammo1.Icon, (-17, y)); DrawString(mHUDFont, FormatNumber(ammo1.Amount, 3), (-3, y+7), DI_TEXT_ALIGN_RIGHT); y -= 40; } if (ammo2 != null) { DrawTexture(ammo2.Icon, (-14, y)); DrawString(mHUDFont, FormatNumber(ammo2.Amount, 3), (-3, y+7), DI_TEXT_ALIGN_RIGHT); y -= 40; } if (!isInventoryBarVisible() && !Level.NoInventoryBar && CPlayer.mo.InvSel != null) { // This code was changed to always fit the item into the box, regardless of alignment or sprite size. // Heretic's ARTIBOX is 30x30 pixels. DrawImage("ARTIBOX", (-46, -1), 0, HX_SHADOW); DrawInventoryIcon(CPlayer.mo.InvSel, (-46, -15), DI_ARTIFLASH|DI_ITEM_CENTER|DI_DIMDEPLETED, boxsize:(28, 28)); if (CPlayer.mo.InvSel.Amount > 1) { DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-32, -2 - mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT); } } if (isInventoryBarVisible()) { DrawInventoryBar(diparms, (0, 0), 7, DI_SCREEN_CENTER_BOTTOM, HX_SHADOW); } } } // Mesh Armor (1) ----------------------------------------------------------- class MeshArmor : HexenArmor { Default { +NOGRAVITY Health 0; // Armor class Inventory.Amount 0; Inventory.PickupMessage "$TXT_ARMOR1"; } States { Spawn: AR_1 A -1; Stop; } } // Falcon Shield (2) -------------------------------------------------------- class FalconShield : HexenArmor { Default { +NOGRAVITY Health 1; // Armor class Inventory.Amount 0; Inventory.PickupMessage "$TXT_ARMOR2"; } States { Spawn: AR_2 A -1; Stop; } } // Platinum Helm (3) -------------------------------------------------------- class PlatinumHelm : HexenArmor { Default { +NOGRAVITY Health 2; // Armor class Inventory.Amount 0; Inventory.PickupMessage "$TXT_ARMOR3"; } States { Spawn: AR_3 A -1; Stop; } } // Amulet of Warding (4) ---------------------------------------------------- class AmuletOfWarding : HexenArmor { Default { +NOGRAVITY Health 3; // Armor class Inventory.Amount 0; Inventory.PickupMessage "$TXT_ARMOR4"; } States { Spawn: AR_4 A -1; Stop; } } class ZWingedStatue : Actor { Default { Radius 10; Height 62; +SOLID } States { Spawn: STTW A -1; Stop; } } class ZRock1 : Actor { Default { Radius 20; Height 16; } States { Spawn: RCK1 A -1; Stop; } } class ZRock2 : Actor { Default { Radius 20; Height 16; } States { Spawn: RCK2 A -1; Stop; } } class ZRock3 : Actor { Default { Radius 20; Height 16; } States { Spawn: RCK3 A -1; Stop; } } class ZRock4 : Actor { Default { Radius 20; Height 16; +SOLID } States { Spawn: RCK4 A -1; Stop; } } class ZChandelier : Actor { Default { Radius 20; Height 60; +SPAWNCEILING +NOGRAVITY } States { Spawn: CDLR ABC 4; Loop; } } class ZChandelierUnlit : Actor { Default { Radius 20; Height 60; +SPAWNCEILING +NOGRAVITY } States { Spawn: CDLR D -1; Stop; } } class ZTreeDead : Actor { Default { Radius 10; Height 96; +SOLID } States { Spawn: ZTRE A -1; Stop; } } class ZTree : Actor { Default { Radius 15; Height 128; +SOLID } States { Spawn: ZTRE A -1; Stop; } } class ZTreeSwamp150 : Actor { Default { Radius 10; Height 150; +SOLID } States { Spawn: TRES A -1; Stop; } } class ZTreeSwamp120 : Actor { Default { Radius 10; Height 120; +SOLID } States { Spawn: TRE3 A -1; Stop; } } class ZStumpBurned : Actor { Default { Radius 12; Height 20; +SOLID } States { Spawn: STM1 A -1; Stop; } } class ZStumpBare : Actor { Default { Radius 12; Height 20; +SOLID } States { Spawn: STM2 A -1; Stop; } } class ZStumpSwamp1 : Actor { Default { Radius 20; Height 16; } States { Spawn: STM3 A -1; Stop; } } class ZStumpSwamp2 : Actor { Default { Radius 20; Height 16; } States { Spawn: STM4 A -1; Stop; } } class ZShroomLarge1 : Actor { Default { Radius 20; Height 16; } States { Spawn: MSH1 A -1; Stop; } } class ZShroomLarge2 : Actor { Default { Radius 20; Height 16; } States { Spawn: MSH2 A -1; Stop; } } class ZShroomLarge3 : Actor { Default { Radius 20; Height 16; } States { Spawn: MSH3 A -1; Stop; } } class ZShroomSmall1 : Actor { Default { Radius 20; Height 16; } States { Spawn: MSH4 A -1; Stop; } } class ZShroomSmall2 : Actor { Default { Radius 20; Height 16; } States { Spawn: MSH5 A -1; Stop; } } class ZShroomSmall3 : Actor { Default { Radius 20; Height 16; } States { Spawn: MSH6 A -1; Stop; } } class ZShroomSmall4 : Actor { Default { Radius 20; Height 16; } States { Spawn: MSH7 A -1; Stop; } } class ZShroomSmall5 : Actor { Default { Radius 20; Height 16; } States { Spawn: MSH8 A -1; Stop; } } class ZStalagmitePillar : Actor { Default { Radius 8; Height 138; +SOLID } States { Spawn: SGMP A -1; Stop; } } class ZStalagmiteLarge : Actor { Default { Radius 8; Height 48; +SOLID } States { Spawn: SGM1 A -1; Stop; } } class ZStalagmiteMedium : Actor { Default { Radius 6; Height 40; +SOLID } States { Spawn: SGM2 A -1; Stop; } } class ZStalagmiteSmall : Actor { Default { Radius 8; Height 36; +SOLID } States { Spawn: SGM3 A -1; Stop; } } class ZStalactiteLarge : Actor { Default { Radius 8; Height 66; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: SLC1 A -1; Stop; } } class ZStalactiteMedium : Actor { Default { Radius 6; Height 50; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: SLC2 A -1; Stop; } } class ZStalactiteSmall : Actor { Default { Radius 8; Height 40; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: SLC3 A -1; Stop; } } class ZMossCeiling1 : Actor { Default { Radius 20; Height 20; +SPAWNCEILING +NOGRAVITY } States { Spawn: MSS1 A -1; Stop; } } class ZMossCeiling2 : Actor { Default { Radius 20; Height 24; +SPAWNCEILING +NOGRAVITY } States { Spawn: MSS2 A -1; Stop; } } class ZSwampVine : Actor { Default { Radius 8; Height 52; +SOLID } States { Spawn: SWMV A -1; Stop; } } class ZCorpseKabob : Actor { Default { Radius 10; Height 92; +SOLID } States { Spawn: CPS1 A -1; Stop; } } class ZCorpseSleeping : Actor { Default { Radius 20; Height 16; } States { Spawn: CPS2 A -1; Stop; } } class ZTombstoneRIP : Actor { Default { Radius 10; Height 46; +SOLID } States { Spawn: TMS1 A -1; Stop; } } class ZTombstoneShane : Actor { Default { Radius 10; Height 46; +SOLID } States { Spawn: TMS2 A -1; Stop; } } class ZTombstoneBigCross : Actor { Default { Radius 10; Height 46; +SOLID } States { Spawn: TMS3 A -1; Stop; } } class ZTombstoneBrianR : Actor { Default { Radius 10; Height 52; +SOLID } States { Spawn: TMS4 A -1; Stop; } } class ZTombstoneCrossCircle : Actor { Default { Radius 10; Height 52; +SOLID } States { Spawn: TMS5 A -1; Stop; } } class ZTombstoneSmallCross : Actor { Default { Radius 8; Height 46; +SOLID } States { Spawn: TMS6 A -1; Stop; } } class ZTombstoneBrianP : Actor { Default { Radius 8; Height 46; +SOLID } States { Spawn: TMS7 A -1; Stop; } } class ZCorpseHanging : Actor { Default { Radius 6; Height 75; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: CPS3 A -1; Stop; } } class ZStatueGargoyleGreenTall : Actor { Default { Radius 14; Height 108; +SOLID } States { Spawn: STT2 A -1; Stop; } } class ZStatueGargoyleBlueTall : Actor { Default { Radius 14; Height 108; +SOLID } States { Spawn: STT3 A -1; Stop; } } class ZStatueGargoyleGreenShort : Actor { Default { Radius 14; Height 62; +SOLID } States { Spawn: STT4 A -1; Stop; } } class ZStatueGargoyleBlueShort : Actor { Default { Radius 14; Height 62; +SOLID } States { Spawn: STT5 A -1; Stop; } } class ZStatueGargoyleStripeTall : Actor { Default { Radius 14; Height 108; +SOLID } States { Spawn: GAR1 A -1; Stop; } } class ZStatueGargoyleDarkRedTall : Actor { Default { Radius 14; Height 108; +SOLID } States { Spawn: GAR2 A -1; Stop; } } class ZStatueGargoyleRedTall : Actor { Default { Radius 14; Height 108; +SOLID } States { Spawn: GAR3 A -1; Stop; } } class ZStatueGargoyleTanTall : Actor { Default { Radius 14; Height 108; +SOLID } States { Spawn: GAR4 A -1; Stop; } } class ZStatueGargoyleRustTall : Actor { Default { Radius 14; Height 108; +SOLID } States { Spawn: GAR5 A -1; Stop; } } class ZStatueGargoyleDarkRedShort : Actor { Default { Radius 14; Height 62; +SOLID } States { Spawn: GAR6 A -1; Stop; } } class ZStatueGargoyleRedShort : Actor { Default { Radius 14; Height 62; +SOLID } States { Spawn: GAR7 A -1; Stop; } } class ZStatueGargoyleTanShort : Actor { Default { Radius 14; Height 62; +SOLID } States { Spawn: GAR8 A -1; Stop; } } class ZStatueGargoyleRustShort : Actor { Default { Radius 14; Height 62; +SOLID } States { Spawn: GAR9 A -1; Stop; } } class ZBannerTattered : Actor { Default { Radius 8; Height 120; +SOLID } States { Spawn: BNR1 A -1; Stop; } } class ZTreeLarge1 : Actor { Default { Radius 15; Height 180; +SOLID } States { Spawn: TRE4 A -1; Stop; } } class ZTreeLarge2 : Actor { Default { Radius 15; Height 180; +SOLID } States { Spawn: TRE5 A -1; Stop; } } class ZTreeGnarled1 : Actor { Default { Radius 22; Height 100; +SOLID } States { Spawn: TRE6 A -1; Stop; } } class ZTreeGnarled2 : Actor { Default { Radius 22; Height 100; +SOLID } States { Spawn: TRE7 A -1; Stop; } } class ZLog : Actor { Default { Radius 20; Height 25; +SOLID } States { Spawn: LOGG A -1; Stop; } } class ZStalactiteIceLarge : Actor { Default { Radius 8; Height 66; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: ICT1 A -1; Stop; } } class ZStalactiteIceMedium : Actor { Default { Radius 5; Height 50; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: ICT2 A -1; Stop; } } class ZStalactiteIceSmall : Actor { Default { Radius 4; Height 32; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: ICT3 A -1; Stop; } } class ZStalactiteIceTiny : Actor { Default { Radius 4; Height 8; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: ICT4 A -1; Stop; } } class ZStalagmiteIceLarge : Actor { Default { Radius 8; Height 66; +SOLID } States { Spawn: ICM1 A -1; Stop; } } class ZStalagmiteIceMedium : Actor { Default { Radius 5; Height 50; +SOLID } States { Spawn: ICM2 A -1; Stop; } } class ZStalagmiteIceSmall : Actor { Default { Radius 4; Height 32; +SOLID } States { Spawn: ICM3 A -1; Stop; } } class ZStalagmiteIceTiny : Actor { Default { Radius 4; Height 8; +SOLID } States { Spawn: ICM4 A -1; Stop; } } class ZRockBrown1 : Actor { Default { Radius 17; Height 72; +SOLID } States { Spawn: RKBL A -1; Stop; } } class ZRockBrown2 : Actor { Default { Radius 15; Height 50; +SOLID } States { Spawn: RKBS A -1; Stop; } } class ZRockBlack : Actor { Default { Radius 20; Height 40; +SOLID } States { Spawn: RKBK A -1; Stop; } } class ZRubble1 : Actor { Default { Radius 20; Height 16; } States { Spawn: RBL1 A -1; Stop; } } class ZRubble2 : Actor { Default { Radius 20; Height 16; } States { Spawn: RBL2 A -1; Stop; } } class ZRubble3 : Actor { Default { Radius 20; Height 16; } States { Spawn: RBL3 A -1; Stop; } } class ZVasePillar : Actor { Default { Radius 12; Height 54; +SOLID } States { Spawn: VASE A -1; Stop; } } class ZCorpseLynched : Actor { Default { Radius 11; Height 95; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: CPS4 A -1; Stop; } } class ZCandle : Actor { Default { Radius 20; Height 16; +NOGRAVITY +NOBLOCKMAP } States { Spawn: CNDL ABC 4 Bright; Loop; } } class ZBarrel : Actor { Default { Radius 15; Height 32; +SOLID } States { Spawn: ZBAR A -1; Stop; } } class ZBucket : Actor { Default { Radius 8; Height 72; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: BCKT A -1; Stop; } } class FireThing : Actor { Default { Radius 5; Height 10; +SOLID } States { Spawn: FSKL A 4 Bright; FSKL B 3 Bright; FSKL C 4 Bright; FSKL D 3 Bright; FSKL E 4 Bright; FSKL F 3 Bright; FSKL G 4 Bright; FSKL H 3 Bright; FSKL I 4 Bright; Loop; } } class BrassTorch : Actor { Default { Radius 6; Height 35; +SOLID } States { Spawn: BRTR ABCDEFGHIJKLM 4 Bright; Loop; } } class ZBlueCandle : Actor { Default { Radius 20; Height 16; +NOBLOCKMAP } States { Spawn: BCAN ABCDE 5 Bright; Loop; } } class ZIronMaiden : Actor { Default { Radius 12; Height 60; +SOLID } States { Spawn: IRON A -1; Stop; } } class ZChainBit32 : Actor { Default { Radius 4; Height 32; +SPAWNCEILING +NOGRAVITY +NOBLOCKMAP } States { Spawn: CHNS A -1; Stop; } } class ZChainBit64 : Actor { Default { Radius 4; Height 64; +SPAWNCEILING +NOGRAVITY +NOBLOCKMAP } States { Spawn: CHNS B -1; Stop; } } class ZChainEndHeart : Actor { Default { Radius 4; Height 32; +SPAWNCEILING +NOGRAVITY +NOBLOCKMAP } States { Spawn: CHNS C -1; Stop; } } class ZChainEndHook1 : Actor { Default { Radius 4; Height 32; +SPAWNCEILING +NOGRAVITY +NOBLOCKMAP } States { Spawn: CHNS D -1; Stop; } } class ZChainEndHook2 : Actor { Default { Radius 4; Height 32; +SPAWNCEILING +NOGRAVITY +NOBLOCKMAP } States { Spawn: CHNS E -1; Stop; } } class ZChainEndSpike : Actor { Default { Radius 4; Height 32; +SPAWNCEILING +NOGRAVITY +NOBLOCKMAP } States { Spawn: CHNS F -1; Stop; } } class ZChainEndSkull : Actor { Default { Radius 4; Height 32; +SPAWNCEILING +NOGRAVITY +NOBLOCKMAP } States { Spawn: CHNS G -1; Stop; } } class TableShit1 : Actor { Default { Radius 20; Height 16; +NOBLOCKMAP } States { Spawn: TST1 A -1; Stop; } } class TableShit2 : Actor { Default { Radius 20; Height 16; +NOBLOCKMAP } States { Spawn: TST2 A -1; Stop; } } class TableShit3 : Actor { Default { Radius 20; Height 16; +NOBLOCKMAP } States { Spawn: TST3 A -1; Stop; } } class TableShit4 : Actor { Default { Radius 20; Height 16; +NOBLOCKMAP } States { Spawn: TST4 A -1; Stop; } } class TableShit5 : Actor { Default { Radius 20; Height 16; +NOBLOCKMAP } States { Spawn: TST5 A -1; Stop; } } class TableShit6 : Actor { Default { Radius 20; Height 16; +NOBLOCKMAP } States { Spawn: TST6 A -1; Stop; } } class TableShit7 : Actor { Default { Radius 20; Height 16; +NOBLOCKMAP } States { Spawn: TST7 A -1; Stop; } } class TableShit8 : Actor { Default { Radius 20; Height 16; +NOBLOCKMAP } States { Spawn: TST8 A -1; Stop; } } class TableShit9 : Actor { Default { Radius 20; Height 16; +NOBLOCKMAP } States { Spawn: TST9 A -1; Stop; } } class TableShit10 : Actor { Default { Radius 20; Height 16; +NOBLOCKMAP } States { Spawn: TST0 A -1; Stop; } } class TeleSmoke : Actor { Default { Radius 20; Height 16; +NOGRAVITY +NOBLOCKMAP RenderStyle "Translucent"; Alpha 0.6; } States { Spawn: TSMK A 4; TSMK B 3; TSMK C 4; TSMK D 3; TSMK E 4; TSMK F 3; TSMK G 4; TSMK H 3; TSMK I 4; TSMK J 3; TSMK K 4; TSMK L 3; TSMK M 4; TSMK N 3; TSMK O 4; TSMK P 3; TSMK Q 4; TSMK R 3; TSMK S 4; TSMK T 3; TSMK U 4; TSMK V 3; TSMK W 4; TSMK X 3; TSMK Y 4; TSMK Z 3; Loop; } } class HexenKey : Key { Default { Radius 8; Height 20; } } class KeySteel : HexenKey { Default { Inventory.Icon "KEYSLOT1"; Inventory.PickupMessage "$TXT_KEY_STEEL"; } States { Spawn: KEY1 A -1; Stop; } } class KeyCave : HexenKey { Default { Inventory.Icon "KEYSLOT2"; Inventory.PickupMessage "$TXT_KEY_CAVE"; } States { Spawn: KEY2 A -1; Stop; } } class KeyAxe : HexenKey { Default { Inventory.Icon "KEYSLOT3"; Inventory.PickupMessage "$TXT_KEY_AXE"; } States { Spawn: KEY3 A -1; Stop; } } class KeyFire : HexenKey { Default { Inventory.Icon "KEYSLOT4"; Inventory.PickupMessage "$TXT_KEY_FIRE"; } States { Spawn: KEY4 A -1; Stop; } } class KeyEmerald : HexenKey { Default { Inventory.Icon "KEYSLOT5"; Inventory.PickupMessage "$TXT_KEY_EMERALD"; } States { Spawn: KEY5 A -1; Stop; } } class KeyDungeon : HexenKey { Default { Inventory.Icon "KEYSLOT6"; Inventory.PickupMessage "$TXT_KEY_DUNGEON"; } States { Spawn: KEY6 A -1; Stop; } } class KeySilver : HexenKey { Default { Inventory.Icon "KEYSLOT7"; Inventory.PickupMessage "$TXT_KEY_SILVER"; } States { Spawn: KEY7 A -1; Stop; } } class KeyRusted : HexenKey { Default { Inventory.Icon "KEYSLOT8"; Inventory.PickupMessage "$TXT_KEY_RUSTED"; } States { Spawn: KEY8 A -1; Stop; } } class KeyHorn : HexenKey { Default { Inventory.Icon "KEYSLOT9"; Inventory.PickupMessage "$TXT_KEY_HORN"; } States { Spawn: KEY9 A -1; Stop; } } class KeySwamp : HexenKey { Default { Inventory.Icon "KEYSLOTA"; Inventory.PickupMessage "$TXT_KEY_SWAMP"; } States { Spawn: KEYA A -1; Stop; } } class KeyCastle : HexenKey { Default { Inventory.Icon "KEYSLOTB"; Inventory.PickupMessage "$TXT_KEY_CASTLE"; } States { Spawn: KEYB A -1; Stop; } } // Winged Statue (no skull) ------------------------------------------------- class ZWingedStatueNoSkull : SwitchingDecoration { Default { Radius 10; Height 62; +SOLID } States { Spawn: STWN A -1; Stop; Active: STWN B -1; Stop; } } // Gem pedestal ------------------------------------------------------------- class ZGemPedestal : SwitchingDecoration { Default { Radius 10; Height 40; +SOLID } States { Spawn: GMPD A -1; Stop; Active: GMPD B -1; Stop; } } // Tree (destructible) ------------------------------------------------------ class TreeDestructible : Actor { Default { Health 70; Radius 15; Height 180; DeathHeight 24; Mass 0x7fffffff; PainSound "TreeExplode"; DeathSound "TreeBreak"; +SOLID +SHOOTABLE +NOBLOOD +NOICEDEATH } States { Spawn: TRDT A -1; Stop; Death: TRDT B 5; TRDT C 5 A_Scream; TRDT DEF 5; TRDT G -1; Stop; Burn: TRDT H 5 Bright A_Pain; TRDT IJKL 5 Bright; TRDT M 5 Bright A_Explode(10, 128); TRDT N 5 Bright; TRDT OP 5; TRDT Q -1; Stop; } } // Pottery1 ------------------------------------------------------------------ class Pottery1 : Actor { Default { Health 15; Speed 10; Height 32; +SOLID +SHOOTABLE +NOBLOOD +DROPOFF +SMASHABLE +SLIDESONWALLS +PUSHABLE +TELESTOMP +CANPASS +NOICEDEATH } States { Spawn: POT1 A -1; Loop; Death: POT1 A 0 A_PotteryExplode; Stop; } //============================================================================ // // A_PotteryExplode // //============================================================================ void A_PotteryExplode() { Actor mo = null; int i; for(i = random[Pottery](3, 6); i; i--) { mo = Spawn ("PotteryBit", Pos, ALLOW_REPLACE); if (mo) { mo.SetState (mo.SpawnState + random[Pottery](0, 4)); mo.Vel.X = random2[Pottery]() / 64.; mo.Vel.Y = random2[Pottery]() / 64.; mo.Vel.Z = random[Pottery](5, 12) * 0.75; } } mo.A_StartSound ("PotteryExplode", CHAN_BODY); // Spawn an item? Class type = GetSpawnableType(args[0]); if (type != null) { if (!(level.nomonsters || sv_nomonsters) || !(GetDefaultByType (type).bIsMonster)) { // Only spawn monsters if not -nomonsters Spawn (type, Pos, ALLOW_REPLACE); } } } } // Pottery2 ----------------------------------------------------------------- class Pottery2 : Pottery1 { Default { Height 25; } States { Spawn: POT2 A -1; Stop; } } // Pottery3 ----------------------------------------------------------------- class Pottery3 : Pottery1 { Default { Height 25; } States { Spawn: POT3 A -1; Stop; } } // Pottery Bit -------------------------------------------------------------- class PotteryBit : Actor { State LoopState; Default { Radius 5; Height 5; +MISSILE +NOTELEPORT +NOICEDEATH } States { Spawn: PBIT ABCDE -1; Stop; Death: PBIT F 0 A_PotteryChooseBit; Stop; Pottery1: PBIT F 140; PBIT F 1 A_PotteryCheck; Stop; Pottery2: PBIT G 140; PBIT G 1 A_PotteryCheck; Stop; Pottery3: PBIT H 140; PBIT H 1 A_PotteryCheck; Stop; Pottery4: PBIT I 140; PBIT I 1 A_PotteryCheck; Stop; Pottery5: PBIT J 140; PBIT J 1 A_PotteryCheck; Stop; } //============================================================================ // // A_PotteryChooseBit // //============================================================================ void A_PotteryChooseBit() { static const statelabel bits[] = { "Pottery1", "Pottery2", "Pottery3", "Pottery4", "Pottery5" }; LoopState = FindState(bits[random[PotteryBit](0, 4)]); // Save the state for jumping back to. SetState (LoopState); tics = 256 + (random[PotteryBit]() << 1); } //============================================================================ // // A_PotteryCheck // //============================================================================ void A_PotteryCheck() { for(int i = 0; i < MAXPLAYERS; i++) { if (playeringame[i]) { Actor pmo = players[i].mo; if (CheckSight (pmo) && (absangle(pmo.AngleTo(self), pmo.Angle) <= 45)) { // jump back to previpusly set state. SetState (LoopState); return; } } } } } // Blood pool --------------------------------------------------------------- class BloodPool : Actor { States { Spawn: BDPL A -1; Stop; } } // Lynched corpse (no heart) ------------------------------------------------ class ZCorpseLynchedNoHeart : Actor { Default { Radius 10; Height 100; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: CPS5 A 140 A_CorpseBloodDrip; Loop; } override void PostBeginPlay () { Super.PostBeginPlay (); Spawn ("BloodPool", (pos.xy, floorz), ALLOW_REPLACE); } //============================================================================ // // A_CorpseBloodDrip // //============================================================================ void A_CorpseBloodDrip() { if (random[CorpseDrip]() <= 128) { Spawn ("CorpseBloodDrip", pos + (0, 0, Height / 2), ALLOW_REPLACE); } } } // CorpseBloodDrip ---------------------------------------------------------- class CorpseBloodDrip : Actor { Default { Radius 1; Height 4; Gravity 0.125; +MISSILE +NOICEDEATH DeathSound "Drip"; } States { Spawn: BDRP A -1; Stop; Death: BDSH AB 3; BDSH CD 2; Stop; } } // Corpse bit --------------------------------------------------------------- class CorpseBit : Actor { Default { Radius 5; Height 5; +NOBLOCKMAP +TELESTOMP } States { Spawn: CPB1 A -1; Stop; CPB2 A -1; Stop; CPB3 A -1; Stop; CPB4 A -1; Stop; } } // Corpse (sitting, splatterable) ------------------------------------------- class ZCorpseSitting : Actor { Default { Health 30; Radius 15; Height 35; +SOLID +SHOOTABLE +NOBLOOD +NOICEDEATH DeathSound "FireDemonDeath"; } States { Spawn: CPS6 A -1; Stop; Death: CPS6 A 1 A_CorpseExplode; Stop; } //============================================================================ // // A_CorpseExplode // //============================================================================ void A_CorpseExplode() { Actor mo; for (int i = random[CorpseExplode](3, 6); i; i--) { mo = Spawn ("CorpseBit", Pos, ALLOW_REPLACE); if (mo) { mo.SetState (mo.SpawnState + random[CorpseExplode](0, 2)); mo.Vel.X = random2[CorpseExplode]() / 64.; mo.Vel.Y = random2[CorpseExplode]() / 64.; mo.Vel.Z = random[CorpseExplode](5, 12) * 0.75; } } // Spawn a skull mo = Spawn ("CorpseBit", Pos, ALLOW_REPLACE); if (mo) { mo.SetState (mo.SpawnState + 3); mo.Vel.X = random2[CorpseExplode]() / 64.; mo.Vel.Y = random2[CorpseExplode]() / 64.; mo.Vel.Z = random[CorpseExplode](5, 12) * 0.75; } A_StartSound (DeathSound, CHAN_BODY); Destroy (); } } // Leaf Spawner ------------------------------------------------------------- class LeafSpawner : Actor { Default { +NOBLOCKMAP +NOSECTOR +INVISIBLE } States { Spawn: TNT1 A 20 A_LeafSpawn; Loop; } //============================================================================ // // A_LeafSpawn // //============================================================================ void A_LeafSpawn() { static const class leaves[] = { "Leaf1", "Leaf2" }; for (int i = random[LeafSpawn](1, 4); i; i--) { double xo = random2[LeafSpawn]() / 4.; double yo = random2[LeafSpawn]() / 4.; double zo = random[LeafSpawn]() / 4.; Actor mo = Spawn (leaves[random[LeafSpawn](0, 1)], Vec3Offset(xo, yo, zo), ALLOW_REPLACE); if (mo) { mo.Thrust(random[LeafSpawn]() / 128. + 3, angle); mo.target = self; mo.special1 = 0; } } } } // Leaf 1 ------------------------------------------------------------------- class Leaf1 : Actor { Default { Radius 2; Height 4; Gravity 0.125; +NOBLOCKMAP +MISSILE +NOTELEPORT +DONTSPLASH +NOICEDEATH } States { Spawn: LEF1 ABC 4; LEF1 D 4 A_LeafThrust; LEF1 EFG 4; Looping: LEF1 H 4 A_LeafThrust; LEF1 I 4; LEF1 AB 4; LEF1 C 4 A_LeafThrust; LEF1 DEF 4; LEF1 G 4 A_LeafThrust; LEF1 HI 4; Stop; Death: LEF3 D 10 A_LeafCheck; Wait; } //============================================================================ // // A_LeafThrust // //============================================================================ void A_LeafThrust() { if (random[LeafThrust]() <= 96) { Vel.Z += random[LeafThrust]() / 128. + 1; } } //============================================================================ // // A_LeafCheck // //============================================================================ void A_LeafCheck() { special1++; if (special1 >= 20) { Destroy(); return; } double ang = target ? target.angle : angle; if (random[LeafCheck]() > 64) { if (Vel.X == 0 && Vel.Y == 0) { Thrust(random[LeafCheck]() / 128. + 1, ang); } return; } SetStateLabel ("Looping"); Vel.Z = random[LeafCheck]() / 128. + 1; Thrust(random[LeafCheck]() / 128. + 2, ang); bMissile = true; } } // Leaf 2 ------------------------------------------------------------------- class Leaf2 : Leaf1 { States { Spawn: LEF2 ABC 4; LEF2 D 4 A_LeafThrust; LEF2 EFG 4; LEF2 H 4 A_LeafThrust; LEF2 I 4; LEF2 AB 4; LEF2 C 4 A_LeafThrust; LEF2 DEF 4; LEF2 G 4 A_LeafThrust; LEF2 HI 4; Stop; } } // Twined torch ------------------------------------------------------------- class ZTwinedTorch : SwitchableDecoration { Default { Radius 10; Height 64; +SOLID } States { Active: TWTR A 0 Bright A_StartSound("Ignite"); Spawn: TWTR ABCDEFGH 4 Bright; Loop; Inactive: TWTR I -1; Stop; } } class ZTwinedTorchUnlit : ZTwinedTorch { States { Spawn: Goto Super::Inactive; } } // Wall torch --------------------------------------------------------------- class ZWallTorch : SwitchableDecoration { Default { +NOBLOCKMAP +NOGRAVITY +FIXMAPTHINGPOS Radius 6.5; } States { Active: WLTR A 0 Bright A_StartSound("Ignite"); Spawn: WLTR ABCDEFGH 5 Bright; Loop; Inactive: WLTR I -1; Stop; } } class ZWallTorchUnlit : ZWallTorch { States { Spawn: Goto Super::Inactive; } } // Shrub1 ------------------------------------------------------------------- class ZShrub1 : Actor { Default { Radius 8; Height 24; Health 20; Mass 0x7fffffff; +SOLID +SHOOTABLE +NOBLOOD +NOICEDEATH DeathSound "TreeExplode"; } States { Spawn: SHB1 A -1; Stop; Burn: SHB1 B 7 Bright; SHB1 C 6 Bright A_Scream; SHB1 D 5 Bright; Stop; } } // Shrub2 ------------------------------------------------------------------- class ZShrub2 : Actor { Default { Radius 16; Height 40; Health 20; Mass 0x7fffffff; +SOLID +SHOOTABLE +NOBLOOD +NOICEDEATH DeathSound "TreeExplode"; } States { Spawn: SHB2 A -1; Stop; Burn: SHB2 B 7 Bright; SHB2 C 6 Bright A_Scream; SHB2 D 5 Bright A_Explode(30, 64); SHB2 E 5 Bright; Stop; } } // Fire Bull ---------------------------------------------------------------- class ZFireBull : SwitchableDecoration { Default { Radius 20; Height 80; +SOLID } States { Active: FBUL I 4 Bright A_StartSound("Ignite"); FBUL J 4 Bright; Spawn: FBUL ABCDEFG 4 Bright; Loop; Inactive: FBUL JI 4 Bright; FBUL H -1; Stop; } } class ZFireBullUnlit : ZFireBull { States { Spawn: Goto Super::Inactive+2; } } // Suit of armor ------------------------------------------------------------ class ZSuitOfArmor : Actor { Default { Health 60; Radius 16; Height 72; Mass 0x7fffffff; +SOLID +SHOOTABLE +NOBLOOD +NOICEDEATH DeathSound "SuitofArmorBreak"; } States { Spawn: ZSUI A -1; Stop; Death: ZSUI A 1 A_SoAExplode; Stop; } //=========================================================================== // // A_SoAExplode - Suit of Armor Explode // //=========================================================================== void A_SoAExplode() { for (int i = 0; i < 10; i++) { double xo = (random[SoAExplode]() - 128) / 16.; double yo = (random[SoAExplode]() - 128) / 16.; double zo = random[SoAExplode]() * Height / 256.; Actor mo = Spawn ("ZArmorChunk", Vec3Offset(xo, yo, zo), ALLOW_REPLACE); if (mo) { mo.SetState (mo.SpawnState + i); mo.Vel.X = random2[SoAExplode]() / 64.; mo.Vel.Y = random2[SoAExplode]() / 64.; mo.Vel.Z = random[SoAExplode](5, 12); } } // Spawn an item? Class type = GetSpawnableType(args[0]); if (type != null) { if (!(level.nomonsters || sv_nomonsters) || !(GetDefaultByType (type).bIsMonster)) { // Only spawn monsters if not -nomonsters Spawn (type, Pos, ALLOW_REPLACE); } } A_StartSound (DeathSound, CHAN_BODY); Destroy (); } } // Armor chunk -------------------------------------------------------------- class ZArmorChunk : Actor { Default { Radius 4; Height 8; } States { Spawn: ZSUI B -1; Stop; ZSUI C -1; Stop; ZSUI D -1; Stop; ZSUI E -1; Stop; ZSUI F -1; Stop; ZSUI G -1; Stop; ZSUI H -1; Stop; ZSUI I -1; Stop; ZSUI J -1; Stop; ZSUI K -1; Stop; } } // Bell --------------------------------------------------------------------- class ZBell : Actor { Default { Health 5; Radius 56; Height 120; Mass 0x7fffffff; +SOLID +SHOOTABLE +NOBLOOD +NOGRAVITY +SPAWNCEILING +NOICEDEATH DeathSound "BellRing"; } States { Spawn: BBLL F -1; Stop; Death: BBLL A 4 A_BellReset1; BBLL BC 4; BBLL D 5 A_Scream; BBLL CB 4; BBLL A 3; BBLL E 4; BBLL F 5; BBLL G 6 A_Scream; BBLL F 5; BBLL EA 4; BBLL BC 5; BBLL D 6 A_Scream; BBLL CB 5; BBLL A 4; BBLL EF 5; BBLL G 7 A_Scream; BBLL FEA 5; BBLL B 6; BBLL C 6; BBLL D 7 A_Scream; BBLL CB 6; BBLL A 5; BBLL EF 6; BBLL G 7 A_Scream; BBLL FEABC 6; BBLL B 7; BBLL A 8; BBLL E 12; BBLL A 10; BBLL B 12; BBLL A 12; BBLL E 14; BBLL A 1 A_BellReset2; Goto Spawn; } override void Activate (Actor activator) { if (health > 0) { DamageMobj (activator, activator, 10, 'Melee', DMG_THRUSTLESS); // 'ring' the bell } } //=========================================================================== // // A_BellReset1 // //=========================================================================== void A_BellReset1() { bNoGravity = true; Height = Default.Height; } //=========================================================================== // // A_BellReset2 // //=========================================================================== void A_BellReset2() { bShootable = true; bCorpse = false; bKilled = false; health = 5; } } // "Christmas" Tree --------------------------------------------------------- class ZXmasTree : Actor { Default { Radius 11; Height 130; Health 20; Mass 0x7fffffff; +SOLID +SHOOTABLE +NOBLOOD +NOICEDEATH DeathSound "TreeExplode"; } States { Spawn: XMAS A -1; Stop; Burn: XMAS B 6 Bright; XMAS C 6 Bright A_Scream; XMAS D 5 Bright; XMAS E 5 Bright A_Explode(30, 64); XMAS F 5 Bright; XMAS G 4 Bright; XMAS H 5; XMAS I 4 A_NoBlocking; XMAS J 4; XMAS K -1; Stop; } } // Cauldron ----------------------------------------------------------------- class ZCauldron : SwitchableDecoration { Default { Radius 12; Height 26; +SOLID } States { Active: CDRN B 0 Bright A_StartSound("Ignite"); Spawn: CDRN BCDEFGH 4 Bright; Loop; Inactive: CDRN A -1; Stop; } } class ZCauldronUnlit : ZCauldron { States { Spawn: Goto Super::Inactive; } } // Water Drip --------------------------------------------------------------- class HWaterDrip : Actor { Default { +MISSILE +NOTELEPORT Gravity 0.125; Mass 1; DeathSound "Drip"; } States { Spawn: HWAT A -1; Stop; } } class HexenStatusBar : BaseStatusBar { DynamicValueInterpolator mHealthInterpolator; DynamicValueInterpolator mHealthInterpolator2; HUDFont mHUDFont; HUDFont mIndexFont; HUDFont mBigFont; InventoryBarState diparms; InventoryBarState diparms_sbar; override void Init() { Super.Init(); SetSize(38, 320, 200); // Create the font used for the fullscreen HUD Font fnt = "HUDFONT_RAVEN"; mHUDFont = HUDFont.Create(fnt, fnt.GetCharWidth("0") + 1, Mono_CellLeft, 1, 1); fnt = "INDEXFONT_RAVEN"; mIndexFont = HUDFont.Create(fnt, fnt.GetCharWidth("0"), Mono_CellLeft); fnt = "BIGFONT"; mBigFont = HUDFont.Create(fnt, fnt.GetCharWidth("0"), Mono_CellLeft, 2, 2); diparms = InventoryBarState.Create(mIndexFont); diparms_sbar = InventoryBarState.CreateNoBox(mIndexFont, boxsize:(31, 31), arrowoffs:(0,-10)); mHealthInterpolator = DynamicValueInterpolator.Create(0, 0.25, 1, 8); mHealthInterpolator2 = DynamicValueInterpolator.Create(0, 0.25, 1, 6); // the chain uses a maximum of 6, not 8. } override void NewGame () { Super.NewGame(); mHealthInterpolator.Reset (0); mHealthInterpolator2.Reset (0); } override int GetProtrusion(double scaleratio) const { return scaleratio > 0.85? 28 : 12; // need to get past the gargoyle's wings } override void Tick() { Super.Tick(); mHealthInterpolator.Update(CPlayer.health); mHealthInterpolator2.Update(CPlayer.health); } override void Draw (int state, double TicFrac) { Super.Draw (state, TicFrac); if (state == HUD_StatusBar) { BeginStatusBar(); DrawMainBar (TicFrac); } else if (state == HUD_Fullscreen) { BeginHUD(); DrawFullScreenStuff (); } } protected void DrawFullScreenStuff () { //health DrawImage("PTN1A0", (60, -3)); DrawString(mBigFont, FormatNumber(mHealthInterpolator.GetValue()), (41, -21), DI_TEXT_ALIGN_RIGHT); //armor DrawImage("AR_1A0", (60, -23)); DrawString(mBigFont, FormatNumber(GetArmorSavePercent() / 5, 2), (41, -41), DI_TEXT_ALIGN_RIGHT); //frags/keys if (deathmatch) { DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (70, -16)); } if (!isInventoryBarVisible() && !Level.NoInventoryBar && CPlayer.mo.InvSel != null) { // This code was changed to always fit the item into the box, regardless of alignment or sprite size. // Heretic's ARTIBOX is 30x30 pixels. DrawImage("ARTIBOX", (-66, -1), 0, HX_SHADOW); DrawInventoryIcon(CPlayer.mo.InvSel, (-66, -15), DI_ARTIFLASH|DI_ITEM_CENTER|DI_DIMDEPLETED, boxsize:(28, 28)); if (CPlayer.mo.InvSel.Amount > 1) { DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-52, -2 - mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT); } } Ammo ammo1, ammo2; [ammo1, ammo2] = GetCurrentAmmo(); if ((ammo1 is "Mana1") || (ammo2 is "Mana1")) DrawImage("MANABRT1", (-17, -30), DI_ITEM_OFFSETS); else DrawImage("MANADIM1", (-17, -30), DI_ITEM_OFFSETS); if ((ammo1 is "Mana2") || (ammo2 is "Mana2")) DrawImage("MANABRT2", (-17, -15), DI_ITEM_OFFSETS); else DrawImage("MANADIM2", (-17, -15), DI_ITEM_OFFSETS); DrawString(mHUDFont, FormatNumber(GetAmount("Mana1"), 3), (-21, -30), DI_TEXT_ALIGN_RIGHT); DrawString(mHUDFont, FormatNumber(GetAmount("Mana2"), 3), (-21, -15), DI_TEXT_ALIGN_RIGHT); if (isInventoryBarVisible()) { DrawInventoryBar(diparms, (0, 0), 7, DI_SCREEN_CENTER_BOTTOM, HX_SHADOW); } } protected void DrawMainBar (double TicFrac) { DrawImage("H2BAR", (0, 134), DI_ITEM_OFFSETS); String Gem, Chain; if (CPlayer.mo is "ClericPlayer") { Gem = "LIFEGMC2"; Chain = "CHAIN2"; } else if (CPlayer.mo is "MagePlayer") { Gem = "LIFEGMM2"; Chain = "CHAIN3"; } else { Gem = "LIFEGMF2"; Chain = "CHAIN"; } int inthealth = mHealthInterpolator2.GetValue(); DrawGem(Chain, Gem, inthealth, CPlayer.mo.GetMaxHealth(true), (30, 193), -23, 49, 15, (multiplayer? DI_TRANSLATABLE : 0) | DI_ITEM_LEFT_TOP); DrawImage("LFEDGE", (0, 193), DI_ITEM_OFFSETS); DrawImage("RTEDGE", (277, 193), DI_ITEM_OFFSETS); if (!automapactive) { if (isInventoryBarVisible()) { DrawImage("INVBAR", (38, 162), DI_ITEM_OFFSETS); DrawInventoryBar(diparms_sbar, (52, 163), 7, DI_ITEM_LEFT_TOP, HX_SHADOW); } else { DrawImage("STATBAR", (38, 162), DI_ITEM_OFFSETS); //inventory box if (CPlayer.mo.InvSel != null) { DrawInventoryIcon(CPlayer.mo.InvSel, (159.5, 177), DI_ARTIFLASH|DI_ITEM_CENTER|DI_DIMDEPLETED, boxsize:(28, 28)); if (CPlayer.mo.InvSel.Amount > 1) { DrawString(mIndexFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (174, 184), DI_TEXT_ALIGN_RIGHT); } } if (deathmatch || teamplay) { DrawImage("KILLS", (38, 163), DI_ITEM_OFFSETS); DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (66, 176), DI_TEXT_ALIGN_RIGHT); } else { DrawImage("ARMCLS", (41, 178), DI_ITEM_OFFSETS); // Note that this has been changed to use red only if the REAL health is below 25, not when an interpolated value is below 25! DrawString(mHUDFont, FormatNumber(mHealthInterpolator.GetValue(), 3), (66, 176), DI_TEXT_ALIGN_RIGHT, CPlayer.Health < 25? Font.CR_RED : Font.CR_UNTRANSLATED); } //armor DrawImage("ARMCLS", (255, 178), DI_ITEM_OFFSETS); DrawString(mHUDFont, FormatNumber(GetArmorSavePercent() / 5, 2), (276, 176), DI_TEXT_ALIGN_RIGHT); Ammo ammo1, ammo2; [ammo1, ammo2] = GetCurrentAmmo(); if (ammo1 != null && !(ammo1 is "Mana1") && !(ammo1 is "Mana2")) { DrawImage("HAMOBACK", (77, 164), DI_ITEM_OFFSETS); if (ammo2 != null) { DrawTexture(ammo1.icon, (89, 172), DI_ITEM_CENTER); DrawTexture(ammo2.icon, (113, 172), DI_ITEM_CENTER); DrawString(mIndexFont, FormatNumber(ammo1.amount, 3), ( 98, 182), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(ammo2.amount, 3), (122, 182), DI_TEXT_ALIGN_RIGHT); } else { DrawTexture(ammo1.icon, (100, 172), DI_ITEM_CENTER); DrawString(mIndexFont, FormatNumber(ammo1.amount, 3), (109, 182), DI_TEXT_ALIGN_RIGHT); } } else { int amt1, maxamt1, amt2, maxamt2; [amt1, maxamt1] = GetAmount("Mana1"); [amt2, maxamt2] = GetAmount("Mana2"); if ((ammo1 is "Mana1") || (ammo2 is "Mana1")) { DrawImage("MANABRT1", (77, 164), DI_ITEM_OFFSETS); DrawBar("MANAVL1", "", amt1, maxamt1, (94, 164), 1, SHADER_VERT, DI_ITEM_OFFSETS); } else { DrawImage("MANADIM1", (77, 164), DI_ITEM_OFFSETS); DrawBar("MANAVL1D", "", amt1, maxamt1, (94, 164), 1, SHADER_VERT, DI_ITEM_OFFSETS); } if ((ammo1 is "Mana2") || (ammo2 is "Mana2")) { DrawImage("MANABRT2", (110, 164), DI_ITEM_OFFSETS); DrawBar("MANAVL2", "", amt2, maxamt2, (102, 164), 1, SHADER_VERT, DI_ITEM_OFFSETS); } else { DrawImage("MANADIM2", (110, 164), DI_ITEM_OFFSETS); DrawBar("MANAVL2D", "", amt2, maxamt2, (102, 164), 1, SHADER_VERT, DI_ITEM_OFFSETS); } DrawString(mIndexFont, FormatNumber(amt1, 3), ( 92, 181), DI_TEXT_ALIGN_RIGHT); DrawString(mIndexFont, FormatNumber(amt2, 3), (124, 181), DI_TEXT_ALIGN_RIGHT); } if (CPlayer.mo is "ClericPlayer") { DrawImage("WPSLOT1", (190, 162), DI_ITEM_OFFSETS); if (CheckInventory("CWeapWraithverge")) DrawImage("WPFULL1", (190, 162), DI_ITEM_OFFSETS); else { int pieces = GetWeaponPieceMask("CWeapWraithverge"); if (pieces & 1) DrawImage("WPIECEC1", (190, 162), DI_ITEM_OFFSETS); if (pieces & 2) DrawImage("WPIECEC2", (212, 162), DI_ITEM_OFFSETS); if (pieces & 4) DrawImage("WPIECEC3", (225, 162), DI_ITEM_OFFSETS); } } else if (CPlayer.mo is "MagePlayer") { DrawImage("WPSLOT2", (190, 162), DI_ITEM_OFFSETS); if (CheckInventory("MWeapBloodscourge")) DrawImage("WPFULL2", (190, 162), DI_ITEM_OFFSETS); else { int pieces = GetWeaponPieceMask("MWeapBloodscourge"); if (pieces & 1) DrawImage("WPIECEM1", (190, 162), DI_ITEM_OFFSETS); if (pieces & 2) DrawImage("WPIECEM2", (205, 162), DI_ITEM_OFFSETS); if (pieces & 4) DrawImage("WPIECEM3", (224, 162), DI_ITEM_OFFSETS); } } else { DrawImage("WPSLOT0", (190, 162), DI_ITEM_OFFSETS); if (CheckInventory("FWeapQuietus")) DrawImage("WPFULL0", (190, 162), DI_ITEM_OFFSETS); else { int pieces = GetWeaponPieceMask("FWeapQuietus"); if (pieces & 1) DrawImage("WPIECEF1", (190, 162), DI_ITEM_OFFSETS); if (pieces & 2) DrawImage("WPIECEF2", (225, 162), DI_ITEM_OFFSETS); if (pieces & 4) DrawImage("WPIECEF3", (234, 162), DI_ITEM_OFFSETS); } } } } else // automap { DrawImage("KEYBAR", (38, 162), DI_ITEM_OFFSETS); int cnt = 0; Vector2 keypos = (46, 164); for(let i = CPlayer.mo.Inv; i != null; i = i.Inv) { if (i is "Key" && i.Icon.IsValid()) { DrawTexture(i.Icon, keypos, DI_ITEM_OFFSETS); keypos.X += 20; if (++cnt >= 5) break; } } DrawHexenArmor(HEXENARMOR_ARMOR, "ARMSLOT1", (150, 164), DI_ITEM_OFFSETS); DrawHexenArmor(HEXENARMOR_SHIELD, "ARMSLOT2", (181, 164), DI_ITEM_OFFSETS); DrawHexenArmor(HEXENARMOR_HELM, "ARMSLOT3", (212, 164), DI_ITEM_OFFSETS); DrawHexenArmor(HEXENARMOR_AMULET, "ARMSLOT4", (243, 164), DI_ITEM_OFFSETS); } } } //========================================================================== // // Ice chunk // //========================================================================== class IceChunk : Actor { Default { Radius 3; Height 4; Mass 5; Gravity 0.125; +DROPOFF +CANNOTPUSH +FLOORCLIP +NOTELEPORT +NOBLOCKMAP +MOVEWITHSECTOR } void A_IceSetTics () { tics = random[IceTics](70, 133); Name dtype = GetFloorTerrain().DamageMOD; if (dtype == 'Fire') { tics >>= 2; } else if (dtype == 'Ice') { tics <<= 1; } } States { Spawn: ICEC ABCD 10 A_IceSetTics; Stop; } } //========================================================================== // // A chunk of ice that is also a player // //========================================================================== class IceChunkHead : PlayerChunk { Default { Radius 3; Height 4; Mass 5; Gravity 0.125; DamageType "Ice"; +DROPOFF +CANNOTPUSH } States { Spawn: ICEC A 0; ICEC A 10 A_CheckPlayerDone; wait; } } extend class Actor { //============================================================================ // // A_FreezeDeath // //============================================================================ void A_FreezeDeath() { int t = random[freezedeath](); tics = 75+t+random[freezedeath](); bSolid = bShootable = bNoBlood = bIceCorpse = bPushable = bTelestomp = bCanPass = bSlidesOnWalls = bCrashed = true; Height = Default.Height; A_SetRenderStyle(1, STYLE_Normal); A_StartSound ("misc/freeze", CHAN_BODY); // [RH] Andy Baker's stealth monsters if (bStealth) { Alpha = 1; visdir = 0; } if (player) { player.damagecount = 0; player.poisoncount = 0; player.bonuscount = 0; } else if (bIsMonster && special) { // Initiate monster death actions A_CallSpecial(special, args[0], args[1], args[2], args[3], args[4]); special = 0; } } //============================================================================ // // A_FreezeDeathChunks // //============================================================================ void A_FreezeDeathChunks() { if (Vel != (0,0,0) && !bShattering) { tics = 3*TICRATE; return; } Vel = (0,0,0); A_StartSound ("misc/icebreak", CHAN_BODY); // [RH] In Hexen, this creates a random number of shards (range [24,56]) // with no relation to the size of the self shattering. I think it should // base the number of shards on the size of the dead thing, so bigger // things break up into more shards than smaller things. // An actor with radius 20 and height 64 creates ~40 chunks. int numChunks = max(4, int(radius * Height)/32); int i = Random[FreezeDeathChunks](0, numChunks/4 - 1); for (i = max(24, numChunks + i); i >= 0; i--) { double xo = (random[FreezeDeathChunks]() - 128)*radius / 128; double yo = (random[FreezeDeathChunks]() - 128)*radius / 128; double zo = (random[FreezeDeathChunks]() * Height / 255); Actor mo = Spawn("IceChunk", Vec3Offset(xo, yo, zo), ALLOW_REPLACE); if (mo) { mo.SetState (mo.SpawnState + random[FreezeDeathChunks](0, 2)); mo.Vel.X = random2[FreezeDeathChunks]() / 128.; mo.Vel.Y = random2[FreezeDeathChunks]() / 128.; mo.Vel.Z = (mo.pos.Z - pos.Z) / Height * 4; } } if (player) { // attach the player's view to a chunk of ice Actor head = Spawn("IceChunkHead", pos + (0, 0, player.mo.ViewHeight), ALLOW_REPLACE); if (head != null) { head.Vel.X = random2[FreezeDeathChunks]() / 128.; head.Vel.Y = random2[FreezeDeathChunks]() / 128.; head.Vel.Z = (head.pos.Z - pos.Z) / Height * 4; head.health = health; head.Angle = Angle; if (head is "PlayerPawn") { head.player = player; head.player.mo = PlayerPawn(head); player = null; head.ObtainInventory (self); } head.Pitch = 0.; if (head.player.camera == self) { head.player.camera = head; } } } // [RH] Do some stuff to make this more useful outside Hexen if (bBossDeath) { A_BossDeath(); } A_NoBlocking(); SetStateLabel('null'); } void A_GenericFreezeDeath() { A_SetTranslation('Ice'); A_FreezeDeath(); } } // Ice Guy ------------------------------------------------------------------ class IceGuy : Actor { Default { Health 120; PainChance 144; Speed 14; Radius 22; Height 75; Mass 150; DamageType "Ice"; Monster; +NOBLOOD +TELESTOMP +NOICEDEATH SeeSound "IceGuySight"; AttackSound "IceGuyAttack"; ActiveSound "IceGuyActive"; Obituary "$OB_ICEGUY"; Tag "$FN_ICEGUY"; } States { Spawn: ICEY A 10 A_IceGuyLook; Loop; See: ICEY A 4 A_Chase; ICEY B 4 A_IceGuyChase; ICEY CD 4 A_Chase; Loop; Pain: ICEY A 1 A_Pain; Goto See; Missile: ICEY EF 3 A_FaceTarget; ICEY G 8 Bright A_IceGuyAttack; ICEY F 4 A_FaceTarget; Goto See; Death: ICEY A 1 A_IceGuyDie; Stop; Inactive: ICEY A -1; Goto See; } //============================================================================ // // SpawnWisp // //============================================================================ private void SpawnWisp() { static const class WispTypes[] = { "IceGuyWisp1", "IceGuyWisp2" }; double dist = (random[IceGuyLook]() - 128) * radius / 128.; double an = angle + 90; Actor mo = Spawn(WispTypes[random[IceGuyLook](0, 1)], Vec3Angle(dist, an, 60.), ALLOW_REPLACE); if (mo) { mo.Vel = Vel; mo.target = self; } } //============================================================================ // // A_IceGuyLook // //============================================================================ void A_IceGuyLook() { A_Look(); if (random[IceGuyLook]() < 64) SpawnWisp(); } //============================================================================ // // A_IceGuyChase // //============================================================================ void A_IceGuyChase() { A_Chase(); if (random[IceGuyLook]() < 128) SpawnWisp(); } //============================================================================ // // A_IceGuyAttack // //============================================================================ void A_IceGuyAttack() { if(!target) { return; } SpawnMissileXYZ(Vec3Angle(radius / 2, angle + 90, 40.), target, "IceGuyFX"); SpawnMissileXYZ(Vec3Angle(radius / 2, angle - 90, 40.), target, "IceGuyFX"); A_StartSound (AttackSound, CHAN_WEAPON); } } extend class Actor { //============================================================================ // // A_IceGuyDie (globally accessible) // //============================================================================ void A_IceGuyDie() { Vel = (0,0,0); Height = Default.Height; A_FreezeDeathChunks(); } } // Ice Guy Projectile ------------------------------------------------------- class IceGuyFX : Actor { Default { Speed 14; Radius 8; Height 10; Damage 1; DamageType "Ice"; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS DeathSound "IceGuyMissileExplode"; } States { Spawn: ICPR ABC 3 Bright A_SpawnItemEx("IceFXPuff", 0,0,2); Loop; Death: ICPR D 4 Bright; ICPR E 4 Bright A_IceGuyMissileExplode; ICPR FG 4 Bright; ICPR H 3 Bright; Stop; } //============================================================================ // // A_IceGuyMissileExplode // //============================================================================ void A_IceGuyMissileExplode() { for (int i = 0; i < 8; i++) { SpawnMissileAngleZ (pos.z+3, "IceGuyFX2", i*45., -0.3, target); } } } // Ice Guy Projectile's Puff ------------------------------------------------ class IceFXPuff : Actor { Default { Radius 1; Height 1; +NOBLOCKMAP +NOGRAVITY +DROPOFF +SHADOW +NOTELEPORT RenderStyle "Translucent"; Alpha 0.4; } States { Spawn: ICPR IJK 3; ICPR LM 2; Stop; } } // Secondary Ice Guy Projectile (ejected by the primary projectile) --------- class IceGuyFX2 : Actor { Default { Speed 10; Radius 4; Height 4; Damage 1; DamageType "Ice"; Gravity 0.125; +NOBLOCKMAP +DROPOFF +MISSILE +NOTELEPORT +STRIFEDAMAGE } States { Spawn: ICPR NOP 3 Bright; Loop; } } // Ice Guy Bit -------------------------------------------------------------- class IceGuyBit : Actor { Default { Radius 1; Height 1; Gravity 0.125; +NOBLOCKMAP +DROPOFF +NOTELEPORT } States { Spawn: ICPR Q 50 Bright; Stop; ICPR R 50 Bright; Stop; } } // Ice Guy Wisp 1 ----------------------------------------------------------- class IceGuyWisp1 : Actor { Default { +NOBLOCKMAP +NOGRAVITY +DROPOFF +MISSILE +NOTELEPORT RenderStyle "Translucent"; Alpha 0.4; } States { Spawn: ICWS ABCDEFGHI 2; Stop; } } // Ice Guy Wisp 2 ----------------------------------------------------------- class IceGuyWisp2 : IceGuyWisp1 { States { Spawn: ICWS JKLMNOPQR 2; Stop; } } /* ** imagescroller.cpp ** Scrolls through multiple fullscreen image pages, ** **--------------------------------------------------------------------------- ** Copyright 2019-220 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ class ImageScrollerDescriptor : MenuDescriptor native { native Array mItems; native Font textFont; native TextureID textBackground; native Color textBackgroundBrightness; native double textScale; native bool mAnimatedTransition; native bool mAnimated; native bool mDontBlur; native bool mDontDim; native int virtWidth, virtHeight; } class ImageScrollerPage : MenuItemBase { int virtWidth, virtHeight; protected void DrawText(Font fnt, int color, double x, double y, String text) { screen.DrawText(fnt, color, x, y, text, DTA_VirtualWidth, virtWidth, DTA_VirtualHeight, virtHeight, DTA_FullscreenScale, FSMode_ScaleToFit43); } protected void DrawTexture(TextureID tex, double x, double y) { screen.DrawTexture(tex, true, x, y, DTA_VirtualWidth, virtWidth, DTA_VirtualHeight, virtHeight, DTA_FullscreenScale, FSMode_ScaleToFit43); } virtual void OnStartPage() {} virtual void OnEndPage() {} } //============================================================================= // // an image page // //============================================================================= class ImageScrollerPageImageItem : ImageScrollerPage { TextureID mTexture; void Init(ImageScrollerDescriptor desc, String patch) { Super.Init(); mTexture = TexMan.CheckForTexture(patch); } override void Drawer(bool selected) { Screen.DrawTexture(mTexture, true, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal); } } //============================================================================= // // a simple text page // //============================================================================= class ImageScrollerPageTextItem : ImageScrollerPage { Font mFont; BrokenLines mText; TextureID mTexture; Color mBrightness; double mTextScale; void Init(ImageScrollerDescriptor desc, String txt, int y = -1) { Super.Init(); mTexture = desc.textBackground; mBrightness = desc.textBackgroundBrightness; mFont = desc.textFont; mTextScale = desc.textScale; virtWidth = desc.virtWidth; virtHeight = desc.virtHeight; mText = mFont.BreakLines(Stringtable.Localize(txt.Filter()), int(virtWidth / mTextScale)); mYpos = y >= 0? y : virtHeight / 2 - mText.Count() * mFont.GetHeight() * mTextScale / 2; } override void Drawer(bool selected) { Screen.DrawTexture(mTexture, true, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, DTA_Color, mBrightness); let fontheight = mFont.GetHeight() * mTextScale; let y = mYpos; let c = mText.Count(); for (int i = 0; i < c; i++) { screen.DrawText (mFont, Font.CR_UNTRANSLATED, virtWidth/2 - mText.StringWidth(i) * mTextScale / 2, y, mText.StringAt(i), DTA_ScaleX, mTextScale, DTA_ScaleY, mTextScale, DTA_VirtualWidth, virtWidth, DTA_VirtualHeight, virtHeight, DTA_FullscreenScale, FSMode_ScaleToFit43); y += fontheight; } } } //============================================================================= // // The main class // //============================================================================= class ImageScrollerMenu : Menu { ImageScrollerPage previous; ImageScrollerPage current; double start; int length; int dir; int index; ImageScrollerDescriptor mDesc; private void StartTransition(ImageScrollerPage to, int animtype) { if (AnimatedTransition) { start = MSTimeF() * (120. / 1000.); length = 30; dir = animtype; previous = current; } to.onStartPage(); current = to; } virtual void Init(Menu parent, ImageScrollerDescriptor desc) { mParentMenu = parent; index = 0; mDesc = desc; AnimatedTransition = mDesc.mAnimatedTransition; Animated = mDesc.mAnimated; DontBlur = mDesc.mDontBlur; DontDim = mDesc.mDontDim; current = mDesc.mItems[0]; current.onStartPage(); previous = null; } //============================================================================= // // // //============================================================================= override bool MenuEvent(int mkey, bool fromcontroller) { if (mDesc.mItems.Size() <= 1) { if (mkey == MKEY_Enter) mkey = MKEY_Back; else if (mkey == MKEY_Right || mkey == MKEY_Left) return true; } switch (mkey) { case MKEY_Back: // Before going back the currently running transition must be terminated. previous = null; return Super.MenuEvent(mkey, fromcontroller); case MKEY_Left: if (previous == null) { if (--index < 0) index = mDesc.mItems.Size() - 1; let next = mDesc.mItems[index]; StartTransition(next, -1); MenuSound("menu/choose"); } return true; case MKEY_Right: case MKEY_Enter: if (previous == null) { int oldindex = index; if (++index >= mDesc.mItems.Size()) index = 0; let next = mDesc.mItems[index]; StartTransition(next, 1); MenuSound("menu/choose"); } return true; default: return Super.MenuEvent(mkey, fromcontroller); } } //============================================================================= // // // //============================================================================= override bool MouseEvent(int type, int x, int y) { // Todo: Implement some form of drag event to switch between pages. if (type == MOUSE_Release) { return MenuEvent(MKEY_Enter, false); } return Super.MouseEvent(type, x, y); } //============================================================================= // // // //============================================================================= private bool DrawTransition() { double now = MSTimeF() * (120. / 1000.); if (now < start + length) { double factor = screen.GetWidth()/2; double phase = (now - start) / length * 180. + 90.; screen.SetOffset(factor * dir * (sin(phase) - 1.), 0); previous.Drawer(false); screen.SetOffset(factor * dir * (sin(phase) + 1.), 0); current.Drawer(false); screen.SetOffset(0, 0); return true; } previous.OnEndPage(); previous = null; return false; } //============================================================================= // // // //============================================================================= override void Drawer() { if (previous != null) { bool wasAnimated = Animated; Animated = true; if (DrawTransition()) return; previous = null; Animated = wasAnimated; } current.Drawer(false); } } struct UiEvent native ui version("2.4") { // d_gui.h enum EGUIEvent { Type_None, Type_KeyDown, Type_KeyRepeat, Type_KeyUp, Type_Char, Type_FirstMouseEvent, // ? Type_MouseMove, Type_LButtonDown, Type_LButtonUp, Type_LButtonClick, Type_MButtonDown, Type_MButtonUp, Type_MButtonClick, Type_RButtonDown, Type_RButtonUp, Type_RButtonClick, Type_WheelUp, Type_WheelDown, Type_WheelRight, // ??? Type_WheelLeft, // ??? Type_BackButtonDown, // ??? Type_BackButtonUp, // ??? Type_FwdButtonDown, // ??? Type_FwdButtonUp, // ??? Type_LastMouseEvent } // for KeyDown, KeyRepeat, KeyUp enum ESpecialGUIKeys { Key_PgDn = 1, Key_PgUp = 2, Key_Home = 3, Key_End = 4, Key_Left = 5, Key_Right = 6, Key_Alert = 7, // ASCII bell Key_Backspace = 8, // ASCII Key_Tab = 9, // ASCII Key_LineFeed = 10, // ASCII Key_Down = 10, Key_VTab = 11, // ASCII Key_Up = 11, Key_FormFeed = 12, // ASCII Key_Return = 13, // ASCII Key_F1 = 14, Key_F2 = 15, Key_F3 = 16, Key_F4 = 17, Key_F5 = 18, Key_F6 = 19, Key_F7 = 20, Key_F8 = 21, Key_F9 = 22, Key_F10 = 23, Key_F11 = 24, Key_F12 = 25, Key_Del = 26, Key_Escape = 27, // ASCII Key_Free1 = 28, Key_Free2 = 29, Key_Back = 30, // browser back key Key_CEscape = 31 // color escape } // native readonly EGUIEvent Type; // native readonly String KeyString; native readonly int KeyChar; // native readonly int MouseX; native readonly int MouseY; // native readonly bool IsShift; native readonly bool IsCtrl; native readonly bool IsAlt; } struct InputEvent native play version("2.4") { enum EGenericEvent { Type_None, Type_KeyDown, Type_KeyUp, Type_Mouse, Type_GUI, // unused, kept for completeness Type_DeviceChange } // ew. enum EDoomInputKeys { Key_Pause = 0xc5, // DIK_PAUSE Key_RightArrow = 0xcd, // DIK_RIGHT Key_LeftArrow = 0xcb, // DIK_LEFT Key_UpArrow = 0xc8, // DIK_UP Key_DownArrow = 0xd0, // DIK_DOWN Key_Escape = 0x01, // DIK_ESCAPE Key_Enter = 0x1c, // DIK_RETURN Key_Space = 0x39, // DIK_SPACE Key_Tab = 0x0f, // DIK_TAB Key_F1 = 0x3b, // DIK_F1 Key_F2 = 0x3c, // DIK_F2 Key_F3 = 0x3d, // DIK_F3 Key_F4 = 0x3e, // DIK_F4 Key_F5 = 0x3f, // DIK_F5 Key_F6 = 0x40, // DIK_F6 Key_F7 = 0x41, // DIK_F7 Key_F8 = 0x42, // DIK_F8 Key_F9 = 0x43, // DIK_F9 Key_F10 = 0x44, // DIK_F10 Key_F11 = 0x57, // DIK_F11 Key_F12 = 0x58, // DIK_F12 Key_Grave = 0x29, // DIK_GRAVE KEY_kpad_1 = 0x4f, KEY_kpad_2 = 0x50, KEY_kpad_3 = 0x51, KEY_kpad_4 = 0x4b, KEY_kpad_5 = 0x4c, KEY_kpad_6 = 0x4d, KEY_kpad_7 = 0x47, KEY_kpad_8 = 0x48, KEY_kpad_9 = 0x49, KEY_kpad_0 = 0x52, KEY_kpad_Minus = 0x4a, KEY_kpad_Plus = 0x4e, KEY_kpad_Period = 0x53, Key_Backspace = 0x0e, // DIK_BACK Key_Equals = 0x0d, // DIK_EQUALS Key_Minus = 0x0c, // DIK_MINUS Key_LShift = 0x2A, // DIK_LSHIFT Key_LCtrl = 0x1d, // DIK_LCONTROL Key_LAlt = 0x38, // DIK_LMENU Key_RShift = Key_LSHIFT, Key_RCtrl = Key_LCTRL, Key_RAlt = Key_LALT, Key_Ins = 0xd2, // DIK_INSERT Key_Del = 0xd3, // DIK_DELETE Key_End = 0xcf, // DIK_END Key_Home = 0xc7, // DIK_HOME Key_PgUp = 0xc9, // DIK_PRIOR Key_PgDn = 0xd1, // DIK_NEXT KEY_VOLUMEDOWN = 0xAE, // DIK_VOLUMEDOWN KEY_VOLUMEUP = 0xB0, // DIK_VOLUMEUP Key_Mouse1 = 0x100, Key_Mouse2 = 0x101, Key_Mouse3 = 0x102, Key_Mouse4 = 0x103, Key_Mouse5 = 0x104, Key_Mouse6 = 0x105, Key_Mouse7 = 0x106, Key_Mouse8 = 0x107, Key_FirstJoyButton = 0x108, Key_Joy1 = (Key_FirstJoyButton+0), Key_Joy2 = (Key_FirstJoyButton+1), Key_Joy3 = (Key_FirstJoyButton+2), Key_Joy4 = (Key_FirstJoyButton+3), Key_Joy5 = (Key_FirstJoyButton+4), Key_Joy6 = (Key_FirstJoyButton+5), Key_Joy7 = (Key_FirstJoyButton+6), Key_Joy8 = (Key_FirstJoyButton+7), Key_LastJoyButton = 0x187, Key_JoyPOV1_Up = 0x188, Key_JoyPOV1_Right = 0x189, Key_JoyPOV1_Down = 0x18a, Key_JoyPOV1_Left = 0x18b, Key_JoyPOV2_Up = 0x18c, Key_JoyPOV3_Up = 0x190, Key_JoyPOV4_Up = 0x194, Key_MWheelUp = 0x198, Key_MWheelDown = 0x199, Key_MWheelRight = 0x19A, Key_MWheelLeft = 0x19B, Key_JoyAxis1Plus = 0x19C, Key_JoyAxis1Minus = 0x19D, Key_JoyAxis2Plus = 0x19E, Key_JoyAxis2Minus = 0x19F, Key_JoyAxis3Plus = 0x1A0, Key_JoyAxis3Minus = 0x1A1, Key_JoyAxis4Plus = 0x1A2, Key_JoyAxis4Minus = 0x1A3, Key_JoyAxis5Plus = 0x1A4, Key_JoyAxis5Minus = 0x1A5, Key_JoyAxis6Plus = 0x1A6, Key_JoyAxis6Minus = 0x1A7, Key_JoyAxis7Plus = 0x1A8, Key_JoyAxis7Minus = 0x1A9, Key_JoyAxis8Plus = 0x1AA, Key_JoyAxis8Minus = 0x1AB, Num_JoyAxisButtons = 8, Key_Pad_LThumb_Right = 0x1AC, Key_Pad_LThumb_Left = 0x1AD, Key_Pad_LThumb_Down = 0x1AE, Key_Pad_LThumb_Up = 0x1AF, Key_Pad_RThumb_Right = 0x1B0, Key_Pad_RThumb_Left = 0x1B1, Key_Pad_RThumb_Down = 0x1B2, Key_Pad_RThumb_Up = 0x1B3, Key_Pad_DPad_Up = 0x1B4, Key_Pad_DPad_Down = 0x1B5, Key_Pad_DPad_Left = 0x1B6, Key_Pad_DPad_Right = 0x1B7, Key_Pad_Start = 0x1B8, Key_Pad_Back = 0x1B9, Key_Pad_LThumb = 0x1BA, Key_Pad_RThumb = 0x1BB, Key_Pad_LShoulder = 0x1BC, Key_Pad_RShoulder = 0x1BD, Key_Pad_LTrigger = 0x1BE, Key_Pad_RTrigger = 0x1BF, Key_Pad_A = 0x1C0, Key_Pad_B = 0x1C1, Key_Pad_X = 0x1C2, Key_Pad_Y = 0x1C3, Num_Keys = 0x1C4 } // native readonly EGenericEvent Type; // native readonly int KeyScan; // as in EDoomInputKeys enum native readonly String KeyString; native readonly int KeyChar; // ASCII char (if any) // native readonly int MouseX; native readonly int MouseY; } // Inquisitor --------------------------------------------------------------- class Inquisitor : Actor { Default { Health 1000; Speed 12; Radius 40; Height 110; Mass 0x7fffffff; Monster; +DROPOFF +NOBLOOD +BOSS +FLOORCLIP +DONTMORPH +NORADIUSDMG MaxDropOffHeight 32; MinMissileChance 150; Tag "$TAG_INQUISITOR"; SeeSound "inquisitor/sight"; DeathSound "inquisitor/death"; ActiveSound "inquisitor/active"; Obituary "$OB_INQUISITOR"; } States { Spawn: ROB3 AB 10 A_Look; Loop; See: ROB3 B 3 A_InquisitorWalk; ROB3 B 3 A_Chase; ROB3 CCDD 4 A_Chase; ROB3 E 3 A_InquisitorWalk; ROB3 E 3 A_InquisitorDecide; Loop; Missile: ROB3 A 2 A_InquisitorDecide; ROB3 F 6 A_FaceTarget; ROB3 G 8 Bright A_ReaverRanged; ROB3 G 8 A_ReaverRanged; Goto See; Grenade: ROB3 K 12 A_FaceTarget; ROB3 J 6 Bright A_InquisitorAttack; ROB3 K 12; Goto See; Jump: ROB3 H 8 Bright A_InquisitorJump; ROB3 I 4 Bright A_InquisitorCheckLand; ROB3 H 4 Bright A_InquisitorCheckLand; Goto Jump+1; Death: ROB3 L 0 A_StopSound(CHAN_ITEM); ROB3 L 4 A_TossGib; ROB3 M 4 A_Scream; ROB3 N 4 A_TossGib; ROB3 O 4 Bright A_Explode(128, 128, alert:true); ROB3 P 4 Bright A_TossGib; ROB3 Q 4 Bright A_NoBlocking; ROB3 RSTUV 4 A_TossGib; ROB3 W 4 Bright A_Explode(128, 128, alert:true); ROB3 XY 4 Bright A_TossGib; ROB3 Z 4 A_TossGib; ROB3 [ 4 A_TossGib; ROB3 \ 3 A_TossGib; ROB3 ] 3 Bright A_Explode(128, 128, alert:true); RBB3 A 3 Bright A_TossArm; RBB3 B 3 Bright A_TossGib; RBB3 CD 3 A_TossGib; RBB3 E -1; Stop; } // Inquisitor --------------------------------------------------------------- void A_InquisitorWalk () { A_StartSound ("inquisitor/walk", CHAN_BODY); A_Chase (); } private bool InquisitorCheckDistance () { if (reactiontime == 0 && CheckSight (target)) { return Distance2D (target) < 264.; } return false; } void A_InquisitorDecide () { if (target == null) return; A_FaceTarget (); if (!InquisitorCheckDistance ()) { SetStateLabel("Grenade"); } if (target.pos.z != pos.z) { if (pos.z + height + 54 < ceilingz) { SetStateLabel("Jump"); } } } void A_InquisitorAttack () { if (target == null) return; A_FaceTarget (); AddZ(32); angle -= 45./32; Actor proj = SpawnMissileZAimed (pos.z, target, "InquisitorShot"); if (proj != null) { proj.Vel.Z += 9; } angle += 45./16; proj = SpawnMissileZAimed (pos.z, target, "InquisitorShot"); if (proj != null) { proj.Vel.Z += 16; } AddZ(-32); } void A_InquisitorJump () { if (target == null) return; A_StartSound ("inquisitor/jump", CHAN_ITEM, CHANF_LOOPING); AddZ(64); A_FaceTarget (); let localspeed = Speed * (2./3); VelFromAngle(localspeed); double dist = DistanceBySpeed(target, localspeed); Vel.Z = (target.pos.z - pos.z) / dist; reactiontime = 60; bNoGravity = true; } void A_InquisitorCheckLand () { reactiontime--; if (reactiontime < 0 || Vel.X == 0 || Vel.Y == 0 || pos.z <= floorz) { SetState (SeeState); reactiontime = 0; bNoGravity = false; A_StopSound (CHAN_ITEM); return; } A_StartSound ("inquisitor/jump", CHAN_ITEM, CHANF_LOOPING); } void A_TossArm () { Actor foo = Spawn("InquisitorArm", Pos + (0,0,24), ALLOW_REPLACE); if (foo != null) { foo.angle = angle - 90. + Random2[Inquisitor]() * (360./1024.); foo.VelFromAngle(foo.Speed / 8); foo.Vel.Z = random[Inquisitor]() / 64.; } } } // Inquisitor Shot ---------------------------------------------------------- class InquisitorShot : Actor { Default { ReactionTime 15; Speed 25; Radius 13; Height 13; Mass 15; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS -NOGRAVITY +STRIFEDAMAGE MaxStepHeight 4; SeeSound "inquisitor/attack"; DeathSound "inquisitor/atkexplode"; } States { Spawn: UBAM AB 3 A_Countdown; Loop; Death: BNG2 A 0 Bright A_SetRenderStyle(1, STYLE_Normal); BNG2 A 4 Bright A_Explode(192, 192, alert:true); BNG2 B 4 Bright; BNG2 C 4 Bright; BNG2 D 4 Bright; BNG2 E 4 Bright; BNG2 F 4 Bright; BNG2 G 4 Bright; BNG2 H 4 Bright; BNG2 I 4 Bright; Stop; } } // The Dead Inquisitor's Detached Arm --------------------------------------- class InquisitorArm : Actor { Default { Speed 25; +NOBLOCKMAP +NOCLIP +NOBLOOD } States { Spawn: RBB3 FG 5 Bright; RBB3 H -1; Stop; } } extend class Actor { virtual void ApplyKickback(Actor inflictor, Actor source, int damage, double angle, Name mod, int flags) { double ang; int kickback; double thrust; if (inflictor && inflictor.projectileKickback) kickback = inflictor.projectileKickback; else if (!source || !source.player || !source.player.ReadyWeapon) kickback = gameinfo.defKickback; else kickback = source.player.ReadyWeapon.Kickback; kickback = int(kickback * G_SkillPropertyFloat(SKILLP_KickbackFactor)); if (kickback) { Actor origin = (source && (flags & DMG_INFLICTOR_IS_PUFF)) ? source : inflictor; if (flags & DMG_USEANGLE) { ang = angle; } else if (origin.pos.xy == pos.xy) { // If the origin and target are in exactly the same spot, choose a random direction. // (Most likely cause is from telefragging somebody during spawning because they // haven't moved from their spawn spot at all.) ang = frandom[Kickback](0., 360.); } else { ang = origin.AngleTo(self); } thrust = mod == 'MDK' ? 10 : 32; if (Mass > 0) { thrust = clamp((damage * 0.125 * kickback) / Mass, 0., thrust); } // Don't apply ultra-small damage thrust if (thrust < 0.01) thrust = 0; // make fall forwards sometimes if ((damage < 40) && (damage > health) && (pos.Z - origin.pos.Z > 64) && random[Kickback](0, 1) // [RH] But only if not too fast and not flying && thrust < 10 && !bNoGravity && !bNoForwardFall && (inflictor == NULL || !inflictor.bNoForwardFall) ) { ang += 180.; thrust *= 4; } if (source && source.player && (flags & DMG_INFLICTOR_IS_PUFF) && source.player.ReadyWeapon != NULL && (source.player.ReadyWeapon.bSTAFF2_KICKBACK)) { // Staff power level 2 Thrust(10, ang); if (!bNoGravity) { Vel.Z += 5.; } } else { Thrust(thrust, ang); } } } } class IntermissionController native ui { // This is mostly a black box to the native intermission code. // May be scriptified later, but right now we do not need it. native void Start(); native bool Responder(InputEvent ev); native bool Ticker(); native void Drawer(); native bool NextPage(); } // Wrapper to play the native intermissions within a screen job. class IntermissionScreenJob : ScreenJob { IntermissionController controller; ScreenJob Init(IntermissionController ctrl, bool allowwipe) { Super.Init(); if (allowwipe && wipetype != 0) flags = wipetype << ScreenJob.transition_shift; controller = ctrl; return self; } override void Start() { controller.Start(); } override bool OnEvent(InputEvent evt) { return controller.Responder(evt); } override void OnTick() { if (!controller.Ticker()) jobstate = finished; } override void Draw(double smoothratio) { controller.Drawer(); } override void OnDestroy() { if (controller) controller.Destroy(); Super.OnDestroy(); } } class DoomCutscenes ui { //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- static void BuildMapTransition(ScreenJobRunner runner, IntermissionController inter, StatusScreen status) { if (status) { runner.Append(status); } if (inter) { runner.Append(new("IntermissionScreenJob").Init(inter, status != null)); } } } struct VisStyle { bool Invert; float Alpha; int RenderStyle; } class Inventory : Actor { const BLINKTHRESHOLD = (4*32); const BONUSADD = 6; deprecated("3.7") private int ItemFlags; Actor Owner; // Who owns this item? NULL if it's still a pickup. int Amount; // Amount of item this instance has int MaxAmount; // Max amount of item this instance can have int InterHubAmount; // Amount of item that can be kept between hubs or levels int RespawnTics; // Tics from pickup time to respawn time TextureID Icon; // Icon to show on status bar or HUD TextureID AltHUDIcon; int DropTime; // Countdown after dropping Class SpawnPointClass; // For respawning like Heretic's mace Class PickupFlash; // actor to spawn as pickup flash Sound PickupSound; bool bPickupGood; bool bCreateCopyMoved; bool bInitEffectFailed; meta String PickupMsg; meta int GiveQuest; meta array > ForbiddenToPlayerClass; meta array > RestrictedToPlayerClass; property PickupMessage: PickupMsg; property GiveQuest: GiveQuest; property Amount: Amount; property InterHubAmount: InterHubAmount; property MaxAmount: MaxAmount; property PickupFlash: PickupFlash; property PickupSound: PickupSound; property UseSound: UseSound; property RespawnTics: RespawnTics; flagdef Quiet: ItemFlags, 0; flagdef Autoactivate: ItemFlags, 1; flagdef Undroppable: ItemFlags, 2; flagdef Invbar: ItemFlags, 3; flagdef HubPower: ItemFlags, 4; flagdef Untossable: ItemFlags, 5; flagdef AdditiveTime: ItemFlags, 6; flagdef FancyPickupSound: ItemFlags, 7; flagdef BigPowerup: ItemFlags, 8; flagdef KeepDepleted: ItemFlags, 9; flagdef IgnoreSkill: ItemFlags, 10; flagdef NoAttenPickupSound: ItemFlags, 11; flagdef PersistentPower : ItemFlags, 12; flagdef RestrictAbsolutely: ItemFlags, 13; flagdef NeverRespawn: ItemFlags, 14; flagdef NoScreenFlash: ItemFlags, 15; flagdef Tossed: ItemFlags, 16; flagdef AlwaysRespawn: ItemFlags, 17; flagdef Transfer: ItemFlags, 18; flagdef NoTeleportFreeze: ItemFlags, 19; flagdef NoScreenBlink: ItemFlags, 20; flagdef IsArmor: ItemFlags, 21; flagdef IsHealth: ItemFlags, 22; flagdef AlwaysPickup: ItemFlags, 23; flagdef Unclearable: ItemFlags, 24; flagdef ForceRespawnInSurvival: none, 0; flagdef PickupFlash: none, 6; flagdef InterHubStrip: none, 12; Default { Inventory.Amount 1; Inventory.MaxAmount 1; Inventory.InterHubAmount 1; Inventory.UseSound "misc/invuse"; Inventory.PickupSound "misc/i_pkup"; Inventory.PickupMessage "$TXT_DEFAULTPICKUPMSG"; } //native override void Tick(); override void Tick() { if (Owner == null) { // AActor::Tick is only handling interaction with the world // and we don't want that for owned inventory items. Super.Tick(); } else if (tics != -1) // ... but at least we have to advance the states { tics--; // you can cycle through multiple states in a tic // [RH] Use <= 0 instead of == 0 so that spawnstates // of 0 tics work as expected. if (tics <= 0) { if (curstate == null) { Destroy(); return; } if (!SetState (curstate.NextState)) return; // freed itself } } if (DropTime) { if (--DropTime == 0) { bSpecial = default.bSpecial; bSolid = default.bSolid; } } } native static void PrintPickupMessage (bool localview, String str); States(Actor) { HideDoomish: TNT1 A 1050; TNT1 A 0 A_RestoreSpecialPosition; TNT1 A 1 A_RestoreSpecialDoomThing; Stop; HideSpecial: ACLO E 1400; ACLO A 0 A_RestoreSpecialPosition; ACLO A 4 A_RestoreSpecialThing1; ACLO BABCBCDC 4; ACLO D 4 A_RestoreSpecialThing2; Stop; Held: TNT1 A -1; Stop; HoldAndDestroy: TNT1 A 1; Stop; } //=========================================================================== // // Inventory :: MarkPrecacheSounds // //=========================================================================== override void MarkPrecacheSounds() { Super.MarkPrecacheSounds(); MarkSound(PickupSound); } //=========================================================================== // // Inventory :: BeginPlay // //=========================================================================== override void BeginPlay () { Super.BeginPlay (); bDropped = true; // [RH] Items are dropped by default } //=========================================================================== // // Inventory :: Destroy // //=========================================================================== override void OnDestroy () { if (Owner != NULL) { Owner.RemoveInventory (self); } Inv = NULL; Super.OnDestroy(); } //=========================================================================== // // Inventory :: ShouldSpawn // //=========================================================================== override bool ShouldSpawn() { // [RH] Other things that shouldn't be spawned depending on dmflags if (deathmatch || alwaysapplydmflags) { if (sv_nohealth && bIsHealth) return false; if (sv_noarmor && bIsArmor) return false; } return true; } //--------------------------------------------------------------------------- // // PROC A_RestoreSpecialThing1 // // Make a special thing visible again. // //--------------------------------------------------------------------------- void A_RestoreSpecialThing1() { bInvisible = false; if (DoRespawn ()) { A_StartSound ("misc/spawn", CHAN_VOICE); } } //--------------------------------------------------------------------------- // // PROC A_RestoreSpecialThing2 // //--------------------------------------------------------------------------- void A_RestoreSpecialThing2() { bSpecial = true; if (!Default.bNoGravity) { bNoGravity = false; } SetState (SpawnState); } //--------------------------------------------------------------------------- // // PROC A_RestoreSpecialDoomThing // //--------------------------------------------------------------------------- void A_RestoreSpecialDoomThing() { bInvisible = false; bSpecial = true; if (!Default.bNoGravity) { bNoGravity = false; } if (DoRespawn ()) { SetState (SpawnState); A_StartSound ("misc/spawn", CHAN_VOICE); Spawn ("ItemFog", Pos, ALLOW_REPLACE); } } //=========================================================================== // // Inventory :: DoRespawn // //=========================================================================== bool DoRespawn () { if (SpawnPointClass != NULL) { Actor spot = NULL; let state = Level.GetSpotState(); if (state != NULL) spot = state.GetRandomSpot(SpawnPointClass, false); if (spot != NULL) { SetOrigin (spot.Pos, false); SetZ(floorz); } } return true; } //=========================================================================== // // Inventory :: Grind // //=========================================================================== override bool Grind(bool items) { // Does this grind request even care about items? if (!items) { return false; } // Dropped items are normally destroyed by crushers. Set the DONTGIB flag, // and they'll act like corpses with it set and be immune to crushers. if (bDropped) { if (!bDontGib) { Destroy(); } return false; } // Non-dropped items call the super method for compatibility. return Super.Grind(items); } //=========================================================================== // // Inventory :: BecomeItem // // Lets this actor know that it's about to be placed in an inventory. // //=========================================================================== void BecomeItem () { if (!bNoBlockmap || !bNoSector) { A_ChangeLinkFlags(1, 1); } ChangeTid(0); bSpecial = false; // if the item was turned into a monster through Dehacked, undo that here. bCountkill = false; bIsMonster = false; ChangeStatNum(STAT_INVENTORY); // stop all sounds this item is playing. A_StopAllSounds(); SetState (FindState("Held")); } //=========================================================================== // // Inventory :: BecomePickup // // Lets this actor know it should wait to be picked up. // //=========================================================================== void BecomePickup () { if (Owner != NULL) { Owner.RemoveInventory (self); } if (bNoBlockmap || bNoSector) { A_ChangeLinkFlags(0, 0); FindFloorCeiling(); } bSpecial = true; bDropped = true; bCountItem = false; bInvisible = false; ChangeStatNum(STAT_DEFAULT); SetState (SpawnState); } //=========================================================================== // // Inventory :: CreateCopy // // Returns an actor suitable for placing in an inventory, either itself or // a copy based on whether it needs to respawn or not. Returning NULL // indicates the item should not be picked up. // //=========================================================================== virtual Inventory CreateCopy (Actor other) { Inventory copy; Amount = MIN(Amount, MaxAmount); if (GoAway ()) { copy = Inventory(Spawn (GetClass())); copy.Amount = Amount; copy.MaxAmount = MaxAmount; } else { copy = self; } return copy; } //=========================================================================== // // Inventory :: HandlePickup // // Returns true if the pickup was handled (or should not happen at all), // false if not. // //=========================================================================== virtual bool HandlePickup (Inventory item) { if (item.GetClass() == GetClass()) { if (Amount < MaxAmount || (sv_unlimited_pickup && !item.ShouldStay())) { if (Amount > 0 && Amount + item.Amount < 0) { Amount = 0x7fffffff; } else { Amount += item.Amount; } if (Amount > MaxAmount && !sv_unlimited_pickup) { Amount = MaxAmount; } item.bPickupGood = true; } return true; } return false; } //=========================================================================== // // Inventory :: CallHandlePickup // // Runs all HandlePickup methods in the chain // //=========================================================================== private bool CallHandlePickup(Inventory item) { let me = self; while (me != null) { if (me.HandlePickup(item)) return true; me = me.Inv; } return false; } //=========================================================================== // // Inventory :: TryPickup // //=========================================================================== virtual protected bool TryPickup (in out Actor toucher) { Actor newtoucher = toucher; // in case changed by the powerup // If HandlePickup() returns true, it will set the IF_PICKUPGOOD flag // to indicate that self item has been picked up. If the item cannot be // picked up, then it leaves the flag cleared. bPickupGood = false; if (toucher.Inv != NULL && toucher.Inv.CallHandlePickup (self)) { // Let something else the player is holding intercept the pickup. if (!bPickupGood) { return false; } bPickupGood = false; GoAwayAndDie (); } else if (MaxAmount > 0) { // Add the item to the inventory. It is not already there, or HandlePickup // would have already taken care of it. let copy = CreateCopy (toucher); if (copy == NULL) { return false; } // Some powerups cannot activate absolutely, for // example, PowerMorph; fail the pickup if so. if (copy.bInitEffectFailed) { if (copy != self) copy.Destroy(); else bInitEffectFailed = false; return false; } // Handle owner-changing powerups if (copy.bCreateCopyMoved) { newtoucher = copy.Owner; copy.Owner = NULL; bCreateCopyMoved = false; } // Continue onwards with the rest copy.AttachToOwner (newtoucher); if (bAutoActivate) { if (copy.Use (true)) { if (--copy.Amount <= 0) { copy.bSpecial = false; copy.SetStateLabel ("HoldAndDestroy"); } } } } else if (bAutoActivate) { // Special case: If an item's MaxAmount is 0, you can still pick it // up if it is autoactivate-able. // The item is placed in the inventory just long enough to be used. toucher.AddInventory(self); bool usegood = Use(true); // Handle potential change of toucher/owner because of morph if (usegood && self.owner) { toucher = self.owner; } toucher.RemoveInventory(self); if (usegood) { GoAwayAndDie(); } else { return false; } } return true; } //=========================================================================== // // Inventory :: GiveQuest // //=========================================================================== void GiveQuestItem (Actor toucher) { if (GiveQuest > 0) { String qname = "QuestItem" .. GiveQuest; class type = qname; if (type != null) { toucher.GiveInventoryType (type); } } } //=========================================================================== // // Inventory :: CanPickup // //=========================================================================== virtual bool CanPickup(Actor toucher) { if (toucher == null) return false; int rsize = RestrictedToPlayerClass.Size(); if (rsize > 0) { for (int i=0; i < rsize; i++) { if (toucher is RestrictedToPlayerClass[i]) return true; } return false; } rsize = ForbiddenToPlayerClass.Size(); if (rsize > 0) { for (int i=0; i < rsize; i++) { if (toucher is ForbiddenToPlayerClass[i]) return false; } } return true; } //=========================================================================== // // Inventory :: CallTryPickup // // In this case the caller function is more than a simple wrapper around the virtual method and // is what must be actually called to pick up an item. // //=========================================================================== bool, Actor CallTryPickup(Actor toucher) { let saved_toucher = toucher; let Invstack = Inv; // A pointer of the inventories item stack. // unmorphed versions of a currently morphed actor cannot pick up anything. if (bUnmorphed) return false, null; bool res; if (CanPickup(toucher)) { res = TryPickup(toucher); } else if (!bRestrictAbsolutely) { // let an item decide for itself how it will handle this res = TryPickupRestricted(toucher); } else return false, null; if (!res && (bAlwaysPickup) && !ShouldStay()) { res = true; GoAwayAndDie(); } if (res) { GiveQuestItem(toucher); // Transfer all inventory across that the old object had, if requested. if (bTransfer) { while (Invstack) { let titem = Invstack; Invstack = titem.Inv; if (titem.Owner == self) { if (!titem.CallTryPickup(toucher)) // The object no longer can exist { titem.Destroy(); } } } } } return res, toucher; } //=========================================================================== // // Inventory :: ShouldStay // // Returns true if the item should not disappear, even temporarily. // //=========================================================================== virtual bool ShouldStay () { return false; } //=========================================================================== // // Inventory :: TryPickupRestricted // //=========================================================================== virtual bool TryPickupRestricted (in out Actor toucher) { return false; } //=========================================================================== // // Inventory :: AttachToOwner // //=========================================================================== virtual void AttachToOwner (Actor other) { BecomeItem (); other.AddInventory (self); } //=========================================================================== // // Inventory :: DetachFromOwner // // Performs any special work needed when the item leaves an inventory, // either through destruction or becoming a pickup. // //=========================================================================== virtual void DetachFromOwner () { } //=========================================================================== // // Inventory::CreateTossable // // Creates a copy of the item suitable for dropping. If this actor embodies // only one item, then it is tossed out itself. Otherwise, the count drops // by one and a new item with an amount of 1 is spawned. // //=========================================================================== virtual Inventory CreateTossable (int amt = -1) { // If self actor lacks a SpawnState, don't drop it. (e.g. A base weapon // like the fist can't be dropped because you'll never see it.) if (SpawnState == GetDefaultByType("Actor").SpawnState || SpawnState == NULL) { return NULL; } if (bUndroppable || bUntossable || Owner == NULL || Amount <= 0 || amt == 0) { return NULL; } if (Amount == 1 && !bKeepDepleted) { BecomePickup (); DropTime = 30; bSpecial = bSolid = false; return self; } let copy = Inventory(Spawn (GetClass(), Owner.Pos, NO_REPLACE)); if (copy != NULL) { amt = clamp(amt, 1, Amount); copy.MaxAmount = MaxAmount; copy.Amount = amt; copy.DropTime = 30; copy.bSpecial = copy.bSolid = false; Amount -= amt; } return copy; } //=========================================================================== // // Inventory :: PickupMessage // // Returns the message to print when this actor is picked up. // //=========================================================================== virtual String PickupMessage () { return PickupMsg; } //=========================================================================== // // Inventory :: Touch // // Handles collisions from another actor, possible adding itself to the // collider's inventory. // //=========================================================================== override void Touch (Actor toucher) { let player = toucher.player; // If a voodoo doll touches something, pretend the real player touched it instead. if (player != NULL) { toucher = player.mo; } bool localview = toucher.CheckLocalView(); if (!toucher.CanTouchItem(self)) return; bool res; [res, toucher] = CallTryPickup(toucher); if (!res) return; // This is the only situation when a pickup flash should ever play. if (PickupFlash != NULL && !ShouldStay()) { Spawn(PickupFlash, Pos, ALLOW_REPLACE); } if (!bQuiet) { PrintPickupMessage(localview, PickupMessage ()); // Special check so voodoo dolls picking up items cause the // real player to make noise. if (player != NULL) { PlayPickupSound (player.mo); if (!bNoScreenFlash && player.playerstate != PST_DEAD) { player.bonuscount = BONUSADD; } } else { PlayPickupSound (toucher); } } // [RH] Execute an attached special (if any) DoPickupSpecial (toucher); if (bCountItem) { if (player != NULL) { player.itemcount++; } level.found_items++; } if (bCountSecret) { Actor ac = player != NULL? Actor(player.mo) : toucher; ac.GiveSecret(true, true); } //Added by MC: Check if item taken was the roam destination of any bot for (int i = 0; i < MAXPLAYERS; i++) { if (players[i].Bot != NULL && self == players[i].Bot.dest) players[i].Bot.dest = NULL; } } //=========================================================================== // // Inventory :: DepleteOrDestroy // // If the item is depleted, just change its amount to 0, otherwise it's destroyed. // //=========================================================================== virtual void DepleteOrDestroy () { // If it's not ammo or an internal armor, destroy it. // Ammo needs to stick around, even when it's zero for the benefit // of the weapons that use it and to maintain the maximum ammo // amounts a backpack might have given. // Armor shouldn't be removed because they only work properly when // they are the last items in the inventory. if (bKeepDepleted) { Amount = 0; } else { Destroy(); } } //=========================================================================== // // Inventory :: PreTravelled // // Called when an item in somebody's inventory is about to be carried // over to another map, in case it needs to do special clean-up. // //=========================================================================== virtual void PreTravelled() {} //=========================================================================== // // Inventory :: Travelled // // Called when an item in somebody's inventory is carried over to another // map, in case it needs to do special reinitialization. // //=========================================================================== virtual void Travelled() {} //=========================================================================== // // Inventory :: DoEffect // // Handles any effect an item might apply to its owner // Normally only used by subclasses of Powerup // //=========================================================================== virtual void DoEffect() {} //=========================================================================== // // Inventory :: Hide // // Hides this actor until it's time to respawn again. // //=========================================================================== virtual void Hide () { State HideSpecialState = NULL, HideDoomishState = NULL; bSpecial = false; bNoGravity = true; bInvisible = true; if (gameinfo.gametype & GAME_Raven) { HideSpecialState = FindState("HideSpecial"); if (HideSpecialState == NULL) { HideDoomishState = FindState("HideDoomish"); } } else { HideDoomishState = FindState("HideDoomish"); if (HideDoomishState == NULL) { HideSpecialState = FindState("HideSpecial"); } } if (HideSpecialState != NULL) { SetState (HideSpecialState); tics = 1400; if (PickupFlash != NULL) tics += 30; } else if (HideDoomishState != NULL) { SetState (HideDoomishState); tics = 1050; } if (RespawnTics != 0) { tics = RespawnTics; } } //=========================================================================== // // Inventory :: ShouldRespawn // // Returns true if the item should hide itself and reappear later when picked // up. // //=========================================================================== virtual bool ShouldRespawn () { if (bBigPowerup && !sv_respawnsuper) return false; if (bNeverRespawn) return false; return sv_itemrespawn || bAlwaysRespawn; } //=========================================================================== // // Inventory :: GoAway // // Returns true if you must create a copy of this item to give to the player // or false if you can use this one instead. // //=========================================================================== protected bool GoAway () { // Dropped items never stick around if (bDropped) { return false; } if (!ShouldStay ()) { Hide (); if (ShouldRespawn ()) { return true; } return false; } return true; } //=========================================================================== // // Inventory :: GoAwayAndDie // // Like GoAway but used by items that don't insert themselves into the // inventory. If they won't be respawning, then they can destroy themselves. // //=========================================================================== protected void GoAwayAndDie () { if (!GoAway ()) { bSpecial = false; if (!bNoBlockmap || !bNoSector) // make sure that the item no longer interacts with the world for the short rest of its life. { A_ChangeLinkFlags(1, 1); } SetStateLabel("HoldAndDestroy"); } } //=========================================================================== // // Inventory :: ModifyDamage // // Allows inventory items to manipulate the amount of damage // inflicted. Damage is the amount of damage that would be done without manipulation, // and newdamage is the amount that should be done after the item has changed // it. // 'active' means it is called by the inflictor, 'passive' by the target. // It may seem that this is redundant and AbsorbDamage is the same. However, // AbsorbDamage is called only for players and also depends on other settings // which are undesirable for a protection artifact. // //=========================================================================== virtual void ModifyDamage(int damage, Name damageType, out int newdamage, bool passive, Actor inflictor = null, Actor source = null, int flags = 0) {} virtual Vector2 ModifyBob(Vector2 Bob, double ticfrac) {return Bob;} virtual Vector3, Vector3 ModifyBob3D(Vector3 Translation, Vector3 Rotation, double ticfrac) {return Translation, Rotation;} virtual bool Use (bool pickup) { return false; } virtual double GetSpeedFactor() { return 1; } virtual bool GetNoTeleportFreeze() { return false; } virtual version("2.4") ui void AlterWeaponSprite(VisStyle vis, in out int changed) {} virtual void OwnerDied() {} virtual Color GetBlend () { return 0; } virtual void UseAll(Actor user) { if (bInvBar) user.UseInventory(self); } //=========================================================================== // // Inventory :: DoPickupSpecial // // Executes this actor's special when it is picked up. // //=========================================================================== virtual void DoPickupSpecial (Actor toucher) { if (special) { toucher.A_CallSpecial(special, args[0], args[1], args[2], args[3], args[4]); special = 0; } } //=========================================================================== // // Inventory :: PlayPickupSound // //=========================================================================== virtual void PlayPickupSound (Actor toucher) { double atten; int chan; int flags = 0; if (bNoAttenPickupSound) { atten = ATTN_NONE; } /* else if ((ItemFlags & IF_FANCYPICKUPSOUND) && (toucher == NULL || toucher->CheckLocalView())) { atten = ATTN_NONE; } */ else { atten = ATTN_NORM; } if (toucher != NULL && toucher.CheckLocalView()) { chan = CHAN_ITEM; flags = CHANF_NOPAUSE | CHANF_MAYBE_LOCAL; } else { chan = CHAN_ITEM; flags = CHANF_MAYBE_LOCAL; } toucher.A_StartSound(PickupSound, chan, flags, 1, atten); } //=========================================================================== // // Inventory :: DrawPowerup // // This has been deprecated because it is not how this should be done // Use GetPowerupIcon instead! // //=========================================================================== virtual ui version("2.4") bool DrawPowerup(int x, int y) { return false; } //=========================================================================== // // Inventory :: AbsorbDamage // // Allows inventory items (primarily armor) to reduce the amount of damage // taken. Damage is the amount of damage that would be done without armor, // and newdamage is the amount that should be done after the armor absorbs // it. // //=========================================================================== virtual void AbsorbDamage (int damage, Name damageType, out int newdamage, Actor inflictor = null, Actor source = null, int flags = 0) {} //=========================================================================== // // Inventory :: SpecialDropAction // // Called by P_DropItem. Return true to prevent the standard drop tossing. // A few Strife items that are meant to trigger actions rather than be // picked up use this. Normal items shouldn't need it. // //=========================================================================== virtual bool SpecialDropAction (Actor dropper) { return false; } //=========================================================================== // // Inventory :: NextInv // // Returns the next item with IF_INVBAR set. // //=========================================================================== clearscope Inventory NextInv () const { Inventory item = Inv; while (item != NULL && !item.bInvBar) { item = item.Inv; } return item; } //=========================================================================== // // Inventory :: PrevInv // // Returns the previous item with IF_INVBAR set. // //=========================================================================== clearscope Inventory PrevInv () { Inventory lastgood = NULL; Inventory item = Owner.Inv; while (item != NULL && item != self) { if (item.bInvBar) { lastgood = item; } item = item.Inv; } return lastgood; } //=========================================================================== // // Inventory :: OnDrop // // Called by AActor::DropInventory. Allows items to modify how they behave // after being dropped. // //=========================================================================== virtual void OnDrop (Actor dropper) {} //--------------------------------------------------------------------------- // // Modifies the drop amount of this item according to the current skill's // settings (also called by ADehackedPickup::TryPickup) // //--------------------------------------------------------------------------- virtual void ModifyDropAmount(int dropamount) { if (dropamount > 0) { Amount = dropamount; } } //--------------------------------------------------------------------------- // // Modifies the amount based on what an item should contain if given // //--------------------------------------------------------------------------- virtual void SetGiveAmount(Actor receiver, int amount, bool givecheat) { if (givecheat) { let haveitem = receiver.FindInventory(GetClass()); self.Amount = MIN(amount, haveitem == null? self.Default.MaxAmount : haveitem.MaxAmount); } else { self.Amount = amount; } } } //=========================================================================== // // // //=========================================================================== class DehackedPickup : Inventory { Inventory RealPickup; bool droppedbymonster; private native class DetermineType(); override bool TryPickup (in out Actor toucher) { let type = DetermineType (); if (type == NULL) { return false; } RealPickup = Inventory(Spawn (type, Pos, NO_REPLACE)); if (RealPickup != NULL) { // The internally spawned item should never count towards statistics. RealPickup.ClearCounters(); if (!bDropped) { RealPickup.bDropped = false; } // If this item has been dropped by a monster the // amount of ammo this gives must be adjusted. if (droppedbymonster) { RealPickup.ModifyDropAmount(0); } if (!RealPickup.CallTryPickup (toucher)) { RealPickup.Destroy (); RealPickup = NULL; return false; } GoAwayAndDie (); return true; } return false; } override String PickupMessage () { if (RealPickup != null) return RealPickup.PickupMessage (); else return ""; } override bool ShouldStay () { if (RealPickup != null) return RealPickup.ShouldStay (); else return true; } override bool ShouldRespawn () { if (RealPickup != null) return RealPickup.ShouldRespawn (); else return false; } override void PlayPickupSound (Actor toucher) { if (RealPickup != null) RealPickup.PlayPickupSound (toucher); } override void DoPickupSpecial (Actor toucher) { Super.DoPickupSpecial (toucher); // If the real pickup hasn't joined the toucher's inventory, make sure it // doesn't stick around. if (RealPickup != null && RealPickup.Owner != toucher) { RealPickup.Destroy (); } RealPickup = null; } override void OnDestroy () { if (RealPickup != null) { RealPickup.Destroy (); RealPickup = null; } Super.OnDestroy(); } override void ModifyDropAmount(int dropamount) { // Must forward the adjustment to the real item. // dropamount is not relevant here because Dehacked cannot change it. droppedbymonster = true; } } //=========================================================================== // // // //=========================================================================== class FakeInventory : Inventory { bool Respawnable; property respawns: Respawnable; override bool ShouldRespawn () { return Respawnable && Super.ShouldRespawn(); } override bool TryPickup (in out Actor toucher) { let success = toucher.A_CallSpecial(special, args[0], args[1], args[2], args[3], args[4]); if (success) { GoAwayAndDie (); return true; } return false; } override void DoPickupSpecial (Actor toucher) { // The special was already executed by TryPickup, so do nothing here } } extend class Actor { //============================================================================ // // AActor :: FirstInv // // Returns the first item in this actor's inventory that has IF_INVBAR set. // //============================================================================ clearscope Inventory FirstInv () { if (Inv == NULL) { return NULL; } if (Inv.bInvBar) { return Inv; } return Inv.NextInv (); } //============================================================================ // // AActor :: AddInventory // //============================================================================ virtual void AddInventory (Inventory item) { // Check if it's already attached to an actor if (item.Owner != NULL) { // Is it attached to us? if (item.Owner == self) return; // No, then remove it from the other actor first item.Owner.RemoveInventory (item); } item.Owner = self; item.Inv = Inv; Inv = item; // Each item receives an unique ID when added to an actor's inventory. // This is used by the DEM_INVUSE command to identify the item. Simply // using the item's position in the list won't work, because ticcmds get // run sometime in the future, so by the time it runs, the inventory // might not be in the same state as it was when DEM_INVUSE was sent. Inv.InventoryID = InventoryID++; } //============================================================================ // // AActor :: GiveInventory // //============================================================================ bool GiveInventory(Class type, int amount, bool givecheat = false) { bool result = true; let player = self.player; // This can be called from places which do not check the given item's type. if (type == null || !(type is 'Inventory')) return false; Weapon savedPendingWeap = player != NULL ? player.PendingWeapon : NULL; bool hadweap = player != NULL ? player.ReadyWeapon != NULL : true; Inventory item; if (!givecheat) { item = Inventory(Spawn (type)); } else { item = Inventory(Spawn (type, Pos, NO_REPLACE)); if (item == NULL) return false; } // This shouldn't count for the item statistics. item.ClearCounters(); if (!givecheat || amount > 0) { item.SetGiveAmount(self, amount, givecheat); } if (!item.CallTryPickup (self)) { item.Destroy (); result = false; } // If the item was a weapon, don't bring it up automatically // unless the player was not already using a weapon. // Don't bring it up automatically if this is called by the give cheat. if (!givecheat && player != NULL && savedPendingWeap != NULL && hadweap) { player.PendingWeapon = savedPendingWeap; } return result; } //============================================================================ // // AActor :: RemoveInventory // //============================================================================ virtual void RemoveInventory(Inventory item) { if (item != NULL && item.Owner != NULL) // can happen if the owner was destroyed by some action from an item's use state. { if (Inv == item) Inv = item.Inv; else { for (Actor invp = self; invp != null; invp = invp.Inv) { if (invp.Inv == item) { invp.Inv = item.Inv; break; } } } item.DetachFromOwner(); item.Owner = NULL; item.Inv = NULL; } } //============================================================================ // // AActor :: TakeInventory // //============================================================================ bool TakeInventory(class itemclass, int amount, bool fromdecorate = false, bool notakeinfinite = false) { amount = abs(amount); let item = FindInventory(itemclass); if (item == NULL) return false; if (!fromdecorate) { item.Amount -= amount; if (item.Amount <= 0) { item.DepleteOrDestroy(); } // It won't be used in non-decorate context, so return false here return false; } bool result = false; if (item.Amount > 0) { result = true; } // Do not take ammo if the "no take infinite/take as ammo depletion" flag is set // and infinite ammo is on if (notakeinfinite && (sv_infiniteammo || (player && FindInventory('PowerInfiniteAmmo', true))) && (item is 'Ammo')) { // Nothing to do here, except maybe res = false;? Would it make sense? result = false; } else if (!amount || amount >= item.Amount) { item.DepleteOrDestroy(); } else item.Amount -= amount; return result; } //============================================================================ // // AActor :: SetInventory // //============================================================================ bool SetInventory(class itemclass, int amount, bool beyondMax = false) { let item = FindInventory(itemclass); if (item != null) { // A_SetInventory sets the absolute amount. // Subtract or set the appropriate amount as necessary. if (amount == item.Amount) { // Nothing was changed. return false; } else if (amount <= 0) { //Remove it all. return TakeInventory(itemclass, item.Amount, true, false); } else if (amount < item.Amount) { int amt = abs(item.Amount - amount); return TakeInventory(itemclass, amt, true, false); } else { item.Amount = (beyondMax ? amount : clamp(amount, 0, item.MaxAmount)); return true; } } else { if (amount <= 0) { return true; } item = Inventory(Spawn(itemclass)); if (item == null) { return false; } else { item.Amount = amount; item.bDropped = true; item.bIgnoreSkill = true; item.ClearCounters(); if (!item.CallTryPickup(self)) { item.Destroy(); return false; } return true; } } return false; } //============================================================================ // // AActor :: UseInventory // // Attempts to use an item. If the use succeeds, one copy of the item is // removed from the inventory. If all copies are removed, then the item is // destroyed. // //============================================================================ virtual bool UseInventory (Inventory item) { // No using items if you're dead or you don't have them. if (health <= 0 || item.Amount <= 0 || item.bDestroyed) { return false; } if (!item.Use(false)) { return false; } if (sv_infiniteinventory) { return true; } if (--item.Amount <= 0) { item.DepleteOrDestroy (); } return true; } //=========================================================================== // // AActor :: DropInventory // // Removes a single copy of an item and throws it out in front of the actor. // //=========================================================================== Inventory DropInventory (Inventory item, int amt = 1) { Inventory drop = item.CreateTossable(amt); if (drop == null) return NULL; drop.SetOrigin(Pos + (0, 0, 10.), false); drop.Angle = Angle; drop.VelFromAngle(5.); drop.Vel.Z = 1.; drop.Vel += Vel; drop.bNoGravity = false; // Don't float drop.ClearCounters(); // do not count for statistics again drop.OnDrop(self); return drop; } //============================================================================ // // AActor :: ClearInventory // // Clears the inventory of a single actor. // //============================================================================ virtual void ClearInventory() { // In case destroying an inventory item causes another to be destroyed // (e.g. Weapons destroy their sisters), keep track of the pointer to // the next inventory item rather than the next inventory item itself. // For example, if a weapon is immediately followed by its sister, the // next weapon we had tracked would be to the sister, so it is now // invalid and we won't be able to find the complete inventory by // following it. // // When we destroy an item, we leave last alone, since the destruction // process will leave it pointing to the next item we want to check. If // we don't destroy an item, then we move last to point to its Inventory // pointer. // // It should be safe to assume that an item being destroyed will only // destroy items further down in the chain, because if it was going to // destroy something we already processed, we've already destroyed it, // so it won't have anything to destroy. let last = self; while (last.inv != NULL) { let inv = last.inv; if (!inv.bUndroppable && !inv.bUnclearable) { inv.DepleteOrDestroy(); if (!inv.bDestroyed) last = inv; // was only depleted so advance the pointer manually. } else { last = inv; } } if (player != null) { player.ReadyWeapon = null; player.PendingWeapon = WP_NOCHANGE; } } //============================================================================ // // AActor :: GiveAmmo // // Returns true if the ammo was added, false if not. // //============================================================================ bool GiveAmmo (Class type, int amount) { if (type != NULL && type is 'Ammo') { let item = Inventory(Spawn (type)); if (item) { item.Amount = amount; item.bDropped = true; if (!item.CallTryPickup (self)) { item.Destroy (); return false; } return true; } } return false; } //=========================================================================== // // DoGiveInventory // //=========================================================================== static bool DoGiveInventory(Actor receiver, bool orresult, class mi, int amount, int setreceiver) { int paramnum = 0; if (receiver == NULL) { // If there's nothing to receive it, it's obviously a fail, right? return false; } if (!orresult) { receiver = receiver.GetPointer(setreceiver); if (receiver == NULL) { return false; } } // Owned inventory items cannot own anything because their Inventory pointer is repurposed for the owner's linked list. if (receiver is 'Inventory' && Inventory(receiver).Owner != null) { return false; } if (amount <= 0) { amount = 1; } if (mi) { let item = Inventory(Spawn(mi)); if (item == NULL) { return false; } if (item is 'Health') { item.Amount *= amount; } else { item.Amount = amount; } item.bDropped = true; item.ClearCounters(); if (!item.CallTryPickup(receiver)) { item.Destroy(); return false; } else { return true; } } return false; } bool A_GiveInventory(class itemtype, int amount = 0, int giveto = AAPTR_DEFAULT) { return DoGiveInventory(self, false, itemtype, amount, giveto); } bool A_GiveToTarget(class itemtype, int amount = 0, int giveto = AAPTR_DEFAULT) { return DoGiveInventory(target, false, itemtype, amount, giveto); } int A_GiveToChildren(class itemtype, int amount = 0) { let it = ThinkerIterator.Create('Actor'); Actor mo; int count = 0; while ((mo = Actor(it.Next()))) { if (mo.master == self) { count += DoGiveInventory(mo, true, itemtype, amount, AAPTR_DEFAULT); } } return count; } int A_GiveToSiblings(class itemtype, int amount = 0) { let it = ThinkerIterator.Create('Actor'); Actor mo; int count = 0; if (self.master != NULL) { while ((mo = Actor(it.Next()))) { if (mo.master == self.master && mo != self) { count += DoGiveInventory(mo, true, itemtype, amount, AAPTR_DEFAULT); } } } return count; } //=========================================================================== // // A_TakeInventory // //=========================================================================== bool DoTakeInventory(Actor receiver, bool orresult, class itemtype, int amount, int flags, int setreceiver = AAPTR_DEFAULT) { int paramnum = 0; if (itemtype == NULL) { return false; } if (receiver == NULL) { return false; } if (!orresult) { receiver = receiver.GetPointer(setreceiver); } if (receiver == NULL) { return false; } return receiver.TakeInventory(itemtype, amount, true, (flags & TIF_NOTAKEINFINITE) != 0); } bool A_TakeInventory(class itemtype, int amount = 0, int flags = 0, int giveto = AAPTR_DEFAULT) { return DoTakeInventory(self, false, itemtype, amount, flags, giveto); } bool A_TakeFromTarget(class itemtype, int amount = 0, int flags = 0, int giveto = AAPTR_DEFAULT) { return DoTakeInventory(target, false, itemtype, amount, flags, giveto); } int A_TakeFromChildren(class itemtype, int amount = 0) { let it = ThinkerIterator.Create('Actor'); Actor mo; int count = 0; while ((mo = Actor(it.Next()))) { if (mo.master == self) { count += DoTakeInventory(mo, true, itemtype, amount, 0, AAPTR_DEFAULT); } } return count; } int A_TakeFromSiblings(class itemtype, int amount = 0) { let it = ThinkerIterator.Create('Actor'); Actor mo; int count = 0; if (self.master != NULL) { while ((mo = Actor(it.Next()))) { if (mo.master == self.master && mo != self) { count += DoTakeInventory(mo, true, itemtype, amount, 0, AAPTR_DEFAULT); } } } return count; } //=========================================================================== // // A_SetInventory // //=========================================================================== bool A_SetInventory(class itemtype, int amount, int ptr = AAPTR_DEFAULT, bool beyondMax = false) { bool res = false; if (itemtype == null) { return false; } Actor mobj = GetPointer(ptr); if (mobj == null) { return false; } // Do not run this function on voodoo dolls because the way they transfer the inventory to the player will not work with the code below. if (mobj.player != null) { mobj = mobj.player.mo; } return mobj.SetInventory(itemtype, amount, beyondMax); } //============================================================================ // // P_TossItem // //============================================================================ void TossItem () { int style = sv_dropstyle; if (style==0) style = gameinfo.defaultdropstyle; if (style==2) { Vel.X += random2[DropItem](7); Vel.Y += random2[DropItem](7); } else { Vel.X += random2[DropItem]() / 256.; Vel.Y += random2[DropItem]() / 256.; Vel.Z = 5. + random[DropItem]() / 64.; } } //--------------------------------------------------------------------------- // // PROC A_DropItem // //--------------------------------------------------------------------------- Actor A_DropItem(class item, int dropamount = -1, int chance = 256) { if (item != NULL && random[DropItem]() <= chance) { Actor mo; double spawnz = 0; if (!(Level.compatflags & COMPATF_NOTOSSDROPS)) { int style = sv_dropstyle; if (style == 0) { style = gameinfo.defaultdropstyle; } if (style == 2) { spawnz = 24; } else { spawnz = Height / 2; } } mo = Spawn(item, pos + (0, 0, spawnz), ALLOW_REPLACE); if (mo != NULL) { mo.bDropped = true; mo.bNoGravity = false; // [RH] Make sure it is affected by gravity if (!(Level.compatflags & COMPATF_NOTOSSDROPS)) { mo.TossItem (); } let inv = Inventory(mo); if (inv) { inv.ModifyDropAmount(dropamount); inv.bTossed = true; if (inv.SpecialDropAction(self)) { // The special action indicates that the item should not spawn inv.Destroy(); return null; } } return mo; } } return NULL; } //========================================================================== // // CountInv // // NON-ACTION function to return the inventory count of an item. // //========================================================================== clearscope int CountInv(class itemtype, int ptr_select = AAPTR_DEFAULT) const { let realself = GetPointer(ptr_select); if (realself == NULL || itemtype == NULL) { return 0; } else { let item = realself.FindInventory(itemtype); return item ? item.Amount : 0; } } //========================================================================== // // State jump function // //========================================================================== bool CheckInventory(class itemtype, int itemamount, int owner = AAPTR_DEFAULT) { if (itemtype == null) { return false; } let owner = GetPointer(owner); if (owner == null) { return false; } let item = owner.FindInventory(itemtype); if (item) { if (itemamount > 0) { if (item.Amount >= itemamount) { return true; } } else if (item.Amount >= item.MaxAmount) { return true; } } return false; } //============================================================================ // // AActor :: ObtainInventory // // Removes the items from the other actor and puts them in this actor's // inventory. The actor receiving the inventory must not have any items. // //============================================================================ void ObtainInventory (Actor other) { Inv = other.Inv; InventoryID = other.InventoryID; other.Inv = NULL; other.InventoryID = 0; let you = PlayerPawn(other); let me = PlayerPawn(self); if (you) { if (me) { me.InvFirst = you.InvFirst; me.InvSel = you.InvSel; } you.InvFirst = NULL; you.InvSel = NULL; } for (let item = Inv; item != null; item = item.Inv) { item.Owner = self; } } //=========================================================================== // // A_SelectWeapon // //=========================================================================== bool A_SelectWeapon(class whichweapon, int flags = 0) { bool selectPriority = !!(flags & SWF_SELECTPRIORITY); let player = self.player; if ((!selectPriority && whichweapon == NULL) || player == NULL) { return false; } let weaponitem = Weapon(FindInventory(whichweapon)); if (weaponitem != NULL) { if (player.ReadyWeapon != weaponitem) { player.PendingWeapon = weaponitem; } return true; } else if (selectPriority) { // [XA] if the named weapon cannot be found (or is a dummy like 'None'), // select the next highest priority weapon. This is basically // the same as A_CheckReload minus the ammo check. Handy. player.mo.PickNewWeapon(NULL); return true; } else { return false; } } int GetAmmoCapacity(class type) { if (type != NULL) { let item = FindInventory(type); if (item != NULL) { return item.MaxAmount; } else { return GetDefaultByType(type).MaxAmount; } } return 0; } void SetAmmoCapacity(class type, int amount) { if (type != NULL) { let item = FindInventory(type); if (item != NULL) { item.MaxAmount = amount; } else { item = GiveInventoryType(type); if (item != NULL) { item.MaxAmount = amount; item.Amount = 0; } } } } } //=========================================================================== // // // //=========================================================================== class ScoreItem : Inventory { Default { Height 10; +COUNTITEM Inventory.Amount 1; +Inventory.ALWAYSPICKUP } override bool TryPickup (in out Actor toucher) { toucher.Score += Amount; GoAwayAndDie(); return true; } } //=========================================================================== // // // //=========================================================================== class Key : Inventory { Default { +DONTGIB; // Don't disappear due to a crusher Inventory.InterHubAmount 0; Inventory.PickupSound "misc/k_pkup"; } static native clearscope bool IsLockDefined(int locknum); static native clearscope Color GetMapColorForLock(int locknum); static native clearscope Color GetMapColorForKey(Key key); static native clearscope int GetKeyTypeCount(); static native clearscope class GetKeyType(int index); override bool HandlePickup (Inventory item) { // In single player, you can pick up an infinite number of keys // even though you can only hold one of each. if (multiplayer) { return Super.HandlePickup (item); } if (GetClass() == item.GetClass()) { item.bPickupGood = true; return true; } return false; } override bool ShouldStay () { return !!multiplayer; } } //=========================================================================== // // AMapRevealer // // A MapRevealer reveals the whole map for the player who picks it up. // The MapRevealer doesn't actually go in your inventory. Instead, it sets // a flag on the level. // //=========================================================================== class MapRevealer : Inventory { override bool TryPickup (in out Actor toucher) { level.allmap = true; GoAwayAndDie (); return true; } } //=========================================================================== // // // //=========================================================================== class PuzzleItem : Inventory { meta int PuzzleItemNumber; meta String PuzzFailMessage; meta Sound PuzzFailSound; property Number: PuzzleItemNumber; property FailMessage: PuzzFailMessage; property FailSound: PuzzFailSound; Default { +NOGRAVITY +INVENTORY.INVBAR Inventory.DefMaxAmount; Inventory.UseSound "PuzzleSuccess"; Inventory.PickupSound "misc/i_pkup"; PuzzleItem.FailMessage("$TXT_USEPUZZLEFAILED"); PuzzleItem.FailSound "*puzzfail"; } override bool HandlePickup (Inventory item) { // Can't carry more than 1 of each puzzle item in coop netplay if (multiplayer && !deathmatch && item.GetClass() == GetClass()) { return true; } return Super.HandlePickup (item); } override bool Use (bool pickup) { if (Owner == NULL) return false; if (Owner.UsePuzzleItem (PuzzleItemNumber)) { return true; } // [RH] Always play the sound if the use fails. Owner.A_StartSound (PuzzFailSound, CHAN_VOICE); if (Owner.CheckLocalView()) { Console.MidPrint (null, PuzzFailMessage, true); } return false; } override void UseAll(Actor user) { } override bool ShouldStay () { return !!multiplayer; } } // Ironlich ----------------------------------------------------------------- class Ironlich : Actor { Default { Health 700; Radius 40; Height 72; Mass 325; Speed 6; Painchance 32; Monster; +NOBLOOD +DONTMORPH +DONTSQUASH +BOSSDEATH SeeSound "ironlich/sight"; AttackSound "ironlich/attack"; PainSound "ironlich/pain"; DeathSound "ironlich/death"; ActiveSound "ironlich/active"; Obituary "$OB_IRONLICH"; HitObituary "$OB_IRONLICHHIT"; Tag "$FN_IRONLICH"; DropItem "BlasterAmmo", 84, 10; DropItem "ArtiEgg", 51, 0; } States { Spawn: LICH A 10 A_Look; Loop; See: LICH A 4 A_Chase; Loop; Missile: LICH A 5 A_FaceTarget; LICH B 20 A_LichAttack; Goto See; Pain: LICH A 4; LICH A 4 A_Pain; Goto See; Death: LICH C 7; LICH D 7 A_Scream; LICH EF 7; LICH G 7 A_NoBlocking; LICH H 7; LICH I -1 A_BossDeath; Stop; } //---------------------------------------------------------------------------- // // PROC A_LichAttack // //---------------------------------------------------------------------------- void A_LichAttack () { static const int atkResolve1[] = { 50, 150 }; static const int atkResolve2[] = { 150, 200 }; // Ice ball (close 20% : far 60%) // Fire column (close 40% : far 20%) // Whirlwind (close 40% : far 20%) // Distance threshold = 8 cells let targ = target; if (targ == null) { return; } A_FaceTarget (); if (CheckMeleeRange ()) { int damage = random[LichAttack](1, 8) * 6; int newdam = targ.DamageMobj (self, self, damage, 'Melee'); targ.TraceBleed (newdam > 0 ? newdam : damage, self); return; } int dist = Distance2D(targ) > 8 * 64; int randAttack = random[LichAttack](); if (randAttack < atkResolve1[dist]) { // Ice ball SpawnMissile (targ, "HeadFX1"); A_StartSound ("ironlich/attack2", CHAN_BODY); } else if (randAttack < atkResolve2[dist]) { // Fire column Actor baseFire = SpawnMissile (targ, "HeadFX3"); if (baseFire != null) { baseFire.SetStateLabel("NoGrow"); for (int i = 0; i < 5; i++) { Actor fire = Spawn("HeadFX3", baseFire.Pos, ALLOW_REPLACE); if (i == 0) { A_StartSound ("ironlich/attack1", CHAN_BODY); } if (fire != null) { fire.target = baseFire.target; fire.angle = baseFire.angle; fire.Vel = baseFire.Vel; fire.SetDamage(0); fire.health = (i+1) * 2; fire.CheckMissileSpawn (radius); } } } } else { // Whirlwind Actor mo = SpawnMissile (targ, "Whirlwind"); if (mo != null) { mo.AddZ(-32); mo.tracer = targ; mo.health = 20*TICRATE; // Duration A_StartSound ("ironlich/attack3", CHAN_BODY); } } } } // Head FX 1 ---------------------------------------------------------------- class HeadFX1 : Actor { Default { Radius 12; Height 6; Speed 13; FastSpeed 20; Damage 1; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS +THRUGHOST +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: FX05 ABC 6 BRIGHT; Loop; Death: FX05 D 5 BRIGHT A_LichIceImpact; FX05 EFG 5 BRIGHT; Stop; } //---------------------------------------------------------------------------- // // PROC A_LichIceImpact // //---------------------------------------------------------------------------- void A_LichIceImpact() { for (int i = 0; i < 8; i++) { Actor shard = Spawn("HeadFX2", Pos, ALLOW_REPLACE); if (shard != null) { shard.target = target; shard.angle = i*45.; shard.VelFromAngle(); shard.Vel.Z = -.6; shard.CheckMissileSpawn (radius); } } } } // Head FX 2 ---------------------------------------------------------------- class HeadFX2 : Actor { Default { Radius 12; Height 6; Speed 8; Damage 3; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: FX05 HIJ 6 BRIGHT; Loop; Death: FX05 DEFG 5 BRIGHT; Stop; } } // Head FX 3 ---------------------------------------------------------------- class HeadFX3 : Actor { Default { Radius 14; Height 12; Speed 10; FastSpeed 18; Damage 5; Projectile; +WINDTHRUST +ZDOOMTRANS -ACTIVATEIMPACT -ACTIVATEPCROSS -NOBLOCKMAP RenderStyle "Add"; } States { Spawn: FX06 ABC 4 BRIGHT A_LichFireGrow; Loop; NoGrow: FX06 ABC 5 BRIGHT; Loop; Death: FX06 DEFG 5 BRIGHT; Stop; } //---------------------------------------------------------------------------- // // PROC A_LichFireGrow // //---------------------------------------------------------------------------- void A_LichFireGrow () { health--; AddZ(9.); if (health == 0) { RestoreDamage(); SetStateLabel("NoGrow"); } } } // Whirlwind ---------------------------------------------------------------- class Whirlwind : Actor { Default { Radius 16; Height 74; Speed 10; Damage 1; Projectile; -ACTIVATEIMPACT -ACTIVATEMCROSS +SEEKERMISSILE +EXPLOCOUNT +StepMissile RenderStyle "Translucent"; DefThreshold 60; Threshold 50; Alpha 0.4; } States { Spawn: FX07 DEFG 3; FX07 ABC 3 A_WhirlwindSeek; Goto Spawn+4; Death: FX07 GFED 4; Stop; } override int DoSpecialDamage (Actor target, int damage, Name damagetype) { int randVal; if (!target.bDontThrust) { target.angle += Random2[WhirlwindDamage]() * (360 / 4096.); target.Vel.X += Random2[WhirlwindDamage]() / 64.; target.Vel.Y += Random2[WhirlwindDamage]() / 64.; } if ((Level.maptime & 16) && !target.bBoss && !target.bDontThrust) { randVal = min(160, random[WhirlwindSeek]()); target.Vel.Z += randVal / 32.; if (target.Vel.Z > 12) { target.Vel.Z = 12; } } if (!(Level.maptime & 7)) { target.DamageMobj (null, target, 3, 'Melee'); } return -1; } //---------------------------------------------------------------------------- // // PROC A_WhirlwindSeek // //---------------------------------------------------------------------------- void A_WhirlwindSeek() { health -= 3; if (health < 0) { Vel = (0,0,0); SetStateLabel("Death"); bMissile = false; return; } if ((threshold -= 3) < 0) { threshold = random[WhirlwindSeek](58, 89); A_StartSound("ironlich/attack3", CHAN_BODY); } if (tracer && tracer.bShadow) { return; } A_SeekerMissile(10, 30); } } /***************************************************************************/ // // shown for respawning Doom and Strife items // /***************************************************************************/ class ItemFog : Actor { default { +NOBLOCKMAP +NOGRAVITY } States { Spawn: IFOG ABABCDE 6 BRIGHT; Stop; } } // Pickup flash ------------------------------------------------------------- class PickupFlash : Actor { default { +NOGRAVITY } States { Spawn: ACLO DCDCBCBABA 3; Stop; } } /* ** joystickmenu.cpp ** The joystick configuration menus ** **--------------------------------------------------------------------------- ** Copyright 2010-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ //============================================================================= // // // //============================================================================= class OptionMenuSliderJoySensitivity : OptionMenuSliderBase { JoystickConfig mJoy; OptionMenuSliderJoySensitivity Init(String label, double min, double max, double step, int showval, JoystickConfig joy) { Super.Init(label, min, max, step, showval); mJoy = joy; return self; } override double GetSliderValue() { return mJoy.GetSensitivity(); } override void SetSliderValue(double val) { mJoy.SetSensitivity(val); } } //============================================================================= // // // //============================================================================= class OptionMenuSliderJoyScale : OptionMenuSliderBase { int mAxis; int mNeg; JoystickConfig mJoy; OptionMenuSliderJoyScale Init(String label, int axis, double min, double max, double step, int showval, JoystickConfig joy) { Super.Init(label, min, max, step, showval); mAxis = axis; mNeg = 1; mJoy = joy; return self; } override double GetSliderValue() { double d = mJoy.GetAxisScale(mAxis); mNeg = d < 0? -1:1; return d; } override void SetSliderValue(double val) { mJoy.SetAxisScale(mAxis, val * mNeg); } } //============================================================================= // // // //============================================================================= class OptionMenuSliderJoyDeadZone : OptionMenuSliderBase { int mAxis; int mNeg; JoystickConfig mJoy; OptionMenuSliderJoyDeadZone Init(String label, int axis, double min, double max, double step, int showval, JoystickConfig joy) { Super.Init(label, min, max, step, showval); mAxis = axis; mNeg = 1; mJoy = joy; return self; } override double GetSliderValue() { double d = mJoy.GetAxisDeadZone(mAxis); mNeg = d < 0? -1:1; return d; } override void SetSliderValue(double val) { mJoy.SetAxisDeadZone(mAxis, val * mNeg); } } //============================================================================= // // // //============================================================================= class OptionMenuItemJoyMap : OptionMenuItemOptionBase { int mAxis; JoystickConfig mJoy; OptionMenuItemJoyMap Init(String label, int axis, Name values, int center, JoystickConfig joy) { Super.Init(label, 'none', values, null, center); mAxis = axis; mJoy = joy; return self; } override int GetSelection() { double f = mJoy.GetAxisMap(mAxis); let opt = OptionValues.GetCount(mValues); if (opt > 0) { // Map from joystick axis to menu selection. for(int i = 0; i < opt; i++) { if (f ~== OptionValues.GetValue(mValues, i)) { return i; } } } return -1; } override void SetSelection(int selection) { let opt = OptionValues.GetCount(mValues); // Map from menu selection to joystick axis. if (opt == 0 || selection >= opt) { selection = JoystickConfig.JOYAXIS_None; } else { selection = int(OptionValues.GetValue(mValues, selection)); } mJoy.SetAxisMap(mAxis, selection); } } //============================================================================= // // // //============================================================================= class OptionMenuItemInverter : OptionMenuItemOptionBase { int mAxis; JoystickConfig mJoy; OptionMenuItemInverter Init(String label, int axis, int center, JoystickConfig joy) { Super.Init(label, "none", "YesNo", NULL, center); mAxis = axis; mJoy = joy; return self; } override int GetSelection() { float f = mJoy.GetAxisScale(mAxis); return f > 0? 0:1; } override void SetSelection(int Selection) { let f = abs(mJoy.GetAxisScale(mAxis)); if (Selection) f*=-1; mJoy.SetAxisScale(mAxis, f); } } //============================================================================= // // Executes a CCMD, action is a CCMD name // //============================================================================= class OptionMenuJoyEnable : OptionMenuItemOptionBase { JoystickConfig mJoy; OptionMenuJoyEnable Init(String label, JoystickConfig joy) { Super.Init(label,"none","YesNo",null,0); mJoy = joy; return self; } override int GetSelection() { return mJoy.GetEnabled() ? 1 : 0; } override void SetSelection(int Selection) { mJoy.SetEnabled(Selection); } } class OptionMenuItemJoyConfigMenu : OptionMenuItemSubmenu { JoystickConfig mJoy; OptionMenuItemJoyConfigMenu Init(String label, JoystickConfig joy) { Super.Init(label, "JoystickConfigMenu"); mJoy = joy; return self; } override bool Activate() { let desc = OptionMenuDescriptor(MenuDescriptor.GetDescriptor('JoystickConfigMenu')); if (desc != NULL) { SetController(OptionMenuDescriptor(desc), mJoy); } let res = Super.Activate(); let joymenu = JoystickConfigMenu(Menu.GetCurrentMenu()); if (res && joymenu != null) joymenu.mJoy = mJoy; return res; } static void SetController(OptionMenuDescriptor opt, JoystickConfig joy) { OptionMenuItem it; opt.mItems.Clear(); if (joy == NULL) { opt.mTitle = "$JOYMNU_CONFIG"; it = new("OptionMenuItemStaticText").Init("$JOYMNU_INVALID", false); opt.mItems.Push(it); } else { it = new("OptionMenuItemStaticText").Init(joy.GetName(), false); it = new("OptionMenuItemStaticText").Init("", false); it = new("OptionMenuJoyEnable").Init("$JOYMNU_JOYENABLE", joy); opt.mItems.Push(it); it = new("OptionMenuSliderJoySensitivity").Init("$JOYMNU_OVRSENS", 0, 2, 0.1, 3, joy); opt.mItems.Push(it); it = new("OptionMenuItemStaticText").Init(" ", false); opt.mItems.Push(it); if (joy.GetNumAxes() > 0) { it = new("OptionMenuItemStaticText").Init("$JOYMNU_AXIS", true); opt.mItems.Push(it); for (int i = 0; i < joy.GetNumAxes(); ++i) { it = new("OptionMenuItemStaticText").Init(" ", false); opt.mItems.Push(it); it = new("OptionMenuItemJoyMap").Init(joy.GetAxisName(i), i, "JoyAxisMapNames", false, joy); opt.mItems.Push(it); it = new("OptionMenuSliderJoyScale").Init("$JOYMNU_OVRSENS", i, 0, 4, 0.1, 3, joy); opt.mItems.Push(it); it = new("OptionMenuItemInverter").Init("$JOYMNU_INVERT", i, false, joy); opt.mItems.Push(it); it = new("OptionMenuSliderJoyDeadZone").Init("$JOYMNU_DEADZONE", i, 0, 0.9, 0.05, 3, joy); opt.mItems.Push(it); } } else { it = new("OptionMenuItemStaticText").Init("$JOYMNU_NOAXES", false); opt.mItems.Push(it); } } opt.mScrollPos = 0; opt.mSelectedItem = -1; opt.mIndent = 0; opt.mPosition = -25; opt.CalcIndent(); } } //============================================================================= // // // //============================================================================= class JoystickConfigMenu : OptionMenu { JoystickConfig mJoy; } //=========================================================================== // // Commander Keen // //=========================================================================== class CommanderKeen : Actor { Default { Health 100; Radius 16; Height 72; Mass 10000000; PainChance 256; +SOLID +SPAWNCEILING +NOGRAVITY +SHOOTABLE +COUNTKILL +NOICEDEATH +ISMONSTER PainSound "keen/pain"; DeathSound "keen/death"; } States { Spawn: KEEN A -1; Loop; Death: KEEN AB 6; KEEN C 6 A_Scream; KEEN DEFGH 6; KEEN I 6; KEEN J 6; KEEN K 6 A_KeenDie; KEEN L -1; Stop; Pain: KEEN M 4; KEEN M 8 A_Pain; Goto Spawn; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== extend class Actor { // // A_KeenDie // DOOM II special, map 32. // Uses special tag 666 by default. // void A_KeenDie(int doortag = 666) { A_NoBlocking(false); // scan the remaining thinkers to see if all Keens are dead ThinkerIterator it = ThinkerIterator.Create(GetClass()); Actor mo; while (mo = Actor(it.Next(true))) { if (mo.health > 0 && mo != self) { // Added check for Dehacked and repurposed inventory items. let inv = Inventory(mo); if (inv == null || inv.Owner == null) { // other Keen not dead return; } } } Door_Open(doortag, 16); } } // Klaxon Warning Light ----------------------------------------------------- class KlaxonWarningLight : Actor { Default { ReactionTime 60; Radius 5; +NOBLOCKMAP +AMBUSH +SPAWNCEILING +NOGRAVITY +FIXMAPTHINGPOS +NOSPLASHALERT +SYNCHRONIZED } States { Spawn: KLAX A 5 A_TurretLook; Loop; See: KLAX B 6 A_KlaxonBlare; KLAX C 60; Loop; } } // CeilingTurret ------------------------------------------------------------ class CeilingTurret : Actor { Default { Health 125; Speed 0; Painchance 0; Mass 10000000; Monster; -SOLID -CANPASS +AMBUSH +SPAWNCEILING +NOGRAVITY +NOBLOOD +NOSPLASHALERT +DONTFALL MinMissileChance 150; Tag "$TAG_CEILINGTURRET"; Obituary "$OB_TURRET"; DeathSound "turret/death"; } States { Spawn: TURT A 5 A_TurretLook; Loop; See: TURT A 2 A_Chase; Loop; Missile: Pain: TURT B 4 Slow A_ShootGun; TURT D 3 Slow A_SentinelRefire; TURT A 4 A_SentinelRefire; Loop; Death: BALL A 6 Bright A_Scream; BALL BCDE 6 Bright; TURT C -1; Stop; } } extend class Actor { void A_TurretLook() { if (bInConversation) return; threshold = 0; Actor targ = LastHeard; if (targ != NULL && targ.health > 0 && targ.bShootable && !IsFriend(targ)) { target = targ; if (bAmbush && !CheckSight (targ)) { return; } if (SeeSound != 0) { A_StartSound (SeeSound, CHAN_VOICE); } LastHeard = NULL; threshold = 10; SetState (SeeState); } } void A_KlaxonBlare() { if (--reactiontime < 0) { target = NULL; reactiontime = Default.reactiontime; A_TurretLook(); if (target == NULL) { SetIdle(); } else { reactiontime = 50; } } if (reactiontime == 2) { // [RH] Unalert monsters near the alarm and not just those in the same sector as it. SoundAlert (NULL, false); } else if (reactiontime > 50) { A_StartSound ("misc/alarm", CHAN_VOICE); } } } // Knight ------------------------------------------------------------------- class Knight : Actor { Default { Health 200; Radius 24; Height 78; Mass 150; Speed 12; Painchance 100; Monster; +FLOORCLIP SeeSound "hknight/sight"; AttackSound "hknight/attack"; PainSound "hknight/pain"; DeathSound "hknight/death"; ActiveSound "hknight/active"; Obituary "$OB_BONEKNIGHT"; HitObituary "$OB_BONEKNIGHTHIT"; Tag "$FN_BONEKNIGHT"; DropItem "CrossbowAmmo", 84, 5; } States { Spawn: KNIG AB 10 A_Look; Loop; See: KNIG ABCD 4 A_Chase; Loop; Melee: Missile: KNIG E 10 A_FaceTarget; KNIG F 8 A_FaceTarget; KNIG G 8 A_KnightAttack; KNIG E 10 A_FaceTarget; KNIG F 8 A_FaceTarget; KNIG G 8 A_KnightAttack; Goto See; Pain: KNIG H 3; KNIG H 3 A_Pain; Goto See; Death: KNIG I 6; KNIG J 6 A_Scream; KNIG K 6; KNIG L 6 A_NoBlocking; KNIG MN 6; KNIG O -1; Stop; } //---------------------------------------------------------------------------- // // PROC A_KnightAttack // //---------------------------------------------------------------------------- void A_KnightAttack () { let targ = target; if (!targ) return; if (CheckMeleeRange ()) { int damage = random[KnightAttack](1, 8) * 3; int newdam = targ.DamageMobj (self, self, damage, 'Melee'); targ.TraceBleed (newdam > 0 ? newdam : damage, self); A_StartSound ("hknight/melee", CHAN_BODY); return; } // Throw axe A_StartSound (AttackSound, CHAN_BODY); if (self.bShadow || random[KnightAttack]() < 40) { // Red axe SpawnMissileZ (pos.Z + 36, targ, "RedAxe"); } else { // Green axe SpawnMissileZ (pos.Z + 36, targ, "KnightAxe"); } } } // Knight ghost ------------------------------------------------------------- class KnightGhost : Knight { Default { +SHADOW +GHOST RenderStyle "Translucent"; Alpha 0.4; } } // Knight axe --------------------------------------------------------------- class KnightAxe : Actor { Default { Radius 10; Height 8; Speed 9; FastSpeed 18; Damage 2; Projectile; -NOBLOCKMAP -ACTIVATEIMPACT -ACTIVATEPCROSS +WINDTHRUST +THRUGHOST DeathSound "hknight/hit"; } States { Spawn: SPAX A 3 BRIGHT A_StartSound("hknight/axewhoosh"); SPAX BC 3 BRIGHT; Loop; Death: SPAX DEF 6 BRIGHT; Stop; } } // Red axe ------------------------------------------------------------------ class RedAxe : KnightAxe { Default { +NOBLOCKMAP -WINDTHRUST Damage 7; } States { Spawn: RAXE AB 5 BRIGHT A_DripBlood; Loop; Death: RAXE CDE 6 BRIGHT; Stop; } //---------------------------------------------------------------------------- // // PROC A_DripBlood // //---------------------------------------------------------------------------- void A_DripBlood () { double xo = random2[DripBlood]() / 32.0; double yo = random2[DripBlood]() / 32.0; Actor mo = Spawn ("Blood", Vec3Offset(xo, yo, 0.), ALLOW_REPLACE); if (mo != null) { mo.Vel.X = random2[DripBlood]() / 64.0; mo.Vel.Y = random2[DripBlood]() / 64.0; mo.Gravity = 1./8; } } } //=========================================================================== // Korax Variables // tracer last teleport destination // special2 set if "below half" script not yet run // // Korax Scripts (reserved) // 249 Tell scripts that we are below half health // 250-254 Control scripts (254 is only used when less than half health) // 255 Death script // // Korax TIDs (reserved) // 245 Reserved for Korax himself // 248 Initial teleport destination // 249 Teleport destination // 250-254 For use in respective control scripts // 255 For use in death script (spawn spots) //=========================================================================== class Korax : Actor { const KORAX_ARM_EXTENSION_SHORT = 40; const KORAX_ARM_EXTENSION_LONG = 55; const KORAX_ARM1_HEIGHT = 108; const KORAX_ARM2_HEIGHT = 82; const KORAX_ARM3_HEIGHT = 54; const KORAX_ARM4_HEIGHT = 104; const KORAX_ARM5_HEIGHT = 86; const KORAX_ARM6_HEIGHT = 53; const KORAX_FIRST_TELEPORT_TID = 248; const KORAX_TELEPORT_TID = 249; const KORAX_DELTAANGLE = 85; const KORAX_COMMAND_HEIGHT = 120; const KORAX_COMMAND_OFFSET = 27; const KORAX_SPIRIT_LIFETIME = 5*TICRATE/5; // 5 seconds Default { Health 5000; Painchance 20; Speed 10; Radius 65; Height 115; Mass 2000; Damage 15; Monster; +BOSS +FLOORCLIP +TELESTOMP +DONTMORPH +NOTARGET +NOICEDEATH SeeSound "KoraxSight"; AttackSound "KoraxAttack"; PainSound "KoraxPain"; DeathSound "KoraxDeath"; ActiveSound "KoraxActive"; Obituary "$OB_KORAX"; Tag "$FN_KORAX"; } States { Spawn: KORX A 5 A_Look; Loop; See: KORX AAA 3 A_KoraxChase; KORX B 3 A_Chase; KORX BBB 3 A_KoraxChase; KORX C 3 A_KoraxStep; KORX CCC 3 A_KoraxChase; KORX D 3 A_Chase; KORX DDD 3 A_KoraxChase; KORX A 3 A_KoraxStep; Loop; Pain: KORX H 5 A_Pain; KORX H 5; Goto See; Missile: KORX E 2 Bright A_FaceTarget; KORX E 5 Bright A_KoraxDecide; Wait; Death: KORX I 5; KORX J 5 A_FaceTarget; KORX K 5 A_Scream; KORX LMNOP 5; KORX Q 10; KORX R 5 A_KoraxBonePop; KORX S 5 A_NoBlocking; KORX TU 5; KORX V -1; Stop; Attack: KORX E 4 Bright A_FaceTarget; KORX F 8 Bright A_KoraxMissile; KORX E 8 Bright; Goto See; Command: KORX E 5 Bright A_FaceTarget; KORX W 10 Bright A_FaceTarget; KORX G 15 Bright A_KoraxCommand; KORX W 10 Bright; KORX E 5 Bright; Goto See; } void A_KoraxStep() { A_StartSound("KoraxStep"); A_Chase(); } //============================================================================ // // A_KoraxChase // //============================================================================ void A_KoraxChase() { if ((!special2) && (health <= (SpawnHealth()/2))) { ActorIterator it = Level.CreateActorIterator(KORAX_FIRST_TELEPORT_TID); Actor spot = it.Next (); if (spot != null) { Teleport ((spot.pos.xy, ONFLOORZ), spot.angle, TELF_SOURCEFOG | TELF_DESTFOG); } ACS_Execute(249, 0); special2 = 1; // Don't run again return; } if (target == null) { return; } if (random[KoraxChase]() < 30) { SetState (MissileState); } else if (random[KoraxChase]() < 30) { A_StartSound("KoraxActive", CHAN_VOICE, CHANF_DEFAULT, 1., ATTN_NONE); } // Teleport away if (health < (SpawnHealth() >> 1)) { if (random[KoraxChase]() < 10) { ActorIterator it = Level.CreateActorIterator(KORAX_TELEPORT_TID); Actor spot; if (tracer != null) { // Find the previous teleport destination do { spot = it.Next (); } while (spot != null && spot != tracer); } // Go to the next teleport destination spot = it.Next (); tracer = spot; if (spot) { Teleport ((spot.pos.xy, ONFLOORZ), spot.angle, TELF_SOURCEFOG | TELF_DESTFOG); } } } } //============================================================================ // // A_KoraxDecide // //============================================================================ void A_KoraxDecide() { if (random[KoraxDecide]() < 220) { SetStateLabel ("Attack"); } else { SetStateLabel ("Command"); } } //============================================================================ // // A_KoraxBonePop // //============================================================================ void A_KoraxBonePop() { // Spawn 6 spirits equalangularly for (int i = 0; i < 6; ++i) { Actor mo = SpawnMissileAngle ("KoraxSpirit", 60.*i, 5.); if (mo) { KSpiritInit (mo); } } ACS_Execute(255, 0); } //============================================================================ // // KSpiritInit // //============================================================================ private void KSpiritInit (Actor spirit) { spirit.health = KORAX_SPIRIT_LIFETIME; spirit.tracer = self; // Swarm around korax spirit.WeaveIndexZ = random[Kspiritnit](32, 39); // Float bob index spirit.args[0] = 10; // initial turn value spirit.args[1] = 0; // initial look angle // Spawn a tail for spirit HolyTail.SpawnSpiritTail (spirit); } //============================================================================ // // A_KoraxMissile // //============================================================================ void A_KoraxMissile() { if (!target) { return; } static const class choices[] = { "WraithFX1", "Demon1FX1", "Demon2FX1", "FireDemonMissile", "CentaurFX", "SerpentFX" }; static const sound sounds[] = { "WraithMissileFire", "DemonMissileFire", "DemonMissileFire", "FireDemonAttack", "CentaurLeaderAttack", "SerpentLeaderAttack" }; int type = random[KoraxMissile](0, 5); A_StartSound("KoraxAttack", CHAN_VOICE); // Fire all 6 missiles at once A_StartSound(sounds[type], CHAN_WEAPON, CHANF_DEFAULT, 1., ATTN_NONE); class info = choices[type]; for (int i = 0; i < 6; ++i) { KoraxFire(info, i); } } //============================================================================ // // KoraxFire // // Arm projectiles // arm positions numbered: // 1 top left // 2 middle left // 3 lower left // 4 top right // 5 middle right // 6 lower right // //============================================================================ void KoraxFire (Class type, int arm) { if (!target) { return; } static const int extension[] = { KORAX_ARM_EXTENSION_SHORT, KORAX_ARM_EXTENSION_LONG, KORAX_ARM_EXTENSION_LONG, KORAX_ARM_EXTENSION_SHORT, KORAX_ARM_EXTENSION_LONG, KORAX_ARM_EXTENSION_LONG }; static const int armheight[] = { KORAX_ARM1_HEIGHT, KORAX_ARM2_HEIGHT, KORAX_ARM3_HEIGHT, KORAX_ARM4_HEIGHT, KORAX_ARM5_HEIGHT, KORAX_ARM6_HEIGHT }; double ang = angle + (arm < 3 ? -KORAX_DELTAANGLE : KORAX_DELTAANGLE); Vector3 pos = Vec3Angle(extension[arm], ang, armheight[arm] - Floorclip); SpawnKoraxMissile (pos, target, type); } //============================================================================ // // P_SpawnKoraxMissile // //============================================================================ private void SpawnKoraxMissile (Vector3 pos, Actor dest, Class type) { Actor th = Spawn (type, pos, ALLOW_REPLACE); if (th != null) { th.target = self; // Originator double an = th.AngleTo(dest); if (dest.bShadow) { // Invisible target an += Random2[KoraxMissile]() * (45/256.); } th.angle = an; th.VelFromAngle(); double dist = dest.DistanceBySpeed(th, th.Speed); th.Vel.Z = (dest.pos.z - pos.Z + 30) / dist; th.CheckMissileSpawn(radius); } } //============================================================================ // // A_KoraxCommand // // Call action code scripts (250-254) // //============================================================================ void A_KoraxCommand() { int numcommands; A_StartSound("KoraxCommand", CHAN_VOICE); // Shoot stream of lightning to ceiling double ang = angle - 90; Vector3 pos = Vec3Angle(KORAX_COMMAND_OFFSET, ang, KORAX_COMMAND_HEIGHT); Spawn("KoraxBolt", pos, ALLOW_REPLACE); if (health <= (SpawnHealth() >> 1)) { numcommands = 4; } else { numcommands = 3; } ACS_Execute(250 + (random[KoraxCommand](0, numcommands)), 0); } } class KoraxSpirit : Actor { Default { Speed 8; Projectile; +NOCLIP -ACTIVATEPCROSS -ACTIVATEIMPACT RenderStyle "Translucent"; Alpha 0.4; } States { Spawn: SPIR AB 5 A_KSpiritRoam; Loop; Death: SPIR DEFGHI 5; Stop; } //============================================================================ // // A_KSpiritSeeker // //============================================================================ private void KSpiritSeeker (double thresh, double turnMax) { Actor target = tracer; if (target == null) { return; } double dir = deltaangle(angle, AngleTo(target)); double delta = abs(dir); if (delta > thresh) { delta /= 2; if(delta > turnMax) { delta = turnMax; } } if(dir > 0) { // Turn clockwise angle += delta; } else { // Turn counter clockwise angle -= delta; } VelFromAngle(); if (!(Level.maptime&15) || pos.z > target.pos.z + target.Default.Height || pos.z + height < target.pos.z) { double newZ = target.pos.z + random[KoraxRoam]() * target.Default.Height / 256; double deltaZ = newZ - pos.z; if (abs(deltaZ) > 15) { if(deltaZ > 0) { deltaZ = 15; } else { deltaZ = -15; } } Vel.Z = deltaZ + DistanceBySpeed(target, Speed); } } //============================================================================ // // A_KSpiritRoam // //============================================================================ void A_KSpiritRoam() { if (health-- <= 0) { A_StartSound("SpiritDie", CHAN_VOICE); SetStateLabel ("Death"); } else { if (tracer) { KSpiritSeeker(args[0], args[0] * 2.); } int xyspeed = random[KoraxRoam](0, 4); int zspeed = random[KoraxRoam](0, 4); A_Weave(xyspeed, zspeed, 4., 2.); if (random[KoraxRoam]() < 50) { A_StartSound("SpiritActive", CHAN_VOICE, CHANF_DEFAULT, 1., ATTN_NONE); } } } } class KoraxBolt : Actor { const KORAX_BOLT_HEIGHT = 48.; const KORAX_BOLT_LIFETIME = 3; Default { Radius 15; Height 35; Projectile; -ACTIVATEPCROSS -ACTIVATEIMPACT RenderStyle "Add"; } States { Spawn: MLFX I 2 Bright; MLFX J 2 Bright A_KBoltRaise; MLFX IJKLM 2 Bright A_KBolt; Stop; } //============================================================================ // // A_KBolt // //============================================================================ void A_KBolt() { // Countdown lifetime if (special1-- <= 0) { Destroy (); } } //============================================================================ // // A_KBoltRaise // //============================================================================ void A_KBoltRaise() { // Spawn a child upward double z = pos.z + KORAX_BOLT_HEIGHT; if ((z + KORAX_BOLT_HEIGHT) < ceilingz) { Actor mo = Spawn("KoraxBolt", (pos.xy, z), ALLOW_REPLACE); if (mo) { mo.special1 = KORAX_BOLT_LIFETIME; } } } } class LevelCompatibility : LevelPostProcessor { protected void Apply(Name checksum, String mapname) { switch (checksum) { case 'none': return; case '9BC9E12781903D7C2D5697A5E0AEFD6F': // HACX.WAD map05 from 21.10.2010 case '9527DD0809FDA39CCFC316A21D135783': // HACX.WAD map05 from 20.10.2010 { // fix non-functional self-referencing sector hack. for(int i = 578; i < 582; i++) SetLineSectorRef(i, Line.back, 91); for(int i = 707; i < 714; i++) SetLineSectorRef(i, Line.back, 91); SetLineSectorRef(736, Line.front, 91); SetLineSectorRef(659, Line.front, 91); SetLineSpecial(659, Transfer_Heights, 60); break; } case 'E2B5D1400279335811C1C1C0B437D9C8': // Deathknights of the Dark Citadel, map54 { // This map has two gear boxes which are flagged for player cross // activation instead of the proper player uses activation. SetLineActivation(943, SPAC_Use); SetLineActivation(963, SPAC_Use); break; } case '3F249EDD62A3A08F53A6C53CB4C7ABE5': // Artica 3 map01 { ClearLineSpecial(66); break; } case 'F481922F4881F74760F3C0437FD5EDD0': // Community Chest 3 map03 { // I have no idea how this conveyor belt setup manages to work under Boom. // Set the sector the voodoo doll ends up standing on when sectors tagged // 1 are raised so that the voodoo doll will be carried. SetLineSpecial(3559, Sector_CopyScroller, 17, 6); break; } case '5B862477519B21B30059A466F2FF6460': // Khorus, map08 { // This map uses a voodoo conveyor with slanted walls to shunt the // voodoo doll into side areas. For some reason, this voodoo doll // is unable to slide on them, because the slide calculation gets // them slightly inside the walls and thinks they are stuck. I could // not reproduce this with the real player, which is what has me // stumped. So, help them out be attaching some ThrustThing specials // to the walls. SetLineSpecial(443, ThrustThing, 96, 4); SetLineFlags(443, Line.ML_REPEAT_SPECIAL); SetLineActivation(443, SPAC_Push); SetLineSpecial(455, ThrustThing, 96, 4); SetLineFlags(455, Line.ML_REPEAT_SPECIAL); SetLineActivation(455, SPAC_Push); break; } case '3D1E36E50F5A8D289E15433941605224': // Master Levels, catwalk.wad { // make it impossible to open door to 1-way bridge before getting red key ClearSectorTags(35); AddSectorTag(35, 15); for(int i=605; i<609;i++) { SetLineActivation(i, SPAC_Cross); SetLineSpecial(i, Door_Open, 15, 64); } break; } case '3B9CAA02952F405269353FAAD8F8EC33': // Master Levels, nessus.wad { // move secret sector from too-thin doorframe to BFG closet SetSectorSpecial(211, 0); SetSectorSpecial(212, 1024); // lower floor a bit so secret sector can be entered fully OffsetSectorPlane(212, Sector.floor, -16); // make secret door stay open so you can't get locked in closet SetLineSpecial(1008, Door_Open, 0, 64); break; } case '7ED9800213C00D6E7FB98652AB48B3DE': // Ultimate Simplicity, map04 { // Add missing map spots on easy and medium skills // Demons will teleport into starting room making 100% kills possible SetThingSkills(31, 31); SetThingSkills(32, 31); break; } case '1891E029994B023910CFE0B3209C3CDB': // Ultimate Simplicity, map07 { // It is possible to get stuck on skill 0 or 1 when no shots have been fired // after sector 17 became accessible and before entering famous mancubus room. // Monsters from the mentioned sector won't be alerted and so // they won't teleport into the battle. ACS will wait forever for their deaths. SetLineSpecial(397, NoiseAlert); SetLineSpecial(411, NoiseAlert); break; } case 'F0E6F30F57B0425F17E43600AA813E80': // Ultimate Simplicity, map11 { // If door (sector #309) is closed it cannot be open again // from one side potentially blocking level progression ClearLineSpecial(2445); break; } case '952CC8D03572E17BA550B01B366EFBB9': // Cheogsh map01 { // make the blue key spawn above the 3D floor SetThingZ(918, 296); break; } case 'D62DCA9EC226DE49108D5DD9271F7631': // Cheogsh 2 map04 { // Stuff in megasphere cage is positioned too low for(int i=1640; i<=1649; i++) { SetThingZ(i, 528); } break; } case '0F898F0688AECD42F2CD102FAE06F271': // TNT: Evilution MAP07 { // Dropping onto the outdoor lava now also raises the // triangle sectors. SetLineSpecial(320, Floor_RaiseToNearest, 16, 32); SetLineActivation(320, SPAC_Cross); SetLineSpecial(959, Floor_RaiseToNearest, 16, 32); SetLineActivation(959, SPAC_Cross); SetLineSpecial(960, Floor_RaiseToNearest, 16, 32); SetLineActivation(960, SPAC_Cross); // Dropping into the holes themselves raises sectors for(int i=0; i<9; i++) { SetLineSpecial(999+i, Floor_RaiseToNearest, 16, 32); SetLineActivation(999+i, SPAC_Cross); } break; } case '1E785E841A5247B6223C042EC712EBB3': // TNT: Evilution MAP08 { // Missing texture when lowering sector to red keycard SetWallTexture(480, Line.back, Side.bottom, "METAL2"); break; } case 'DFC18B92BF3E8142B8684ECD8BD2EF06': // TNT: Evilution map15 { // raise up sector with its counterpart so 100% kills becomes possible AddSectorTag(330, 11); break; } case '55C8DA7B531AE47014AD73FFF4687A36': // TNT: Evilution MAP21 { // Missing texture that is most likely unintentional SetWallTexture(1138, Line.front, Side.top, "PANEL4"); break; } case '2C4A3356C5EB3526D2C72A4AA4B18A36': // TNT: Evilution map29 { // remove mancubus who always gets stuck in teleport tunnel, preventing // 100% kills on HMP SetThingFlags(405, 0); break; } case 'A53AE580A4AF2B5D0B0893F86914781E': // TNT: Evilution map31 case '55192065F7FAA7D161767145DA008293': // TNT Anthology/GOG MAP31 { // The famous missing yellow key... SetThingFlags(470, 2016); // Fix textures on the two switches that rise from the floor in the eastern area for (int i = 0; i < 8; i++) { SetLineFlags(1676 + i, 0, Line.ML_DONTPEGBOTTOM); } break; } case 'D99AD22FF21A41B4EECDB3A7C803D75E': // TNT: Evilution map32 { // door can close permanently; make switch that opens it repeatable SetLineFlags(872, Line.ML_REPEAT_SPECIAL); // switch should only open way to red key, don't lower bars yet, // instead make line just before red key open bars ClearSectorTags(197); AddSectorTag(197, 8); SetLineSpecial(1279, Floor_LowerToLowest, 8, 32); SetLineActivation(1240, SPAC_Cross); SetLineSpecial(1240, Floor_LowerToLowest, 38, 32); break; } case '56D4060662C290791822EDB7225273B7': // Plutonia Experiment MAP08 { // Raising ceiling causing a HOM. OffsetSectorPlane(130, Sector.ceiling, 16); break; } case '25A16C30CD10157382C01E5DD9C6604B': // Plutonia Experiment MAP10 { // Missing textures SetWallTexture(548, Line.front, Side.bottom, "METAL"); SetSectorTexture(71, Sector.ceiling, "FLOOR7_1"); SetWallTexture(1010, Line.front, Side.top, "GSTONE1"); break; } case '1EF7DEAECA03DE03BF363A3193757B5C': // PLUTONIA.wad map11 { SetLineSectorRef(41, Line.back, 6); break; } case 'B02ACA32AE9630042543037BA630CDE9': // Plutonia Experiment MAP13 { // Textures on wrong side at level start. SetWallTexture(107, Line.back, Side.top, "A-BROWN1"); SetWallTexture(119, Line.back, Side.top, "A-BROWN1"); break; } case 'ECA0559E85EFFB6966ECB8DE01E3A35B': // Plutonia Experiment MAP16 { // Have it so that the slime pit at the end of the level can // actually kill the player. SetSectorSpecial(95, 768); SetSectorSpecial(96, 768); break; } case '9D84B423D8FD28553DDE23B55F97CF4A': // Plutonia Experiment MAP25 { // Missing texture at level exit. SetWallTexture(1152, Line.front, Side.top, "A-BROCK2"); break; } case 'ABC4EB5A1535ECCD0061AD14F3547908': // Plutonia Experiment, map26 { SetSectorSpecial(156, 0); // Missing textures SetWallTexture(322, Line.front, Side.top, "A-MUD"); SetWallTexture(323, Line.front, Side.top, "A-MUD"); break; } case 'A2634C462717328CC1AD81E81EE77B08': // Plutonia Experiment MAP28 { // Missing textures SetWallTexture(675, Line.front, Side.bottom, "BRICK10"); SetWallTexture(676, Line.front, Side.bottom, "BRICK10"); SetWallTexture(834, Line.front, Side.bottom, "WOOD8"); SetWallTexture(835, Line.front, Side.bottom, "WOOD8"); SetWallTexture(2460, Line.front, Side.top, "BIGDOOR7"); SetWallTexture(2496, Line.front, Side.top, "BRICK10"); // Allow a player to leave the room in deathmatch without // needing another player to activate a switch. SetLineSpecial(1033, Floor_LowerToLowest, 10, 8); SetLineActivation(1033, SPAC_Use); break; } case '850AC6D62F0AC57A4DD7EBC2689AC38E': // Plutonia Experiment MAP29 { // Texture applied on bottom instead of top SetWallTexture(2842, Line.front, Side.top, "A-BROCK2"); break; } case '279BB50468FE9F5B36C6D821E4902369': // Plutonia Experiment map30 { // Missing texture and unpegged gate texture during boss reveal SetWallTexture(730, Line.front, Side.bottom, "ROCKRED1"); SetLineFlags(730, 0, Line.ML_DONTPEGBOTTOM); // flag items in deathmatch-only area correctly so that 100% items // are possible in solo SetThingFlags(250, 17); SetThingFlags(251, 17); SetThingFlags(252, 17); SetThingFlags(253, 17); SetThingFlags(254, 17); SetThingFlags(206, 17); break; } case 'D5F64E02679A81B82006AF34A6A8EAC3': // Plutonia Experiment MAP32 { // Missing textures TextureID mosrok = TexMan.CheckForTexture("A-MOSROK", TexMan.Type_Wall); for(int i=0; i<4; i++) { SetWallTextureID(569+i, Line.front, Side.top, MOSROK); } SetWallTexture(805, Line.front, Side.top, "A-BRICK3"); break; } case '3B68019EE3154C284B90F0CAEDBD8D8A': // Plutonia 2 MAP05 { // Missing texture TextureID step1 = TexMan.CheckForTexture("STEP1", TexMan.Type_Wall); SetWallTextureID(1525, Line.front, Side.bottom, step1); break; } case 'FB613B36589FFB09AA2C03633A7D13F4': // Plutonia 2 MAP20 { // Remove the pain elementals stuck in the closet boxes that cannot teleport. SetThingFlags(758,0); SetThingFlags(759,0); SetThingFlags(764,0); SetThingFlags(765,0); break; } case 'A3165C53F9BF0B7D80CDB14665A349EB': // Plutonia 2 MAP23 { // Arch-vile in outdoor secret area sometimes don't spawn if revenants // block its one-time teleport. Make this teleport repeatable to ensure // maxkills are always possible. SetLineFlags(756, Line.ML_REPEAT_SPECIAL); break; } case '9191658A6705B131AB005948E2FDFCE1': // Plutonia 2 MAP24 { // Fix improperly pegged blue door for(int i = 957; i <= 958; i++) { SetLineFlags(i, 0, Line.ML_DONTPEGTOP); level.lines[i].sidedef[0].SetTextureYOffset(Side.top,-24); } break; } case 'EF251B8F36DE709901B0D32A97F341D7': // Plutonia 2 MAP27 { // Remove the monsters stuck in the closet boxes that cannot teleport. // Top row, 2nd from left SetThingFlags(156,0); SetThingFlags(210,0); SetThingFlags(211,0); // 2nd row, 2nd-5th from left for(int i = 242; i <= 249; i++) SetThingFlags(i,0); // 3rd row, rightmost box SetThingFlags(260,0); SetThingFlags(261,0); SetThingFlags(266,0); SetThingFlags(271,0); SetThingFlags(272,0); SetThingFlags(277,0); SetThingFlags(278,0); SetThingFlags(283,0); break; } case '4CB7AAC5C43CF32BDF05FD36481C1D9F': // Plutonia: Revisited map27 { SetLineSpecial(1214, Plat_DownWaitUpStayLip, 20, 64, 150); SetLineSpecial(1215, Plat_DownWaitUpStayLip, 20, 64, 150); SetLineSpecial(1216, Plat_DownWaitUpStayLip, 20, 64, 150); SetLineSpecial(1217, Plat_DownWaitUpStayLip, 20, 64, 150); SetLineSpecial(1227, Plat_DownWaitUpStayLip, 20, 64, 150); break; } case '5B26545FF21B051CA06D389CE535684C': // doom.wad e1m4 { // missing textures SetWallTexture(693, Line.back, Side.top, "BROWN1"); // fix HOM errors with sectors too low OffsetSectorPlane(9, Sector.floor, 8); OffsetSectorPlane(105, Sector.floor, 8); OffsetSectorPlane(132, Sector.floor, 8); OffsetSectorPlane(137, Sector.floor, 8); break; } case 'A24FE135D5B6FD427FE27BEF89717A65': // doom.wad e2m2 { // missing textures SetWallTexture(947, Line.back, Side.top, "BROWN1"); SetWallTexture(1596, Line.back, Side.top, "WOOD1"); break; } case '1BC04D646B32D3A3E411DAF3C1A38FF8': // doom.wad e2m4 { // missing textures SetWallTexture(551, Line.back, Side.top, "PIPE4"); SetWallTexture(865, Line.back, Side.bottom, "STEP5"); SetWallTexture(1062, Line.front, Side.top, "GSTVINE1"); SetWallTexture(1071, Line.front, Side.top, "MARBLE1"); // Door requiring yellow keycard can only be opened once, // change other side to one-shot Door_Open SetLineSpecial(165, Door_Open, 0, 16); SetLineFlags(165, 0, Line.ML_REPEAT_SPECIAL); break; } case '99C580AD8FABE923CAB485CB7F3C5E5D': // doom.wad e2m5 { // missing textures SetWallTexture(590, Line.back, Side.top, "GRAYBIG"); SetWallTexture(590, Line.front, Side.bottom, "BROWN1"); SetWallTexture(1027, Line.back, Side.top, "SP_HOT1"); // Replace tag for eastern secret at level start to not // cause any action to the two-Baron trap ClearSectorTags(127); AddSectorTag(127, 100); SetLineSpecial(382, Door_Open, 100, 16); SetLineSpecial(388, Door_Open, 100, 16); break; } case '3838AB29292587A7EE3CA71E7040868D': // doom.wad e2m6 { // missing texture SetWallTexture(1091, Line.back, Side.top, "compspan"); break; } case '8590F489879870C098CD7029C3187159': // doom.wad e2m7 { // missing texture SetWallTexture(1286, Line.front, Side.bottom, "SHAWN2"); break; } case '8A6399FAAA2E68649D4E4B16642074BE': // doom.wad e2m9 { // missing textures SetWallTexture(121, Line.back, Side.top, "SW1LION"); SetWallTexture(123, Line.back, Side.top, "GSTONE1"); SetWallTexture(140, Line.back, Side.top, "GSTONE1"); break; } case 'BBDC4253AE277DA5FCE2F19561627496': // Doom E3M2 { // Switch at index finger repeatable in case of being stuck SetLineFlags(368, Line.ML_REPEAT_SPECIAL); break; } case '2B65CB046EA40D2E44576949381769CA': // Commercial Doom e3m4 { // This line is erroneously specified as Door_Raise that monsters // can operate. If they do, they block you off from half the map. Change // this into a one-shot Door_Open so that it won't close. SetLineSpecial(1069, Door_Open, 0, 16); SetLineFlags(1069, 0, Line.ML_REPEAT_SPECIAL); // Fix HOM error from AASTINKY texture SetWallTexture(470, Line.front, Side.top, "BIGDOOR2"); break; } case '100106C75157B7DECB0DCAD2A59C1919': // Doom E3M5 { // Replace AASTINKY textures SetWallTexture(833, Line.front, Side.mid, "FIREWALL"); SetWallTexture(834, Line.front, Side.mid, "FIREWALL"); SetWallTexture(836, Line.front, Side.mid, "FIREWALL"); SetWallTexture(839, Line.front, Side.mid, "FIREWALL"); // Missing textures at the door leading to the BFG SetWallTexture(1329, Line.back, Side.bottom, "METAL"); SetWallTexture(1330, Line.back, Side.bottom, "METAL"); break; } case '5AC51CA9F1B57D4538049422A5E37291': // doom.wad e3m7 { // missing textures SetWallTexture(901, Line.back, Side.bottom, "GSTONE1"); SetWallTexture(971, Line.back, Side.top, "SP_HOT1"); break; } case 'FE97DCB9E6235FB3C52AE7C143160D73': // Doom E3M9 { // Missing textures SetWallTexture(102, Line.back, Side.bottom, "STONE3"); SetWallTexture(445, Line.back, Side.bottom, "GRAY4"); // First door cannot be opened from inside and can stop you // from finishing the level if somehow locked in. SetLineSpecial(24, Door_Open, 0, 16); SetLineActivation(24, SPAC_Use); SetLineFlags(24, Line.ML_REPEAT_SPECIAL); // Door that requires blue skull can only be opened once, // make it repeatable in case of being locked SetLineFlags(194, Line.ML_REPEAT_SPECIAL); break; } case 'DA0C8281AC70EEC31127C228BCD7FE2C': // doom.wad e4m1 { // missing textures TextureID support3 = TexMan.CheckForTexture("SUPPORT3", TexMan.Type_Wall); for(int i=0; i<4; i++) { SetWallTextureID(252+i, Line.back, Side.top, SUPPORT3); } SetWallTexture(322, Line.back, Side.bottom, "GSTONE1"); SetWallTexture(470, Line.front, Side.top, "GSTONE1"); break; } case '771092812F38236C9DF2CB06B2D6B24F': // Ultimate Doom E4M2 { // Missing texture SetWallTexture(165, Line.back, Side.top, "WOOD5"); break; } case 'F6EE16F770AD309D608EA0B1F1E249FC': // Ultimate Doom, e4m3 { // Remove unreachable secrets SetSectorSpecial(124, 0); SetSectorSpecial(125, 0); // clear staircase to secret area SetSectorSpecial(127, 0); SetSectorSpecial(128, 0); SetSectorSpecial(129, 0); SetSectorSpecial(130, 0); SetSectorSpecial(131, 0); SetSectorSpecial(132, 0); SetSectorSpecial(133, 0); SetSectorSpecial(134, 0); SetSectorSpecial(136, 0); SetSectorSpecial(137, 0); SetSectorSpecial(138, 0); SetSectorSpecial(147, 0); SetSectorSpecial(148, 0); SetSectorSpecial(149, 0); SetSectorSpecial(150, 0); SetSectorSpecial(151, 0); SetSectorSpecial(152, 0); SetSectorSpecial(155, 0); // Stuck Imp SetThingXY(69, -656, -1696); // One line special at the northern lifts is incorrect, change // to a repeatable line you can walk over to lower lift SetLineSpecial(46, Plat_DownWaitUpStayLip, 1, 32, 105, 0); SetLineActivation(46, SPAC_AnyCross); SetLineFlags(46, Line.ML_REPEAT_SPECIAL); break; } case 'AAECADD4D97970AFF702D86FAFAC7D17': // doom.wad e4m4 { // missing textures TextureID brownhug = TexMan.CheckForTexture("BROWNHUG", TexMan.Type_Wall); SetWallTextureID(427, Line.back, Side.top, BROWNHUG); SetWallTextureID(558, Line.back, Side.top, BROWNHUG); SetWallTextureID(567, Line.front, Side.top, BROWNHUG); SetWallTextureID(572, Line.front, Side.top, BROWNHUG); break; } case 'C2E09AB0BDD03925305A48AE935B71CA': // Ultimate Doom E4M5 { // Missing textures SetWallTexture(19, Line.back, Side.bottom, "GSTONE1"); SetWallTexture(109, Line.back, Side.top, "GSTONE1"); SetWallTexture(711, Line.back, Side.bottom, "FIRELAV2"); SetWallTexture(713, Line.back, Side.bottom, "FIRELAV2"); // Lower ceiling on teleporter to fix HOMs. OffsetSectorPlane(35, Sector.ceiling, -24); break; } case 'CBBFF61A8C231DFFC8E8A2A2BAEB77FF': // Ultimate Doom E4M6 { // Textures on wrong side at Yellow Skull room. SetWallTexture(475, Line.back, Side.top, "MARBLE2"); SetWallTexture(476, Line.back, Side.top, "MARBLE2"); SetWallTexture(479, Line.back, Side.top, "MARBLE2"); SetWallTexture(480, Line.back, Side.top, "MARBLE2"); SetWallTexture(481, Line.back, Side.top, "MARBLE2"); SetWallTexture(482, Line.back, Side.top, "MARBLE2"); break; } case '94D4C869A0C02EF4F7375022B36AAE45': // Ultimate Doom, e4m7 { // Remove unreachable secrets SetSectorSpecial(263, 0); SetSectorSpecial(264, 0); break; } case '2DC939E508AB8EB68AF79D5B60568711': // Ultimate Doom E4M8 { // Missing texture SetWallTexture(425, Line.front, Side.mid, "SP_HOT1"); break; } case 'AB24AE6E2CB13CBDD04600A4D37F9189': // doom2.wad map02 case '1EC0AF1E3985650F0C9000319C599D0C': // doom2bfg.wad map02 { // Missing textures TextureID stone4 = TexMan.CheckForTexture("STONE4", TexMan.Type_Wall); SetWallTextureID(327, Line.front, Side.bottom, stone4); SetWallTextureID(328, Line.front, Side.bottom, stone4); SetWallTextureID(338, Line.front, Side.bottom, stone4); SetWallTextureID(339, Line.front, Side.bottom, stone4); break; } case 'CEC791136A83EEC4B91D39718BDF9D82': // doom2.wad map04 { // missing textures SetWallTexture(456, Line.back, Side.top, "SUPPORT3"); TextureID stone = TexMan.CheckForTexture("STONE", TexMan.Type_Wall); SetWallTextureID(108, Line.front, Side.top, STONE); SetWallTextureID(109, Line.front, Side.top, STONE); SetWallTextureID(110, Line.front, Side.top, STONE); SetWallTextureID(111, Line.front, Side.top, STONE); SetWallTextureID(127, Line.front, Side.top, STONE); SetWallTextureID(128, Line.front, Side.top, STONE); // remove erroneous blue keycard pickup ambush sector tags // (nearby viewing windows, and the lights) ClearSectorTags(19); ClearSectorTags(20); ClearSectorTags(23); ClearSectorTags(28); ClearSectorTags(33); ClearSectorTags(34); ClearSectorTags(83); ClearSectorTags(85); // Visually align floors between crushers SetLineSpecial(3, Transfer_Heights, 14, 6); break; } case '9E061AD7FBCD7FAD968C976CB4AA3B9D': // doom2.wad map05 { // fix bug with opening westmost door in door hallway // incorrect sector tagging - see doomwiki.org for more info ClearSectorTags(4); ClearSectorTags(153); // Missing textures SetWallTexture(489, Line.back, Side.top, "SUPPORT3"); SetWallTexture(560, Line.back, Side.top, "SUPPORT3"); break; } case '291F24417FB3DD411339AE82EF9B3597': // Doom II MAP07 { // Missing texture at BFG deathmatch spawn. SetWallTexture(168, Line.back, Side.bottom, "BRONZE3"); SetLineFlags(168, 0, Line.ML_DONTPEGBOTTOM); break; } case '66C46385EB1A23D60839D1532522076B': // doom2.wad map08 { // Missing texture SetWallTexture(101, Line.back, Side.top, "BRICK7"); break; } case '6C620F43705BEC0ABBABBF46AC3E62D2': // Doom II MAP10 { // Allow player to leave exit room SetLineSpecial(786, Door_Raise, 0, 16, 150, 0); SetLineActivation(786, SPAC_Use); SetLineFlags(786, Line.ML_REPEAT_SPECIAL); break; } case '1AF4DEC2627360A55B3EB397BC15C39D': // Doom II MAP12 { // Missing texture SetWallTexture(648, Line.back, Side.bottom, "PIPES"); // Remove erroneous tag for teleporter at the south building ClearSectorTags(149); break; } case 'FBA6547B9FD44E95671A923A066E516F': // Doom II MAP13 { // Missing texture SetWallTexture(622, Line.back, Side.top, "BROWNGRN"); break; } case '5BDA34DA60C0530794CC1EA2DA017976': // doom2.wad map14 { // missing textures SetWallTexture(429, Line.front, Side.top, "BSTONE2"); SetWallTexture(430, Line.front, Side.top, "BSTONE2"); SetWallTexture(531, Line.front, Side.top, "BSTONE1"); SetWallTexture(1259, Line.back, Side.top, "BSTONE2"); SetWallTexture(1305, Line.back, Side.top, "BSTONE2"); TextureID bstone2 = TexMan.CheckForTexture("BSTONE2", TexMan.Type_Wall); for(int i=0; i<3; i++) { SetWallTextureID(607+i, Line.back, Side.top, BSTONE2); } TextureID tanrock5 = TexMan.CheckForTexture("TANROCK5", TexMan.Type_Wall); for(int i=0; i<7; i++) { SetWallTextureID(786+i, Line.back, Side.top, TANROCK5); } TextureID bstone1 = TexMan.CheckForTexture("BSTONE1", TexMan.Type_Wall); for(int i=0; i<3; i++) { SetWallTextureID(1133+i, Line.back, Side.top, BSTONE1); SetWallTextureID(1137+i, Line.back, Side.top, BSTONE1); SetWallTextureID(1140+i, Line.back, Side.top, BSTONE1); } // Raise floor between lifts to correspond with others. OffsetSectorPlane(106, Sector.floor, 16); break; } case '1A540BA717BF9EC85F8522594C352F2A': // Doom II, map15 { // Remove unreachable secret SetSectorSpecial(147, 0); // Missing textures SetWallTexture(94, Line.back, Side.top, "METAL"); SetWallTexture(95, Line.back, Side.top, "METAL"); SetWallTexture(989, Line.back, Side.top, "BRICK10"); break; } case '6B60F37B91309DFF1CDF02E5E476210D': // Doom II MAP16 { // Missing textures SetWallTexture(162, Line.back, Side.top, "BRICK6"); SetWallTexture(303, Line.front, Side.top, "STUCCO"); SetWallTexture(304, Line.front, Side.top, "STUCCO"); break; } case 'E1CFD5C6E60C3B6C30F8B95FC287E9FE': // Doom II MAP17 { // Missing texture SetWallTexture(379, Line.back, Side.top, "METAL2"); break; } case '0D491365C1B88B7D1B603890100DD03E': // doom2.wad map18 { // missing textures SetWallTexture(451, Line.front, Side.mid, "metal"); SetWallTexture(459, Line.front, Side.mid, "metal"); SetWallTexture(574, Line.front, Side.top, "grayvine"); break; } case 'B5506B1E8F2FC272AD0C77B9E0DF5491': // doom2.wad map19 { // missing textures SetWallTexture(355, Line.back, Side.top, "STONE2"); SetWallTexture(736, Line.front, Side.top, "SLADWALL"); SetWallTexture(1181, Line.back, Side.top, "MARBLE1"); TextureID step4 = TexMan.CheckForTexture("STEP4", TexMan.Type_Wall); for(int i=0; i<3; i++) { SetWallTextureID(286+i, Line.back, Side.bottom, STEP4); } // Southwest teleporter in the teleporter room now works on // easier difficulties SetThingSkills(112, 31); break; } case 'EBDAC00E9D25D884B2C8F4B1F0390539': // doom2.wad map21 { // push ceiling down in glitchy sectors above the stair switches OffsetSectorPlane(50, Sector.ceiling, -56); OffsetSectorPlane(54, Sector.ceiling, -56); break; } case '4AA9B3CE449FB614497756E96509F096': // Doom II MAP22 { // Only use switch once to raise sector to rocket launcher SetLineFlags(120, 0, Line.ML_REPEAT_SPECIAL); break; } case '94893A0DC429A22ADC4B3A73DA537E16': // Doom II MAP25 { // Missing texture at bloodfall near level start SetWallTexture(436, Line.back, Side.top, "STONE6"); break; } case '1037366026AAB4B0CF11BAB27DB90E4E': // Doom II MAP26 { // Missing texture at level exit SetWallTexture(761, Line.back, Side.top, "METAL2"); break; } case '110F84DE041052B59307FAF0293E6BC0': // Doom II, map27 { // Remove unreachable secret SetSectorSpecial(93, 0); // Missing texture SetWallTexture(582, Line.back, Side.top, "ZIMMER3"); // Make line near switch to level exit passable SetLineFlags(342, 0, Line.ML_BLOCKING); // Can leave Pain Elemental room if stuck SetLineSpecial(580, Door_Open, 0, 16); SetLineActivation(580, SPAC_Use); SetLineSpecial(581, Door_Open, 0, 16); SetLineActivation(581, SPAC_Use); break; } case '84BB2C8ED2343C91136B87F1832E7CA5': // Doom II MAP28 { // Missing textures TextureID ashwall6 = TexMan.CheckForTexture("ASHWALL6", TexMan.Type_Wall); for(int i=0; i<5; i++) { SetWallTextureID(103+i, Line.front, Side.top, ASHWALL6); } SetWallTexture(221, Line.front, Side.bottom, "BFALL1"); SetWallTexture(391, Line.front, Side.top, "BIGDOOR5"); SetWallTexture(531, Line.back, Side.top, "WOOD8"); SetWallTexture(547, Line.back, Side.top, "WOOD8"); SetWallTexture(548, Line.back, Side.top, "WOOD8"); // Raise holes near level exit when walking over them for(int i=0; i<12; i++) { SetLineSpecial(584+i, Floor_RaiseToNearest, 5, 8); SetLineActivation(584+i, SPAC_Cross); } break; } case '20251EDA21B2F2ECF6FF5B8BBC00B26C': // Doom II, MAP29 { // Missing textures on teleporters TextureID support3 = TexMan.CheckForTexture("SUPPORT3", TexMan.Type_Wall); for(int i=0;i<4;i++) { SetWallTextureID(405+i, Line.back, Side.bottom, SUPPORT3); SetWallTextureID(516+i, Line.back, Side.bottom, SUPPORT3); SetWallTextureID(524+i, Line.back, Side.bottom, SUPPORT3); SetWallTextureID(1146+i, Line.back, Side.bottom, SUPPORT3); SetWallTextureID(1138+i, Line.back, Side.bottom, SUPPORT3); } // Fix missing textures at switch with Arch-Vile. OffsetSectorPlane(152, Sector.ceiling, -32); SetWallTexture(603, Line.back, Side.top, "WOOD5"); break; } case '915409A89746D6BFD92C7956BE6A0A2D': // Doom II: BFG Edition MAP33 { // Missing textures on sector with a Super Shotgun at map start. TextureID rock2 = TexMan.CheckForTexture("ROCK2", TexMan.Type_Wall); for(int i=0; i<4; i++) { SetWallTextureID(567+i, Line.front, Side.bottom, ROCK2); SetWallTextureID(567+i, Line.back, Side.top, ROCK2); } // Tags the linedefs on the teleporter at the end of the level so that // it's possible to leave the room near the yellow keycard door. for(int i=0; i<2; i++) { SetLineSpecial(400+i, Teleport, 0, 36); SetLineSpecial(559+i, Teleport, 0, 36); } break; } case 'FF635FB9A2F076566299910F8C78F707': // nerve.wad, level04 { SetSectorSpecial(868, 0); break; } case 'D94587625BA779644D58151A87897CF1': // heretic.wad e1m2 { // Missing textures TextureID mossrck1 = TexMan.CheckForTexture("MOSSRCK1", TexMan.Type_Wall); SetWallTextureID( 477, Line.back, Side.top, mossrck1); SetWallTextureID( 478, Line.back, Side.top, mossrck1); SetWallTextureID( 479, Line.back, Side.top, mossrck1); SetWallTextureID(1057, Line.front, Side.top, mossrck1); break; } case 'ADD0FAC41AFB0B3C9B9F3C0006F93805': // heretic.wad e1m3 { // Broken door between the hallway that leads to a Torch // and the passage that has a Bag of Holding at its end OffsetSectorPlane(86, Sector.floor, -128); OffsetSectorPlane(86, Sector.ceiling, -128); break; } case '916318D8B06DAC2D83424B23E4B66531': // heretic.wad e1m4 { // Wrong sector offsets OffsetSectorPlane( 0, Sector.ceiling, 8); OffsetSectorPlane( 1, Sector.ceiling, 8); OffsetSectorPlane( 2, Sector.ceiling, 8); OffsetSectorPlane( 3, Sector.ceiling, 8); OffsetSectorPlane( 4, Sector.ceiling, 8); OffsetSectorPlane( 6, Sector.ceiling, 8); OffsetSectorPlane( 6, Sector.floor, 8); OffsetSectorPlane(17, Sector.ceiling, 8); // Yellow key door OffsetSectorPlane(284, Sector.floor, -8); OffsetSectorPlane(284, Sector.ceiling, -8); // Missing textures SetWallTexture(490, Line.back, Side.bottom, "GRSTNPB"); TextureID woodwl = TexMan.CheckForTexture("WOODWL", TexMan.Type_Wall); SetWallTextureID( 722, Line.front, Side.bottom, woodwl); SetWallTextureID( 911, Line.front, Side.bottom, woodwl); SetWallTextureID(1296, Line.front, Side.bottom, woodwl); break; } case '397A0E17A39542E4E8294E156FAB0502': // heretic.wad e2m2 { // Missing green door statues on easy and hard difficulties SetThingSkills(17, 31); SetThingSkills(18, 31); break; } case 'FAA0550BE9923B3A3332B4F7DB897A4A': // heretic.wad e2m7 { // missing texture TextureID looserck = TexMan.CheckForTexture("LOOSERCK", TexMan.Type_Wall); SetWallTextureID( 629, Line.back, Side.top, looserck); break; } case 'CA3773ED313E8899311F3DD0CA195A68': // heretic.wad e3m6 { // Quartz flask outside of map SetThingSkills(373, 0); // Missing wall torch on hard difficulty SetThingSkills(448, 31); // Missing textures TextureID mossrck1 = TexMan.CheckForTexture("MOSSRCK1", TexMan.Type_Wall); SetWallTextureID(343, Line.front, Side.top, mossrck1); SetWallTextureID(370, Line.front, Side.top, mossrck1); break; } case '5E3FCFDE78310BB89F92B1626A47D0AD': // heretic.wad E4M7 { // Missing textures TextureID cstlrck = TexMan.CheckForTexture("CSTLRCK", TexMan.Type_Wall); SetWallTextureID(1274, Line.front, Side.top, cstlrck); SetWallTextureID(1277, Line.back, Side.top, cstlrck); SetWallTextureID(1278, Line.front, Side.top, cstlrck); break; } case '30D1480A6D4F3A3153739D4CCF659C4E': // heretic.wad E4M8 { // multiplayer teleporter prevents exit on cooperative SetThingFlags(78,MTF_DEATHMATCH); break; } case '6CDA2721AA1076F063557CF89D88E92B': // hexen.wad map08 { // Amulet of warding accidentally shifted outside of map SetThingXY(256,-1632,2352); // Icon of the defender outside of map SetThingSkills(261,0); break; } case '39C594CAC07EE51C80F757DA465FCC94': // strife1.wad map10 { // fix the shooting range by matching sector 138 and 145 properties together OffsetSectorPlane(145, Sector.floor, -32); OffsetSectorPlane(145, Sector.ceiling, 40); SetSectorTexture(145, Sector.floor, "F_CONCRP"); SetSectorLight(138, 192); SetWallTexture(3431, Line.back, Side.top, "BRKGRY01"); break; } case '8D7A24B169717907DDA8399D8C1655DF': // strife1.wad map15 { SetWallTexture(319, Line.back, Side.top, "WALTEK21"); break; } case 'D5FD90FA7A8133E7BFED682D3D313962': // strife1.wad map21 { SetWallTexture(603, Line.front, Side.bottom, "IRON04"); break; } case '775CBC35C0A58326FE87AAD638FF9E2A': // Strife1.wad map29 case 'A75099ACB622C7013EE737480FCB0D67': // SVE.wad map29 // disable teleporter that would always teleport into a blocking position. ClearLineSpecial(271); break; case 'DB31D71B11E3E4393B9C0CCB44A8639F': // rop_2015.wad e1m5 { // Lower floor a bit so secret switch becomes accessible OffsetSectorPlane(527, Sector.floor, -32); break; } case 'CC3911090452D7C39EC8B3D97CEFDD6F': // jenesis.wad map16 { // Missing texture with hardware renderer because of wrongly lowered sector ClearSectorTags(483); break; } case 'B68EB7CFB4CC481796E2919B9C16DFBD': // Moc11.wad e1m6 { SetVertex(1650, -3072, 2671); SetVertex(1642, -2944, 2671); break; } case '5C594C67CF7721005DE71429F9811370': // Eternal Doom map03 { // fix broken staircase. The compatibility option is not sufficient // to reliably handle this so clear the tags from the unwanted sectors. ClearSectorTags(212); ClearSectorTags(213); ClearSectorTags(214); break; } case '9A4615498C3451413F1CD3D15099ACC7': // Eternal Doom map05 { // an imp and two cyberdemons are located at the softlock area SetThingFlags(272, GetThingFlags (272) | MTF_NOCOUNT); SetThingFlags(273, GetThingFlags (273) | MTF_NOCOUNT); SetThingFlags(274, GetThingFlags (274) | MTF_NOCOUNT); break; } case '8B55842D5A509902738040AF10B4E787': // Eternal Doom map10 { // soulsphere at the end of the level is there merely to replicate the start of the next map SetThingFlags(548, GetThingFlags (548) | MTF_NOCOUNT); break; } case 'DCE862393CAAA6FF1294FB7056B53057': // UAC Ultra map07 { // Contains a scroller depending on Boom side effects SetLineSpecial(391, Sector_CopyScroller, 99, 6); break; } case '9D50EBE17CEC78938C7A668DB0768611': // Strain map07 { // Make the exit accessible SetLineFlags(1021, 0, Line.ML_BLOCKING); break; } case '3D8ED20BF5CAAE6D6AE0E10999C75084': // hgarden.pk3 map01 { // spawn trees on top of arches SetThingZ(399, 168); SetThingZ(400, 168); SetThingZ(401, 168); SetThingZ(402, 168); SetThingZ(403, 168); SetThingZ(404, 168); break; } case '6DC9F6CCEAE7A91AEC48EBE506F22BC4': // void.wad MAP01 { // Slightly squash the pillars in the starting room with "stimpacks" // floating on them so that they can be obtained. OffsetSectorPlane( 62, Sector.floor, -8); OffsetSectorPlane( 63, Sector.floor, -8); OffsetSectorPlane(118, Sector.floor, -8); OffsetSectorPlane(119, Sector.floor, -8); for (int i = 0; i < 8; ++i) { SetWallYScale(286 + i, Line.front, Side.bottom, 1.090909); SetWallYScale(710 + i, Line.front, Side.bottom, 1.090909); } break; } case '57386AEF275684BA06756359B08F4391': // Perdition's Gate MAP03 { // Stairs where one sector is too thin to score. SetSectorSpecial(227, 0); break; } case 'F1A9938C4FC3906A582AB7D5088B5F87': // Perdition's Gate MAP12 { // Sector unintentionally left as a secret near switch SetSectorSpecial(112, 0); break; } case '5C419E581D9570F44A24163A83032086': // Perdition's Gate MAP27 { // Sectors unintentionally left as secrets and cannot be scored SetSectorSpecial(338, 0); SetSectorSpecial(459, 0); break; } case 'FCCA97FC851F6473EAA069F74247B317': // pg-raw.wad map31 { SetLineSectorRef(331, Line.front, 74); SetLineSectorRef(326, Line.front, 74); SetLineSectorRef(497, Line.front, 74); SetLineSectorRef(474, Line.front, 74); SetLineSectorRef(471, Line.front, 74); SetLineSectorRef(327, Line.front, 74); SetLineSectorRef(328, Line.front, 74); SetLineSectorRef(329, Line.front, 74); AddSectorTag(74, 4); SetLineSpecial(357, Transfer_Heights, 4, 6); break; } case '5379C080299EB961792B50AD96821543': // Hell to Pay MAP14 { // Two secrets are unreachable without jumping and crouching. SetSectorSpecial(82, 0); SetSectorSpecial(83, 0); break; } case '7837B5334A277F107515D649BCEFB682': // Hell to Pay MAP22 { // Four enemies (six if multiplayer) never spawn in the map, // so the lines closest to them should teleport them instead. SetLineSpecial(1835, Teleport, 0, 40); SetLineActivation(1835, SPAC_MCross); SetLineFlags(1835, Line.ML_REPEAT_SPECIAL); SetLineSpecial(1847, Teleport, 0, 40); SetLineActivation(1847, SPAC_MCross); SetLineFlags(1847, Line.ML_REPEAT_SPECIAL); break; } case '1A1AB6415851B9F17715A0C36412752E': // Hell to Pay MAP24 { // Remove Chaingunner far below the map, making 100% kills // impractical. SetThingFlags(70, 0); break; } case 'A7ACB57A2CAF17434D0DFE0FAC0E0480': // Hell to Pay MAP28 { // Three Lost Souls placed outside the map for some reason. for(int i=0; i<3; i++) { SetThingFlags(217+i, 0); } break; } case '2F1A18633C30E938B50B6D928C730CB6': // Hell to Pay MAP29 { // Three Lost Souls placed outside the map, again... for(int i=0; i<3; i++) { SetThingFlags(239+i, 0); } break; } case '712BB4CFBD0753178CA0C6814BE4C288': // beta version of map12 BTSX_E1 { // patch some rendering glitches that are problematic to detect AddSectorTag(545, 32000); AddSectorTag(1618, 32000); SetLineSpecial(2853, Sector_Set3DFloor, 32000, 4); AddSectorTag(439, 32001); AddSectorTag(458, 32001); SetLineSpecial(2182, Sector_Set3DFloor, 32001, 4); AddSectorTag(454, 32002); AddSectorTag(910, 32002); SetLineSpecial(2410, Sector_Set3DFloor, 32002, 4, 1); break; } case '5A24FC83A3F9A2D6D54AF04E2E96684F': // AV.WAD MAP01 { SetLineSectorRef(225, Line.back, 36); SetLineSectorRef(222, Line.back, 36); SetLineSectorRef(231, Line.back, 36); SetLineSectorRef(223, Line.back, 36); SetLineSectorRef(224, Line.back, 36); SetLineSectorRef(227, Line.back, 36); SetLineSectorRef(229, Line.back, 39); SetLineSectorRef(233, Line.back, 39); TextureID nukage = TexMan.CheckForTexture("NUKAGE1", TexMan.Type_Flat); SetWallTextureID(222, Line.front, Side.bottom, nukage); SetWallTextureID(223, Line.front, Side.bottom, nukage); SetWallTextureID(224, Line.front, Side.bottom, nukage); SetWallTextureID(225, Line.front, Side.bottom, nukage); SetWallTextureID(227, Line.front, Side.bottom, nukage); SetWallTextureID(231, Line.front, Side.bottom, nukage); SetWallTextureID(229, Line.front, Side.bottom, nukage); SetWallTextureID(233, Line.front, Side.bottom, nukage); for(int i = 0; i < 8; i++) { SetLineSectorRef(i+234, Line.back, 37); SetLineSectorRef(i+243, Line.back, 37); SetWallTextureID(i+234, Line.back, Side.bottom, nukage); SetWallTextureID(i+243, Line.back, Side.bottom, nukage); } SetLineSpecial(336, Transfer_Heights, 32000, 6); AddSectorTag(40, 32000); AddSectorTag(38, 32000); AddSectorTag(37, 32000); AddSectorTag(34, 32000); break; } case '32FADD80710CAFCC2B09B4610C3340B3': // ksutra.wad map01 { // This rebuilds the ending pit with a 3D floor. for(int i = Line.front; i <= Line.back; i++) { SetLineSectorRef(509, i, 129); SetLineSectorRef(510, i, 129); SetLineSectorRef(522, i, 129); SetLineSectorRef(526, i, 129); SetLineSectorRef(527, i, 129); for(int j = 538; j <= 544; j++) { SetLineSectorRef(j, i, 129); } for(int j = 547; j <= 552; j++) { SetLineSectorRef(j, i, 129); } } AddSectorTag(129, 32000); SetSectorLight(129, 160); for(int i = 148; i <= 151; i++) { AddSectorTag(i, 32000); SetSectorLight(i, 160); } SetSectorTexture(126, Sector.Ceiling, "GRASS1"); OffsetSectorPlane(126, Sector.Floor, 72); OffsetSectorPlane(126, Sector.Ceiling, 128); SetLineSpecial(524, Sector_Set3DFloor, 32000, 1, 0, 255); SetWallTexture(524, Line.Front, Side.Mid, "ASHWALL3"); SetWallTexture(537, Line.Front, Side.Bottom, "ASHWALL3"); SetWallTexture(536, Line.Front, Side.Bottom, "ASHWALL3"); SetWallTexture(546, Line.Front, Side.Bottom, "ASHWALL3"); SetWallTexture(449, Line.Front, Side.Mid, "-"); break; } case '9C14350A111C3DC6A8AF04D950E6DDDB': // ma_val.pk3 map01 { // Missing wall textures with hardware renderer OffsetSectorPlane(7072, Sector.floor, -48); OffsetSectorPlane(7073, Sector.floor, -32); // Missing teleporting monsters SetThingFlags(376, 0x200); SetThingFlags(377, 0x300); for (int i = 437; i < 449; ++i) { SetThingFlags(i, 0x600); } // Stuck imp SetThingXY(8, 1200, -1072); break; } case '5B8689912D21E91D899C61BBBDD44D7C': // altar of evil.wad map01 { // Missing teleport destination on easy skill SetThingSkills(115, 31); break; } case 'CCF699953746087E46185B2A40D9F8AF': // satanx.wad map01 { // Restore monster cross flag for DeHackEd friendly marine GetDefaultActor('WolfensteinSS').bActivateMCross = true; break; } case 'D67CECE3F60083383DF992B8C824E4AC': // Icarus: Alien Vanguard MAP13 { // Moves sector special to platform with Berserk powerup. The // map's only secret can now be scored. SetSectorSpecial(119, 0); SetSectorSpecial(122, 1024); break; } case '61373587339A768854E2912CC99A4781': // Icarus: Alien Vanguard MAP15 { // Can press use on the lift to reveal the secret Shotgun, // making 100% secrets possible. SetLineSpecial(222, Plat_DownWaitUpStayLip, 11, 64, 105, 0); SetLineActivation(222, SPAC_Use); SetLineFlags(222, Line.ML_REPEAT_SPECIAL); break; } case '9F66B0797925A09D4DC0725540F8EEF7': // Icarus: Alien Vanguard MAP16 { // Can press use on the walls at the secret Rocket Launcher in // case of getting stuck. for(int i=0; i<7; i++) { SetLineSpecial(703+i, Plat_DownWaitUpStayLip, 14, 64, 105, 0); SetLineActivation(703+i, SPAC_Use); SetLineFlags(703+i, Line.ML_REPEAT_SPECIAL); } break; } case '09645D198010BF634EF0DE3EFCB0052C': // Flashback to Hell MAP12 { // Can press use behind bookshelf in case of getting stuck. SetLineSpecial(4884, Plat_DownWaitUpStayLip, 15, 32, 105, 0); SetLineActivation(4884, SPAC_UseBack); SetLineFlags(4884, Line.ML_REPEAT_SPECIAL); break; } case '7FB847B522DE80D0B2A217E1EF8D1A15': // av.wad map28 { // Fix the soulsphere in a secret area (sector 324) // so that it doesn't end up in an unreachable position. SetThingXY(516, -934, 48); break; } case '11EA5B8357DEB70A8F00900117831191': // kdizd_12.pk3 z1m3 { // Fix incorrectly tagged underwater sector which causes render glitches. AddSectorTag(7857, 82); break; } case '7B1EB6C1231CD03E90F4A1C0D51A8B6D': // ur_final.wad map17 { SetLineSpecial(3020, Transfer_Heights, 19); break; } case '01592ACF001C534076556D9E1B5D85E7': // Darken2.wad map12 { // fix some holes the player can fall in. This map went a bit too far with lighting hacks depending on holes in the floor. OffsetSectorPlane(126, Sector.floor, 1088); level.sectors[126].SetPlaneLight(Sector.floor, level.sectors[125].GetLightLevel() - level.sectors[126].GetLightLevel()); OffsetSectorPlane(148, Sector.floor, 1136); level.sectors[148].SetPlaneLight(Sector.floor, level.sectors[122].GetLightLevel() - level.sectors[148].GetLightLevel()); OffsetSectorPlane(149, Sector.floor, 1136); level.sectors[149].SetPlaneLight(Sector.floor, level.sectors[122].GetLightLevel() - level.sectors[149].GetLightLevel()); OffsetSectorPlane(265, Sector.floor, 992); level.sectors[265].SetPlaneLight(Sector.floor, level.sectors[264].GetLightLevel() - level.sectors[265].GetLightLevel()); OffsetSectorPlane(279, Sector.floor, 1072); level.sectors[279].SetPlaneLight(Sector.floor, level.sectors[267].GetLightLevel() - level.sectors[279].GetLightLevel()); SetSectorTexture(279, Sector.floor, "OMETL13"); OffsetSectorPlane(280, Sector.floor, 1072); level.sectors[280].SetPlaneLight(Sector.floor, level.sectors[267].GetLightLevel() - level.sectors[280].GetLightLevel()); SetSectorTexture(280, Sector.floor, "OMETL13"); OffsetSectorPlane(281, Sector.floor, 1072); level.sectors[281].SetPlaneLight(Sector.floor, level.sectors[267].GetLightLevel() - level.sectors[281].GetLightLevel()); SetSectorTexture(281, Sector.floor, "OMETL13"); OffsetSectorPlane(292, Sector.floor, 1056); level.sectors[292].SetPlaneLight(Sector.floor, level.sectors[291].GetLightLevel() - level.sectors[292].GetLightLevel()); OffsetSectorPlane(472, Sector.floor, 1136); level.sectors[472].SetPlaneLight(Sector.floor, level.sectors[216].GetLightLevel() - level.sectors[472].GetLightLevel()); OffsetSectorPlane(473, Sector.floor, 1136); level.sectors[473].SetPlaneLight(Sector.floor, level.sectors[216].GetLightLevel() - level.sectors[473].GetLightLevel()); OffsetSectorPlane(526, Sector.floor, 1024); level.sectors[526].SetPlaneLight(Sector.floor, level.sectors[525].GetLightLevel() - level.sectors[526].GetLightLevel()); OffsetSectorPlane(527, Sector.floor, 1024); level.sectors[527].SetPlaneLight(Sector.floor, level.sectors[500].GetLightLevel() - level.sectors[527].GetLightLevel()); OffsetSectorPlane(528, Sector.floor, 1024); level.sectors[528].SetPlaneLight(Sector.floor, level.sectors[525].GetLightLevel() - level.sectors[528].GetLightLevel()); OffsetSectorPlane(554, Sector.floor, 1024); level.sectors[554].SetPlaneLight(Sector.floor, level.sectors[500].GetLightLevel() - level.sectors[554].GetLightLevel()); OffsetSectorPlane(588, Sector.floor, 928); level.sectors[588].SetPlaneLight(Sector.floor, level.sectors[587].GetLightLevel() - level.sectors[588].GetLightLevel()); OffsetSectorPlane(604, Sector.floor, 1056); level.sectors[604].SetPlaneLight(Sector.floor, level.sectors[298].GetLightLevel() - level.sectors[604].GetLightLevel()); OffsetSectorPlane(697, Sector.floor, 1136); level.sectors[697].SetPlaneLight(Sector.floor, level.sectors[696].GetLightLevel() - level.sectors[697].GetLightLevel()); OffsetSectorPlane(698, Sector.floor, 1136); level.sectors[698].SetPlaneLight(Sector.floor, level.sectors[696].GetLightLevel() - level.sectors[698].GetLightLevel()); OffsetSectorPlane(699, Sector.floor, 1136); level.sectors[699].SetPlaneLight(Sector.floor, level.sectors[696].GetLightLevel() - level.sectors[699].GetLightLevel()); OffsetSectorPlane(700, Sector.floor, 1136); level.sectors[700].SetPlaneLight(Sector.floor, level.sectors[696].GetLightLevel() - level.sectors[700].GetLightLevel()); break; } case '3B1F637295F5669E99BE63F1B1CA29DF': // titan426.wad map01 { // Missing teleport destinations on easy skill SetThingSkills(138, 31); // secret SetThingSkills(1127, 31); // return from exit room break; } case '5E9AF879343D6E44E429F91D57777D26': // cchest.wad map16 { // Fix misplaced vertex SetVertex(202, -2, -873); break; } case 'E9EB4D16CA7E491E98D61615E4613E70': // sigil.wad e5m2 { // Floating Skulls missing in lower difficulties SetThingSkills(113, 31); SetThingSkills(114, 31); break; } case 'C43B99F34E5211F9AF24459842852B0D': // sigil.wad e5m4 { // Fix missing texture on the Baron-invulnerability-secret platform SetWallTexture(1926, Line.back, Side.bottom, "MARBLE3"); break; } case 'A7C4FC8CAEB3E375B7214E35C6298B03': // Illusions of Home e1m6 { // Convert zero-tagged GR door into regular open-stay door to fix map SetLineActivation(37, SPAC_Use); SetLineSpecial(37, Door_Open, 0, 16); SetLineActivation(203, SPAC_Use); SetLineSpecial(203, Door_Open, 0, 16); break; } case '5084755C29FB0A1912113E36F37C958A': // Illusions of Home e3m4 { // Fix action of final switch SetLineSpecial(765, Door_Open, 6, 16); break; } case '0EF86635676FD512CE0E962040125553': // Illusions of Home e3m7 { // Fix red key and missing texture in red key area SetThingFlags(247, 2016); SetThingSkills(247, 31); SetWallTexture(608, Line.back, Side.bottom, "GRAY5"); break; } case '63BDD083A98A48C04B8CD58AA857F77D': // Scythe MAP22 { // Wall behind start creates HOM in software renderer due to weird sector OffsetSectorPlane(236, Sector.Floor, -40); break; } case '1C795660D2BA9FC93DA584C593FD1DA3': // Scythe 2 MAP17 { // Texture displays incorrectly in hardware renderer SetVertex(2687, -4540, -1083); //Fixes bug with minimal effect on geometry break; } case '7483D7BDB8375358F12D146E1D63A85C': // Scythe 2 MAP24 { // Missing texture TextureID adel_q62 = TexMan.CheckForTexture("ADEL_Q62", TexMan.Type_Wall); SetWallTextureID(7775, Line.front, Side.bottom, adel_q62); break; } case '16E621E46F87418F6F8DB71D68433AE0': // Hell Revealed MAP23 { // Arachnotrons near beginning sometimes don't spawn if imps block // their one-time teleport. Make these teleports repeatable to ensure // maxkills are always possible. SetLineFlags(2036, Line.ML_REPEAT_SPECIAL); SetLineFlags(2038, Line.ML_REPEAT_SPECIAL); SetLineFlags(2039, Line.ML_REPEAT_SPECIAL); SetLineFlags(2040, Line.ML_REPEAT_SPECIAL); break; } case '145C4DFCF843F2B92C73036BA0E1D98A': // Hell Revealed MAP26 { // The 4 archviles that produce the ghost monsters cannot be killed // Make them not count so they still produce ghosts while allowing 100% kills. SetThingFlags(320, GetThingFlags (320) | MTF_NOCOUNT); SetThingFlags(347, GetThingFlags (347) | MTF_NOCOUNT); SetThingFlags(495, GetThingFlags (495) | MTF_NOCOUNT); SetThingFlags(496, GetThingFlags (496) | MTF_NOCOUNT); break; } case '0E379EEBEB189F294ED122BC60D10A68': // Hellbound MAP29 { // Remove the cyberdemons stuck in the closet boxes that cannot teleport. SetThingFlags(2970,0); SetThingFlags(2969,0); SetThingFlags(2968,0); SetThingFlags(2169,0); SetThingFlags(2168,0); SetThingFlags(2167,0); break; } case '66B931B03618EDE5C022A1EC87189158': // Restoring Deimos MAP03 { // Missing teleport destination on easy skill SetThingSkills(62, 31); break; } case '6B9D31106CE290205A724FA61C165A80': // Restoring Deimos MAP07 { // Missing map spots on easy skill SetThingSkills(507, 31); SetThingSkills(509, 31); break; } case '17314071AB76F4789763428FA2E8DA4C': // Skulldash Expanded Edition MAP04 { // Missing teleport destination on easy skill SetThingSkills(164, 31); break; } case '1B27E04F707E7988800582F387F609CD': // One against hell (ONE1.wad) { //Turn map spots into teleport destinations so that teleports work SetThingEdNum(19, 14); SetThingEdNum(20, 14); SetThingEdNum(22, 14); SetThingEdNum(23, 14); SetThingEdNum(34, 14); SetThingEdNum(35, 14); SetThingEdNum(36, 14); SetThingEdNum(39, 14); SetThingEdNum(40, 14); SetThingEdNum(172, 14); SetThingEdNum(173, 14); SetThingEdNum(225, 14); SetThingEdNum(226, 14); SetThingEdNum(247, 14); break; } case '25E178C981BAC28BA586B3B0A2A0FD72': // swan fox doom v2.4.wad map13 { //Actors with no game mode will now appear SetThingFlags(0, MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH); for(int i = 2; i < 452; i++) SetThingFlags(i, MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH); //Awaken monsters with Thing_Hate, since NoiseAlert is unreliable SetThingID(465, 9); SetLineSpecial(1648, 177, 9); for(int i = 1650; i <= 1653; i++) SetLineSpecial(i, 177, 9); SetLineSpecial(1655, 177, 9); break; } case 'FDFB3D209CC0F3706AAF3E51646003D5': // swan fox doom v2.4.wad map23 { //Missing Teleport Destination on Easy/Normal difficulty SetThingSkills(650, SKILLS_ALL); //Fix the exit portal to allow walking into it instead of shooting it SetLineSpecial(1970, Exit_Normal, 0); SetLineActivation(1970, SPAC_Cross); ClearLineSpecial(2010); SetWallTexture(1966, Line.back, Side.mid, "TELR1"); OffsetSectorPlane(170, Sector.floor, -120); break; } case 'BC969ED0191CCD9B69B316864362B0D7': // swan fox doom v2.4.wad map24 { //Actors with no game mode will now appear for(int i = 1; i < 88; i++) SetThingFlags(i, MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH); break; } case 'ED740248422026326650F6A4BC1C0A5A': // swan fox doom v2.4.wad map25 { //Actors with no game mode will now appear for(int i = 0; i < 8; i++) SetThingFlags(i, MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH); for(int i = 9; i < 26; i++) SetThingFlags(i, MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH); break; } case '52F532F95E2D5862E56F7214FA5C5C59': // Toon Doom II (toon2b.wad) map10 { //This lift needs to be repeatable to prevent trapping the player SetLineSpecial(224, Plat_DownWaitUpStayLip, 5, 32, 105); SetLineActivation(224, SPAC_Use); SetLineFlags(224, Line.ML_REPEAT_SPECIAL); break; } case '3345D12AD97F20EDCA5E27BA4288F758': // Toon Doom II (toon2b.wad) map30 { //These doors need to be repeatable to prevent trapping the player SetLineSpecial(417, Door_Raise, 17, 16, 150); SetLineActivation(417, SPAC_Use); SetLineFlags(417, Line.ML_REPEAT_SPECIAL); SetLineSpecial(425, Door_Raise, 15, 16, 150); SetLineActivation(425, SPAC_Use); SetLineFlags(425, Line.ML_REPEAT_SPECIAL); SetLineSpecial(430, Door_Raise, 16, 16, 150); SetLineActivation(430, SPAC_Use); SetLineFlags(430, Line.ML_REPEAT_SPECIAL); break; } case 'BA1288DF7A7AD637948825EA87E18728': // Valletta's Doom Nightmare (vltnight.wad) map02 { //This door's backside had a backwards linedef so it wouldn't work FlipLineCompletely(306); //Set the exit to point to Position 0, since that's the only one on the next map SetLineSpecial(564, Exit_Normal, 0); break; } case '9B966DA88265AC8972B7E15C86928AFB': // Clavicula Nox: Revised Edition map01 { // All swimmable water in Clavicula Nox is Vavoom-style, and doesn't work. // Change it to ZDoom-style and extend the control sector heights to fill. // Lava also sometimes needs the damage effect added manually. SetLineSpecial(698, 160, 4, 2, 0, 128); OffsetSectorPlane(121, Sector.floor, -32); break; } case '9FD0C47C2E132F64B48CA5BFBDE47F1D': // clavnoxr map02 { SetLineSpecial(953, 160, 12, 2, 0, 128); OffsetSectorPlane(139, Sector.floor, -24); SetLineSpecial(989, 160, 13, 2, 0, 128); OffsetSectorPlane(143, Sector.floor, -24); SetLineSpecial(1601, 160, 19, 2, 0, 128); SetLineSpecial(1640, 160, 20, 2, 0, 128); SetLineSpecial(1641, 160, 21, 2, 0, 128); OffsetSectorPlane(236, Sector.floor, -96); break; } case '969B9691007490CF022B632B2729CA49': // clavnoxr map03 { SetLineSpecial(96, 160, 1, 2, 0, 128); OffsetSectorPlane(11, Sector.floor, -80); SetLineSpecial(955, 160, 13, 2, 0, 128); OffsetSectorPlane(173, Sector.floor, -16); SetLineSpecial(1082, 160, 14, 2, 0, 128); OffsetSectorPlane(195, Sector.floor, -16); SetLineSpecial(1111, 160, 15, 2, 0, 128); OffsetSectorPlane(203, Sector.floor, -16); SetLineSpecial(1115, 160, 16, 2, 0, 128); OffsetSectorPlane(204, Sector.floor, -16); SetLineSpecial(1163, 160, 17, 2, 0, 128); OffsetSectorPlane(216, Sector.floor, -56); SetLineSpecial(1169, 160, 18, 2, 0, 128); OffsetSectorPlane(217, Sector.floor, -16); break; } case '748EDAEB3990F13B22C13C593631B2E6': // clavnoxr map04 { SetLineSpecial(859, 160, 22, 2, 0, 128); SetLineSpecial(861, 160, 23, 2, 0, 128); OffsetSectorPlane(172, Sector.floor, -168); break; } case 'A066B0B432FAE8ED20B83383F9E03E12': // clavnoxr map05 { SetLineSpecial(1020, 160, 2, 2, 0, 128); SetSectorSpecial(190, 69); OffsetSectorPlane(190, Sector.floor, -24); break; } case '5F36D758ED26CAE907FA79902330877D': // clavnoxr map06 { SetLineSpecial(1086, 160, 1, 2, 0, 128); SetLineSpecial(60, 160, 4, 2, 0, 128); SetLineSpecial(561, 160, 2, 2, 0, 128); SetLineSpecial(280, 160, 3, 2, 0, 128); SetLineSpecial(692, 160, 5, 2, 0, 128); SetLineSpecial(1090, 160, 7, 2, 0, 128); SetLineSpecial(1091, 160, 8, 2, 0, 128); SetLineSpecial(1094, 160, 9, 2, 0, 128); SetLineSpecial(1139, 160, 12, 2, 0, 128); SetLineSpecial(1595, 160, 16, 2, 0, 128); SetLineSpecial(1681, 160, 17, 2, 0, 128); SetLineSpecial(1878, 160, 20, 2, 0, 128); SetLineSpecial(1882, 160, 22, 2, 0, 128); OffsetSectorPlane(8, Sector.floor, -64); OffsetSectorPlane(34, Sector.floor, -24); OffsetSectorPlane(64, Sector.floor, -16); OffsetSectorPlane(102, Sector.floor, -16); OffsetSectorPlane(170, Sector.floor, -64); OffsetSectorPlane(171, Sector.floor, -64); OffsetSectorPlane(178, Sector.floor, -16); OffsetSectorPlane(236, Sector.floor, -16); OffsetSectorPlane(250, Sector.floor, -16); OffsetSectorPlane(283, Sector.floor, -64); OffsetSectorPlane(284, Sector.floor, -56); break; } case 'B7E98C1EA1B38B707ADA8097C25CFA75': // clavnoxr map07 { SetLineSpecial(1307, 160, 22, 2, 0, 128); SetLineSpecial(1305, 160, 23, 2, 0, 128); OffsetSectorPlane(218, Sector.floor, -64); break; } case '7DAB2E8BB5759D742211505A3E5054D1': // clavnoxr map08 { SetLineSpecial(185, 160, 1, 2, 0, 128); SetLineSpecial(735, 160, 13, 2, 0, 128); OffsetSectorPlane(20, Sector.floor, -16); SetSectorSpecial(20, 69); OffsetSectorPlane(102, Sector.floor, -64); break; } case 'C17A9D1350399E251C70711EB22856AE': // clavnoxr map09 { SetLineSpecial(63, 160, 1, 2, 0, 128); SetLineSpecial(84, 160, 2, 2, 0, 128); SetLineSpecial(208, 160, 4, 2, 0, 128); SetLineSpecial(326, 160, 6, 2, 0, 128); SetLineSpecial(433, 160, 10, 2, 0, 128); OffsetSectorPlane(6, Sector.floor, -64); OffsetSectorPlane(9, Sector.floor, -64); OffsetSectorPlane(34, Sector.floor, -64); OffsetSectorPlane(59, Sector.floor, -64); SetSectorSpecial(75, 69); OffsetSectorPlane(75, Sector.floor, -64); break; } case 'B6BB8A1792FE51C773E6770CD91DB618': // clavnoxr map11 { SetLineSpecial(1235, 160, 23, 2, 0, 128); SetLineSpecial(1238, 160, 24, 2, 0, 128); OffsetSectorPlane(240, Sector.floor, -80); break; } case 'ADDF57B80E389F86D324571D43F3CAB7': // clavnoxr map12 { SetLineSpecial(1619, 160, 19, 2, 0, 128); SetLineSpecial(1658, 160, 20, 2, 0, 128); SetLineSpecial(1659, 160, 21, 2, 0, 128); OffsetSectorPlane(254, Sector.floor, -160); // Raising platforms in MAP12 didn't work, so this will redo them. SetLineSpecial(1469, 160, 6, 1, 0, 255); OffsetSectorPlane(65, Sector.floor, -8); OffsetSectorPlane(65, Sector.ceiling, 8); break; } case '75E2685CA8AB29108DBF1AC98C5450AC': // Ancient Beliefs (beliefs.wad) map01 { //Actors with no game mode will now appear SetThingFlags(0, MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH); for(int i = 2; i < 7; i++) SetThingFlags(i, MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH); break; } case 'C4850382A78BF637AC9FC58153E03C87': // sapphire.wad map01 { SetLineSpecial(11518, 9, 0, 0, 0, 0); break; } case 'BA530202AF0BA0C6CBAE6A0C7076FB72': // Requiem MAP04 { // Flag deathmatch berserk for 100% items in single-player SetThingFlags(284, 17); // Make Hell Knight trap switch repeatable to prevent softlock SetLineFlags(823, Line.ML_REPEAT_SPECIAL); break; } case '104415DDEBCAFB9783CA60807C46B57D': // Requiem MAP05 { // Raise spectre pit near soulsphere if player drops into it for(int i = 0; i < 4; i++) { SetLineSpecial(2130+i, Floor_LowerToHighest, 28, 8, 128); SetLineActivation(2130+i, SPAC_Cross); } break; } case '1B0AF5286D4E914C5E903BC505E6A844': // Requiem MAP06 { // Flag deathmatch berserks for 100% items in single-player SetThingFlags(103, 17); SetThingFlags(109, 17); // Shooting the cross before all Imps spawn in can make 100% // kills impossible, add line actions and change sector tag for(int i = 0; i < 7; i++) { SetLineSpecial(1788+i, Floor_RaiseToNearest, 100, 32); SetLineActivation(1788+i, SPAC_Cross); } SetLineSpecial(1796, Floor_RaiseToNearest, 100, 32); SetLineActivation(1796, SPAC_Cross); SetLineSpecial(1800, Floor_RaiseToNearest, 100, 32); SetLineActivation(1800, SPAC_Cross); SetLineSpecial(1802, Floor_RaiseToNearest, 100, 32); SetLineActivation(1802, SPAC_Cross); ClearSectorTags(412); AddSectorTag(412, 100); // Shootable cross at demon-faced floor changed to repeatable // action to prevent softlock if "spikes" are raised again SetLineFlags(2600, Line.ML_REPEAT_SPECIAL); break; } case '3C10B1B017E902BE7CDBF2436DF56973': // Requiem MAP08 { // Flag deathmatch soulsphere for 100% items in single-player SetThingFlags(48, 17); // Allow player to leave inescapable lift using the walls for(int i = 0; i < 3; i++) { SetLineSpecial(2485+i, Plat_DownWaitUpStayLip, 68, 64, 105, 0); SetLineActivation(2485+i, SPAC_Use); SetLineFlags(2485+i, Line.ML_REPEAT_SPECIAL); } SetLineSpecial(848, Plat_DownWaitUpStayLip, 68, 64, 105, 0); SetLineActivation(848, SPAC_UseBack); SetLineFlags(848, Line.ML_REPEAT_SPECIAL); SetLineSpecial(895, Plat_DownWaitUpStayLip, 68, 64, 105, 0); SetLineActivation(895, SPAC_UseBack); SetLineFlags(895, Line.ML_REPEAT_SPECIAL); break; } case '14FE46ED0458979118007E1906A0C9BC': // Requiem MAP09 { // Flag deathmatch items for 100% items in single-player for(int i = 0; i < 6; i++) SetThingFlags(371+i, 17); for(int i = 0; i < 19; i++) SetThingFlags(402+i, 17); SetThingFlags(359, 17); SetThingFlags(389, 17); SetThingFlags(390, 17); // Change sides of blue skull platform to be repeatable for(int i = 0; i < 4; i++) SetLineFlags(873+i, Line.ML_REPEAT_SPECIAL); // Make switch that raises bars near yellow skull repeatable SetLineFlags(2719, Line.ML_REPEAT_SPECIAL); break; } case '53A6369C3C8DA4E7AC443A8F8684E38E': // Requiem MAP12 { // Remove unreachable secrets SetSectorSpecial(352, 0); SetSectorSpecial(503, 0); // Change action of eastern switch at pool of water so that it // lowers the floor properly, making the secret accessible SetLineSpecial(4873, Floor_LowerToLowest, 62, 8); break; } case '2DAB6E4B19B4F2763695267D39CD0275': // Requiem MAP13 { // Fix missing nukage at starting bridge on hardware renderer for(int i = 0; i < 4; i++) SetLineSectorRef(2152+i, Line.back, 8); break; } case 'F55FB2A8DC68CFC75E4340EF4ED7A8BF': // Requiem MAP21 { // Fix self-referencing floor hack for(int i = 0; i < 4; i++) SetLineSectorRef(3+i, Line.back, 219); SetLineSpecial(8, Transfer_Heights, 80); // Fix south side of pit hack so textures don't bleed through // the fake floor on hardware renderer SetLineSectorRef(267, Line.back, 63); SetLineSectorRef(268, Line.back, 63); SetLineSectorRef(270, Line.back, 63); SetLineSectorRef(271, Line.back, 63); SetLineSectorRef(274, Line.back, 63); SetLineSectorRef(275, Line.back, 63); SetLineSectorRef(3989, Line.back, 63); SetLineSectorRef(3994, Line.back, 63); // Fix fake 3D bridge on hardware renderer SetLineSectorRef(506, Line.back, 841); SetLineSectorRef(507, Line.back, 841); SetLineSectorRef(536, Line.back, 841); SetLineSectorRef(537, Line.back, 841); SetLineSectorRef(541, Line.back, 841); SetLineSectorRef(547, Line.back, 841); AddSectorTag(90, 1000); AddSectorTag(91, 1000); SetSectorTexture(90, Sector.floor, "MFLR8_4"); SetSectorTexture(91, Sector.floor, "MFLR8_4"); SetLineSectorRef(553, Line.back, 841); SetLineSectorRef(554, Line.back, 841); SetLineSectorRef(559, Line.back, 841); SetLineSectorRef(560, Line.back, 841); SetLineSectorRef(562, Line.back, 841); SetLineSectorRef(568, Line.back, 841); AddSectorTag(96, 1000); AddSectorTag(97, 1000); SetSectorTexture(96, Sector.floor, "MFLR8_4"); SetSectorTexture(97, Sector.floor, "MFLR8_4"); SetLineSpecial(505, Transfer_Heights, 1000); // Fix randomly appearing ceiling at deep water SetLineSectorRef(1219, Line.front, 233); SetLineSectorRef(1222, Line.front, 233); SetLineSectorRef(1223, Line.front, 233); SetLineSectorRef(1228, Line.front, 233); // Make switch in sky room repeatable so player does not get // trapped at red cross if returning a second time SetLineFlags(3870, Line.ML_REPEAT_SPECIAL); // Move unreachable item bonuses SetThingXY(412, -112, 6768); SetThingXY(413, -112, 6928); SetThingXY(414, -96, 6928); SetThingXY(415, -96, 6768); // Remove unreachable secret at exit megasphere SetSectorSpecial(123, 0); break; } case '2499CF9A9351BE9BC4E9C66FC9F291A7': // Requiem MAP23 { // Have arch-vile who creates ghost monsters not count as a kill SetThingFlags(0, GetThingFlags(0) | MTF_NOCOUNT); // Remove secret at switch that can only be scored by crouching SetSectorSpecial(240, 0); break; } case '1497894956B3C8EBE8A240B7FDD99C6A': // Memento Mori 2 MAP25 { // an imp is used for the lift activation and cannot be killed SetThingFlags(51, GetThingFlags (51) | MTF_NOCOUNT); break; } case '51960F3E9D46449E98DBC7D97F49DB23': // Shotgun Symphony E1M1 { // harmless cyberdemon included for the 'story' sake SetThingFlags(158, GetThingFlags (158) | MTF_NOCOUNT); break; } case '60D362BAE16B4C10A1DCEE442C878CAE': // 50 Shades of Graytall MAP06 { // there are four invisibility spheres used for decoration SetThingFlags(144, GetThingFlags (144) | MTF_NOCOUNT); SetThingFlags(145, GetThingFlags (145) | MTF_NOCOUNT); SetThingFlags(194, GetThingFlags (194) | MTF_NOCOUNT); SetThingFlags(195, GetThingFlags (195) | MTF_NOCOUNT); break; } case 'C104E740CC3F70BCFD5D2EA8E833318D': // 50 Monsters MAP29 { // there are two invisibility spheres used for decoration SetThingFlags(111, GetThingFlags (111) | MTF_NOCOUNT); SetThingFlags(112, GetThingFlags (112) | MTF_NOCOUNT); break; } case '76393C84102480A4C75A4674C9C3217A': // Deadly Standards 2 E2M8 { // 923 lost souls are used as environmental hazard for (int i = 267; i < 275; i++) SetThingFlags (i, GetThingFlags (i) | MTF_NOCOUNT); for (int i = 482; i < 491; i++) SetThingFlags (i, GetThingFlags (i) | MTF_NOCOUNT); for (int i = 510; i < 522; i++) SetThingFlags (i, GetThingFlags (i) | MTF_NOCOUNT); for (int i = 880; i < 1510; i++) SetThingFlags (i, GetThingFlags (i) | MTF_NOCOUNT); for (int i = 1622; i < 1660; i++) SetThingFlags (i, GetThingFlags (i) | MTF_NOCOUNT); for (int i = 1682; i < 1820; i++) SetThingFlags (i, GetThingFlags (i) | MTF_NOCOUNT); for (int i = 1847; i < 1875; i++) SetThingFlags (i, GetThingFlags (i) | MTF_NOCOUNT); for (int i = 2110; i < 2114; i++) SetThingFlags (i, GetThingFlags (i) | MTF_NOCOUNT); for (int i = 2243; i < 2293; i++) SetThingFlags (i, GetThingFlags (i) | MTF_NOCOUNT); SetThingFlags(493, GetThingFlags (493) | MTF_NOCOUNT); SetThingFlags(573, GetThingFlags (573) | MTF_NOCOUNT); SetThingFlags(613, GetThingFlags (613) | MTF_NOCOUNT); SetThingFlags(614, GetThingFlags (614) | MTF_NOCOUNT); SetThingFlags(1679, GetThingFlags (1679) | MTF_NOCOUNT); SetThingFlags(1680, GetThingFlags (1680) | MTF_NOCOUNT); break; } case '42B4D294A60BE4E3500AF150291CF6D4': // Hell Ground MAP05 { // 5 cyberdemons are located at the 'pain end' sector for (int i = 523; i < 528; i++) SetThingFlags (i, GetThingFlags (i) | MTF_NOCOUNT); break; } case '0C0513A9821F26F3D7997E3B0359A318': // Mayhem 1500 MAP06 { // there's an archvile behind the bossbrain at the very end that can't be killed SetThingFlags(61, GetThingFlags (61) | MTF_NOCOUNT); break; } case '00641DA23DDE998F6725BC5896A0DBC2': // 20 Years of Doom E1M8 { // 32 lost souls are located at the 'pain end' sector for (int i = 1965; i < 1975; i++) SetThingFlags (i, GetThingFlags (i) | MTF_NOCOUNT); for (int i = 2189; i < 2202; i++) SetThingFlags (i, GetThingFlags (i) | MTF_NOCOUNT); for (int i = 2311; i < 2320; i++) SetThingFlags (i, GetThingFlags (i) | MTF_NOCOUNT); break; } case 'EEBDD9CA280F6FF06C30AF2BEE85BF5F': // 2002ad10.wad E3M3 { // swarm of cacodemons at the end meant to be pseudo-endless and not killed for (int i = 467; i < 547; i++) SetThingFlags (i, GetThingFlags (i) | MTF_NOCOUNT); break; } case '988DFF5BB7073B857DEE3957A91C8518': // Speed of Doom MAP14 { // you can get only one of the soulspheres, the other, depending on your choice, becomes unavailable SetThingFlags(1044, GetThingFlags (1044) | MTF_NOCOUNT); SetThingFlags(1045, GetThingFlags (1045) | MTF_NOCOUNT); break; } case '361734AC5D78E872A05335C83E4F6DB8': // inf-lutz.wad E3M8 { // there is a trap with 10 cyberdemons at the end of the map, you are not meant to kill them for (int i = 541; i < 546; i++) SetThingFlags (i, GetThingFlags (i) | MTF_NOCOUNT); for (int i = 638; i < 643; i++) SetThingFlags (i, GetThingFlags (i) | MTF_NOCOUNT); break; } case '8F844B272E7235E82EA78AD2A2EB2D4A': // Serenity E3M7 { // two spheres can't be obtained and thus should not count towards 100% items SetThingFlags(443, GetThingFlags (443) | MTF_NOCOUNT); SetThingFlags(444, GetThingFlags (444) | MTF_NOCOUNT); // one secret is unobtainable SetSectorSpecial (97, 0); break; } case 'A50AC05CCE4F07413A0C4883C5E24215': // dbimpact.wad e1m7 { SetLineFlags(1461, Line.ML_REPEAT_SPECIAL); SetLineFlags(1468, Line.ML_REPEAT_SPECIAL); break; } case 'E0D747B9EE58A0CB74B9AD54423AC15C': // return01.wad e1m2 { // fix broken switch to raise the exit bridge SetLineSpecial(1248, Floor_RaiseByValue, 39, 8, 512); break; } case '1C35384B22BD805F51B3B2C9D17D62E4': // 007ltsd.wad E4M7 { // Fix impassable exit line SetLineFlags(6842, 0, Line.ML_BLOCKING); break; } case '50E394239FF64264950D11883E933553': // 1024.wad map05 { // Change duplicate player 2 start to player 3 start SetThingEdNum(59, 3); break; } case '3F0965ADCEB2F4A7BF46FADF6DD941B0': // phocas2.wad map01 { // turn map spot into teleport dest. SetThingEdNum(699, 9044); break; } case 'C8E727FFBA0BA445666C80340BF3D0AC': // god_.WAD E1M2 { // fix bad skill flags for a monster that's required to be killed. SetThingSkills(1184, 1); break; } } } } class LevelPostProcessor native play { protected native LevelLocals level; protected void Apply(Name checksum, String mapname) { } protected native void ClearSectorTags(int sector); protected native void AddSectorTag(int sector, int tag); protected native void ClearLineIDs(int line); protected native void AddLineID(int line, int tag); protected native void OffsetSectorPlane(int sector, int plane, double offset); protected native void SetSectorPlane(int sector, int plane, vector3 normal, double d); const SKILLS_ALL = 31; const MODES_ALL = MTF_SINGLE | MTF_COOPERATIVE | MTF_DEATHMATCH; protected native uint GetThingCount(); protected native uint AddThing(int ednum, Vector3 pos, int angle = 0, uint skills = SKILLS_ALL, uint flags = MODES_ALL); protected native int GetThingEdNum(uint thing); protected native void SetThingEdNum(uint thing, int ednum); protected native vector3 GetThingPos(uint thing); protected native void SetThingXY(uint thing, double x, double y); protected native void SetThingZ(uint thing, double z); protected native int GetThingAngle(uint thing); protected native void SetThingAngle(uint thing, int angle); protected native uint GetThingSkills(uint thing); protected native void SetThingSkills(uint thing, uint skills); protected native uint GetThingFlags(uint thing); protected native void SetThingFlags(uint thing, uint flags); protected native int GetThingID(uint thing); protected native void SetThingID(uint thing, int id); protected native int GetThingSpecial(uint thing); protected native void SetThingSpecial(uint thing, int special); protected native int GetThingArgument(uint thing, uint index); protected native Name GetThingStringArgument(uint thing); protected native void SetThingArgument(uint thing, uint index, int value); protected native void SetThingStringArgument(uint thing, Name value); protected native void SetVertex(uint vertex, double x, double y); protected native double, bool GetVertexZ(uint vertex, int plane); protected native void SetVertexZ(uint vertex, int plane, double z); protected native void RemoveVertexZ(uint vertex, int plane); protected native void SetLineVertexes(uint Line, uint v1, uint v2); protected native void FlipLineSideRefs(uint Line); protected native void SetLineSectorRef(uint line, uint side, uint sector); protected native Actor GetDefaultActor(Name actorclass); protected void FlipLineVertexes(uint Line) { uint v1 = level.lines[Line].v1.Index(); uint v2 = level.lines[Line].v2.Index(); SetLineVertexes(Line, v2, v1); } protected void FlipLineCompletely(uint Line) { FlipLineVertexes(Line); FlipLineSideRefs(Line); } protected void SetWallTexture(int line, int side, int texpart, String texture) { SetWallTextureID(line, side, texpart, TexMan.CheckForTexture(texture, TexMan.Type_Wall)); } protected void SetWallTextureID(int line, int side, int texpart, TextureID texture) { level.Lines[line].sidedef[side].SetTexture(texpart, texture); } protected void SetLineFlags(int line, int setflags, int clearflags = 0) { level.Lines[line].flags = (level.Lines[line].flags & ~clearflags) | setflags; } protected void SetLineActivation(int line, int acttype) { level.Lines[line].activation = acttype; } protected void ClearLineSpecial(int line) { level.Lines[line].special = 0; } protected void SetLineSpecial(int line, int special, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0, int arg5 = 0) { level.Lines[line].special = special; level.Lines[line].args[0] = arg1; level.Lines[line].args[1] = arg2; level.Lines[line].args[2] = arg3; level.Lines[line].args[3] = arg4; level.Lines[line].args[4] = arg5; } protected void SetSectorSpecial(int sectornum, int special) { level.sectors[sectornum].special = special; } protected void SetSectorTextureID(int sectornum, int plane, TextureID texture) { level.sectors[sectornum].SetTexture(plane, texture); } protected void SetSectorTexture(int sectornum, int plane, String texture) { SetSectorTextureID(sectornum, plane, TexMan.CheckForTexture(texture, TexMan.Type_Flat)); } protected void SetSectorLight(int sectornum, int newval) { level.sectors[sectornum].SetLightLevel(newval); } protected void SetWallYScale(int line, int side, int texpart, double scale) { level.lines[line].sidedef[side].SetTextureYScale(texpart, scale); } } /* ** listmenu.zs ** The main menu class ** **--------------------------------------------------------------------------- ** Copyright 2010-2020 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ class ListMenuDescriptor : MenuDescriptor native { enum EScale { CleanScale = -1, OptCleanScale = -2 }; native Array mItems; native int mSelectedItem; native double mSelectOfsX; native double mSelectOfsY; native TextureID mSelector; native int mDisplayTop; native double mXpos, mYpos; native int mWLeft, mWRight; native int mLinespacing; // needs to be stored for dynamically created menus native int mAutoselect; // this can only be set by internal menu creation functions native Font mFont; native int mFontColor; native int mFontColor2; native bool mCenter; native bool mAnimatedTransition; native bool mAnimated; native bool mDontBlur; native bool mDontDim; native int mVirtWidth, mVirtHeight; native void Reset(); int DisplayWidth() { if (mVirtWidth == OptCleanScale) return m_cleanscale ? CleanScale : 320; return mVirtWidth; } int DisplayHeight() { if (mVirtWidth == OptCleanScale) return m_cleanscale ? CleanScale : 200; return mVirtHeight; } } //============================================================================= // // list menu class runs a menu described by a DListMenuDescriptor // //============================================================================= class ListMenu : Menu { ListMenuDescriptor mDesc; MenuItemBase mFocusControl; virtual void Init(Menu parent = NULL, ListMenuDescriptor desc = NULL) { Super.Init(parent); mDesc = desc; AnimatedTransition = mDesc.mAnimatedTransition; Animated = mDesc.mAnimated; DontBlur = mDesc.mDontBlur; DontDim = mDesc.mDontDim; if (desc.mCenter) { double center = 160; for(int i=0; i < mDesc.mItems.Size(); i++) { double xpos = mDesc.mItems[i].GetX(); int width = mDesc.mItems[i].GetWidth(); double curx = mDesc.mSelectOfsX; if (width > 0 && mDesc.mItems[i].Selectable()) { double left = 160 - (width - curx) / 2 - curx; if (left < center) center = left; } } for(int i=0;i 0) { mDesc.mItems[i].SetX(center); } } } // notify all items that the menu was just created. for(int i=0;i 0) { // tolower int ch = ev.KeyChar; ch = ch >= 65 && ch < 91 ? ch + 32 : ch; for(int i = mDesc.mSelectedItem + 1; i < mDesc.mItems.Size(); i++) { if (mDesc.mitems[i].Selectable() && mDesc.mItems[i].CheckHotkey(ch)) { mDesc.mSelectedItem = i; MenuSound("menu/cursor"); return true; } } for(int i = 0; i < mDesc.mSelectedItem; i++) { if (mDesc.mitems[i].Selectable() && mDesc.mItems[i].CheckHotkey(ch)) { mDesc.mSelectedItem = i; MenuSound("menu/cursor"); return true; } } } return Super.OnUIEvent(ev); } //============================================================================= // // // //============================================================================= override bool MenuEvent (int mkey, bool fromcontroller) { int oldSelect = mDesc.mSelectedItem; int startedAt = max(0, mDesc.mSelectedItem); switch (mkey) { case MKEY_Up: do { if (--mDesc.mSelectedItem < 0) mDesc.mSelectedItem = mDesc.mItems.Size()-1; } while (!mDesc.mItems[mDesc.mSelectedItem].Selectable() && mDesc.mSelectedItem != startedAt); if (mDesc.mSelectedItem == startedAt) mDesc.mSelectedItem = oldSelect; MenuSound("menu/cursor"); return true; case MKEY_Down: do { if (++mDesc.mSelectedItem >= mDesc.mItems.Size()) mDesc.mSelectedItem = 0; } while (!mDesc.mItems[mDesc.mSelectedItem].Selectable() && mDesc.mSelectedItem != startedAt); if (mDesc.mSelectedItem == startedAt) mDesc.mSelectedItem = oldSelect; MenuSound("menu/cursor"); return true; case MKEY_Enter: if (mDesc.mSelectedItem >= 0 && mDesc.mItems[mDesc.mSelectedItem].Activate()) { MenuSound("menu/advance"); } return true; default: return Super.MenuEvent(mkey, fromcontroller); } } //============================================================================= // // // //============================================================================= override bool MouseEvent(int type, int x, int y) { int sel = -1; int w = mDesc.DisplayWidth(); double sx, sy; if (w == ListMenuDescriptor.CleanScale) { // convert x/y from screen to virtual coordinates, according to CleanX/Yfac use in DrawTexture x = ((x - (screen.GetWidth() / 2)) / CleanXfac) + 160; y = ((y - (screen.GetHeight() / 2)) / CleanYfac) + 100; } else { // for fullscreen scale, transform coordinates so that for the given rect the coordinates are within (0, 0, w, h) int h = mDesc.DisplayHeight(); double fx, fy, fw, fh; [fx, fy, fw, fh] = Screen.GetFullscreenRect(w, h, FSMode_ScaleToFit43); x = int((x - fx) * w / fw); y = int((y - fy) * h / fh); } if (mFocusControl != NULL) { mFocusControl.MouseEvent(type, x, y); return true; } else { if ((mDesc.mWLeft <= 0 || x > mDesc.mWLeft) && (mDesc.mWRight <= 0 || x < mDesc.mWRight)) { for(int i=0;i= 0 && mDesc.mSelectedItem < mDesc.mItems.Size()) { if (!menuDelegate.DrawSelector(mDesc)) mDesc.mItems[mDesc.mSelectedItem].DrawSelector(mDesc.mSelectOfsX, mDesc.mSelectOfsY, mDesc.mSelector, mDesc); } Super.Drawer(); } //============================================================================= // // // //============================================================================= override void SetFocus(MenuItemBase fc) { mFocusControl = fc; } override bool CheckFocus(MenuItemBase fc) { return mFocusControl == fc; } override void ReleaseFocus() { mFocusControl = NULL; } //============================================================================= // // // //============================================================================= void ChangeLineSpacing(int newspace) { double top = -32767; for (int i = 0; i < mDesc.mItems.Size(); i++) { let selitem = ListMenuItemSelectable(mDesc.mItems[i]); if (selitem) { let y = mDesc.mItems[i].GetY(); if (top == -32767) { top = y; } else { let newy = top + (y - top) / mDesc.mLineSpacing * newspace; mDesc.mItems[i].SetY(newy); } } } mDesc.mLineSpacing = newspace; } } /* ** listmenu.cpp ** A simple menu consisting of a list of items ** **--------------------------------------------------------------------------- ** Copyright 2010-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ class ListMenuItem : MenuItemBase { protected void DrawText(ListMenuDescriptor desc, Font fnt, int color, double x, double y, String text, bool ontop = false) { int w = desc ? desc.DisplayWidth() : ListMenuDescriptor.CleanScale; int h = desc ? desc.DisplayHeight() : -1; if (w == ListMenuDescriptor.CleanScale) { screen.DrawText(fnt, color, x, y, text, ontop? DTA_CleanTop : DTA_Clean, true); } else { screen.DrawText(fnt, color, x, y, text, DTA_VirtualWidth, w, DTA_VirtualHeight, h, DTA_FullscreenScale, FSMode_ScaleToFit43); } } protected void DrawTexture(ListMenuDescriptor desc, TextureID tex, double x, double y, bool ontop = false) { int w = desc ? desc.DisplayWidth() : ListMenuDescriptor.CleanScale; int h = desc ? desc.DisplayHeight() : -1; if (w == ListMenuDescriptor.CleanScale) { screen.DrawTexture(tex, true, x, y, ontop ? DTA_CleanTop : DTA_Clean, true); } else { screen.DrawTexture(tex, true, x, y, DTA_VirtualWidth, w, DTA_VirtualHeight, h, DTA_FullscreenScale, FSMode_ScaleToFit43); } } virtual void DrawSelector(double xofs, double yofs, TextureID tex, ListMenuDescriptor desc = null) { if (tex.isNull()) { if ((Menu.MenuTime() % 8) < 6) { DrawText(desc, ConFont, OptionMenuSettings.mFontColorSelection, mXpos + xofs, mYpos + yofs + 8, "\xd"); } } else { DrawTexture(desc, tex, mXpos + xofs, mYpos + yofs); } } // We cannot extend Drawer here because it is inherited from the parent class. virtual void Draw(bool selected, ListMenuDescriptor desc) { Drawer(selected); // fall back to the legacy version, if not overridden } } //============================================================================= // // static patch // //============================================================================= class ListMenuItemStaticPatch : ListMenuItem { TextureID mTexture; bool mCentered; String mSubstitute; Font mFont; int mColor; void Init(ListMenuDescriptor desc, double x, double y, TextureID patch, bool centered = false, String substitute = "") { Super.Init(x, y); mTexture = patch; mCentered = centered; mSubstitute = substitute; mFont = desc.mFont; mColor = desc.mFontColor; } override void Draw(bool selected, ListMenuDescriptor desc) { if (!mTexture.Exists()) { return; } double x = mXpos; Vector2 vec = TexMan.GetScaledSize(mTexture); if (mSubstitute == "" || TexMan.OkForLocalization(mTexture, mSubstitute)) { if (mCentered) x -= vec.X / 2; DrawTexture(desc, mTexture, x, abs(mYpos), mYpos < 0); } else { let font = generic_ui ? NewSmallFont : mFont; if (mCentered) x -= font.StringWidth(mSubstitute) / 2; DrawText(desc, font, mColor, x, abs(mYpos), mSubstitute, mYpos < 0); } } } class ListMenuItemStaticPatchCentered : ListMenuItemStaticPatch { void Init(ListMenuDescriptor desc, double x, double y, TextureID patch) { Super.Init(desc, x, y, patch, true); } } //============================================================================= // // static text // //============================================================================= class ListMenuItemStaticText : ListMenuItem { String mText; Font mFont; int mColor; bool mCentered; void Init(ListMenuDescriptor desc, double x, double y, String text, int color = -1) { Super.Init(x, y); mText = text; mFont = desc.mFont; mColor = color >= 0? color : desc.mFontColor; mCentered = false; } void InitDirect(double x, double y, String text, Font font, int color = Font.CR_UNTRANSLATED, bool centered = false) { Super.Init(x, y); mText = text; mFont = font; mColor = color; mCentered = centered; } override void Draw(bool selected, ListMenuDescriptor desc) { if (mText.Length() != 0) { let font = generic_ui? NewSmallFont : mFont; String text = Stringtable.Localize(mText); double x = mXpos; if (mCentered) x -= font.StringWidth(text) / 2; DrawText(desc, font, mColor, x, abs(mYpos), text, mYpos < 0); } } } class ListMenuItemStaticTextCentered : ListMenuItemStaticText { void Init(ListMenuDescriptor desc, double x, double y, String text, int color = -1) { Super.Init(desc, x, y, text, color); mCentered = true; } } //============================================================================= // // selectable items // //============================================================================= class ListMenuItemSelectable : ListMenuItem { int mHotkey; int mHeight; int mParam; protected void Init(double x, double y, int height, Name childmenu, int param = -1) { Super.Init(x, y, childmenu); mHeight = height; mParam = param; mHotkey = 0; } override bool CheckCoordinate(int x, int y) { return mEnabled > 0 && y >= mYpos && y < mYpos + mHeight; // no x check here } override bool Selectable() { return mEnabled > 0; } override bool CheckHotkey(int c) { return c > 0 && c == mHotkey; } override bool Activate() { Menu.SetMenu(mAction, mParam); return true; } override bool MouseEvent(int type, int x, int y) { if (type == Menu.MOUSE_Release) { let m = Menu.GetCurrentMenu(); if (m != NULL && m.MenuEvent(Menu.MKEY_Enter, true)) { return true; } } return false; } override Name, int GetAction() { return mAction, mParam; } } //============================================================================= // // text item // //============================================================================= class ListMenuItemTextItem : ListMenuItemSelectable { String mText; Font mFont; int mColor; int mColorSelected; void Init(ListMenuDescriptor desc, String text, String hotkey, Name child, int param = 0) { Super.Init(desc.mXpos, desc.mYpos, desc.mLinespacing, child, param); mText = text; mFont = desc.mFont; mColor = desc.mFontColor; mColorSelected = desc.mFontcolor2; mHotkey = hotkey.GetNextCodePoint(0); } void InitDirect(double x, double y, int height, String hotkey, String text, Font font, int color, int color2, Name child, int param = 0) { Super.Init(x, y, height, child, param); mText = text; mFont = font; mColor = color; mColorSelected = color2; int pos = 0; mHotkey = hotkey.GetNextCodePoint(0); } override void Draw(bool selected, ListMenuDescriptor desc) { let font = menuDelegate.PickFont(mFont); DrawText(desc, font, selected ? mColorSelected : mColor, mXpos, mYpos, mText); } override int GetWidth() { let font = menuDelegate.PickFont(mFont); return max(1, font.StringWidth(StringTable.Localize(mText))); } } //============================================================================= // // patch item // //============================================================================= class ListMenuItemPatchItem : ListMenuItemSelectable { TextureID mTexture; void Init(ListMenuDescriptor desc, TextureID patch, String hotkey, Name child, int param = 0) { Super.Init(desc.mXpos, desc.mYpos, desc.mLinespacing, child, param); mHotkey = hotkey.GetNextCodePoint(0); mTexture = patch; } void InitDirect(double x, double y, int height, TextureID patch, String hotkey, Name child, int param = 0) { Super.Init(x, y, height, child, param); mHotkey = hotkey.GetNextCodePoint(0); mTexture = patch; } override void Draw(bool selected, ListMenuDescriptor desc) { DrawTexture(desc, mTexture, mXpos, mYpos); } override int GetWidth() { return TexMan.GetSize(mTexture); } } //============================================================================= // // caption - draws a text using the customizer's caption hook // //============================================================================= class ListMenuItemCaptionItem : ListMenuItem { String mText; Font mFont; void Init(ListMenuDescriptor desc, String text, String fnt = "BigFont") { Super.Init(0, 0); mText = text; mFont = Font.FindFont(fnt); } override void Draw(bool selected, ListMenuDescriptor desc) { let font = menuDelegate.PickFont(desc.mFont); if (font && mText.Length() > 0) { menuDelegate.DrawCaption(mText, font, 0, true); } } } /* ** loacpp ** The load game and save game menus ** **--------------------------------------------------------------------------- ** Copyright 2001-2010 Randy Heit ** Copyright 2010-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ struct SaveGameNode native { native String SaveTitle; native readonly String Filename; native bool bOldVersion; native bool bMissingWads; native bool bNoDelete; } struct SavegameManager native ui { native int WindowSize; native SaveGameNode quickSaveSlot; native readonly String SaveCommentString; native static SavegameManager GetManager(); native void ReadSaveStrings(); native void UnloadSaveData(); native int RemoveSaveSlot(int index); native void LoadSavegame(int Selected); native void DoSave(int Selected, String savegamestring); native int ExtractSaveData(int index); native void ClearSaveStuff(); native bool DrawSavePic(int x, int y, int w, int h); deprecated("4.0") void DrawSaveComment(Font font, int cr, int x, int y, int scalefactor) { // Unfortunately, this was broken beyond repair so it now prints nothing. } native void SetFileInfo(int Selected); native int SavegameCount(); native SaveGameNode GetSavegame(int i); native void InsertNewSaveNode(); native bool RemoveNewSaveNode(); } class LoadSaveMenu : ListMenu { SavegameManager manager; int TopItem; int Selected; int savepicLeft; int savepicTop; int savepicWidth; int savepicHeight; int rowHeight; int listboxLeft; int listboxTop; int listboxWidth; int listboxRows; int listboxHeight; int listboxRight; int commentLeft; int commentTop; int commentWidth; int commentHeight; int commentRows; bool mEntering; TextEnterMenu mInput; double FontScale; BrokenLines BrokenSaveComment; //============================================================================= // // // //============================================================================= override void Init(Menu parent, ListMenuDescriptor desc) { Super.Init(parent, desc); manager = SavegameManager.GetManager(); manager.ReadSaveStrings(); SetWindows(); } private void SetWindows() { bool aspect43 = true; int Width43 = screen.GetHeight() * 4 / 3; int Left43 = (screen.GetWidth() - Width43) / 2; double wScale = Width43 / 640.; savepicLeft = Left43 + int(20 * wScale); savepicTop = int(mDesc.mYpos * screen.GetHeight() / 200); savepicWidth = int(240 * wScale); savepicHeight = int(180 * wScale); FontScale = max(screen.GetHeight() / 480, 1); rowHeight = int(max((NewConsoleFont.GetHeight() + 1) * FontScale, 1)); listboxLeft = savepicLeft + savepicWidth + int(20*wScale); listboxTop = savepicTop; listboxWidth = Width43 + Left43 - listboxLeft - int(30 * wScale); int listboxHeight1 = screen.GetHeight() - listboxTop - int(20*wScale); listboxRows = (listboxHeight1 - 1) / rowHeight; listboxHeight = listboxRows * rowHeight + 1; listboxRight = listboxLeft + listboxWidth; commentLeft = savepicLeft; commentTop = savepicTop + savepicHeight + int(16 * wScale); commentWidth = savepicWidth; commentHeight = listboxHeight - savepicHeight - int(16 * wScale); commentRows = commentHeight / rowHeight; } //============================================================================= // // // //============================================================================= override void OnDestroy() { //manager.ClearSaveStuff (); Super.OnDestroy(); } //============================================================================= // // // //============================================================================= virtual void DrawFrame(int left, int top, int width, int height) { let framecolor = Color(255, 80, 80, 80); Screen.DrawLineFrame(framecolor, left, top, width, height, screen.GetHeight() / 240); } override void Drawer () { Super.Drawer(); SaveGameNode node; int i; int j; bool didSeeSelected = false; // Draw picture area if (gameaction == ga_loadgame || gameaction == ga_loadgamehidecon || gameaction == ga_savegame) { return; } SetWindows(); DrawFrame(savepicLeft, savepicTop, savepicWidth, savepicHeight); if (!manager.DrawSavePic(savepicLeft, savepicTop, savepicWidth, savepicHeight)) { screen.Dim(0, 0.6, savepicLeft, savepicTop, savepicWidth, savepicHeight); if (manager.SavegameCount() > 0) { if (Selected >= manager.SavegameCount()) Selected = 0; String text = (Selected == -1 || !manager.GetSavegame(Selected).bOldVersion)? Stringtable.Localize("$MNU_NOPICTURE") : Stringtable.Localize("$MNU_DIFFVERSION"); int textlen = NewSmallFont.StringWidth(text); screen.DrawText (NewSmallFont, Font.CR_GOLD, (savepicLeft + savepicWidth / 2) / FontScale - textlen/2, (savepicTop+(savepicHeight-rowHeight)/2) / FontScale, text, DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale, DTA_KeepRatio, true); } } // Draw comment area DrawFrame (commentLeft, commentTop, commentWidth, commentHeight); screen.Dim(0, 0.6, commentLeft, commentTop, commentWidth, commentHeight); int numlinestoprint = min(commentRows, BrokenSaveComment? BrokenSaveComment.Count() : 0); for(int i = 0; i < numlinestoprint; i++) { screen.DrawText(NewConsoleFont, Font.CR_ORANGE, commentLeft / FontScale, (commentTop + rowHeight * i) / FontScale, BrokenSaveComment.StringAt(i), DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale, DTA_KeepRatio, true); } // Draw file area DrawFrame (listboxLeft, listboxTop, listboxWidth, listboxHeight); screen.Dim(0, 0.6, listboxLeft, listboxTop, listboxWidth, listboxHeight); if (manager.SavegameCount() == 0) { String text = Stringtable.Localize("$MNU_NOFILES"); int textlen = int(NewConsoleFont.StringWidth(text) * FontScale); screen.DrawText (NewConsoleFont, Font.CR_GOLD, (listboxLeft+(listboxWidth-textlen)/2) / FontScale, (listboxTop+(listboxHeight-rowHeight)/2) / FontScale, text, DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale, DTA_KeepRatio, true); return; } j = TopItem; for (i = 0; i < listboxRows && j < manager.SavegameCount(); i++) { int colr; node = manager.GetSavegame(j); if (node.bOldVersion) { colr = Font.CR_RED; } else if (node.bMissingWads) { colr = Font.CR_YELLOW; } else if (j == Selected) { colr = Font.CR_WHITE; } else { colr = Font.CR_TAN; } screen.SetClipRect(listboxLeft, listboxTop+rowHeight*i, listboxRight, listboxTop+rowHeight*(i+1)); if (j == Selected) { screen.Clear (listboxLeft, listboxTop+rowHeight*i, listboxRight, listboxTop+rowHeight*(i+1), mEntering ? Color(255,255,0,0) : Color(255,0,0,255)); didSeeSelected = true; if (!mEntering) { screen.DrawText (NewConsoleFont, colr, (listboxLeft+1) / FontScale, (listboxTop+rowHeight*i + FontScale) / FontScale, node.SaveTitle, DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale, DTA_KeepRatio, true); } else { String s = mInput.GetText() .. NewConsoleFont.GetCursor(); int length = int(NewConsoleFont.StringWidth(s) * FontScale); int displacement = min(0, listboxWidth - 2 - length); screen.DrawText (NewConsoleFont, Font.CR_WHITE, (listboxLeft + 1 + displacement) / FontScale, (listboxTop+rowHeight*i + FontScale) / FontScale, s, DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale, DTA_KeepRatio, true); } } else { screen.DrawText (NewConsoleFont, colr, (listboxLeft+1) / FontScale, (listboxTop+rowHeight*i + FontScale) / FontScale, node.SaveTitle, DTA_VirtualWidthF, screen.GetWidth() / FontScale, DTA_VirtualHeightF, screen.GetHeight() / FontScale, DTA_KeepRatio, true); } screen.ClearClipRect(); j++; } } void UpdateSaveComment() { BrokenSaveComment = NewConsoleFont.BreakLines(manager.SaveCommentString, int(commentWidth / FontScale)); } //============================================================================= // // // //============================================================================= override bool MenuEvent (int mkey, bool fromcontroller) { switch (mkey) { case MKEY_Up: if (manager.SavegameCount() > 1) { if (Selected == -1) Selected = TopItem; else { if (--Selected < 0) Selected = manager.SavegameCount()-1; if (Selected < TopItem) TopItem = Selected; else if (Selected >= TopItem + listboxRows) TopItem = MAX(0, Selected - listboxRows + 1); } manager.UnloadSaveData (); manager.ExtractSaveData (Selected); UpdateSaveComment(); } return true; case MKEY_Down: if (manager.SavegameCount() > 1) { if (Selected == -1) Selected = TopItem; else { if (++Selected >= manager.SavegameCount()) Selected = 0; if (Selected < TopItem) TopItem = Selected; else if (Selected >= TopItem + listboxRows) TopItem = MAX(0, Selected - listboxRows + 1); } manager.UnloadSaveData (); manager.ExtractSaveData (Selected); UpdateSaveComment(); } return true; case MKEY_PageDown: if (manager.SavegameCount() > 1) { if (TopItem >= manager.SavegameCount() - listboxRows) { TopItem = 0; if (Selected != -1) Selected = 0; } else { TopItem = MIN(TopItem + listboxRows, manager.SavegameCount() - listboxRows); if (TopItem > Selected && Selected != -1) Selected = TopItem; } manager.UnloadSaveData (); manager.ExtractSaveData (Selected); UpdateSaveComment(); } return true; case MKEY_PageUp: if (manager.SavegameCount() > 1) { if (TopItem == 0) { TopItem = MAX(0, manager.SavegameCount() - listboxRows); if (Selected != -1) Selected = TopItem; } else { TopItem = MAX(TopItem - listboxRows, 0); if (Selected >= TopItem + listboxRows) Selected = TopItem; } manager.UnloadSaveData (); manager.ExtractSaveData (Selected); UpdateSaveComment(); } return true; case MKEY_Enter: return false; // This event will be handled by the subclasses case MKEY_MBYes: { if (Selected < manager.SavegameCount()) { Selected = manager.RemoveSaveSlot (Selected); UpdateSaveComment(); } return true; } default: return Super.MenuEvent(mkey, fromcontroller); } } //============================================================================= // // // //============================================================================= override bool MouseEvent(int type, int x, int y) { if (x >= listboxLeft && x < listboxLeft + listboxWidth && y >= listboxTop && y < listboxTop + listboxHeight) { int lineno = (y - listboxTop) / rowHeight; if (TopItem + lineno < manager.SavegameCount()) { Selected = TopItem + lineno; manager.UnloadSaveData (); manager.ExtractSaveData (Selected); UpdateSaveComment(); if (type == MOUSE_Release) { if (MenuEvent(MKEY_Enter, true)) { return true; } } } else Selected = -1; } else Selected = -1; return Super.MouseEvent(type, x, y); } //============================================================================= // // // //============================================================================= override bool OnUIEvent(UIEvent ev) { if (ev.Type == UIEvent.Type_KeyDown) { if (Selected != -1 && Selected < manager.SavegameCount()) { switch (ev.KeyChar) { case UIEvent.Key_F1: manager.SetFileInfo(Selected); UpdateSaveComment(); return true; case UIEvent.Key_DEL: { String EndString; EndString = String.Format("%s%s%s%s?\n\n%s", Stringtable.Localize("$MNU_DELETESG"), TEXTCOLOR_WHITE, manager.GetSavegame(Selected).SaveTitle, TEXTCOLOR_NORMAL, Stringtable.Localize("$PRESSYN")); StartMessage (EndString, 0); } return true; } } } else if (ev.Type == UIEvent.Type_WheelUp) { if (TopItem > 0) TopItem--; return true; } else if (ev.Type == UIEvent.Type_WheelDown) { if (TopItem < manager.SavegameCount() - listboxRows) TopItem++; return true; } return Super.OnUIEvent(ev); } } class SaveMenu : LoadSaveMenu { String mSaveName; //============================================================================= // // // //============================================================================= override void Init(Menu parent, ListMenuDescriptor desc) { Super.Init(parent, desc); manager.InsertNewSaveNode(); TopItem = 0; Selected = manager.ExtractSaveData (-1); UpdateSaveComment(); } //============================================================================= // // // //============================================================================= override void OnDestroy() { if (manager.RemoveNewSaveNode()) { Selected--; } Super.OnDestroy(); } //============================================================================= // // // //============================================================================= override bool MenuEvent (int mkey, bool fromcontroller) { if (Super.MenuEvent(mkey, fromcontroller)) { return true; } if (Selected == -1) { return false; } if (mkey == MKEY_Enter) { String SavegameString = (Selected != 0)? manager.GetSavegame(Selected).SaveTitle : ""; mInput = TextEnterMenu.OpenTextEnter(self, Menu.OptionFont(), SavegameString, -1, fromcontroller); mInput.ActivateMenu(); mEntering = true; } else if (mkey == MKEY_Input) { // Do not start the save here, it would cause some serious execution ordering problems. mEntering = false; mSaveName = mInput.GetText(); mInput = null; } else if (mkey == MKEY_Abort) { mEntering = false; mInput = null; } return false; } //============================================================================= // // // //============================================================================= override bool MouseEvent(int type, int x, int y) { if (mSaveName.Length() > 0) { // Do not process events when saving is in progress to avoid update of the current index, // i.e. Selected member variable must remain unchanged return true; } return Super.MouseEvent(type, x, y); } //============================================================================= // // // //============================================================================= override bool OnUIEvent(UIEvent ev) { if (ev.Type == UIEvent.Type_KeyDown) { if (Selected != -1) { switch (ev.KeyChar) { case UIEvent.Key_DEL: // cannot delete 'new save game' item if (Selected == 0) return true; break; case 78://'N': Selected = TopItem = 0; manager.UnloadSaveData (); return true; } } } return Super.OnUIEvent(ev); } //============================================================================= // // // //============================================================================= override void Ticker() { if (mSaveName.Length() > 0) { manager.DoSave(Selected, mSaveName); mSaveName = ""; } } } //============================================================================= // // // //============================================================================= class LoadMenu : LoadSaveMenu { //============================================================================= // // // //============================================================================= override void Init(Menu parent, ListMenuDescriptor desc) { Super.Init(parent, desc); TopItem = 0; Selected = manager.ExtractSaveData (-1); UpdateSaveComment(); } //============================================================================= // // // //============================================================================= override bool MenuEvent (int mkey, bool fromcontroller) { if (Super.MenuEvent(mkey, fromcontroller)) { return true; } if (Selected == -1 || manager.SavegameCount() == 0) { return false; } if (mkey == MKEY_Enter) { manager.LoadSavegame(Selected); return true; } return false; } } // Loremaster (aka Priest) -------------------------------------------------- class Loremaster : Actor { Default { Health 800; Speed 10; Radius 15; Height 56; FloatSpeed 5; Monster; +FLOAT +NOBLOOD +NOGRAVITY +NOTDMATCH +FLOORCLIP +NOBLOCKMONST +INCOMBAT +LOOKALLAROUND +NOICEDEATH +NEVERRESPAWN DamageFactor "Fire", 0.5; MinMissileChance 150; Tag "$TAG_PRIEST"; SeeSound "loremaster/sight"; AttackSound "loremaster/attack"; PainSound "loremaster/pain"; DeathSound "loremaster/death"; ActiveSound "loremaster/active"; Obituary "$OB_LOREMASTER"; DropItem "Junk"; } States { Spawn: PRST A 10 A_Look; PRST B 10 A_SentinelBob; Loop; See: PRST A 4 A_Chase; PRST A 4 A_SentinelBob; PRST B 4 A_Chase; PRST B 4 A_SentinelBob; PRST C 4 A_Chase; PRST C 4 A_SentinelBob; PRST D 4 A_Chase; PRST D 4 A_SentinelBob; Loop; Melee: PRST E 4 A_FaceTarget; PRST F 4 A_CustomMeleeAttack((random[SpectreMelee](0,255)&9)*5); PRST E 4 A_SentinelBob; Goto See; Missile: PRST E 4 A_FaceTarget; PRST F 4 A_SpawnProjectile("LoreShot", 32, 0); PRST E 4 A_SentinelBob; Goto See; Death: PDED A 6; PDED B 6 A_Scream; PDED C 6; PDED D 6 A_Fall; PDED E 6; PDED FGHIJIJIJKL 5; PDED MNOP 4; PDED Q 4 A_SpawnItemEx("AlienSpectre5", 0, 0, 0, 0, 0, random[spectrespawn](0,255)*0.0078125, 0, SXF_NOCHECKPOSITION); PDED RS 4; PDED T -1; Stop; } } // Loremaster Projectile ---------------------------------------------------- class LoreShot : Actor { Default { Speed 20; Height 14; Radius 10; Projectile; +STRIFEDAMAGE Damage 2; MaxStepHeight 4; SeeSound "loremaster/chain"; ActiveSound "loremaster/swish"; } States { Spawn: OCLW A 2 A_LoremasterChain; Loop; Death: OCLW A 6; Stop; } override int DoSpecialDamage (Actor victim, int damage, Name damagetype) { if (victim != NULL && target != NULL && !victim.bDontThrust) { Vector3 thrust = victim.Vec3To(target); victim.Vel += thrust.Unit() * (255. * 50 / max(victim.Mass, 1)); } return damage; } void A_LoremasterChain () { A_StartSound ("loremaster/active", CHAN_BODY); Spawn("LoreShot2", Pos, ALLOW_REPLACE); Spawn("LoreShot2", Vec3Offset(-Vel.x/2., -Vel.y/2., -Vel.z/2.), ALLOW_REPLACE); Spawn("LoreShot2", Vec3Offset(-Vel.x, -Vel.y, -Vel.z), ALLOW_REPLACE); } } // Loremaster Subprojectile ------------------------------------------------- class LoreShot2 : Actor { Default { +NOBLOCKMAP +NOGRAVITY } States { Spawn: TEND A 20; Stop; } } //=========================================================================== // // Lost Soul // //=========================================================================== class LostSoul : Actor { Default { Health 100; Radius 16; Height 56; Mass 50; Speed 8; Damage 3; PainChance 256; Monster; +FLOAT +NOGRAVITY +MISSILEMORE +DONTFALL +NOICEDEATH +ZDOOMTRANS +RETARGETAFTERSLAM AttackSound "skull/melee"; PainSound "skull/pain"; DeathSound "skull/death"; ActiveSound "skull/active"; Obituary "$OB_SKULL"; Tag "$FN_LOST"; } States { Spawn: SKUL AB 10 BRIGHT A_Look; Loop; See: SKUL AB 6 BRIGHT A_Chase; Loop; Missile: SKUL C 10 BRIGHT A_FaceTarget; SKUL D 4 BRIGHT A_SkullAttack; SKUL CD 4 BRIGHT; Goto Missile+2; Pain: SKUL E 3 BRIGHT; SKUL E 3 BRIGHT A_Pain; Goto See; Death: SKUL F 6 BRIGHT; SKUL G 6 BRIGHT A_Scream; SKUL H 6 BRIGHT; SKUL I 6 BRIGHT A_NoBlocking; SKUL J 6; SKUL K 6; Stop; } } class BetaSkull : LostSoul { States { Spawn: SKUL A 10 A_Look; Loop; See: SKUL BCDA 5 A_Chase; Loop; Missile: SKUL E 4 A_FaceTarget; SKUL F 5 A_BetaSkullAttack; SKUL F 4; Goto See; Pain: SKUL G 4; SKUL H 2 A_Pain; Goto See; SKUL I 4; Goto See; Death: SKUL JKLM 5; SKUL N 5 A_Scream; SKUL O 5; SKUL P 5 A_Fall; SKUL Q 5 A_Stop; Wait; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== extend class Actor { const DEFSKULLSPEED = 20; void A_SkullAttack(double skullspeed = DEFSKULLSPEED) { if (target == null) return; if (skullspeed <= 0) skullspeed = DEFSKULLSPEED; bSkullfly = true; A_StartSound(AttackSound, CHAN_VOICE); A_FaceTarget(); VelFromAngle(skullspeed); Vel.Z = (target.pos.Z + target.Height/2 - pos.Z) / DistanceBySpeed(target, skullspeed); } void A_BetaSkullAttack() { if (target == null || target.GetSpecies() == self.GetSpecies()) return; A_StartSound(AttackSound, CHAN_WEAPON); A_FaceTarget(); int damage = GetMissileDamage(7,1); target.DamageMobj(self, self, damage, 'None'); } } // Macil (version 1) --------------------------------------------------------- class Macil1 : Actor { Default { Health 95; Radius 20; Height 56; Speed 8; Painchance 250; Monster; -COUNTKILL +NOTDMATCH +NOICEDEATH +NOSPLASHALERT +NODAMAGE +NEVERRESPAWN DamageFactor "Fire", 0.5; MinMissileChance 150; SeeSound "macil/sight"; PainSound "macil/pain"; ActiveSound "macil/active"; CrushPainSound "misc/pcrush"; Tag "$TAG_MACIL1"; Obituary "$OB_MACIL"; DropItem "BoxOfBullets"; MaxStepHeight 16; MaxDropoffHeight 32; } States { Spawn: LEDR C 5 A_Look2; Loop; LEDR A 8; Loop; LEDR B 8; Loop; LEAD ABCD 6 A_Wander; Loop; See: LEAD AABBCCDD 3 A_Chase; Loop; Missile: Death: LEAD E 2 A_FaceTarget; LEAD F 2 BRIGHT A_ShootGun; LEAD E 1 A_SentinelRefire; Loop; Pain: LEAD Y 3; LEAD Y 3 A_Pain; Goto See; } } // Macil (version 2) --------------------------------------------------------- class Macil2 : Macil1 { Default { Painchance 200; +COUNTKILL +SPECTRAL -NODAMAGE Tag "$TAG_MACIL2"; DeathSound "macil/slop"; DropItem "None"; DamageFactor "SpectralLow", 0; } States { Missile: LEAD E 4 A_FaceTarget; LEAD F 4 BRIGHT A_ShootGun; LEAD E 2 A_SentinelRefire; Loop; Death: LEAD G 5; LEAD H 5 A_Scream; LEAD IJ 4; LEAD K 3; LEAD L 3 A_NoBlocking; LEAD MNOPQRSTUV 3; LEAD W 3 A_SpawnItemEx("AlienSpectre4", 0, 0, 0, 0, 0, random[spectrespawn](0,255)*0.0078125, 0, SXF_NOCHECKPOSITION); LEAD X -1; Stop; } } // Mage Boss (Menelkir) ----------------------------------------------------- class MageBoss : Actor { Default { Health 800; PainChance 50; Speed 25; Radius 16; Height 64; Monster; +FLOORCLIP +TELESTOMP +DONTMORPH PainSound "PlayerMagePain"; DeathSound "PlayerMageCrazyDeath"; Obituary "$OB_MBOSS"; Tag "$FN_MBOSS"; } States { Spawn: MAGE A 2; MAGE A 3 A_ClassBossHealth; MAGE A 5 A_Look; Wait; See: MAGE ABCD 4 A_FastChase; Loop; Pain: MAGE G 4; MAGE G 4 A_Pain; Goto See; Melee: Missile: MAGE E 8 A_FaceTarget; MAGE F 8 Bright A_MageAttack; Goto See; Death: MAGE H 6; MAGE I 6 A_Scream; MAGE JK 6; MAGE L 6 A_NoBlocking; MAGE M 6; MAGE N -1; Stop; XDeath: MAGE O 5 A_Scream; MAGE P 5; MAGE R 5 A_NoBlocking; MAGE S 5; MAGE T 5; MAGE U 5; MAGE V 5; MAGE W 5; MAGE X -1; Stop; Ice: MAGE Y 5 A_FreezeDeath; MAGE Y 1 A_FreezeDeathChunks; Wait; Burn: FDTH E 5 Bright A_StartSound("PlayerMageBurnDeath"); FDTH F 4 Bright; FDTH G 5 Bright; FDTH H 4 Bright A_Scream; FDTH I 5 Bright; FDTH J 4 Bright; FDTH K 5 Bright; FDTH L 4 Bright; FDTH M 5 Bright; FDTH N 4 Bright; FDTH O 5 Bright; FDTH P 4 Bright; FDTH Q 5 Bright; FDTH R 4 Bright; FDTH S 5 Bright A_NoBlocking; FDTH T 4 Bright; FDTH U 5 Bright; FDTH V 4 Bright; Stop; } //============================================================================ // // MStaffSpawn2 - for use by mage class boss // //============================================================================ void MStaffSpawn2 (double angle) { Actor mo = SpawnMissileAngleZ (pos.z + 40, "MageStaffFX2", angle, 0.); if (mo) { mo.target = self; mo.tracer = RoughMonsterSearch(10, true, true); } } //============================================================================ // // A_MStaffAttack2 - for use by mage class boss // //============================================================================ void A_MageAttack() { if (target == NULL) { return; } MStaffSpawn2(angle); MStaffSpawn2(angle - 5); MStaffSpawn2(angle + 5); A_StartSound("MageStaffFire", CHAN_WEAPON); } } // The Mage's Frost Cone ---------------------------------------------------- class MWeapFrost : MageWeapon { Default { +BLOODSPLATTER Weapon.SelectionOrder 1700; Weapon.AmmoUse1 3; Weapon.AmmoGive1 25; Weapon.KickBack 150; Weapon.YAdjust 20; Weapon.AmmoType1 "Mana1"; Inventory.PickupMessage "$TXT_WEAPON_M2"; Obituary "$OB_MPMWEAPFROST"; Tag "$TAG_MWEAPFROST"; } States { Spawn: WMCS ABC 8 Bright; Loop; Select: CONE A 1 A_Raise; Loop; Deselect: CONE A 1 A_Lower; Loop; Ready: CONE A 1 A_WeaponReady; Loop; Fire: CONE B 3; CONE C 4; Hold: CONE D 3; CONE E 5; CONE F 3 A_FireConePL1; CONE G 3; CONE A 9; CONE A 10 A_ReFire; Goto Ready; } //============================================================================ // // A_FireConePL1 // //============================================================================ action void A_FireConePL1() { bool conedone=false; FTranslatedLineTarget t; if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } A_StartSound ("MageShardsFire", CHAN_WEAPON); int damage = random[MageCone](90, 105); for (int i = 0; i < 16; i++) { double ang = angle + i*(45./16); double slope = AimLineAttack (ang, DEFMELEERANGE, t, 0., ALF_CHECK3D); if (t.linetarget) { t.linetarget.DamageMobj (self, self, damage, 'Ice', DMG_USEANGLE, t.angleFromSource); conedone = true; break; } } // didn't find any creatures, so fire projectiles if (!conedone) { Actor mo = SpawnPlayerMissile ("FrostMissile"); if (mo) { mo.special1 = FrostMissile.SHARDSPAWN_LEFT|FrostMissile.SHARDSPAWN_DOWN|FrostMissile.SHARDSPAWN_UP|FrostMissile.SHARDSPAWN_RIGHT; mo.special2 = 3; // Set sperm count (levels of reproductivity) mo.target = self; mo.args[0] = 3; // Mark Initial shard as super damage } } } } // Frost Missile ------------------------------------------------------------ class FrostMissile : Actor { const SHARDSPAWN_LEFT = 1; const SHARDSPAWN_RIGHT = 2; const SHARDSPAWN_UP = 4; const SHARDSPAWN_DOWN = 8; Default { Speed 25; Radius 13; Height 8; Damage 1; DamageType "Ice"; Projectile; DeathSound "MageShardsExplode"; Obituary "$OB_MPMWEAPFROST"; } States { Spawn: SHRD A 2 Bright; SHRD A 3 Bright A_ShedShard; SHRD B 3 Bright; SHRD C 3 Bright; Loop; Death: SHEX ABCDE 5 Bright; Stop; } override int DoSpecialDamage (Actor victim, int damage, Name damagetype) { if (special2 > 0) { damage <<= special2; } return damage; } //============================================================================ // // A_ShedShard // //============================================================================ void A_ShedShard() { int spawndir = special1; int spermcount = special2; Actor mo; if (spermcount <= 0) { return; // No sperm left } special2 = 0; spermcount--; // every so many calls, spawn a new missile in its set directions if (spawndir & SHARDSPAWN_LEFT) { mo = SpawnMissileAngleZSpeed(pos.z, "FrostMissile", angle + 5, 0, (20. + 2 * spermcount), target); if (mo) { mo.special1 = SHARDSPAWN_LEFT; mo.special2 = spermcount; mo.Vel.Z = Vel.Z; mo.args[0] = (spermcount==3)?2:0; } } if (spawndir & SHARDSPAWN_RIGHT) { mo = SpawnMissileAngleZSpeed(pos.z, "FrostMissile", angle - 5, 0, (20. + 2 * spermcount), target); if (mo) { mo.special1 = SHARDSPAWN_RIGHT; mo.special2 = spermcount; mo.Vel.Z = Vel.Z; mo.args[0] = (spermcount==3)?2:0; } } if (spawndir & SHARDSPAWN_UP) { mo = SpawnMissileAngleZSpeed(pos.z + 8., "FrostMissile", angle, 0, (15. + 2 * spermcount), target); if (mo) { mo.Vel.Z = Vel.Z; if (spermcount & 1) // Every other reproduction mo.special1 = SHARDSPAWN_UP | SHARDSPAWN_LEFT | SHARDSPAWN_RIGHT; else mo.special1 = SHARDSPAWN_UP; mo.special2 = spermcount; mo.args[0] = (spermcount==3)?2:0; } } if (spawndir & SHARDSPAWN_DOWN) { mo = SpawnMissileAngleZSpeed(pos.z - 4., "FrostMissile", angle, 0, (15. + 2 * spermcount), target); if (mo) { mo.Vel.Z = Vel.Z; if (spermcount & 1) // Every other reproduction mo.special1 = SHARDSPAWN_DOWN | SHARDSPAWN_LEFT | SHARDSPAWN_RIGHT; else mo.special1 = SHARDSPAWN_DOWN; mo.special2 = spermcount; mo.target = target; mo.args[0] = (spermcount==3)?2:0; } } } } // Ice Shard ---------------------------------------------------------------- class IceShard : FrostMissile { Default { DamageType "Ice"; -ACTIVATEIMPACT -ACTIVATEPCROSS } States { Spawn: SHRD ABC 3 Bright; Loop; } } // The Mage's Lightning Arc of Death ---------------------------------------- class MWeapLightning : MageWeapon { Default { +NOGRAVITY Weapon.SelectionOrder 1100; Weapon.AmmoUse1 5; Weapon.AmmoGive1 25; Weapon.KickBack 0; Weapon.YAdjust 20; Weapon.AmmoType1 "Mana2"; Inventory.PickupMessage "$TXT_WEAPON_M3"; Tag "$TAG_MWEAPLIGHTNING"; } States { Spawn: WMLG ABCDEFGH 4 Bright; Loop; Select: MLNG A 1 Bright A_Raise; Loop; Deselect: MLNG A 1 Bright A_Lower; Loop; Ready: MLNG AAAAA 1 Bright A_WeaponReady; MLNG A 1 Bright A_LightningReady; MLNG BBBBBB 1 Bright A_WeaponReady; MLNG CCCCC 1 Bright A_WeaponReady; MLNG C 1 Bright A_LightningReady; MLNG BBBBBB 1 Bright A_WeaponReady; Loop; Fire: MLNG DE 3 Bright; MLNG F 4 Bright A_MLightningAttack; MLNG G 4 Bright; MLNG HI 3 Bright; MLNG I 6 Bright Offset (0, 199); MLNG C 2 Bright Offset (0, 55); MLNG B 2 Bright Offset (0, 50); MLNG B 2 Bright Offset (0, 45); MLNG B 2 Bright Offset (0, 40); Goto Ready; } //============================================================================ // // A_LightningReady // //============================================================================ action void A_LightningReady() { A_WeaponReady(); if (random[LightningReady]() < 160) { A_StartSound ("MageLightningReady", CHAN_WEAPON); } } //============================================================================ // // A_MLightningAttack // //============================================================================ action void A_MLightningAttack(class floor = "LightningFloor", class ceiling = "LightningCeiling") { LightningFloor fmo = LightningFloor(SpawnPlayerMissile (floor)); LightningCeiling cmo = LightningCeiling(SpawnPlayerMissile (ceiling)); if (fmo) { fmo.special1 = 0; fmo.lastenemy = cmo; fmo.A_LightningZap(); } if (cmo) { cmo.tracer = NULL; cmo.lastenemy = fmo; cmo.A_LightningZap(); } A_StartSound ("MageLightningFire", CHAN_BODY); if (player != NULL) { Weapon weapon = player.ReadyWeapon; if (weapon != NULL) { weapon.DepleteAmmo (weapon.bAltFire); } } } } // Ceiling Lightning -------------------------------------------------------- class Lightning : Actor { Default { MissileType "LightningZap"; AttackSound "MageLightningZap"; ActiveSound "MageLightningContinuous"; Obituary "$OB_MPMWEAPLIGHTNING"; } override int SpecialMissileHit (Actor thing) { if (thing.bShootable && thing != target) { if (thing.Mass < LARGE_MASS) { thing.Vel.X += Vel.X / 16; thing.Vel.Y += Vel.Y / 16; } if ((!thing.player && !thing.bBoss) || !(Level.maptime & 1)) { thing.DamageMobj(self, target, 3, 'Electric'); A_StartSound(AttackSound, CHAN_WEAPON, CHANF_NOSTOP, 1); if (thing.bIsMonster && random[LightningHit]() < 64) { thing.Howl (); } } health--; if (health <= 0 || thing.health <= 0) { return 0; } if (bFloorHugger) { if (lastenemy && ! lastenemy.tracer) { lastenemy.tracer = thing; } } else if (!tracer) { tracer = thing; } } return 1; // lightning zaps through all sprites } } class LightningCeiling : Lightning { const ZAGSPEED = 1; Default { Health 144; Speed 25; Radius 16; Height 40; Damage 8; Projectile; +CEILINGHUGGER +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: MLFX A 2 Bright A_LightningZap; MLFX BCD 2 Bright A_LightningClip; Loop; Death: MLF2 A 2 Bright A_LightningRemove; MLF2 BCDEKLM 3 Bright; ACLO E 35; MLF2 NO 3 Bright; MLF2 P 4 Bright; MLF2 QP 3 Bright; MLF2 Q 4 Bright; MLF2 P 3 Bright; MLF2 O 3 Bright; MLF2 P 3 Bright; MLF2 P 1 Bright A_HideThing; ACLO E 1050; Stop; } //============================================================================ // // A_LightningClip // //============================================================================ void A_LightningClip() { Actor cMo; Actor target = NULL; int zigZag; if (bFloorHugger) { if (lastenemy == NULL) { return; } SetZ(floorz); target = lastenemy.tracer; } else if (bCeilingHugger) { SetZ(ceilingz - Height); target = tracer; } if (bFloorHugger) { // floor lightning zig-zags, and forces the ceiling lightning to mimic cMo = lastenemy; zigZag = random[LightningClip](); if((zigZag > 128 && special1 < 2) || special1 < -2) { Thrust(ZAGSPEED, angle + 90); if(cMo) { cMo.Thrust(ZAGSPEED, angle + 90); } special1++; } else { Thrust(ZAGSPEED,angle - 90); if(cMo) { cMo.Thrust(ZAGSPEED, angle - 90); } special1--; } } if(target) { if(target.health <= 0) { ExplodeMissile(); } else { angle = AngleTo(target); VelFromAngle(Speed / 2); } } } //============================================================================ // // A_LightningZap // //============================================================================ void A_LightningZap() { Class lightning = MissileName; if (lightning == NULL) lightning = "LightningZap"; A_LightningClip(); health -= 8; if (health <= 0) { SetStateLabel ("Death"); return; } double deltaX = (random[LightningZap]() - 128) * radius / 256; double deltaY = (random[LightningZap]() - 128) * radius / 256; double deltaZ = (bFloorHugger) ? 10 : -10; Actor mo = Spawn(lightning, Vec3Offset(deltaX, deltaY, deltaZ), ALLOW_REPLACE); if (mo) { mo.lastenemy = self; mo.Vel.X = Vel.X; mo.Vel.Y = Vel.Y; mo.Vel.Z = (bFloorHugger) ? 20 : -20; mo.target = target; } if (bFloorHugger && random[LightningZap]() < 160) { A_StartSound (ActiveSound, CHAN_BODY); } } //============================================================================ // // A_LightningRemove // //============================================================================ void A_LightningRemove() { Actor mo = lastenemy; if (mo) { bNoTarget = true; // tell A_ZapMimic that we are dead. The original code did a state pointer compare which is not safe. mo.lastenemy = NULL; mo.ExplodeMissile (); } } } // Floor Lightning ---------------------------------------------------------- class LightningFloor : LightningCeiling { Default { -CEILINGHUGGER +FLOORHUGGER +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: MLFX E 2 Bright A_LightningZap; MLFX FGH 2 Bright A_LightningClip; Loop; Death: MLF2 F 2 Bright A_LightningRemove; MLF2 GHIJKLM 3 Bright; ACLO E 20; MLF2 NO 3 Bright; MLF2 P 4 Bright; MLF2 QP 3 Bright; MLF2 Q 4 Bright A_LastZap; MLF2 POP 3 Bright; MLF2 P 1 Bright A_HideThing; Goto Super::Death + 19; } //============================================================================ // // A_LastZap // //============================================================================ void A_LastZap() { Class lightning = MissileName; if (lightning == NULL) lightning = "LightningZap"; Actor mo = Spawn(lightning, self.Pos, ALLOW_REPLACE); if (mo) { mo.SetStateLabel ("Death"); mo.Vel.Z = 40; mo.SetDamage(0); } } } // Lightning Zap ------------------------------------------------------------ class LightningZap : Actor { Default { Radius 15; Height 35; Damage 2; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS +ZDOOMTRANS RenderStyle "Add"; Obituary "$OB_MPMWEAPLIGHTNING"; } States { Spawn: MLFX IJKLM 2 Bright A_ZapMimic; Loop; Death: MLFX NOPQRSTU 2 Bright; Stop; } override int SpecialMissileHit (Actor thing) { Actor lmo; if (thing.bShootable && thing != target) { lmo = lastenemy; if (lmo) { if (lmo.bFloorHugger) { if (lmo.lastenemy && !lmo.lastenemy.tracer) { lmo.lastenemy.tracer = thing; } } else if (!lmo.tracer) { lmo.tracer = thing; } if (!(Level.maptime&3)) { lmo.health--; } } } return -1; } //============================================================================ // // A_ZapMimic // //============================================================================ void A_ZapMimic() { Actor mo = lastenemy; if (mo) { if (mo.bNoTarget) { ExplodeMissile (); } else { Vel.X = mo.Vel.X; Vel.Y = mo.Vel.Y; } } } } // The mage ----------------------------------------------------------------- class MagePlayer : PlayerPawn { Default { Health 100; ReactionTime 0; PainChance 255; Radius 16; Height 64; Speed 1; +NOSKIN +NODAMAGETHRUST +PLAYERPAWN.NOTHRUSTWHENINVUL PainSound "PlayerMagePain"; RadiusDamageFactor 0.25; Player.JumpZ 9; Player.Viewheight 48; Player.SpawnClass "Mage"; Player.DisplayName "Mage"; Player.SoundClass "mage"; Player.ScoreIcon "MAGEFACE"; Player.InvulnerabilityMode "Reflective"; Player.HealRadiusType "Mana"; Player.Hexenarmor 5, 5, 15, 10, 25; Player.StartItem "MWeapWand"; Player.ForwardMove 0.88, 0.92; Player.SideMove 0.875, 0.925; Player.Portrait "P_MWALK1"; Player.WeaponSlot 1, "MWeapWand"; Player.WeaponSlot 2, "MWeapFrost"; Player.WeaponSlot 3, "MWeapLightning"; Player.WeaponSlot 4, "MWeapBloodscourge"; Player.FlechetteType "ArtiPoisonBag2"; Player.ColorRange 146, 163; Player.Colorset 0, "$TXT_COLOR_BLUE", 146, 163, 161; Player.ColorsetFile 1, "$TXT_COLOR_RED", "TRANTBL7", 0xB3; Player.ColorsetFile 2, "$TXT_COLOR_GOLD", "TRANTBL8", 0x8C; Player.ColorsetFile 3, "$TXT_COLOR_DULLGREEN", "TRANTBL9", 0x41; Player.ColorsetFile 4, "$TXT_COLOR_GREEN", "TRANTBLA", 0xC9; Player.ColorsetFile 5, "$TXT_COLOR_GRAY", "TRANTBLB", 0x30; Player.ColorsetFile 6, "$TXT_COLOR_BROWN", "TRANTBLC", 0x72; Player.ColorsetFile 7, "$TXT_COLOR_PURPLE", "TRANTBLD", 0xEE; } States { Spawn: MAGE A -1; Stop; See: MAGE ABCD 4; Loop; Missile: Melee: MAGE EF 8; Goto Spawn; Pain: MAGE G 4; MAGE G 4 A_Pain; Goto Spawn; Death: MAGE H 6; MAGE I 6 A_PlayerScream; MAGE JK 6; MAGE L 6 A_NoBlocking; MAGE M 6; MAGE N -1; Stop; XDeath: MAGE O 5 A_PlayerScream; MAGE P 5; MAGE R 5 A_NoBlocking; MAGE STUVW 5; MAGE X -1; Stop; Ice: MAGE Y 5 A_FreezeDeath; MAGE Y 1 A_FreezeDeathChunks; Wait; Burn: FDTH E 5 BRIGHT A_StartSound("*burndeath"); FDTH F 4 BRIGHT; FDTH G 5 BRIGHT; FDTH H 4 BRIGHT A_PlayerScream; FDTH I 5 BRIGHT; FDTH J 4 BRIGHT; FDTH K 5 BRIGHT; FDTH L 4 BRIGHT; FDTH M 5 BRIGHT; FDTH N 4 BRIGHT; FDTH O 5 BRIGHT; FDTH P 4 BRIGHT; FDTH Q 5 BRIGHT; FDTH R 4 BRIGHT; FDTH S 5 BRIGHT A_NoBlocking; FDTH T 4 BRIGHT; FDTH U 5 BRIGHT; FDTH V 4 BRIGHT; ACLO E 35 A_CheckPlayerDone; Wait; ACLO E 8; Stop; } } // Mage Weapon Piece -------------------------------------------------------- class MageWeaponPiece : WeaponPiece { Default { Inventory.PickupSound "misc/w_pkup"; Inventory.PickupMessage "$TXT_BLOODSCOURGE_PIECE"; Inventory.ForbiddenTo "FighterPlayer", "ClericPlayer"; WeaponPiece.Weapon "MWeapBloodscourge"; +FLOATBOB } } // Mage Weapon Piece 1 ------------------------------------------------------ class MWeaponPiece1 : MageWeaponPiece { Default { WeaponPiece.Number 1; } States { Spawn: WMS1 A -1 Bright; Stop; } } // Mage Weapon Piece 2 ------------------------------------------------------ class MWeaponPiece2 : MageWeaponPiece { Default { WeaponPiece.Number 2; } States { Spawn: WMS2 A -1 Bright; Stop; } } // Mage Weapon Piece 3 ------------------------------------------------------ class MWeaponPiece3 : MageWeaponPiece { Default { WeaponPiece.Number 3; } States { Spawn: WMS3 A -1 Bright; Stop; } } // Bloodscourge Drop -------------------------------------------------------- class BloodscourgeDrop : Actor { States { Spawn: TNT1 A 1; TNT1 A 1 A_DropWeaponPieces("MWeaponPiece1", "MWeaponPiece2", "MWeaponPiece3"); Stop; } } // The Mages's Staff (Bloodscourge) ----------------------------------------- class MWeapBloodscourge : MageWeapon { int MStaffCount; Default { Health 3; Weapon.SelectionOrder 3100; Weapon.AmmoUse1 15; Weapon.AmmoUse2 15; Weapon.AmmoGive1 20; Weapon.AmmoGive2 20; Weapon.KickBack 150; Weapon.YAdjust 20; Weapon.AmmoType1 "Mana1"; Weapon.AmmoType2 "Mana2"; +WEAPON.PRIMARY_USES_BOTH; +Inventory.NoAttenPickupSound Inventory.PickupMessage "$TXT_WEAPON_M4"; Inventory.PickupSound "WeaponBuild"; Tag "$TAG_MWEAPBLOODSCOURGE"; } States { Spawn: TNT1 A -1; Stop; Select: MSTF A 1 A_Raise; Loop; Deselect: MSTF A 1 A_Lower; Loop; Ready: MSTF AAAAAABBBBBBCCCCCCDDDDDDEEEEEEFFFFF 1 A_WeaponReady; Loop; Fire: MSTF G 4 Offset (0, 40); MSTF H 4 Bright Offset (0, 48) A_MStaffAttack; MSTF H 2 Bright Offset (0, 48) A_MStaffPalette; MSTF II 2 Offset (0, 48) A_MStaffPalette; MSTF I 1 Offset (0, 40); MSTF J 5 Offset (0, 36); Goto Ready; } //============================================================================ // // // //============================================================================ override Color GetBlend () { if (paletteflash & PF_HEXENWEAPONS) { if (MStaffCount == 3) return Color(128, 100, 73, 0); else if (MStaffCount == 2) return Color(128, 125, 92, 0); else if (MStaffCount == 1) return Color(128, 150, 110, 0); else return Color(0, 0, 0, 0); } else { return Color (MStaffCount * 128 / 3, 151, 110, 0); } } //============================================================================ // // MStaffSpawn // //============================================================================ private action void MStaffSpawn (double angle, Actor alttarget) { FTranslatedLineTarget t; Actor mo = SpawnPlayerMissile ("MageStaffFX2", angle, pLineTarget:t); if (mo) { mo.target = self; if (t.linetarget && !t.unlinked) mo.tracer = t.linetarget; else mo.tracer = alttarget; } } //============================================================================ // // A_MStaffAttack // //============================================================================ action void A_MStaffAttack() { FTranslatedLineTarget t; if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != NULL) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } // [RH] Let's try and actually track what the player aimed at AimLineAttack (angle, PLAYERMISSILERANGE, t, 32.); if (t.linetarget == NULL) { t.linetarget = RoughMonsterSearch(10, true, true); } MStaffSpawn (angle, t.linetarget); MStaffSpawn (angle-5, t.linetarget); MStaffSpawn (angle+5, t.linetarget); A_StartSound ("MageStaffFire", CHAN_WEAPON); invoker.MStaffCount = 3; } //============================================================================ // // A_MStaffPalette // //============================================================================ action void A_MStaffPalette() { if (invoker.MStaffCount > 0) invoker.MStaffCount--; } } // Mage Staff FX2 (Bloodscourge) -------------------------------------------- class MageStaffFX2 : Actor { Default { Speed 17; Height 8; Damage 4; DamageType "Fire"; Projectile; +SEEKERMISSILE +SCREENSEEKER +EXTREMEDEATH DeathSound "MageStaffExplode"; Obituary "$OB_MPMWEAPBLOODSCOURGE"; } States { Spawn: MSP2 ABCD 2 Bright A_MStaffTrack; Loop; Death: MSP2 E 4 Bright A_SetTranslucent(1,1); MSP2 F 5 Bright A_Explode (80, 192, 0); MSP2 GH 5 Bright; MSP2 I 4 Bright; Stop; } //============================================================================ // // // //============================================================================ override int SpecialMissileHit (Actor victim) { if (victim != target && !victim.player && !victim.bBoss) { victim.DamageMobj (self, target, 10, 'Fire'); return 1; // Keep going } return -1; } override bool SpecialBlastHandling (Actor source, double strength) { // Reflect to originator tracer = target; target = source; return true; } //============================================================================ // // A_MStaffTrack // //============================================================================ void A_MStaffTrack() { if (tracer == null && random[MStaffTrack]() < 50) { tracer = RoughMonsterSearch (10, true); } A_SeekerMissile(2, 10); } } // The Mage's Wand ---------------------------------------------------------- class MWeapWand : MageWeapon { Default { Weapon.SelectionOrder 3600; Weapon.KickBack 0; Weapon.YAdjust 9; Tag "$TAG_MWEAPWAND"; } States { Select: MWND A 1 A_Raise; Loop; Deselect: MWND A 1 A_Lower; Loop; Ready: MWND A 1 A_WeaponReady; Loop; Fire: MWND A 6; MWND B 6 Bright Offset (0, 48) A_FireProjectile ("MageWandMissile"); MWND A 3 Offset (0, 40); MWND A 3 Offset (0, 36) A_ReFire; Goto Ready; } } // Wand Smoke --------------------------------------------------------------- class MageWandSmoke : Actor { Default { +NOBLOCKMAP +NOGRAVITY +SHADOW +NOTELEPORT +CANNOTPUSH +NODAMAGETHRUST RenderStyle "Translucent"; Alpha 0.6; } States { Spawn: MWND CDCD 4; Stop; } } // Wand Missile ------------------------------------------------------------- class MageWandMissile : FastProjectile { Default { Speed 184; Radius 12; Height 8; Damage 2; +RIPPER +CANNOTPUSH +NODAMAGETHRUST +SPAWNSOUNDSOURCE MissileType "MageWandSmoke"; SeeSound "MageWandFire"; Obituary "$OB_MPMWEAPWAND"; } States { Spawn: MWND CD 4 Bright; Loop; Death: MWND E 4 Bright; MWND F 3 Bright; MWND G 4 Bright; MWND H 3 Bright; MWND I 4 Bright; Stop; } } // Blue mana ---------------------------------------------------------------- class Mana1 : Ammo { Default { Inventory.Amount 15; Inventory.MaxAmount 200; Ammo.BackpackAmount 15; Ammo.BackpackMaxAmount 200; Radius 8; Height 8; +FLOATBOB Inventory.Icon "MAN1I0"; Inventory.PickupMessage "$TXT_MANA_1"; Tag "$AMMO_MANA1"; } States { Spawn: MAN1 ABCDEFGHI 4 Bright; Loop; } } // Green mana --------------------------------------------------------------- class Mana2 : Ammo { Default { Inventory.Amount 15; Inventory.MaxAmount 200; Ammo.BackpackAmount 15; Ammo.BackpackMaxAmount 200; Radius 8; Height 8; +FLOATBOB Inventory.Icon "MAN2G0"; Inventory.PickupMessage "$TXT_MANA_2"; Tag "$AMMO_MANA2"; } States { Spawn: MAN2 ABCDEFGHIJKLMNOP 4 Bright; Loop; } } // Combined mana ------------------------------------------------------------ class Mana3 : CustomInventory { Default { Radius 8; Height 8; +FLOATBOB Inventory.PickupMessage "$TXT_MANA_BOTH"; } States { Spawn: MAN3 ABCDEFGHIJKLMNOP 4 Bright; Loop; Pickup: TNT1 A 0 A_GiveInventory("Mana1", 20); TNT1 A 0 A_GiveInventory("Mana2", 20); Stop; } } // Boost Mana Artifact Krater of Might ------------------------------------ class ArtiBoostMana : CustomInventory { Default { +FLOATBOB +COUNTITEM +INVENTORY.INVBAR +INVENTORY.FANCYPICKUPSOUND Inventory.PickupFlash "PickupFlash"; Inventory.DefMaxAmount; Inventory.Icon "ARTIBMAN"; Inventory.PickupSound "misc/p_pkup"; Inventory.PickupMessage "$TXT_ARTIBOOSTMANA"; Tag "$TAG_ARTIBOOSTMANA"; } States { Spawn: BMAN A -1; Stop; Use: TNT1 A 0 A_GiveInventory("Mana1", 200); TNT1 A 0 A_GiveInventory("Mana2", 200); Stop; } } struct SectorPortal native play { enum EType { TYPE_SKYVIEWPOINT = 0, // a regular skybox TYPE_STACKEDSECTORTHING, // stacked sectors with the thing method TYPE_PORTAL, // stacked sectors with Sector_SetPortal TYPE_LINKEDPORTAL, // linked portal (interactive) TYPE_PLANE, // EE-style plane portal (not implemented in SW renderer) TYPE_HORIZON, // EE-style horizon portal (not implemented in SW renderer) }; enum EFlags { FLAG_SKYFLATONLY = 1, // portal is only active on skyflatnum FLAG_INSKYBOX = 2, // to avoid recursion }; native int mType; native int mFlags; native uint mPartner; native int mPlane; native Sector mOrigin; native Sector mDestination; native Vector2 mDisplacement; native double mPlaneZ; native Actor mSkybox; }; struct LinePortal native play { enum EType { PORTT_VISUAL, PORTT_TELEPORT, PORTT_INTERACTIVE, PORTT_LINKED, PORTT_LINKEDEE // Eternity compatible definition which uses only one line ID and a different anchor type to link to. }; enum EFlags { PORTF_VISIBLE = 1, PORTF_PASSABLE = 2, PORTF_SOUNDTRAVERSE = 4, PORTF_INTERACTIVE = 8, PORTF_POLYOBJ = 16, PORTF_TYPETELEPORT = PORTF_VISIBLE | PORTF_PASSABLE | PORTF_SOUNDTRAVERSE, PORTF_TYPEINTERACTIVE = PORTF_VISIBLE | PORTF_PASSABLE | PORTF_SOUNDTRAVERSE | PORTF_INTERACTIVE, }; enum EAlignment { PORG_ABSOLUTE, // does not align at all. z-ccoordinates must match. PORG_FLOOR, PORG_CEILING, }; native Line mOrigin; native Line mDestination; native Vector2 mDisplacement; native uint8 mType; native uint8 mFlags; native uint8 mDefFlags; native uint8 mAlign; native double mAngleDiff; native double mSinRot; native double mCosRot; } struct Vertex native play { native readonly Vector2 p; native clearscope int Index() const; } struct Side native play { enum ETexpart { top=0, mid=1, bottom=2 }; enum EColorPos { walltop = 0, wallbottom = 1 } enum EWallFlags { WALLF_ABSLIGHTING = 1, // Light is absolute instead of relative WALLF_NOAUTODECALS = 2, // Do not attach impact decals to this wall WALLF_NOFAKECONTRAST = 4, // Don't do fake contrast for this wall in side_t::GetLightLevel WALLF_SMOOTHLIGHTING = 8, // Similar to autocontrast but applies to all angles. WALLF_CLIP_MIDTEX = 16, // Like the line counterpart, but only for this side. WALLF_WRAP_MIDTEX = 32, // Like the line counterpart, but only for this side. WALLF_POLYOBJ = 64, // This wall belongs to a polyobject. WALLF_LIGHT_FOG = 128, // This wall's Light is used even in fog. }; enum EPartFlags { NoGradient = 1, FlipGradient = 2, ClampGradient = 4, UseOwnSpecialColors = 8, UseOwnAdditiveColor = 16, }; native readonly Sector sector; // Sector the SideDef is facing. //DBaseDecal* AttachedDecals; // [RH] Decals bound to the wall native readonly Line linedef; native int16 Light; native uint16 Flags; native clearscope TextureID GetTexture(int which) const; native void SetTexture(int which, TextureID tex); native void SetTextureXOffset(int which, double offset); native clearscope double GetTextureXOffset(int which) const; native void AddTextureXOffset(int which, double delta); native void SetTextureYOffset(int which, double offset); native clearscope double GetTextureYOffset(int which) const; native void AddTextureYOffset(int which, double delta); native void SetTextureXScale(int which, double scale); native clearscope double GetTextureXScale(int which) const; native void MultiplyTextureXScale(int which, double delta); native void SetTextureYScale(int which, double scale); native clearscope double GetTextureYScale(int which) const; native void MultiplyTextureYScale(int which, double delta); native clearscope int GetTextureFlags(int tier) const; native void ChangeTextureFlags(int tier, int And, int Or); native void SetSpecialColor(int tier, int position, Color scolor, bool useowncolor = true); native clearscope Color GetAdditiveColor(int tier) const; native void SetAdditiveColor(int tier, Color color); native void EnableAdditiveColor(int tier, bool enable); native void SetColorization(int tier, Name cname); //native DInterpolation *SetInterpolation(int position); //native void StopInterpolation(int position); native clearscope Vertex V1() const; native clearscope Vertex V2() const; native clearscope int Index() const; clearscope int GetUDMFInt(Name nm) const { return Level.GetUDMFInt(LevelLocals.UDMF_Side, Index(), nm); } clearscope double GetUDMFFloat(Name nm) const { return Level.GetUDMFFloat(LevelLocals.UDMF_Side, Index(), nm); } clearscope String GetUDMFString(Name nm) const { return Level.GetUDMFString(LevelLocals.UDMF_Side, Index(), nm); } }; struct Line native play { enum ESide { front=0, back=1 } enum ELineFlags { ML_BLOCKING =0x00000001, // solid, is an obstacle ML_BLOCKMONSTERS =0x00000002, // blocks monsters only ML_TWOSIDED =0x00000004, // backside will not be present at all if not two sided ML_DONTPEGTOP = 0x00000008, // upper texture unpegged ML_DONTPEGBOTTOM = 0x00000010, // lower texture unpegged ML_SECRET = 0x00000020, // don't map as two sided: IT'S A SECRET! ML_SOUNDBLOCK = 0x00000040, // don't let sound cross two of these ML_DONTDRAW = 0x00000080, // don't draw on the automap ML_MAPPED = 0x00000100, // set if already drawn in automap ML_REPEAT_SPECIAL = 0x00000200, // special is repeatable ML_ADDTRANS = 0x00000400, // additive translucency (can only be set internally) // Extended flags ML_MONSTERSCANACTIVATE = 0x00002000, // [RH] Monsters (as well as players) can activate the line ML_BLOCK_PLAYERS = 0x00004000, ML_BLOCKEVERYTHING = 0x00008000, // [RH] Line blocks everything ML_ZONEBOUNDARY = 0x00010000, ML_RAILING = 0x00020000, ML_BLOCK_FLOATERS = 0x00040000, ML_CLIP_MIDTEX = 0x00080000, // Automatic for every Strife line ML_WRAP_MIDTEX = 0x00100000, ML_3DMIDTEX = 0x00200000, ML_CHECKSWITCHRANGE = 0x00400000, ML_FIRSTSIDEONLY = 0x00800000, // activated only when crossed from front side ML_BLOCKPROJECTILE = 0x01000000, ML_BLOCKUSE = 0x02000000, // blocks all use actions through this line ML_BLOCKSIGHT = 0x04000000, // blocks monster line of sight ML_BLOCKHITSCAN = 0x08000000, // blocks hitscan attacks ML_3DMIDTEX_IMPASS = 0x10000000, // [TP] if 3D midtex, behaves like a height-restricted ML_BLOCKING }; enum ELineFlags2 { ML2_BLOCKLANDMONSTERS = 1, } native readonly vertex v1, v2; // vertices, from v1 to v2 native readonly Vector2 delta; // precalculated v2 - v1 for side checking native uint flags; native uint flags2; native uint activation; // activation type native int special; native int args[5]; // <--- hexen-style arguments (expanded to ZDoom's full width) native double alpha; // <--- translucency (0=invisible, 1.0=opaque) native readonly Side sidedef[2]; native readonly double bbox[4]; // bounding box, for the extent of the LineDef. native readonly Sector frontsector, backsector; native int validcount; // if == validcount, already checked native int locknumber; // [Dusk] lock number for special native readonly uint portalindex; native readonly uint portaltransferred; native readonly int health; native readonly int healthgroup; native clearscope bool isLinePortal() const; native clearscope bool isVisualPortal() const; native clearscope Line getPortalDestination() const; native clearscope int getPortalFlags() const; native clearscope int getPortalAlignment() const; native clearscope int getPortalType() const; native clearscope Vector2 getPortalDisplacement() const; native clearscope double getPortalAngleDiff() const; native clearscope int Index() const; native bool Activate(Actor activator, int side, int type); native bool RemoteActivate(Actor activator, int side, int type, Vector3 pos); clearscope int GetUDMFInt(Name nm) const { return Level.GetUDMFInt(LevelLocals.UDMF_Line, Index(), nm); } clearscope double GetUDMFFloat(Name nm) const { return Level.GetUDMFFloat(LevelLocals.UDMF_Line, Index(), nm); } clearscope String GetUDMFString(Name nm) const { return Level.GetUDMFString(LevelLocals.UDMF_Line, Index(), nm); } native clearscope int GetHealth() const; native void SetHealth(int newhealth); native int CountIDs() const; native int GetID(int index) const; } struct SecPlane native play { native Vector3 Normal; native double D; native double negiC; native clearscope bool isSlope() const; native clearscope int PointOnSide(Vector3 pos) const; native clearscope double ZatPoint (Vector2 v) const; native clearscope double ZatPointDist(Vector2 v, double dist) const; native clearscope bool isEqual(Secplane other) const; native void ChangeHeight(double hdiff); native clearscope double GetChangedHeight(double hdiff) const; native clearscope double HeightDiff(double oldd, double newd = 1e37) const; native clearscope double PointToDist(Vector2 xy, double z) const; } struct F3DFloor native play { enum EF3DFloorFlags { FF_EXISTS = 0x1, //MAKE SURE IT'S VALID FF_SOLID = 0x2, //Does it clip things? FF_RENDERSIDES = 0x4, //Render the sides? FF_RENDERPLANES = 0x8, //Render the floor/ceiling? FF_RENDERALL = 0xC, //Render everything? FF_SWIMMABLE = 0x10, //Can we swim? FF_NOSHADE = 0x20, //Does it mess with the lighting? FF_BOTHPLANES = 0x200, //Render both planes all the time? FF_TRANSLUCENT = 0x800, //See through! FF_FOG = 0x1000, //Fog "brush"? FF_INVERTPLANES = 0x2000, //Reverse the plane visibility rules? FF_ALLSIDES = 0x4000, //Render inside and outside sides? FF_INVERTSIDES = 0x8000, //Only render inside sides? FF_DOUBLESHADOW = 0x10000,//Make two lightlist entries to reset light? FF_UPPERTEXTURE = 0x20000, FF_LOWERTEXTURE = 0x40000, FF_THINFLOOR = 0x80000, // EDGE FF_SCROLLY = 0x100000, // old leftover definition FF_NODAMAGE = 0x100000, // no damage transfers FF_FIX = 0x200000, // use floor of model sector as floor and floor of real sector as ceiling FF_INVERTSECTOR = 0x400000, // swap meaning of sector planes FF_DYNAMIC = 0x800000, // created by partitioning another 3D-floor due to overlap FF_CLIPPED = 0x1000000, // split into several dynamic ffloors FF_SEETHROUGH = 0x2000000, FF_SHOOTTHROUGH = 0x4000000, FF_FADEWALLS = 0x8000000, // Applies real fog to walls and doesn't blend the view FF_ADDITIVETRANS = 0x10000000, // Render this floor with additive translucency FF_FLOOD = 0x20000000, // extends towards the next lowest flooding or solid 3D floor or the bottom of the sector FF_THISINSIDE = 0x40000000, // hack for software 3D with FF_BOTHPLANES FF_RESET = 0x80000000, // light effect is completely reset, once interrupted }; native readonly secplane bottom; native readonly secplane top; native readonly uint flags; native readonly Line master; native readonly Sector model; native readonly Sector target; native readonly int alpha; native clearscope TextureID GetTexture(int pos) const; } // This encapsulates all info Doom's original 'special' field contained - for saving and transferring. struct SecSpecial play { Name damagetype; int damageamount; int special; short damageinterval; short leakydamage; int Flags; } struct FColormap { Color LightColor; Color FadeColor; uint8 Desaturation; uint8 BlendFactor; uint16 FogDensity; } struct Sector native play { native readonly FColormap ColorMap; native readonly Color SpecialColors[5]; native readonly Color AdditiveColors[5]; native Actor SoundTarget; native int special; native int16 lightlevel; native int16 seqType; native int sky; native Name SeqName; native readonly Vector2 centerspot; native int validcount; native Actor thinglist; native double friction, movefactor; native int terrainnum[2]; // thinker_t for reversable actions native SectorEffect floordata; native SectorEffect ceilingdata; native SectorEffect lightingdata; enum EPlane { floor, ceiling, // only used for specialcolors array walltop, wallbottom, sprites }; enum EInterpolationType { CeilingMove, FloorMove, CeilingScroll, FloorScroll }; //Interpolation interpolations[4]; native uint8 soundtraversed; native int8 stairlock; native int prevsec; native int nextsec; native readonly Array lines; native readonly @secplane floorplane; native readonly @secplane ceilingplane; native readonly Sector heightsec; native uint bottommap, midmap, topmap; //struct msecnode_t *touching_thinglist; //struct msecnode_t *sectorportal_thinglist; native double gravity; native Name damagetype; native int damageamount; native int16 damageinterval; native int16 leakydamage; native readonly uint16 ZoneNumber; native readonly int healthceiling; native readonly int healthfloor; native readonly int healthceilinggroup; native readonly int healthfloorgroup; enum ESectorMoreFlags { SECMF_FAKEFLOORONLY = 2, // when used as heightsec in R_FakeFlat, only copies floor SECMF_CLIPFAKEPLANES = 4, // as a heightsec, clip planes to target sector's planes SECMF_NOFAKELIGHT = 8, // heightsec does not change lighting SECMF_IGNOREHEIGHTSEC= 16, // heightsec is only for triggering sector actions SECMF_UNDERWATER = 32, // sector is underwater SECMF_FORCEDUNDERWATER= 64, // sector is forced to be underwater SECMF_UNDERWATERMASK = 32+64, SECMF_DRAWN = 128, // sector has been drawn at least once SECMF_HIDDEN = 256, // Do not draw on textured automap } native uint16 MoreFlags; enum ESectorFlags { SECF_SILENT = 1, // actors in sector make no noise SECF_NOFALLINGDAMAGE= 2, // No falling damage in this sector SECF_FLOORDROP = 4, // all actors standing on this floor will remain on it when it lowers very fast. SECF_NORESPAWN = 8, // players can not respawn in this sector SECF_FRICTION = 16, // sector has friction enabled SECF_PUSH = 32, // pushers enabled SECF_SILENTMOVE = 64, // Sector movement makes mo sound (Eternity got this so this may be useful for an extended cross-port standard.) SECF_DMGTERRAINFX = 128, // spawns terrain splash when inflicting damage SECF_ENDGODMODE = 256, // getting damaged by this sector ends god mode SECF_ENDLEVEL = 512, // ends level when health goes below 10 SECF_HAZARD = 1024, // Change to Strife's delayed damage handling. SECF_NOATTACK = 2048, // monsters cannot start attacks in this sector. SECF_WASSECRET = 1 << 30, // a secret that was discovered SECF_SECRET = 1 << 31, // a secret sector SECF_DAMAGEFLAGS = SECF_ENDGODMODE|SECF_ENDLEVEL|SECF_DMGTERRAINFX|SECF_HAZARD, SECF_NOMODIFY = SECF_SECRET|SECF_WASSECRET, // not modifiable by Sector_ChangeFlags SECF_SPECIALFLAGS = SECF_DAMAGEFLAGS|SECF_FRICTION|SECF_PUSH, // these flags originate from 'special and must be transferrable by floor thinkers } enum EMoveResult { MOVE_OK, MOVE_CRUSHED, MOVE_PASTDEST }; native uint Flags; native SectorAction SecActTarget; native internal uint Portals[2]; native readonly int PortalGroup; native readonly int sectornum; native clearscope int Index() const; native clearscope double, Sector, F3DFloor NextHighestCeilingAt(double x, double y, double bottomz, double topz, int flags = 0) const; native clearscope double, Sector, F3DFloor NextLowestFloorAt(double x, double y, double z, int flags = 0, double steph = 0) const; native clearscope F3DFloor Get3DFloor(int index) const; native clearscope int Get3DFloorCount() const; native clearscope Sector GetAttached(int index) const; native clearscope int GetAttachedCount() const; native void RemoveForceField(); deprecated("3.8", "Use Level.PointInSector instead") static clearscope Sector PointInSector(Vector2 pt) { return level.PointInSector(pt); } native clearscope bool PlaneMoving(int pos) const; native clearscope int GetFloorLight() const; native clearscope int GetCeilingLight() const; native clearscope Sector GetHeightSec() const; native void TransferSpecial(Sector model); native clearscope void GetSpecial(out SecSpecial spec) const; native void SetSpecial( SecSpecial spec); native clearscope int GetTerrain(int pos) const; native clearscope TerrainDef GetFloorTerrain(int pos) const; // Gets the terraindef from floor/ceiling (see EPlane const). native void CheckPortalPlane(int plane); native clearscope double, Sector HighestCeilingAt(Vector2 a) const; native clearscope double, Sector LowestFloorAt(Vector2 a) const; native clearscope double, double GetFriction(int plane) const; native void SetXOffset(int pos, double o); native void AddXOffset(int pos, double o); native clearscope double GetXOffset(int pos) const; native void SetYOffset(int pos, double o); native void AddYOffset(int pos, double o); native clearscope double GetYOffset(int pos, bool addbase = true) const; native void SetXScale(int pos, double o); native clearscope double GetXScale(int pos) const; native void SetYScale(int pos, double o); native clearscope double GetYScale(int pos) const; native void SetAngle(int pos, double o); native clearscope double GetAngle(int pos, bool addbase = true) const; native void SetBase(int pos, double y, double o); native void SetAlpha(int pos, double o); native clearscope double GetAlpha(int pos) const; native clearscope int GetFlags(int pos) const; native clearscope int GetVisFlags(int pos) const; native void ChangeFlags(int pos, int And, int Or); native clearscope int GetPlaneLight(int pos) const; native void SetPlaneLight(int pos, int level); native void SetColor(color c, int desat = 0); native void SetFade(color c); native void SetFogDensity(int dens); native clearscope double GetGlowHeight(int pos) const; native clearscope color GetGlowColor(int pos) const; native void SetGlowHeight(int pos, double height); native void SetGlowColor(int pos, color color); native void SetSpecialColor(int pos, color color); native void SetAdditiveColor(int pos, Color color); native void SetColorization(int tier, Name cname); native clearscope TextureID GetTexture(int pos) const; native void SetTexture(int pos, TextureID tex, bool floorclip = true); native clearscope double GetPlaneTexZ(int pos) const; native void SetPlaneTexZ(int pos, double val, bool dirtify = false); // This mainly gets used by init code. The only place where it must set the vertex to dirty is the interpolation code. native void ChangeLightLevel(int newval); native void SetLightLevel(int newval); native clearscope int GetLightLevel() const; native void AdjustFloorClip(); native clearscope bool IsLinked(Sector other, bool ceiling) const; native clearscope bool PortalBlocksView(int plane) const; native clearscope bool PortalBlocksSight(int plane) const; native clearscope bool PortalBlocksMovement(int plane) const; native clearscope bool PortalBlocksSound(int plane) const; native clearscope bool PortalIsLinked(int plane) const; native void ClearPortal(int plane); native clearscope double GetPortalPlaneZ(int plane) const; native clearscope Vector2 GetPortalDisplacement(int plane) const; native clearscope int GetPortalType(int plane) const; native clearscope int GetOppositePortalGroup(int plane) const; native clearscope double CenterFloor() const; native clearscope double CenterCeiling() const; native int MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush, bool instant = false); native int MoveCeiling(double speed, double dest, int crush, int direction, bool hexencrush); native clearscope Sector NextSpecialSector(int type, Sector prev) const; native clearscope double, Vertex FindLowestFloorSurrounding() const; native clearscope double, Vertex FindHighestFloorSurrounding() const; native clearscope double, Vertex FindNextHighestFloor() const; native clearscope double, Vertex FindNextLowestFloor() const; native clearscope double, Vertex FindLowestCeilingSurrounding() const; native clearscope double, Vertex FindHighestCeilingSurrounding() const; native clearscope double, Vertex FindNextLowestCeiling() const; native clearscope double, Vertex FindNextHighestCeiling() const; native clearscope double FindShortestTextureAround() const; native clearscope double FindShortestUpperAround() const; native clearscope Sector FindModelFloorSector(double floordestheight) const; native clearscope Sector FindModelCeilingSector(double floordestheight) const; native clearscope int FindMinSurroundingLight(int max) const; native clearscope double, Vertex FindLowestCeilingPoint() const; native clearscope double, Vertex FindHighestFloorPoint() const; native void SetEnvironment(String env); native void SetEnvironmentID(int envnum); native SeqNode StartSoundSequenceID (int chan, int sequence, int type, int modenum, bool nostop = false); native SeqNode StartSoundSequence (int chan, Name seqname, int modenum); native clearscope SeqNode CheckSoundSequence (int chan) const; native void StopSoundSequence(int chan); native clearscope bool IsMakingLoopingSound () const; clearscope bool isSecret() const { return !!(Flags & SECF_SECRET); } clearscope bool wasSecret() const { return !!(Flags & SECF_WASSECRET); } void ClearSecret() { Flags &= ~SECF_SECRET; } clearscope int GetUDMFInt(Name nm) const { return Level.GetUDMFInt(LevelLocals.UDMF_Sector, Index(), nm); } clearscope double GetUDMFFloat(Name nm) const { return Level.GetUDMFFloat(LevelLocals.UDMF_Sector, Index(), nm); } clearscope String GetUDMFString(Name nm) const { return Level.GetUDMFString(LevelLocals.UDMF_Sector, Index(), nm); } //=========================================================================== // // // //=========================================================================== bool TriggerSectorActions(Actor thing, int activation) { let act = SecActTarget; bool res = false; while (act != null) { Actor next = act.tracer; if (act.TriggerAction(thing, activation)) { if (act.bStandStill) { act.Destroy(); } res = true; } act = SectorAction(next); } return res; } native clearscope int GetHealth(SectorPart part) const; native void SetHealth(SectorPart part, int newhealth); native int CountTags() const; native int GetTag(int index) const; } class SectorTagIterator : Object native { deprecated("3.8", "Use Level.CreateSectorTagIterator() instead") static SectorTagIterator Create(int tag, line defline = null) { return level.CreateSectorTagIterator(tag, defline); } native int Next(); native int NextCompat(bool compat, int secnum); } class LineIdIterator : Object native { deprecated("3.8", "Use Level.CreateLineIdIterator() instead") static LineIdIterator Create(int tag) { return level.CreateLineIdIterator(tag); } native int Next(); } // Map Marker -------------------------------------------------------------- // // This class uses the following argument: // args[0] == 0, shows the sprite at this actor // != 0, shows the sprite for all actors whose TIDs match instead // // args[1] == 0, show the sprite always // == 1, show the sprite only after its sector has been drawn // // args[2] == 0, show the sprite with a constant scale // == 1, show the sprite with a scale relative to automap zoom // // To enable display of the sprite, activate it. To turn off the sprite, // deactivate it. // // All the code to display it is in am_map.cpp. // //-------------------------------------------------------------------------- class MapMarker : Actor { default { +NOBLOCKMAP +NOGRAVITY +DONTSPLASH +INVISIBLE Scale 0.5; } States { Spawn: AMRK A -1; Stop; } override void BeginPlay () { ChangeStatNum (STAT_MAPMARKER); } override void Activate (Actor activator) { bDormant = true; } override void Deactivate (Actor activator) { bDormant = false; } } struct Map_I32_I8 native { native void Copy(Map_I32_I8 other); native void Move(Map_I32_I8 other); native void Swap(Map_I32_I8 other); native void Clear(); native uint CountUsed() const; native int Get(int key); native bool CheckKey(int key) const; native version("4.11") int GetIfExists(int key) const; native version("4.11") int, bool CheckValue(int key) const; native void Insert(int key, int value); native void InsertNew(int key); native void Remove(int key); } struct MapIterator_I32_I8 native { native bool Init(Map_I32_I8 other); native bool ReInit(); native bool Valid(); native bool Next(); native int GetKey(); native int GetValue(); native void SetValue(int value); } struct Map_I32_I16 native { native void Copy(Map_I32_I16 other); native void Move(Map_I32_I16 other); native void Swap(Map_I32_I16 other); native void Clear(); native uint CountUsed() const; native int Get(int key); native bool CheckKey(int key) const; native version("4.11") int GetIfExists(int key) const; native version("4.11") int, bool CheckValue(int key) const; native void Insert(int key, int value); native void InsertNew(int key); native void Remove(int key); } struct MapIterator_I32_I16 native { native bool Init(Map_I32_I16 other); native bool ReInit(); native bool Valid(); native bool Next(); native int GetKey(); native int GetValue(); native void SetValue(int value); } struct Map_I32_I32 native { native void Copy(Map_I32_I32 other); native void Move(Map_I32_I32 other); native void Swap(Map_I32_I32 other); native void Clear(); native uint CountUsed() const; native int Get(int key); native bool CheckKey(int key) const; native version("4.11") int GetIfExists(int key) const; native version("4.11") int, bool CheckValue(int key) const; native void Insert(int key, int value); native void InsertNew(int key); native void Remove(int key); } struct MapIterator_I32_I32 native { native bool Init(Map_I32_I32 other); native bool ReInit(); native bool Valid(); native bool Next(); native int GetKey(); native int GetValue(); native void SetValue(int value); } struct Map_I32_F32 native { native void Copy(Map_I32_F32 other); native void Move(Map_I32_F32 other); native void Swap(Map_I32_F32 other); native void Clear(); native uint CountUsed() const; native double Get(int key); native bool CheckKey(int key) const; native version("4.11") double GetIfExists(int key) const; native version("4.11") double, bool CheckValue(int key) const; native void Insert(int key, double value); native void InsertNew(int key); native void Remove(int key); } struct MapIterator_I32_F32 native { native bool Init(Map_I32_F32 other); native bool ReInit(); native bool Valid(); native bool Next(); native int GetKey(); native double GetValue(); native void SetValue(double value); } struct Map_I32_F64 native { native void Copy(Map_I32_F64 other); native void Move(Map_I32_F64 other); native void Swap(Map_I32_F64 other); native void Clear(); native uint CountUsed() const; native double Get(int key); native bool CheckKey(int key) const; native version("4.11") double GetIfExists(int key) const; native version("4.11") double, bool CheckValue(int key) const; native void Insert(int key, double value); native void InsertNew(int key); native void Remove(int key); } struct MapIterator_I32_F64 native { native bool Init(Map_I32_F64 other); native bool ReInit(); native bool Valid(); native bool Next(); native int GetKey(); native double GetValue(); native void SetValue(double value); } struct Map_I32_Obj native { native void Copy(Map_I32_Obj other); native void Move(Map_I32_Obj other); native void Swap(Map_I32_Obj other); native void Clear(); native uint CountUsed() const; native Object Get(int key); native bool CheckKey(int key) const; native version("4.11") Object GetIfExists(int key) const; native version("4.11") Object, bool CheckValue(int key) const; native void Insert(int key, Object value); native void InsertNew(int key); native void Remove(int key); } struct MapIterator_I32_Obj native { native bool Init(Map_I32_Obj other); native bool ReInit(); native bool Valid(); native bool Next(); native int GetKey(); native Object GetValue(); native void SetValue(Object value); } struct Map_I32_Ptr native { native void Copy(Map_I32_Ptr other); native void Move(Map_I32_Ptr other); native void Swap(Map_I32_Ptr other); native void Clear(); native uint CountUsed() const; native voidptr Get(int key); native bool CheckKey(int key) const; native version("4.11") voidptr GetIfExists(int key) const; native version("4.11") voidptr, bool CheckValue(int key) const; native void Insert(int key, voidptr value); native void InsertNew(int key); native void Remove(int key); } struct MapIterator_I32_Ptr native { native bool Init(Map_I32_Ptr other); native bool Next(); native int GetKey(); native voidptr GetValue(); native void SetValue(voidptr value); } struct Map_I32_Str native { native void Copy(Map_I32_Str other); native void Move(Map_I32_Str other); native void Swap(Map_I32_Str other); native void Clear(); native uint CountUsed() const; native String Get(int key); native bool CheckKey(int key) const; native version("4.11") String GetIfExists(int key) const; native version("4.11") String, bool CheckValue(int key) const; native void Insert(int key, String value); native void InsertNew(int key); native void Remove(int key); } struct MapIterator_I32_Str native { native bool Init(Map_I32_Str other); native bool ReInit(); native bool Valid(); native bool Next(); native int GetKey(); native String GetValue(); native void SetValue(String value); } // --------------- struct Map_Str_I8 native { native void Copy(Map_Str_I8 other); native void Move(Map_Str_I8 other); native void Swap(Map_Str_I8 other); native void Clear(); native uint CountUsed() const; native int Get(String key); native bool CheckKey(String key) const; native version("4.11") int GetIfExists(String key) const; native version("4.11") int, bool CheckValue(String key) const; native void Insert(String key, int value); native void InsertNew(String key); native void Remove(String key); } struct MapIterator_Str_I8 native { native bool Init(Map_Str_I8 other); native bool ReInit(); native bool Valid(); native bool Next(); native String GetKey(); native int GetValue(); native void SetValue(int value); } struct Map_Str_I16 native { native void Copy(Map_Str_I16 other); native void Move(Map_Str_I16 other); native void Swap(Map_Str_I16 other); native void Clear(); native uint CountUsed() const; native int Get(String key); native bool CheckKey(String key) const; native version("4.11") int GetIfExists(String key) const; native version("4.11") int, bool CheckValue(String key) const; native void Insert(String key, int value); native void InsertNew(String key); native void Remove(String key); } struct MapIterator_Str_I16 native { native bool Init(Map_Str_I16 other); native bool ReInit(); native bool Valid(); native bool Next(); native String GetKey(); native int GetValue(); native void SetValue(int value); } struct Map_Str_I32 native { native void Copy(Map_Str_I32 other); native void Move(Map_Str_I32 other); native void Swap(Map_Str_I32 other); native void Clear(); native uint CountUsed() const; native int Get(String key); native bool CheckKey(String key) const; native version("4.11") int GetIfExists(String key) const; native version("4.11") int, bool CheckValue(String key) const; native void Insert(String key, int value); native void InsertNew(String key); native void Remove(String key); } struct MapIterator_Str_I32 native { native bool Init(Map_Str_I32 other); native bool ReInit(); native bool Valid(); native bool Next(); native String GetKey(); native int GetValue(); native void SetValue(int value); } struct Map_Str_F32 native { native void Copy(Map_Str_F32 other); native void Move(Map_Str_F32 other); native void Swap(Map_Str_F32 other); native void Clear(); native uint CountUsed() const; native double Get(String key); native bool CheckKey(String key) const; native version("4.11") double GetIfExists(String key) const; native version("4.11") double, bool CheckValue(String key) const; native void Insert(String key, double value); native void InsertNew(String key); native void Remove(String key); } struct MapIterator_Str_F32 native { native bool Init(Map_Str_F32 other); native bool ReInit(); native bool Valid(); native bool Next(); native String GetKey(); native double GetValue(); native void SetValue(double value); } struct Map_Str_F64 native { native void Copy(Map_Str_F64 other); native void Move(Map_Str_F64 other); native void Swap(Map_Str_F64 other); native void Clear(); native uint CountUsed() const; native double Get(String key); native bool CheckKey(String key) const; native version("4.11") double GetIfExists(String key) const; native version("4.11") double, bool CheckValue(String key) const; native void Insert(String key, double value); native void InsertNew(String key); native void Remove(String key); } struct MapIterator_Str_F64 native { native bool Init(Map_Str_F64 other); native bool ReInit(); native bool Valid(); native bool Next(); native String GetKey(); native double GetValue(); native void SetValue(double value); } struct Map_Str_Obj native { native void Copy(Map_Str_Obj other); native void Move(Map_Str_Obj other); native void Swap(Map_Str_Obj other); native void Clear(); native uint CountUsed() const; native Object Get(String key); native bool CheckKey(String key) const; native version("4.11") Object GetIfExists(String key) const; native version("4.11") Object, bool CheckValue(String key) const; native void Insert(String key, Object value); native void InsertNew(String key); native void Remove(String key); } struct MapIterator_Str_Obj native { native bool Init(Map_Str_Obj other); native bool ReInit(); native bool Valid(); native bool Next(); native String GetKey(); native Object GetValue(); native void SetValue(Object value); } struct Map_Str_Ptr native { native void Copy(Map_Str_Ptr other); native void Move(Map_Str_Ptr other); native void Swap(Map_Str_Ptr other); native void Clear(); native uint CountUsed() const; native voidptr Get(String key); native bool CheckKey(String key) const; native version("4.11") voidptr GetIfExists(String key) const; native version("4.11") voidptr, bool CheckValue(String key) const; native void Insert(String key, voidptr value); native void InsertNew(String key); native void Remove(String key); } struct MapIterator_Str_Ptr native { native bool Init(Map_Str_Ptr other); native bool ReInit(); native bool Valid(); native bool Next(); native String GetKey(); native voidptr GetValue(); native void SetValue(voidptr value); } struct Map_Str_Str native { native void Copy(Map_Str_Str other); native void Move(Map_Str_Str other); native void Swap(Map_Str_Str other); native void Clear(); native uint CountUsed() const; native String Get(String key); native bool CheckKey(String key) const; native version("4.11") String GetIfExists(String key) const; native version("4.11") String, bool CheckValue(String key) const; native void Insert(String key, String value); native void InsertNew(String key); native void Remove(String key); } struct MapIterator_Str_Str native { native bool Init(Map_Str_Str other); native bool ReInit(); native bool Valid(); native bool Next(); native String GetKey(); native String GetValue(); native void SetValue(String value); } // no attempt has been made to merge this with existing code. extend class Actor { // // [XA] New mbf21 codepointers // // // A_SpawnObject // Basically just A_Spawn with better behavior and more args. // args[0]: Type of actor to spawn // args[1]: Angle (degrees, in fixed point), relative to calling actor's angle // args[2]: X spawn offset (fixed point), relative to calling actor // args[3]: Y spawn offset (fixed point), relative to calling actor // args[4]: Z spawn offset (fixed point), relative to calling actor // args[5]: X velocity (fixed point) // args[6]: Y velocity (fixed point) // args[7]: Z velocity (fixed point) // deprecated("2.3", "for Dehacked use only") void MBF21_SpawnObject(class type, double angle, double xofs, double yofs, double zofs, double xvel, double yvel, double zvel) { if (type == null) return; // Don't spawn monsters if this actor has been massacred if (DamageType == 'Massacre' && GetDefaultByType(type).bIsMonster) { return; } // calculate position offsets angle += self.Angle; double s = sin(angle); double c = cos(angle); let pos = Vec2Offset(xofs * c - yofs * s, xofs * s + yofs * c); // spawn it, yo let mo = Spawn(type, (pos, self.pos.Z - Floorclip + GetBobOffset() + zofs), ALLOW_REPLACE); if (!mo) return; // angle dangle mo.angle = angle; // set velocity // Same orientation issue here! mo.vel.X = xvel * c - yvel * s; mo.vel.Y = xvel * s + yvel * c; mo.vel.Z = zvel; // if spawned object is a missile, set target+tracer if (mo.bMissile || mo.bMbfBouncer) { // if spawner is also a missile, copy 'em if (default.bMissile || default.bMbfBouncer) { mo.target = self.target; mo.tracer = self.tracer; } // otherwise, set 'em as if a monster fired 'em else { mo.target = self; mo.tracer = self.target; } } // [XA] don't bother with the dont-inherit-friendliness hack // that exists in A_Spawn, 'cause WTF is that about anyway? // unfortunately this means that this function cannot transfer friendliness at all. Oh well... } // // A_MonsterProjectile // A parameterized monster projectile attack. // args[0]: Type of actor to spawn // args[1]: Angle (degrees, in fixed point), relative to calling actor's angle // args[2]: Pitch (degrees, in fixed point), relative to calling actor's pitch; approximated // args[3]: X/Y spawn offset, relative to calling actor's angle // args[4]: Z spawn offset, relative to actor's default projectile fire height // deprecated("2.3", "for Dehacked use only") void MBF21_MonsterProjectile(class type, double angle, double pitch, double spawnofs_xy, double spawnofs_z) { if (!target || !type) return; A_FaceTarget(); let mo = SpawnMissile(target, type); if (!mo) return; // adjust angle mo.angle += angle; Pitch += mo.PitchFromVel(); let missilespeed = abs(cos(Pitch) * mo.Speed); mo.Vel3DFromAngle(mo.Speed, mo.angle, Pitch); // adjust position double x = Spawnofs_xy * cos(self.angle); double y = Spawnofs_xy * sin(self.angle); mo.SetOrigin(mo.Vec3Offset(x, y, Spawnofs_z), false); // always set the 'tracer' field, so this pointer // can be used to fire seeker missiles at will. mo.tracer = target; } // // A_MonsterBulletAttack // A parameterized monster bullet attack. // args[0]: Horizontal spread (degrees, in fixed point) // args[1]: Vertical spread (degrees, in fixed point) // args[2]: Number of bullets to fire; if not set, defaults to 1 // args[3]: Base damage of attack (e.g. for 3d5, customize the 3); if not set, defaults to 3 // args[4]: Attack damage modulus (e.g. for 3d5, customize the 5); if not set, defaults to 5 // deprecated("2.3", "for Dehacked use only") void MBF21_MonsterBulletAttack(double hspread, double vspread, int numbullets, int damagebase, int damagemod) { if (!target) return; A_FaceTarget(); A_StartSound(AttackSound, CHAN_WEAPON); let bangle = angle; let slope = AimLineAttack(bangle, MISSILERANGE); for (int i = 0; i < numbullets; i++) { int damage = (random[mbf21]() % damagemod + 1) * damagebase; let pangle = bangle + hspread * Random2[mbf21]() / 255.; let pslope = slope + vspread * Random2[mbf21]() / 255.; LineAttack(pangle, MISSILERANGE, pslope, damage, "Hitscan", "Bulletpuff"); } } // // A_MonsterMeleeAttack // A parameterized monster melee attack. // args[0]: Base damage of attack (e.g. for 3d8, customize the 3); if not set, defaults to 3 // args[1]: Attack damage modulus (e.g. for 3d8, customize the 8); if not set, defaults to 8 // args[2]: Sound to play if attack hits // args[3]: Range (fixed point); if not set, defaults to monster's melee range // deprecated("2.3", "for Dehacked use only") void MBF21_MonsterMeleeAttack(int damagebase, int damagemod, Sound hitsound, double range) { let targ = target; if (!targ) return; if (range == 0) range = meleerange; else range -= 20; // DSDA always subtracts 20 from the melee range. A_FaceTarget(); if (!CheckMeleeRange(range)) return; A_StartSound(hitsound, CHAN_WEAPON); int damage = (random[mbf21]() % damagemod + 1) * damagebase; int newdam = targ.DamageMobj(self, self, damage, "Melee"); targ.TraceBleed(newdam > 0 ? newdam : damage, self); } // // A_NoiseAlert // Alerts nearby monsters (via sound) to the calling actor's target's presence. // void A_NoiseAlert() { if (target) SoundAlert(target); } // // A_HealChase // A parameterized version of A_VileChase. // args[0]: State to jump to on the calling actor when resurrecting a corpse // args[1]: Sound to play when resurrecting a corpse // deprecated("2.3", "for Dehacked use only") void MBF21_HealChase(State healstate, Sound healsound) { if (!A_CheckForResurrection(healstate, healsound)) A_Chase(); } // // A_FindTracer // Search for a valid tracer (seek target), if the calling actor doesn't already have one. // args[0]: field-of-view to search in (degrees, in fixed point); if zero, will search in all directions // args[1]: distance to search (map blocks, i.e. 128 units) // void A_FindTracer(double fov, int dist) { // note: mbf21 fov is the angle of the entire cone, while // zdoom fov is defined as 1/2 of the cone, so halve it. if (!tracer) tracer = RoughMonsterSearch(dist, fov: fov/2); } // // A_ClearTracer // Clear current tracer (seek target). // void A_ClearTracer() { tracer = NULL; } // // A_JumpIfHealthBelow // Jumps to a state if caller's health is below the specified threshold. // args[0]: State to jump to // args[1]: Health threshold // deprecated("2.3", "for Dehacked use only") void MBF21_JumpIfHealthBelow(State tstate, int health) { if (self.health < health) self.SetState(tstate); } // // A_JumpIfTargetInSight // Jumps to a state if caller's target is in line-of-sight. // args[0]: State to jump to // args[1]: Field-of-view to check (degrees, in fixed point); if zero, will check in all directions // deprecated("2.3", "for Dehacked use only") void MBF21_JumpIfTargetInSight(State tstate, double fov) { if (!target) return; // Check FOV first since it's faster if (fov > 0 && !CheckFov(target, fov)) return; if (CheckSight(target)) self.SetState(tstate); } // // A_JumpIfTargetCloser // Jumps to a state if caller's target is closer than the specified distance. // args[0]: State to jump to // args[1]: Distance threshold // deprecated("2.3", "for Dehacked use only") void MBF21_JumpIfTargetCloser(State tstate, double dist) { if (!target) return; if (dist > Distance2D(target)) self.SetState(tstate); } // // A_JumpIfTracerInSight // Jumps to a state if caller's tracer (seek target) is in line-of-sight. // args[0]: State to jump to // args[1]: Field-of-view to check (degrees, in fixed point); if zero, will check in all directions // deprecated("2.3", "for Dehacked use only") void MBF21_JumpIfTracerInSight(State tstate, double fov) { if (!tracer) return; // Check FOV first since it's faster if (fov > 0 && !CheckFov(tracer, fov)) return; if (CheckSight(tracer)) self.SetState(tstate); } // // A_JumpIfTracerCloser // Jumps to a state if caller's tracer (seek target) is closer than the specified distance. // args[0]: State to jump to // args[1]: Distance threshold (fixed point) // deprecated("2.3", "for Dehacked use only") void MBF21_JumpIfTracerCloser(State tstate, double dist) { if (!tracer) return; if (dist > Distance2D(tracer)) self.SetState(tstate); } // These are native to lock away the insanity. deprecated("2.3", "for Dehacked use only") native void MBF21_JumpIfFlagsSet(State tstate, int flags, int flags2); deprecated("2.3", "for Dehacked use only") native void MBF21_AddFlags(int flags, int flags2); deprecated("2.3", "for Dehacked use only") native void MBF21_RemoveFlags(int flags, int flags2); } extend class Weapon { // // A_WeaponProjectile // A parameterized player weapon projectile attack. Does not consume ammo. // args[0]: Type of actor to spawn // args[1]: Angle (degrees, in fixed point), relative to calling player's angle // args[2]: Pitch (degrees, in fixed point), relative to calling player's pitch; approximated // args[3]: X/Y spawn offset, relative to calling player's angle // args[4]: Z spawn offset, relative to player's default projectile fire height // deprecated("2.3", "for Dehacked use only") void MBF21_WeaponProjectile(class type, double angle, double pitch, double Spawnofs_xy, double Spawnofs_z) { if (!player || !type) return; FTranslatedLineTarget t; angle += self.angle; Vector2 ofs = AngleToVector(self.Angle - 90, spawnofs_xy); let mo = SpawnPlayerMissile(type, angle, ofs.x, ofs.y, Spawnofs_z, pLineTarget: t); if (!mo) return; Pitch += mo.PitchFromVel(); mo.Vel3DFromAngle(mo.Speed, mo.angle, Pitch); // set tracer to the player's autoaim target, // so player seeker missiles prioritizing the // baddie the player is actually aiming at. ;) mo.tracer = t.linetarget; } // // A_WeaponBulletAttack // A parameterized player weapon bullet attack. Does not consume ammo. // args[0]: Horizontal spread (degrees, in fixed point) // args[1]: Vertical spread (degrees, in fixed point) // args[2]: Number of bullets to fire; if not set, defaults to 1 // args[3]: Base damage of attack (e.g. for 5d3, customize the 5); if not set, defaults to 5 // args[4]: Attack damage modulus (e.g. for 5d3, customize the 3); if not set, defaults to 3 // deprecated("2.3", "for Dehacked use only") void MBF21_WeaponBulletAttack(double hspread, double vspread, int numbullets, int damagebase, int damagemod) { let bangle = angle; let slope = BulletSlope(); for (int i = 0; i < numbullets; i++) { int damage = (random[mbf21]() % damagemod + 1) * damagebase; let pangle = bangle + hspread * Random2[mbf21]() / 255.; let pslope = slope + vspread * Random2[mbf21]() / 255.; LineAttack(pangle, PLAYERMISSILERANGE, pslope, damage, "Hitscan", "Bulletpuff"); } } // // A_WeaponMeleeAttack // A parameterized player weapon melee attack. // args[0]: Base damage of attack (e.g. for 2d10, customize the 2); if not set, defaults to 2 // args[1]: Attack damage modulus (e.g. for 2d10, customize the 10); if not set, defaults to 10 // args[2]: Berserk damage multiplier (fixed point); if not set, defaults to 1.0 (no change). // args[3]: Sound to play if attack hits // args[4]: Range (fixed point); if not set, defaults to player mobj's melee range // deprecated("2.3", "for Dehacked use only") void MBF21_WeaponMeleeAttack(int damagebase, int damagemod, double zerkfactor, Sound hitsound, double range) { if (range == 0) range = meleerange; int damage = (Random[mbf21]() % damagemod + 1) * damagebase; if (FindInventory("PowerStrength")) damage = int(damage * zerkfactor); // slight randomization; weird vanillaism here. :P FTranslatedLineTarget t; double ang = angle + Random2[mbf21]() * (5.625 / 256); double pitch = AimLineAttack(ang, range + MELEEDELTA, t, 0., ALF_CHECK3D); LineAttack(ang, range, pitch, damage, 'Melee', "BulletPuff", LAF_ISMELEEATTACK, t); // turn to face target if (t.linetarget) { A_StartSound(hitsound, CHAN_WEAPON); angle = t.angleFromSource; } } // // A_WeaponAlert // Alerts monsters to the player's presence. Handy when combined with WPF_SILENT. // void A_WeaponAlert() { SoundAlert(self); } // // A_WeaponJump // Jumps to the specified state, with variable random chance. // Basically the same as A_RandomJump, but for weapons. // args[0]: State number // args[1]: Chance, out of 255, to make the jump // deprecated("2.3", "for Dehacked use only") action void MBF21_WeaponJump(State tstate, int chance) { if (stateinfo != null && stateinfo.mStateType == STATE_Psprite) { let player = self.player; if (player == null) return; if (random[mbf21]() < chance) player.SetPSprite(stateinfo.mPSPIndex, tstate); } } // // A_ConsumeAmmo // Subtracts ammo from the player's "inventory". 'Nuff said. // args[0]: Amount of ammo to consume. If zero, use the weapon's ammo-per-shot amount. // deprecated("2.3", "for Dehacked use only") void MBF21_ConsumeAmmo(int consume) { let player = self.player; if (!player) return; let weap = player.ReadyWeapon; if (!weap) return; if (consume == 0) consume = -1; weap.DepleteAmmo(weap.bAltFire, false, consume, true); } // // A_CheckAmmo // Jumps to a state if the player's ammo is lower than the specified amount. // args[0]: State to jump to // args[1]: Minimum required ammo to NOT jump. If zero, use the weapon's ammo-per-shot amount. // deprecated("2.3", "for Dehacked use only") action void MBF21_CheckAmmo(State tstate, int amount) { if (stateinfo != null && stateinfo.mStateType == STATE_Psprite) { let player = self.player; if (player == null) return; let weap = player.ReadyWeapon; if (!weap) return; if (amount == 0) amount = -1; if (!weap.CheckAmmo(weap.bAltFire ? AltFire : PrimaryFire, false, false, amount)) player.SetPSprite(stateinfo.mPSPIndex, tstate); } } // // A_RefireTo // Jumps to a state if the player is holding down the fire button // args[0]: State to jump to // args[1]: If nonzero, skip the ammo check // deprecated("2.3", "for Dehacked use only") action void MBF21_RefireTo(State tstate, int skipcheck) { if (stateinfo != null && stateinfo.mStateType == STATE_Psprite) { let player = self.player; if (player == null) return; let weap = player.ReadyWeapon; if (!weap) return; let pending = player.PendingWeapon != WP_NOCHANGE && (player.WeaponState & WF_REFIRESWITCHOK); if (!skipcheck && !weap.CheckAmmo(weap.bAltFire ? AltFire : PrimaryFire, false, false)) return; if ((player.cmd.buttons & BT_ATTACK) && !player.ReadyWeapon.bAltFire && !pending && player.health > 0) { player.SetPSprite(stateinfo.mPSPIndex, tstate); } } } // // A_GunFlashTo // Sets the weapon flash layer to the specified state. // args[0]: State number // args[1]: If nonzero, don't change the player actor state // deprecated("2.3", "for Dehacked use only") void MBF21_GunFlashTo(State tstate, int dontchangeplayer) { let player = self.player; if (player == null) return; Weapon weapon = player.ReadyWeapon; if (!weapon) return; if (!dontchangeplayer) player.mo.PlayAttacking2(); player.SetPsprite(PSP_FLASH, tstate); } // needed to call A_SeekerMissile with proper defaults. deprecated("2.3", "for Dehacked use only") void MBF21_SeekTracer(double threshold, double turnmax) { A_SeekerMissile(int(threshold), int(turnmax), flags: SMF_PRECISE); // args get truncated to ints here, but it's close enough } } //============================================================================= // // Option Search Menu class. // This menu contains search field, and is dynamically filled with search // results. // //============================================================================= class os_Menu : OptionMenu { override void Init(Menu parent, OptionMenuDescriptor desc) { Super.Init(parent, desc); mDesc.mItems.clear(); addSearchField(); mDesc.mScrollPos = 0; mDesc.mSelectedItem = 0; mDesc.CalcIndent(); } void search() { string text = mSearchField.GetText(); let query = os_Query.fromString(text); bool isAnyTermMatches = mIsAnyOfItem.mCVar.GetBool(); mDesc.mItems.clear(); addSearchField(text); Dictionary searchedMenus = Dictionary.Create(); bool found = listOptions(mDesc, "MainMenu", query, "", isAnyTermMatches, searchedMenus); if (!found) { addNoResultsItem(mDesc); } mDesc.CalcIndent(); } private void addSearchField(string query = "") { string searchLabel = StringTable.Localize("$OS_LABEL"); mSearchField = new("os_SearchField").Init(searchLabel, self, query); mIsAnyOfItem = new("os_AnyOrAllOption").Init(self); mDesc.mItems.push(mSearchField); mDesc.mItems.push(mIsAnyOfItem); addEmptyLine(mDesc); } private static bool listOptions(OptionMenuDescriptor targetDesc, string menuName, os_Query query, string path, bool isAnyTermMatches, Dictionary searchedMenus) { if (searchedMenus.At(menuName).length() > 0) { return false; } searchedMenus.Insert(menuName, "1"); let desc = MenuDescriptor.GetDescriptor(menuName); let listMenuDesc = ListMenuDescriptor(desc); if (listMenuDesc) { return listOptionsListMenu(listMenuDesc, targetDesc, query, path, isAnyTermMatches, searchedMenus); } let optionMenuDesc = OptionMenuDescriptor(desc); if (optionMenuDesc) { return listOptionsOptionMenu(optionMenuDesc, targetDesc, query, path, isAnyTermMatches, searchedMenus); } return false; } private static bool listOptionsListMenu(ListMenuDescriptor sourceDesc, OptionMenuDescriptor targetDesc, os_Query query, string path, bool isAnyTermMatches, Dictionary searchedMenus) { int nItems = sourceDesc.mItems.size(); bool found = false; for (int i = 0; i < nItems; ++i) { let item = sourceDesc.mItems[i]; string actionN = item.GetAction(); let textItem = ListMenuItemTextItem(item); string newPath = textItem ? makePath(path, StringTable.Localize(textItem.mText)) : path; found |= listOptions(targetDesc, actionN, query, newPath, isAnyTermMatches, searchedMenus); } return found; } private static bool listOptionsOptionMenu(OptionMenuDescriptor sourceDesc, OptionMenuDescriptor targetDesc, os_Query query, string path, bool isAnyTermMatches, Dictionary searchedMenus) { if (sourceDesc == targetDesc) { return false; } int nItems = sourceDesc.mItems.size(); bool first = true; bool found = false; for (int i = 0; i < nItems; ++i) { let item = sourceDesc.mItems[i]; if (item is "OptionMenuItemStaticText") { continue; } string label = StringTable.Localize(item.mLabel); if (!query.matches(label, isAnyTermMatches)) { continue; } found = true; if (first) { addEmptyLine(targetDesc); addPathItem(targetDesc, path); first = false; } let itemOptionBase = OptionMenuItemOptionBase(item); if (itemOptionBase) { itemOptionBase.mCenter = false; } targetDesc.mItems.push(item); } for (int i = 0; i < nItems; ++i) { let item = sourceDesc.mItems[i]; string label = StringTable.Localize(item.mLabel); string optionSearchTitle = StringTable.Localize("$OS_TITLE"); if (label == optionSearchTitle) { continue; } if (item is "OptionMenuItemSubMenu") { string newPath = makePath(path, label); found |= listOptions(targetDesc, item.GetAction(), query, newPath, isAnyTermMatches, searchedMenus); } } return found; } private static string makePath(string path, string label) { if (path.length() == 0) { return label; } int pathWidth = SmallFont.StringWidth(path .. "/" .. label); int screenWidth = Screen.GetWidth(); bool isTooWide = (pathWidth > screenWidth / 3); string newPath = isTooWide ? path .. "/" .. "\n" .. label : path .. "/" .. label; return newPath; } private static void addPathItem(OptionMenuDescriptor desc, string path) { Array lines; path.split(lines, "\n"); int nLines = lines.size(); for (int i = 0; i < nLines; ++i) { OptionMenuItemStaticText text = new("OptionMenuItemStaticText").Init(lines[i], 1); desc.mItems.push(text); } } private static void addEmptyLine(OptionMenuDescriptor desc) { int nItems = desc.mItems.size(); if (nItems > 0) { let staticText = OptionMenuItemStaticText(desc.mItems[nItems - 1]); if (staticText != null && staticText.mLabel == "") { return; } } let item = new("OptionMenuItemStaticText").Init(""); desc.mItems.push(item); } private static void addNoResultsItem(OptionMenuDescriptor desc) { string noResults = StringTable.Localize("$OS_NO_RESULTS"); let text = new("OptionMenuItemStaticText").Init(noResults, 0); addEmptyLine(desc); desc.mItems.push(text); } private os_AnyOrAllOption mIsAnyOfItem; private os_SearchField mSearchField; } // This class allows global customization of certain menu aspects, e.g. replacing the menu caption. class MenuDelegateBase ui { virtual int DrawCaption(String title, Font fnt, int y, bool drawit) { if (drawit) screen.DrawText(fnt, OptionMenuSettings.mTitleColor, (screen.GetWidth() - fnt.StringWidth(title) * CleanXfac_1) / 2, 10 * CleanYfac_1, title, DTA_CleanNoMove_1, true); return (y + fnt.GetHeight()) * CleanYfac_1; // return is spacing in screen pixels. } virtual void PlaySound(Name sound) { } virtual bool DrawSelector(ListMenuDescriptor desc) { return false; } virtual void MenuDismissed() { // overriding this allows to execute special actions when the menu closes } virtual Font PickFont(Font fnt) { if (generic_ui || !fnt) return NewSmallFont; if (fnt == SmallFont) return AlternativeSmallFont; if (fnt == BigFont) return AlternativeBigFont; return fnt; } } //============================================================================= // // base class for menu items // //============================================================================= class MenuItemBase : Object native ui version("2.4") { protected native double mXpos, mYpos; protected native Name mAction; native int mEnabled; void Init(double xpos = 0, double ypos = 0, Name actionname = 'None') { mXpos = xpos; mYpos = ypos; mAction = actionname; mEnabled = true; } virtual bool CheckCoordinate(int x, int y) { return false; } virtual void Ticker() {} virtual void Drawer(bool selected) {} virtual bool Selectable() {return false; } virtual bool Activate() { return false; } virtual Name, int GetAction() { return mAction, 0; } virtual bool SetString(int i, String s) { return false; } virtual bool, String GetString(int i) { return false, ""; } virtual bool SetValue(int i, int value) { return false; } virtual bool, int GetValue(int i) { return false, 0; } virtual void Enable(bool on) { mEnabled = on; } virtual bool MenuEvent (int mkey, bool fromcontroller) { return false; } virtual bool MouseEvent(int type, int x, int y) { return false; } virtual bool CheckHotkey(int c) { return false; } virtual int GetWidth() { return 0; } virtual int GetIndent() { return 0; } virtual int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { return indent; } void OffsetPositionY(double ydelta) { mYpos += ydelta; } double GetY() { return mYpos; } double GetX() { return mXpos; } void SetX(double x) { mXpos = x; } void SetY(double x) { mYpos = x; } virtual void OnMenuCreated() {} } // this is only used to parse font color ranges in MENUDEF enum MenudefColorRange { NO_COLOR = -1 } // Base class for the merchants --------------------------------------------- class Merchant : Actor { Default { Health 10000000; PainChance 256; // a merchant should always enter the pain state when getting hurt Radius 20; Height 56; Mass 5000; CrushPainSound "misc/pcrush"; +SOLID +SHOOTABLE +NOTDMATCH +NOSPLASHALERT +NODAMAGE } States { Spawn: MRST A 10 A_Look2; Loop; MRLK A 30 A_ActiveSound; Loop; MRLK B 30; Loop; MRBD ABCDEDCB 4; MRBD A 5; MRBD F 6; Loop; See: Pain: MRPN A 1; MRPN A 2 A_AlertMonsters; MRPN B 3 A_Pain; MRPN C 3; MRPN D 9 Door_CloseWaitOpen(999, 64, 960); MRPN C 4; MRPN B 3; MRPN A 3 A_ClearSoundTarget; Goto Spawn; Yes: MRYS A 20; // Fall through Greetings: MRGT ABCDEFGHI 5; Goto Spawn; No: MRNO AB 6; MRNO C 10; MRNO BA 6; Goto Greetings; } } // Weapon Smith ------------------------------------------------------------- class WeaponSmith : Merchant { Default { PainSound "smith/pain"; Tag "$TAG_WEAPONSMITH"; } } // Bar Keep ----------------------------------------------------------------- class BarKeep : Merchant { Default { Translation 4; PainSound "barkeep/pain"; ActiveSound "barkeep/active"; Tag "$TAG_BARKEEP"; } } // Armorer ------------------------------------------------------------------ class Armorer : Merchant { Default { Translation 5; PainSound "armorer/pain"; Tag "$TAG_ARMORER"; } } // Medic -------------------------------------------------------------------- class Medic : Merchant { Default { Translation 6; PainSound "medic/pain"; Tag "$TAG_MEDIC"; } } /* ** messagebox.cpp ** Confirmation, notification screens ** **--------------------------------------------------------------------------- ** Copyright 2010-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ class MessageBoxMenu : Menu { BrokenLines mMessage; voidptr Handler; int mMessageMode; int messageSelection; int mMouseLeft, mMouseRight, mMouseY; Name mAction; Font textFont, arrowFont; int destWidth, destHeight; String selector; native static void CallHandler(voidptr hnd); //============================================================================= // // // //============================================================================= virtual void Init(Menu parent, String message, int messagemode, bool playsound = false, Name cmd = 'None', voidptr native_handler = null) { Super.Init(parent); mAction = cmd; messageSelection = 0; mMouseLeft = 140; mMouseY = 0x80000000; textFont = null; if (!generic_ui) { if (SmallFont && SmallFont.CanPrint(message) && SmallFont.CanPrint("$TXT_YES") && SmallFont.CanPrint("$TXT_NO")) textFont = SmallFont; else if (OriginalSmallFont && OriginalSmallFont.CanPrint(message) && OriginalSmallFont.CanPrint("$TXT_YES") && OriginalSmallFont.CanPrint("$TXT_NO")) textFont = OriginalSmallFont; } if (!textFont) { arrowFont = textFont = NewSmallFont; int factor = (CleanXfac+1) / 2; destWidth = screen.GetWidth() / factor; destHeight = screen.GetHeight() / factor; selector = "▶"; } else { arrowFont = ((textFont && textFont.GetGlyphHeight(0xd) > 0) ? textFont : ConFont); destWidth = CleanWidth; destHeight = CleanHeight; selector = "\xd"; } int mr1 = destWidth/2 + 10 + textFont.StringWidth(Stringtable.Localize("$TXT_YES")); int mr2 = destWidth/2 + 10 + textFont.StringWidth(Stringtable.Localize("$TXT_NO")); mMouseRight = MAX(mr1, mr2); mParentMenu = parent; mMessage = textFont.BreakLines(Stringtable.Localize(message), int(300/NotifyFontScale)); mMessageMode = messagemode; if (playsound) { MenuSound ("menu/prompt"); } Handler = native_handler; } //============================================================================= // // // //============================================================================= override void Drawer () { int i; double y; let fontheight = textFont.GetHeight() * NotifyFontScale; y = destHeight / 2; int c = mMessage.Count(); y -= c * fontHeight / 2; for (i = 0; i < c; i++) { screen.DrawText (textFont, Font.CR_UNTRANSLATED, destWidth/2 - mMessage.StringWidth(i)*NotifyFontScale/2, y, mMessage.StringAt(i), DTA_VirtualWidth, destWidth, DTA_VirtualHeight, destHeight, DTA_KeepRatio, true, DTA_ScaleX, NotifyFontScale, DTA_ScaleY, NotifyFontScale); y += fontheight; } if (mMessageMode == 0) { y += fontheight; mMouseY = int(y); screen.DrawText(textFont, messageSelection == 0? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor, destWidth / 2, y, Stringtable.Localize("$TXT_YES"), DTA_VirtualWidth, destWidth, DTA_VirtualHeight, destHeight, DTA_KeepRatio, true, DTA_ScaleX, NotifyFontScale, DTA_ScaleY, NotifyFontScale); screen.DrawText(textFont, messageSelection == 1? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor, destWidth / 2, y + fontheight, Stringtable.Localize("$TXT_NO"), DTA_VirtualWidth, destWidth, DTA_VirtualHeight, destHeight, DTA_KeepRatio, true, DTA_ScaleX, NotifyFontScale, DTA_ScaleY, NotifyFontScale); if (messageSelection >= 0) { if ((MenuTime() % 8) < 6) { screen.DrawText(arrowFont, OptionMenuSettings.mFontColorSelection, destWidth/2 - 3 - arrowFont.StringWidth(selector), y + fontheight * messageSelection, selector, DTA_VirtualWidth, destWidth, DTA_VirtualHeight, destHeight, DTA_KeepRatio, true); } } } } //============================================================================= // // // //============================================================================= protected void CloseSound() { MenuSound (GetCurrentMenu() != NULL? "menu/backup" : "menu/dismiss"); } //============================================================================= // // // //============================================================================= virtual void HandleResult(bool res) { if (Handler != null) { if (res) { CallHandler(Handler); } else { Close(); CloseSound(); } } else if (mParentMenu != NULL) { if (mMessageMode == 0) { if (mAction == 'None') { mParentMenu.MenuEvent(res? MKEY_MBYes : MKEY_MBNo, false); Close(); } else { Close(); if (res) SetMenu(mAction, -1); } CloseSound(); } } } //============================================================================= // // // //============================================================================= override bool OnUIEvent(UIEvent ev) { if (ev.type == UIEvent.Type_KeyDown) { if (mMessageMode == 0) { // tolower int ch = ev.KeyChar; ch = ch >= 65 && ch <91? ch + 32 : ch; if (ch == 110 /*'n'*/ || ch == 32) { HandleResult(false); return true; } else if (ch == 121 /*'y'*/) { HandleResult(true); return true; } } else { Close(); return true; } return false; } return Super.OnUIEvent(ev); } override bool OnInputEvent(InputEvent ev) { if (ev.type == InputEvent.Type_KeyDown) { Close(); return true; } return Super.OnInputEvent(ev); } //============================================================================= // // // //============================================================================= override bool MenuEvent(int mkey, bool fromcontroller) { if (mMessageMode == 0) { if (mkey == MKEY_Up || mkey == MKEY_Down) { MenuSound("menu/cursor"); messageSelection = !messageSelection; return true; } else if (mkey == MKEY_Enter) { // 0 is yes, 1 is no HandleResult(!messageSelection); return true; } else if (mkey == MKEY_Back) { HandleResult(false); return true; } return false; } else { Close(); CloseSound(); return true; } } //============================================================================= // // // //============================================================================= override bool MouseEvent(int type, int x, int y) { if (mMessageMode == 1) { if (type == MOUSE_Click) { return MenuEvent(MKEY_Enter, true); } return false; } else { int sel = -1; int fh = textFont.GetHeight() + 1; // convert x/y from screen to virtual coordinates, according to CleanX/Yfac use in DrawTexture x = x * destWidth / screen.GetWidth(); y = y * destHeight / screen.GetHeight(); if (x >= mMouseLeft && x <= mMouseRight && y >= mMouseY && y < mMouseY + 2 * fh) { sel = y >= mMouseY + fh; } messageSelection = sel; if (type == MOUSE_Release) { return MenuEvent(MKEY_Enter, true); } return true; } } } class Minotaur : Actor { const MAULATORTICS = 25 * TICRATE; const MNTR_CHARGE_SPEED =13.; const MINOTAUR_LOOK_DIST = 16*54.; Default { Health 3000; Radius 28; Height 100; Mass 800; Speed 16; Damage 7; Painchance 25; Monster; +DROPOFF +FLOORCLIP +BOSS +NORADIUSDMG +DONTMORPH +NOTARGET +BOSSDEATH SeeSound "minotaur/sight"; AttackSound "minotaur/attack1"; PainSound "minotaur/pain"; DeathSound "minotaur/death"; ActiveSound "minotaur/active"; DropItem "ArtiSuperHealth", 51; DropItem "PhoenixRodAmmo", 84, 10; Obituary "$OB_MINOTAUR"; HitObituary "$OB_MINOTAURHIT"; Tag "$FN_MINOTAUR"; } States { Spawn: MNTR AB 10 A_MinotaurLook; Loop; Roam: MNTR ABCD 5 A_MinotaurRoam; Loop; See: MNTR ABCD 5 A_MinotaurChase; Loop; Melee: MNTR V 10 A_FaceTarget; MNTR W 7 A_FaceTarget; MNTR X 12 A_MinotaurAtk1; Goto See; Missile: MNTR V 10 A_MinotaurDecide; MNTR Y 4 A_FaceTarget; MNTR Z 9 A_MinotaurAtk2; Goto See; Hammer: MNTR V 10 A_FaceTarget; MNTR W 7 A_FaceTarget; MNTR X 12 A_MinotaurAtk3; Goto See; HammerLoop: MNTR X 12; Goto Hammer; Charge: MNTR U 2 A_MinotaurCharge; Loop; Pain: MNTR E 3; MNTR E 6 A_Pain; Goto See; Death: MNTR F 6 A_MinotaurDeath; MNTR G 5; MNTR H 6 A_Scream; MNTR I 5; MNTR J 6; MNTR K 5; MNTR L 6; MNTR M 5 A_NoBlocking; MNTR N 6; MNTR O 5; MNTR P 6; MNTR Q 5; MNTR R 6; MNTR S 5; MNTR T -1 A_BossDeath; Stop; FadeOut: MNTR E 6; MNTR E 2 A_Scream; MNTR E 5 A_SpawnItemEx("MinotaurSmokeExit"); MNTR E 5; MNTR E 5 A_NoBlocking; MNTR E 5; MNTR E 5 A_SetTranslucent(0.66, 0); MNTR E 5 A_SetTranslucent(0.33, 0); MNTR E 10 A_BossDeath; Stop; } //--------------------------------------------------------------------------- // // FUNC P_MinotaurSlam // //--------------------------------------------------------------------------- void MinotaurSlam (Actor target) { double ang = AngleTo(target); double thrust = 16 + random[MinotaurSlam]() / 64.; target.VelFromAngle(thrust, ang); int damage = random[MinotaurSlam](1, 8) * (bSummonedMonster? 4 : 6); int newdam = target.DamageMobj (null, null, damage, 'Melee'); target.TraceBleedAngle (newdam > 0 ? newdam : damage, ang, 0.); if (target.player) { target.reactiontime = random[MinotaurSlam](14, 21); } } //---------------------------------------------------------------------------- // // // //---------------------------------------------------------------------------- override void Tick () { Super.Tick (); // The unfriendly Minotaur (Heretic's) is invulnerable while charging if (!bSummonedMonster) { bInvulnerable = bSkullFly; } } override bool Slam (Actor thing) { // Slamming minotaurs shouldn't move non-creatures if (!thing.bIsMonster && !thing.player) { return false; } return Super.Slam (thing); } override int DoSpecialDamage (Actor target, int damage, Name damagetype) { damage = Super.DoSpecialDamage (target, damage, damagetype); if (damage != -1 && bSkullFly) { // Slam only when in charge mode MinotaurSlam (target); return -1; } return damage; } //---------------------------------------------------------------------------- // // PROC A_MinotaurAtk1 // // Melee attack. // //---------------------------------------------------------------------------- void A_MinotaurAtk1() { let targ = target; if (!targ) { return; } A_StartSound ("minotaur/melee", CHAN_WEAPON); if (CheckMeleeRange()) { PlayerInfo player = targ.player; int damage = random[MinotaurAtk1](1, 8) * 4; int newdam = targ.DamageMobj (self, self, damage, 'Melee'); targ.TraceBleed (newdam > 0 ? newdam : damage, self); if (player != null && player.mo == targ) { // Squish the player player.deltaviewheight = -16; } } } //---------------------------------------------------------------------------- // // PROC A_MinotaurDecide // // Choose a missile attack. // //---------------------------------------------------------------------------- void A_MinotaurDecide() { bool friendly = bSummonedMonster; if (!target) { return; } if (!friendly) { A_StartSound ("minotaur/sight", CHAN_WEAPON); } double dist = Distance2D(target); if (target.pos.z + target.height > pos.z && target.pos.z + target.height < pos.z + height && dist < (friendly ? 16*64. : 8*64.) && dist > 1*64. && random[MinotaurDecide]() < 150) { // Charge attack // Don't call the state function right away SetStateLabel("Charge", true); bSkullFly = true; if (!friendly) { // Heretic's Minotaur is invulnerable during charge attack bInvulnerable = true; } A_FaceTarget (); VelFromAngle(MNTR_CHARGE_SPEED); special1 = TICRATE/2; // Charge duration } else if (target.pos.z == target.floorz && dist < 9*64. && random[MinotaurDecide]() < (friendly ? 100 : 220)) { // Floor fire attack SetStateLabel("Hammer"); special2 = 0; } else { // Swing attack A_FaceTarget (); // Don't need to call P_SetMobjState because the current state // falls through to the swing attack } } //---------------------------------------------------------------------------- // // PROC A_MinotaurCharge // //---------------------------------------------------------------------------- void A_MinotaurCharge() { if (target == null) { return; } if (special1 > 0) { Class type; if (gameinfo.gametype == GAME_Heretic) { type = "PhoenixPuff"; } else { type = "PunchPuff"; } Actor puff = Spawn (type, Pos, ALLOW_REPLACE); if (puff != null) puff.Vel.Z = 2; special1--; } else { bSkullFly = false; bInvulnerable = false; SetState (SeeState); } } //---------------------------------------------------------------------------- // // PROC A_MinotaurAtk2 // // Swing attack. // //---------------------------------------------------------------------------- void A_MinotaurAtk2() { bool friendly = bSummonedMonster; let targ = target; if (targ == null) { return; } A_StartSound ("minotaur/attack2", CHAN_WEAPON); if (CheckMeleeRange()) { int damage = random[MinotaurAtk2](1, 8) * (friendly ? 3 : 5); int newdam = targ.DamageMobj (self, self, damage, 'Melee'); targ.TraceBleed (newdam > 0 ? newdam : damage, self); return; } double z = pos.z + 40; Class fx = "MinotaurFX1"; Actor mo = SpawnMissileZ (z, targ, fx); if (mo != null) { // S_Sound (mo, CHAN_WEAPON, "minotaur/attack2", 1, ATTN_NORM); double vz = mo.Vel.Z; double ang = mo.angle; SpawnMissileAngleZ (z, fx, ang-(45./8), vz); SpawnMissileAngleZ (z, fx, ang+(45./8), vz); SpawnMissileAngleZ (z, fx, ang-(45./16), vz); SpawnMissileAngleZ (z, fx, ang+(45./16), vz); } } //---------------------------------------------------------------------------- // // PROC A_MinotaurAtk3 // // Floor fire attack. // //---------------------------------------------------------------------------- void A_MinotaurAtk3() { bool friendly = bSummonedMonster; let targ = target; if (!targ) { return; } A_StartSound ("minotaur/attack3", CHAN_VOICE); if (CheckMeleeRange()) { PlayerInfo player = targ.player; int damage = random[MinotaurAtk3](1, 8) * (friendly ? 3 : 5); int newdam = targ.DamageMobj (self, self, damage, 'Melee'); targ.TraceBleed (newdam > 0 ? newdam : damage, self); if (player != null && player.mo == targ) { // Squish the player player.deltaviewheight = -16; } } else { if (Floorclip > 0 && (Level.compatflags & COMPATF_MINOTAUR)) { // only play the sound. A_StartSound ("minotaur/fx2hit", CHAN_WEAPON); } else { Actor mo = SpawnMissile (target, "MinotaurFX2"); if (mo != null) { mo.A_StartSound ("minotaur/attack1", CHAN_WEAPON); } } } if (random[MinotaurAtk3]() < 192 && special2 == 0) { SetStateLabel ("HammerLoop"); special2 = 1; } } //---------------------------------------------------------------------------- // // PROC A_MinotaurDeath // //---------------------------------------------------------------------------- void A_MinotaurDeath() { if (Wads.CheckNumForName ("MNTRF1", Wads.ns_sprites) < 0 && Wads.CheckNumForName ("MNTRF0", Wads.ns_sprites) < 0) SetStateLabel("FadeOut"); } //---------------------------------------------------------------------------- // // A_MinotaurRoam // //---------------------------------------------------------------------------- void A_MinotaurRoam() { // In case pain caused him to skip his fade in. A_SetRenderStyle(1, STYLE_Normal); let mf = MinotaurFriend(self); if (mf) { if (mf.StartTime >= 0 && (level.maptime - mf.StartTime) >= MAULATORTICS) { DamageMobj (null, null, TELEFRAG_DAMAGE, 'None'); return; } } if (random[MinotaurRoam]() < 30) A_MinotaurLook(); // adjust to closest target if (random[MinotaurRoam]() < 6) { //Choose new direction movedir = random[MinotaurRoam](0, 7); FaceMovementDirection (); } if (!MonsterMove()) { // Turn if (random[MinotaurRoam](0, 1)) movedir = (movedir + 1) % 8; else movedir = (movedir + 7) % 8; FaceMovementDirection (); } } //---------------------------------------------------------------------------- // // PROC A_MinotaurLook // // Look for enemy of player //---------------------------------------------------------------------------- void A_MinotaurLook() { if (!(self is "MinotaurFriend")) { A_Look(); return; } Actor mo = null; PlayerInfo player; double dist; Actor master = tracer; target = null; if (deathmatch) // Quick search for players { for (int i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i]) continue; player = players[i]; mo = player.mo; if (mo == master) continue; if (mo.health <= 0) continue; dist = Distance2D(mo); if (dist > MINOTAUR_LOOK_DIST) continue; target = mo; break; } } if (!target) // Near player monster search { if (master && (master.health > 0) && (master.player)) mo = master.RoughMonsterSearch(20); else mo = RoughMonsterSearch(20); target = mo; } if (!target) // Normal monster search { ThinkerIterator it = ThinkerIterator.Create("Actor"); while ((mo = Actor(it.Next())) != null) { if (!mo.bIsMonster) continue; if (mo.health <= 0) continue; if (!mo.bShootable) continue; dist = Distance2D(mo); if (dist > MINOTAUR_LOOK_DIST) continue; if (mo == master || mo == self) continue; if (mo.bSummonedMonster && mo.tracer == master) continue; target = mo; break; // Found actor to attack } } if (target) { SetState (SeeState, true); } else { SetStateLabel ("Roam", true); } } //---------------------------------------------------------------------------- // // PROC A_MinotaurChase // //---------------------------------------------------------------------------- void A_MinotaurChase() { let mf = MinotaurFriend(self); if (!mf) { A_Chase(); return; } // In case pain caused him to skip his fade in. A_SetRenderStyle(1, STYLE_Normal); if (mf.StartTime >= 0 && (level.maptime - mf.StartTime) >= MAULATORTICS) { DamageMobj (null, null, TELEFRAG_DAMAGE, 'None'); return; } if (random[MinotaurChase]() < 30) A_MinotaurLook(); // adjust to closest target if (!target || (target.health <= 0) || !target.bShootable) { // look for a new target SetIdle(); return; } FaceMovementDirection (); reactiontime = 0; // Melee attack if (MeleeState && CheckMeleeRange ()) { if (AttackSound) { A_StartSound (AttackSound, CHAN_WEAPON); } SetState (MeleeState); return; } // Missile attack if (MissileState && CheckMissileRange()) { SetState (MissileState); return; } // chase towards target if (!MonsterMove ()) { NewChaseDir (); FaceMovementDirection (); } // Active sound if (random[MinotaurChase]() < 6) { PlayActiveSound (); } } } class MinotaurFriend : Minotaur { int StartTime; Default { Health 2500; -DROPOFF -BOSS -DONTMORPH +FRIENDLY +NOTARGETSWITCH +STAYMORPHED +TELESTOMP +SUMMONEDMONSTER RenderStyle "Translucent"; Alpha 0.3333; DropItem "None"; } States { Spawn: MNTR A 15; MNTR A 15 A_SetTranslucent(0.66, 0); MNTR A 3 A_SetTranslucent(1, 0); Goto Super::Spawn; Idle: Goto Super::Spawn; Death: Goto FadeOut; } //---------------------------------------------------------------------------- // // // //---------------------------------------------------------------------------- override void BeginPlay () { Super.BeginPlay (); StartTime = -1; } override void Die (Actor source, Actor inflictor, int dmgflags, Name MeansOfDeath) { Super.Die (source, inflictor, dmgflags, MeansOfDeath); if (tracer && tracer.health > 0 && tracer.player) { // Search thinker list for minotaur ThinkerIterator it = ThinkerIterator.Create("MinotaurFriend"); MinotaurFriend mo; while ((mo = MinotaurFriend(it.Next())) != null) { if (mo.health <= 0) continue; // [RH] Minotaurs can't be morphed, so this isn't needed //if (!(mo.flags&MF_COUNTKILL)) continue; // for morphed minotaurs if (mo.bCorpse) continue; if (mo.StartTime >= 0 && (level.maptime - StartTime) >= MAULATORTICS) continue; if (mo.tracer != null && mo.tracer.player == tracer.player) break; } if (mo == null) { Inventory power = tracer.FindInventory("PowerMinotaur"); if (power != null) { power.Destroy (); } } } } } // Minotaur FX 1 ------------------------------------------------------------ class MinotaurFX1 : Actor { Default { Radius 10; Height 6; Speed 20; FastSpeed 26; Damage 3; DamageType "Fire"; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: FX12 AB 6 Bright; Loop; Death: FX12 CDEFGH 5 Bright; Stop; } } // Minotaur FX 2 ------------------------------------------------------------ class MinotaurFX2 : MinotaurFX1 { Default { Radius 5; Height 12; Speed 14; FastSpeed 20; Damage 4; +FLOORHUGGER ExplosionDamage 24; DeathSound "minotaur/fx2hit"; } states { Spawn: FX13 A 2 Bright A_MntrFloorFire; Loop; Death: FX13 I 4 Bright A_Explode; FX13 JKLM 4 Bright; Stop; } //---------------------------------------------------------------------------- // // PROC A_MntrFloorFire // //---------------------------------------------------------------------------- void A_MntrFloorFire() { SetZ(floorz); double x = Random2[MntrFloorFire]() / 64.; double y = Random2[MntrFloorFire]() / 64.; Actor mo = Spawn("MinotaurFX3", Vec2OffsetZ(x, y, floorz), ALLOW_REPLACE); if (mo != null) { mo.target = target; mo.Vel.X = MinVel; // Force block checking mo.CheckMissileSpawn (radius); } } } // Minotaur FX 3 ------------------------------------------------------------ class MinotaurFX3 : MinotaurFX2 { Default { Radius 8; Height 16; Speed 0; DeathSound "minotaur/fx3hit"; ExplosionDamage 128; } States { Spawn: FX13 DC 4 Bright; FX13 BCDE 5 Bright; FX13 FGH 4 Bright; Stop; } } // Minotaur Smoke Exit ------------------------------------------------------ class MinotaurSmokeExit : Actor { Default { +NOBLOCKMAP +NOTELEPORT RenderStyle "Translucent"; Alpha 0.4; } States { Spawn: MNSM ABCDEFGHIJIHGFEDCBA 3; Stop; } } extend class Actor { enum dirtype_t { DI_EAST, DI_NORTHEAST, DI_NORTH, DI_NORTHWEST, DI_WEST, DI_SOUTHWEST, DI_SOUTH, DI_SOUTHEAST, DI_NODIR, NUMDIRS }; void FaceMovementDirection() { switch (movedir) { case DI_EAST: angle = 0.; break; case DI_NORTHEAST: angle = 45.; break; case DI_NORTH: angle = 90.; break; case DI_NORTHWEST: angle = 135.; break; case DI_WEST: angle = 180.; break; case DI_SOUTHWEST: angle = 225.; break; case DI_SOUTH: angle = 270.; break; case DI_SOUTHEAST: angle = 315.; break; } } } //----------------------------------------------------------------------------- // // Copyright 1994-1996 Raven Software // Copyright 1999-2016 Randy Heit // Copyright 2002-2018 Christoph Oelckers // Copyright 2005-2008 Martin Howe // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see http://www.gnu.org/licenses/ // //----------------------------------------------------------------------------- // extend class Actor { virtual Actor, int, int MorphedDeath() { return null, 0, 0; } // [MC] Called when an actor morphs, on both the previous form (!current) and present form (current). virtual void PreMorph(Actor mo, bool current) {} virtual void PostMorph(Actor mo, bool current) {} virtual void PreUnmorph(Actor mo, bool current) {} virtual void PostUnmorph(Actor mo, bool current) {} //=========================================================================== // // Main entry point // //=========================================================================== virtual bool Morph(Actor activator, class playerclass, class monsterclass, int duration = 0, int style = 0, class morphflash = null, classunmorphflash = null) { if (player != null && player.mo != null && playerclass != null) { return player.mo.MorphPlayer(activator? activator.player : null, playerclass, duration, style, morphflash, unmorphflash); } else { return MorphMonster(monsterclass, duration, style, morphflash, unmorphflash); } } //=========================================================================== // // Action function variant whose arguments differ from the generic one. // //=========================================================================== bool A_Morph(class type, int duration = 0, int style = 0, class morphflash = null, classunmorphflash = null) { if (self.player != null) { let playerclass = (class)(type); if (playerclass && self.player.mo != null) return player.mo.MorphPlayer(self.player, playerclass, duration, style, morphflash, unmorphflash); } else { return MorphMonster(type, duration, style, morphflash, unmorphflash); } return false; } //=========================================================================== // // Main entry point // //=========================================================================== virtual bool UnMorph(Actor activator, int flags, bool force) { if (player) { return player.mo.UndoPlayerMorph(activator? activator.player : null, flags, force); } else { let morphed = MorphedMonster(self); if (morphed) return morphed.UndoMonsterMorph(force); } return false; } //--------------------------------------------------------------------------- // // FUNC P_MorphMonster // // Returns true if the monster gets turned into a chicken/pig. // //--------------------------------------------------------------------------- virtual bool MorphMonster (Class spawntype, int duration, int style, Class enter_flash, Class exit_flash) { if (player || spawntype == NULL || bDontMorph || !bIsMonster || !(spawntype is 'MorphedMonster')) { return false; } let morphed = MorphedMonster(Spawn (spawntype, Pos, NO_REPLACE)); // [MC] Notify that we're just about to start the transfer. PreMorph(morphed, false); // False: No longer the current. morphed.PreMorph(self, true); // True: Becoming this actor. Substitute (morphed); if ((style & MRF_TRANSFERTRANSLATION) && !morphed.bDontTranslate) { morphed.Translation = Translation; } morphed.ChangeTid(tid); ChangeTid(0); morphed.Angle = Angle; morphed.UnmorphedMe = self; morphed.Alpha = Alpha; morphed.RenderStyle = RenderStyle; morphed.Score = Score; morphed.UnmorphTime = level.time + ((duration) ? duration : DEFMORPHTICS) + random[morphmonst](); morphed.MorphStyle = style; morphed.MorphExitFlash = (exit_flash) ? exit_flash : (class)("TeleportFog"); morphed.FlagsSave = bSolid * 2 + bShootable * 4 + bInvisible * 0x40; // The factors are for savegame compatibility morphed.special = special; morphed.args[0] = args[0]; morphed.args[1] = args[1]; morphed.args[2] = args[2]; morphed.args[3] = args[3]; morphed.args[4] = args[4]; morphed.CopyFriendliness (self, true); morphed.bShadow |= bShadow; morphed.bGhost |= bGhost; special = 0; bSolid = false; bShootable = false; bUnmorphed = true; bInvisible = true; let eflash = Spawn(enter_flash ? enter_flash : (class)("TeleportFog"), Pos + (0, 0, gameinfo.TELEFOGHEIGHT), ALLOW_REPLACE); if (eflash) eflash.target = morphed; PostMorph(morphed, false); morphed.PostMorph(self, true); return true; } } /* ** a_movingcamera.cpp ** Cameras that move and related neat stuff ** **--------------------------------------------------------------------------- ** Copyright 1998-2016 Randy Heit ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, self list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, self list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from self software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ /* == InterpolationPoint: node along a camera's path == == args[0] = pitch == args[1] = time (in octics) to get here from previous node == args[2] = time (in octics) to stay here before moving to next node == args[3] = low byte of next node's tid == args[4] = high byte of next node's tid */ class InterpolationPoint : Actor { InterpolationPoint Next; bool bVisited; default { +NOBLOCKMAP +NOGRAVITY +DONTSPLASH +NOTONAUTOMAP RenderStyle "None"; } override void BeginPlay () { Super.BeginPlay (); Next = null; } override void Tick () {} // Nodes do no thinking void FormChain () { let me = self; while (me != null) { if (me.bVisited) return; me.bVisited = true; let iterator = Level.CreateActorIterator(me.args[3] + 256 * me.args[4], "InterpolationPoint"); me.Next = InterpolationPoint(iterator.Next ()); if (me.Next == me) // Don't link to self me.Next = InterpolationPoint(iterator.Next ()); int pt = (me.args[0] << 24) >> 24; // this is for truncating the value to a byte, presumably because some old WAD needs it... me.Pitch = clamp(pt, -89, 89); if (me.Next == null && (me.args[3] | me.args[4])) { A_Log("Can't find target for camera node " .. me.tid); } me = me.Next; } } // Return the node (if any) where a path loops, relative to self one. InterpolationPoint ScanForLoop () { InterpolationPoint node = self; while (node.Next && node.Next != self && node.special1 == 0) { node.special1 = 1; node = node.Next; } return node.Next == self ? node : null; } } /* == InterpolationSpecial: Holds a special to execute when a == PathFollower reaches an InterpolationPoint of the same TID. */ class InterpolationSpecial : Actor { default { +NOBLOCKMAP +NOSECTOR +NOGRAVITY +DONTSPLASH +NOTONAUTOMAP } override void Tick () {} // Does absolutely nothing itself } /* == PathFollower: something that follows a camera path == Base class for some moving cameras == == args[0] = low byte of first node in path's tid == args[1] = high byte of first node's tid == args[2] = bit 0 = follow a linear path (rather than curved) == bit 1 = adjust angle == bit 2 = adjust pitch == bit 3 = aim in direction of motion == == Also uses: == target = first node in path == lastenemy = node prior to first node (if looped) */ class PathFollower : Actor { default { +NOBLOCKMAP +NOSECTOR +NOGRAVITY +DONTSPLASH } bool bActive, bJustStepped; InterpolationPoint PrevNode, CurrNode; double Time; // Runs from 0.0 to 1.0 between CurrNode and CurrNode.Next int HoldTime; // Interpolate between p2 and p3 along a Catmull-Rom spline // http://research.microsoft.com/~hollasch/cgindex/curves/catmull-rom.html double Splerp (double p1, double p2, double p3, double p4) { double t = Time; double res = 2*p2; res += (p3 - p1) * Time; t *= Time; res += (2*p1 - 5*p2 + 4*p3 - p4) * t; t *= Time; res += (3*p2 - 3*p3 + p4 - p1) * t; return 0.5 * res; } // Linearly interpolate between p1 and p2 double Lerp (double p1, double p2) { return p1 + Time * (p2 - p1); } override void BeginPlay () { Super.BeginPlay (); PrevNode = CurrNode = null; bActive = false; } override void PostBeginPlay () { // Find first node of path let iterator = Level.CreateActorIterator(args[0] + 256 * args[1], "InterpolationPoint"); let node = InterpolationPoint(iterator.Next ()); InterpolationPoint prevnode; target = node; if (node == null) { A_Log ("PathFollower " .. tid .. ": Can't find interpolation point " .. args[0] + 256 * args[1] .. "\n"); return; } // Verify the path has enough nodes node.FormChain (); if (args[2] & 1) { // linear path; need 2 nodes if (node.Next == null) { A_Log ("PathFollower " .. tid .. ": Path needs at least 2 nodes\n"); return; } lastenemy = null; } else { // spline path; need 4 nodes if (node.Next == null || node.Next.Next == null || node.Next.Next.Next == null) { A_Log ("PathFollower " .. tid .. ": Path needs at least 4 nodes\n"); return; } // If the first node is in a loop, we can start there. // Otherwise, we need to start at the second node in the path. prevnode = node.ScanForLoop (); if (prevnode == null || prevnode.Next != node) { lastenemy = target; target = node.Next; } else { lastenemy = prevnode; } } } override void Deactivate (Actor activator) { bActive = false; } override void Activate (Actor activator) { if (!bActive) { CurrNode = InterpolationPoint(target); PrevNode = InterpolationPoint(lastenemy); if (CurrNode != null) { NewNode (); SetOrigin (CurrNode.Pos, false); Time = 0.; HoldTime = 0; bJustStepped = true; bActive = true; } } } override void Tick () { if (!bActive) return; if (bJustStepped) { bJustStepped = false; if (CurrNode.args[2]) { HoldTime = Level.maptime + CurrNode.args[2] * TICRATE / 8; SetXYZ(CurrNode.Pos); } } if (HoldTime > Level.maptime) return; // Splines must have a previous node. if (PrevNode == null && !(args[2] & 1)) { bActive = false; return; } // All paths must have a current node. if (CurrNode.Next == null) { bActive = false; return; } if (Interpolate ()) { Time += (8. / (max(1, CurrNode.args[1]) * TICRATE)); if (Time > 1.) { Time -= 1.; bJustStepped = true; PrevNode = CurrNode; CurrNode = CurrNode.Next; if (CurrNode != null) NewNode (); if (CurrNode == null || CurrNode.Next == null) Deactivate (self); if ((args[2] & 1) == 0 && CurrNode.Next.Next == null) Deactivate (self); } } } void NewNode () { let iterator = Level.CreateActorIterator(CurrNode.tid, "InterpolationSpecial"); InterpolationSpecial spec; while ( (spec = InterpolationSpecial(iterator.Next ())) ) { Level.ExecuteSpecial(spec.special, null, null, false, spec.args[0], spec.args[1], spec.args[2], spec.args[3], spec.args[4]); } } virtual bool Interpolate () { Vector3 dpos = (0, 0, 0); LinkContext ctx; if ((args[2] & 8) && Time > 0) { dpos = Pos; } if (CurrNode.Next==null) return false; UnlinkFromWorld (ctx); Vector3 newpos; if (args[2] & 1) { // linear newpos.X = Lerp(CurrNode.pos.X, CurrNode.Next.pos.X); newpos.Y = Lerp(CurrNode.pos.Y, CurrNode.Next.pos.Y); newpos.Z = Lerp(CurrNode.pos.Z, CurrNode.Next.pos.Z); } else { // spline if (CurrNode.Next.Next==null) return false; newpos.X = Splerp(PrevNode.pos.X, CurrNode.pos.X, CurrNode.Next.pos.X, CurrNode.Next.Next.pos.X); newpos.Y = Splerp(PrevNode.pos.Y, CurrNode.pos.Y, CurrNode.Next.pos.Y, CurrNode.Next.Next.pos.Y); newpos.Z = Splerp(PrevNode.pos.Z, CurrNode.pos.Z, CurrNode.Next.pos.Z, CurrNode.Next.Next.pos.Z); } SetXYZ(newpos); LinkToWorld (ctx); if (args[2] & 6) { if (args[2] & 8) { if (args[2] & 1) { // linear dpos.X = CurrNode.Next.pos.X - CurrNode.pos.X; dpos.Y = CurrNode.Next.pos.Y - CurrNode.pos.Y; dpos.Z = CurrNode.Next.pos.Z - CurrNode.pos.Z; } else if (Time > 0) { // spline dpos = newpos - dpos; } else { int realarg = args[2]; args[2] &= ~(2|4|8); Time += 0.1; dpos = newpos; Interpolate (); Time -= 0.1; args[2] = realarg; dpos = newpos - dpos; newpos -= dpos; SetXYZ(newpos); } if (args[2] & 2) { // adjust yaw Angle = VectorAngle(dpos.X, dpos.Y); } if (args[2] & 4) { // adjust pitch; double dist = dpos.XY.Length(); Pitch = dist != 0 ? VectorAngle(dist, -dpos.Z) : 0.; } } else { if (args[2] & 2) { // interpolate angle double angle1 = Normalize180(CurrNode.angle); double angle2 = angle1 + deltaangle(angle1, CurrNode.Next.angle); angle = Lerp(angle1, angle2); } if (args[2] & 1) { // linear if (args[2] & 4) { // interpolate pitch Pitch = Lerp(CurrNode.Pitch, CurrNode.Next.Pitch); } } else { // spline if (args[2] & 4) { // interpolate pitch Pitch = Splerp(PrevNode.Pitch, CurrNode.Pitch, CurrNode.Next.Pitch, CurrNode.Next.Next.Pitch); } } } } return true; } } /* == ActorMover: Moves any actor along a camera path == == Same as PathFollower, except == args[2], bit 7: make nonsolid == args[3] = tid of thing to move == == also uses: == tracer = thing to move */ class ActorMover : PathFollower { override void BeginPlay() { ChangeStatNum(STAT_ACTORMOVER); } override void PostBeginPlay () { Super.PostBeginPlay (); let iterator = Level.CreateActorIterator(args[3]); tracer = iterator.Next (); if (tracer == null) { A_Log("ActorMover " .. tid .. ": Can't find target " .. args[3] .. "\n"); } else { special1 = tracer.bNoGravity + (tracer.bNoBlockmap<<1) + (tracer.bSolid<<2) + (tracer.bInvulnerable<<4) + (tracer.bDormant<<8); } } override bool Interpolate () { if (tracer == null) return true; if (Super.Interpolate ()) { double savedz = tracer.pos.Z; tracer.SetZ(pos.Z); if (!tracer.TryMove (Pos.XY, true)) { tracer.SetZ(savedz); return false; } if (args[2] & 2) tracer.angle = angle; if (args[2] & 4) tracer.Pitch = Pitch; return true; } return false; } override void Activate (Actor activator) { if (tracer == null || bActive) return; Super.Activate (activator); let tracer = self.tracer; special1 = tracer.bNoGravity + (tracer.bNoBlockmap<<1) + (tracer.bSolid<<2) + (tracer.bInvulnerable<<4) + (tracer.bDormant<<8); tracer.bNoGravity = true; if (args[2] & 128) { LinkContext ctx; tracer.UnlinkFromWorld (ctx); tracer.bNoBlockmap = true; tracer.bSolid = false; tracer.LinkToWorld (ctx); } if (tracer.bIsMonster) { tracer.bInvulnerable = true; tracer.bDormant = true; } // Don't let the renderer interpolate between the actor's // old position and its new position. Interpolate (); tracer.ClearInterpolation(); } override void Deactivate (Actor activator) { if (bActive) { Super.Deactivate (activator); let tracer = self.tracer; if (tracer != null) { LinkContext ctx; tracer.UnlinkFromWorld (ctx); tracer.bNoGravity = (special1 & 1); tracer.bNoBlockmap = !!(special1 & 2); tracer.bSolid = !!(special1 & 4); tracer.bInvulnerable = !!(special1 & 8); tracer.bDormant = !!(special1 & 16); tracer.LinkToWorld (ctx); } } } } /* == MovingCamera: Moves any actor along a camera path == == Same as PathFollower, except == args[3] = tid of thing to look at (0 if none) == == Also uses: == tracer = thing to look at */ class MovingCamera : PathFollower { Actor activator; default { CameraHeight 0; } override void PostBeginPlay () { Super.PostBeginPlay (); Activator = null; if (args[3] != 0) { let iterator = Level.CreateActorIterator(args[3]); tracer = iterator.Next (); if (tracer == null) { A_Log("MovingCamera " .. tid .. ": Can't find thing " .. args[3] .. "\n"); } } } override bool Interpolate () { if (tracer == null) return Super.Interpolate (); if (Super.Interpolate ()) { angle = AngleTo(tracer, true); if (args[2] & 4) { // Also aim camera's pitch; Vector3 diff = Pos - tracer.Pos - (0, 0, tracer.Height / 2); double dist = diff.XY.Length(); Pitch = dist != 0 ? VectorAngle(dist, diff.Z) : 0.; } return true; } return false; } } // Mummy -------------------------------------------------------------------- class Mummy : Actor { Default { Health 80; Radius 22; Height 62; Mass 75; Speed 12; Painchance 128; Monster; +FLOORCLIP SeeSound "mummy/sight"; AttackSound "mummy/attack1"; PainSound "mummy/pain"; DeathSound "mummy/death"; ActiveSound "mummy/active"; HitObituary "$OB_MUMMY"; Tag "$FN_MUMMY"; DropItem "GoldWandAmmo", 84, 3; } States { Spawn: MUMM AB 10 A_Look; Loop; See: MUMM ABCD 4 A_Chase; Loop; Melee: MUMM E 6 A_FaceTarget; MUMM F 6 A_CustomMeleeAttack(random[MummyAttack](1,8)*2, "mummy/attack2", "mummy/attack"); MUMM G 6; Goto See; Pain: MUMM H 4; MUMM H 4 A_Pain; Goto See; Death: MUMM I 5; MUMM J 5 A_Scream; MUMM K 5 A_SpawnItemEx("MummySoul", 0,0,10, 0,0,1); MUMM L 5; MUMM M 5 A_NoBlocking; MUMM NO 5; MUMM P -1; Stop; } } // Mummy leader ------------------------------------------------------------- class MummyLeader : Mummy { Default { Species "MummyLeader"; Health 100; Painchance 64; Obituary "$OB_MUMMYLEADER"; Tag "$FN_MUMMYLEADER"; } States { Missile: MUMM X 5 A_FaceTarget; MUMM Y 5 Bright A_FaceTarget; MUMM X 5 A_FaceTarget; MUMM Y 5 Bright A_FaceTarget; MUMM X 5 A_FaceTarget; MUMM Y 5 Bright A_CustomComboAttack("MummyFX1", 32, random[MummyAttack2](1,8)*2, "mummy/attack2"); Goto See; } } // Mummy ghost -------------------------------------------------------------- class MummyGhost : Mummy { Default { +SHADOW +GHOST RenderStyle "Translucent"; Alpha 0.4; } } // Mummy leader ghost ------------------------------------------------------- class MummyLeaderGhost : MummyLeader { Default { Species "MummyLeaderGhost"; +SHADOW +GHOST RenderStyle "Translucent"; Alpha 0.4; } } // Mummy soul --------------------------------------------------------------- class MummySoul : Actor { Default { +NOBLOCKMAP +NOGRAVITY } States { Spawn: MUMM QRS 5; MUMM TUVW 9; Stop; } } // Mummy FX 1 (flying head) ------------------------------------------------- class MummyFX1 : Actor { Default { Radius 8; Height 14; Speed 9; FastSpeed 18; Damage 4; RenderStyle "Add"; Projectile; -ACTIVATEPCROSS -ACTIVATEIMPACT +SEEKERMISSILE +ZDOOMTRANS } States { Spawn: FX15 A 5 Bright A_StartSound("mummy/head"); FX15 B 5 Bright A_SeekerMissile(10,20); FX15 C 5 Bright; FX15 B 5 Bright A_SeekerMissile(10,20); Loop; Death: FX15 DEFG 5 Bright; Stop; } } /* ** playermenu.cpp ** The player setup menu ** **--------------------------------------------------------------------------- ** Copyright 2001-2010 Randy Heit ** Copyright 2010-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ //============================================================================= // // // //============================================================================= class OptionMenuItemPlayerNameField : OptionMenuItemTextField { OptionMenuItemTextField Init(String label) { Super.Init(label, "", null); mEnter = null; return self; } override bool, String GetString (int i) { if (i == 0) { return true, players[consoleplayer].GetUserName(); ; } return false, ""; } override bool SetString (int i, String s) { if (i == 0) { PlayerMenu.PlayerNameChanged(s); return true; } return false; } } //============================================================================= // // // //============================================================================= class OptionMenuItemPlayerTeamItem : OptionMenuItemOptionBase { OptionMenuItemPlayerTeamItem Init(String label, Name values) { Super.Init(label, 'none', values, null , false); return self; } //============================================================================= override int GetSelection() { int Selection = -1; int cnt = OptionValues.GetCount(mValues); if (cnt > 0) { int myteam = players[consoleplayer].GetTeam(); let f = double(myteam == Team.NoTeam? 0 : myteam + 1); for(int i = 0; i < cnt; i++) { if (f ~== OptionValues.GetValue(mValues, i)) { Selection = i; break; } } } return Selection; } override void SetSelection(int Selection) { int cnt = OptionValues.GetCount(mValues); if (cnt > 0) { PlayerMenu.TeamChanged(Selection); } } } //============================================================================= // // // //============================================================================= class OptionMenuItemPlayerColorItem : OptionMenuItemOptionBase { OptionMenuItemPlayerColorItem Init(String label, Name values) { Super.Init(label, 'none', values, null , false); return self; } //============================================================================= override int GetSelection() { int Selection = -1; int cnt = OptionValues.GetCount(mValues); if (cnt > 0) { int mycolorset = players[consoleplayer].GetColorSet(); let f = double(mycolorset); for(int i = 0; i < cnt; i++) { if (f ~== OptionValues.GetValue(mValues, i)) { Selection = i; break; } } } return Selection; } override void SetSelection(int Selection) { int cnt = OptionValues.GetCount(mValues); if (cnt > 0) { let val = int(OptionValues.GetValue(mValues, Selection)); PlayerMenu.ColorSetChanged(val); let menu = NewPlayerMenu(Menu.GetCurrentMenu()); if (menu) menu.UpdateTranslation(); } } } //============================================================================= // // // //============================================================================= class OptionMenuItemPlayerColorSlider : OptionMenuSliderBase { int mChannel; OptionMenuItemPlayerColorSlider Init(String label, int channel) { Super.Init(label, 0, 255, 16, false, 'none'); mChannel = channel; return self; } override double GetSliderValue() { Color colr = players[consoleplayer].GetColor(); if (mChannel == 0) return colr.r; else if (mChannel == 1) return colr.g; else return colr.b; } override void SetSliderValue(double val) { Color colr = players[consoleplayer].GetColor(); int r = colr.r; int g = colr.g; int b = colr.b; if (mChannel == 0) r = int(val); else if (mChannel == 1) g = int(val); else b = int(val); PlayerMenu.ColorChanged(r, g, b); let menu = NewPlayerMenu(Menu.GetCurrentMenu()); if (menu) menu.UpdateTranslation(); } override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { int mycolorset = players[consoleplayer].GetColorSet(); if (mycolorset == -1) { return super.Draw(desc, y, indent, selected); } return indent; } override bool Selectable() { int mycolorset = players[consoleplayer].GetColorSet(); return (mycolorset == -1); } } //============================================================================= // // // //============================================================================= class OptionMenuItemPlayerClassItem : OptionMenuItemOptionBase { OptionMenuItemPlayerClassItem Init(String label, Name values) { Super.Init(label, 'none', values, null , false); return self; } //============================================================================= override int GetSelection() { int Selection = -1; int cnt = OptionValues.GetCount(mValues); if (cnt > 0) { double f = players[consoleplayer].GetPlayerClassNum(); for(int i = 0; i < cnt; i++) { if (f ~== OptionValues.GetValue(mValues, i)) { Selection = i; break; } } } return Selection; } override void SetSelection(int Selection) { int cnt = OptionValues.GetCount(mValues); if (cnt > 1) { let val = int(OptionValues.GetValue(mValues, Selection)); let menu = NewPlayerMenu(Menu.GetCurrentMenu()); if (menu) { menu.PickPlayerClass(val); PlayerMenu.ClassChanged(val, menu.mPlayerClass); menu.mPlayerDisplay.SetValue(ListMenuItemPlayerDisplay.PDF_CLASS, players[consoleplayer].GetPlayerClassNum()); menu.UpdateSkins(); } } } } //============================================================================= // // // //============================================================================= class OptionMenuItemPlayerSkinItem : OptionMenuItemOptionBase { OptionMenuItemPlayerSkinItem Init(String label, Name values) { Super.Init(label, 'none', values, null , false); return self; } //============================================================================= override int GetSelection() { int Selection = 0; int cnt = OptionValues.GetCount(mValues); if (cnt > 1) { double f = players[consoleplayer].GetSkin(); for(int i = 0; i < cnt; i++) { if (f ~== OptionValues.GetValue(mValues, i)) { Selection = i; break; } } } return Selection; } override void SetSelection(int Selection) { int cnt = OptionValues.GetCount(mValues); if (cnt > 1) { let val = int(OptionValues.GetValue(mValues, Selection)); let menu = NewPlayerMenu(Menu.GetCurrentMenu()); PlayerMenu.SkinChanged(val); if (menu) { menu.mPlayerDisplay.SetValue(ListMenuItemPlayerDisplay.PDF_SKIN, val); menu.UpdateTranslation(); } } } } //============================================================================= // // // //============================================================================= class OptionMenuItemPlayerGenderItem : OptionMenuItemOptionBase { OptionMenuItemPlayerGenderItem Init(String label, Name values) { Super.Init(label, 'none', values, null , false); return self; } //============================================================================= override int GetSelection() { return players[consoleplayer].GetGender(); } override void SetSelection(int Selection) { PlayerMenu.GenderChanged(Selection); } } //============================================================================= // // // //============================================================================= class OptionMenuItemAutoaimSlider : OptionMenuSliderBase { OptionMenuItemAutoaimSlider Init(String label) { Super.Init(label, 0, 35, 1, false, 'none'); return self; } override double GetSliderValue() { return players[consoleplayer].GetAutoaim(); } override void SetSliderValue(double val) { PlayerMenu.AutoaimChanged(val); } } //============================================================================= // // // //============================================================================= class OptionMenuItemPlayerSwitchOnPickupItem : OptionMenuItemOptionBase { OptionMenuItemPlayerSwitchOnPickupItem Init(String label, Name values) { Super.Init(label, 'none', values, null , false); return self; } //============================================================================= override int GetSelection() { return players[consoleplayer].GetNeverSwitch()? 1:0; } override void SetSelection(int Selection) { PlayerMenu.SwitchOnPickupChanged(Selection); } } //============================================================================= // // // //============================================================================= class NewPlayerMenu : OptionMenu { protected native static void UpdateColorsets(PlayerClass cls); protected native static void UpdateSkinOptions(PlayerClass cls); PlayerClass mPlayerClass; int mRotation; PlayerMenuPlayerDisplay mPlayerDisplay; const PLAYERDISPLAY_X = 170; const PLAYERDISPLAY_Y = 60; const PLAYERDISPLAY_W = 144; const PLAYERDISPLAY_H = 160; const PLAYERDISPLAY_SPACE = 180; override void Init(Menu parent, OptionMenuDescriptor desc) { Super.Init(parent, desc); let BaseColor = gameinfo.gametype == GAME_Hexen? 0x200000 : 0x000700; let AddColor = gameinfo.gametype == GAME_Hexen? 0x800040 : 0x405340; mPlayerDisplay = new("PlayerMenuPlayerDisplay"); mPlayerDisplay.init(BaseColor, AddColor); PickPlayerClass(); PlayerInfo p = players[consoleplayer]; mRotation = 0; mPlayerDisplay.SetValue(ListMenuItemPlayerDisplay.PDF_ROTATION, 0); mPlayerDisplay.SetValue(ListMenuItemPlayerDisplay.PDF_MODE, 1); mPlayerDisplay.SetValue(ListMenuItemPlayerDisplay.PDF_TRANSLATE, 1); mPlayerDisplay.SetValue(ListMenuItemPlayerDisplay.PDF_CLASS, p.GetPlayerClassNum()); UpdateSkins(); } override int GetIndent() { return Super.GetIndent() - 75*CleanXfac_1; } //============================================================================= // // // //============================================================================= void UpdateTranslation() { Translation.SetPlayerTranslation(TRANSLATION_Players, MAXPLAYERS, consoleplayer, mPlayerClass); } //============================================================================= // // // //============================================================================= static int GetPlayerClassIndex(int pick = -100) { int pclass = 0; // [GRB] Pick a class from player class list if (PlayerClasses.Size () > 1) { pclass = pick == -100? players[consoleplayer].GetPlayerClassNum() : pick; if (pclass < 0) { pclass = (MenuTime() >> 7) % PlayerClasses.Size (); } } return pclass; } //============================================================================= // // // //============================================================================= void PickPlayerClass(int pick = -100) { let PlayerClassIndex = GetPlayerClassIndex(pick); mPlayerClass = PlayerClasses[PlayerClassIndex]; UpdateColorsets(mPlayerClass); UpdateSkinOptions(mPlayerClass); UpdateTranslation(); } //============================================================================= // // // //============================================================================= void UpdateSkins() { PlayerInfo p = players[consoleplayer]; if (mPlayerClass != NULL && !(GetDefaultByType (mPlayerClass.Type).bNoSkin) && p.GetPlayerClassNum() != -1) { mPlayerDisplay.SetValue(ListMenuItemPlayerDisplay.PDF_SKIN, p.GetSkin()); } UpdateTranslation(); } //============================================================================= // // // //============================================================================= override bool OnUIEvent(UIEvent ev) { if (ev.Type == UIEvent.Type_Char && ev.KeyChar == 32) { // turn the player sprite around mRotation = 8 - mRotation; mPlayerDisplay.SetValue(ListMenuItemPlayerDisplay.PDF_ROTATION, mRotation); return true; } return Super.OnUIEvent(ev); } //============================================================================= // // // //============================================================================= override void Ticker() { mPlayerDisplay.Ticker(); } //============================================================================= // // // //============================================================================= override void Drawer() { Super.Drawer(); mPlayerDisplay.Drawer(false); int x = screen.GetWidth()/(CleanXfac_1*2) + PLAYERDISPLAY_X + PLAYERDISPLAY_W/2; int y = PLAYERDISPLAY_Y + PLAYERDISPLAY_H + 5; String str = Stringtable.Localize("$PLYRMNU_PRESSSPACE"); screen.DrawText (NewSmallFont, Font.CR_GOLD, x - NewSmallFont.StringWidth(str)/2, y, str, DTA_VirtualWidth, CleanWidth_1, DTA_VirtualHeight, CleanHeight_1, DTA_KeepRatio, true); str = Stringtable.Localize(mRotation ? "$PLYRMNU_SEEFRONT" : "$PLYRMNU_SEEBACK"); y += NewSmallFont.GetHeight(); screen.DrawText (NewSmallFont, Font.CR_GOLD,x - NewSmallFont.StringWidth(str)/2, y, str, DTA_VirtualWidth, CleanWidth_1, DTA_VirtualHeight, CleanHeight_1, DTA_KeepRatio, true); } } /* ** optionmenu.cpp ** Handler class for the option menus and associated items ** **--------------------------------------------------------------------------- ** Copyright 2010-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ struct FOptionMenuSettings native version("2.4") { int mTitleColor; int mFontColor; int mFontColorValue; int mFontColorMore; int mFontColorHeader; int mFontColorHighlight; int mFontColorSelection; int mLinespacing; } class OptionMenuDescriptor : MenuDescriptor native { native Array mItems; native String mTitle; native int mSelectedItem; native int mDrawTop; native int mScrollTop; native int mScrollPos; native int mIndent; native int mPosition; native bool mDontDim; native bool mDontBlur; native bool mAnimatedTransition; native bool mAnimated; native Font mFont; void Reset() { // Reset the default settings (ignore all other values in the struct) mPosition = 0; mScrollTop = 0; mIndent = 0; mDontDim = 0; } //============================================================================= // // // //============================================================================= void CalcIndent() { // calculate the menu indent int widest = 0, thiswidth; for (int i = 0; i < mItems.Size(); i++) { thiswidth = mItems[i].GetIndent(); if (thiswidth > widest) widest = thiswidth; } mIndent = widest + 4; } } class OptionMenu : Menu { OptionMenuDescriptor mDesc; bool CanScrollUp; bool CanScrollDown; int VisBottom; OptionMenuItem mFocusControl; //============================================================================= // // // //============================================================================= virtual void Init(Menu parent, OptionMenuDescriptor desc) { mParentMenu = parent; mDesc = desc; DontDim = desc.mDontDim; DontBlur = desc.mDontBlur; AnimatedTransition = desc.mAnimatedTransition; Animated = desc.mAnimated; let itemCount = mDesc.mItems.size(); if (itemCount > 0) { let last = mDesc.mItems[itemCount - 1]; bool lastIsText = (last is "OptionMenuItemStaticText"); if (lastIsText) { String text = last.mLabel; bool lastIsSpace = (text == "" || text == " "); if (lastIsSpace) { mDesc.mItems.Pop(); } } } if (mDesc.mSelectedItem == -1) mDesc.mSelectedItem = FirstSelectable(); mDesc.CalcIndent(); // notify all items that the menu was just created. for(int i=0;i=0 && i < mDesc.mItems.Size()) return i; else return -1; } //============================================================================= // // // //============================================================================= override bool OnUIEvent(UIEvent ev) { if (ev.type == UIEvent.Type_WheelUp) { int scrollamt = MIN(2, mDesc.mScrollPos); mDesc.mScrollPos -= scrollamt; return true; } else if (ev.type == UIEvent.Type_WheelDown) { if (CanScrollDown) { if (VisBottom >= 0 && VisBottom < (mDesc.mItems.Size()-2)) { mDesc.mScrollPos += 2; VisBottom += 2; } else if (VisBottom < mDesc.mItems.Size()-1) { mDesc.mScrollPos++; VisBottom++; } } return true; } else if (ev.type == UIEvent.Type_Char) { int key = String.CharLower(ev.keyChar); int itemsNumber = mDesc.mItems.Size(); int direction = ev.IsAlt ? -1 : 1; for (int i = 0; i < itemsNumber; ++i) { int index = (mDesc.mSelectedItem + direction * (i + 1) + itemsNumber) % itemsNumber; if (!mDesc.mItems[index].Selectable()) continue; String label = StringTable.Localize(mDesc.mItems[index].mLabel); int firstLabelCharacter = String.CharLower(label.GetNextCodePoint(0)); if (firstLabelCharacter == key) { mDesc.mSelectedItem = index; break; } } if (mDesc.mSelectedItem <= mDesc.mScrollTop + mDesc.mScrollPos || mDesc.mSelectedItem > VisBottom) { int pagesize = VisBottom - mDesc.mScrollPos - mDesc.mScrollTop; mDesc.mScrollPos = clamp(mDesc.mSelectedItem - mDesc.mScrollTop - 1, 0, mDesc.mItems.size() - pagesize - 1); } } return Super.OnUIEvent(ev); } //============================================================================= // // // //============================================================================= override bool MenuEvent (int mkey, bool fromcontroller) { int startedAt = mDesc.mSelectedItem; switch (mkey) { case MKEY_Up: if (mDesc.mSelectedItem == -1) { mDesc.mSelectedItem = FirstSelectable(); break; } do { --mDesc.mSelectedItem; if (mDesc.mScrollPos > 0 && mDesc.mSelectedItem <= mDesc.mScrollTop + mDesc.mScrollPos) { mDesc.mScrollPos = MAX(mDesc.mSelectedItem - mDesc.mScrollTop - 1, 0); } if (mDesc.mSelectedItem < 0) { // Figure out how many lines of text fit on the menu int y = mDesc.mPosition; if (y <= 0) { y = DrawCaption(mDesc.mTitle, -y, false); } int rowheight = OptionMenuSettings.mLinespacing * CleanYfac_1; int maxitems = (screen.GetHeight() - rowheight - y) / rowheight + 1; mDesc.mScrollPos = MAX (0, mDesc.mItems.Size() - maxitems + mDesc.mScrollTop); mDesc.mSelectedItem = mDesc.mItems.Size()-1; } } while (!mDesc.mItems[mDesc.mSelectedItem].Selectable() && mDesc.mSelectedItem != startedAt); break; case MKEY_Down: if (mDesc.mSelectedItem == -1) { mDesc.mSelectedItem = FirstSelectable(); break; } do { ++mDesc.mSelectedItem; if (CanScrollDown && mDesc.mSelectedItem == VisBottom) { mDesc.mScrollPos++; VisBottom++; } if (mDesc.mSelectedItem >= mDesc.mItems.Size()) { if (startedAt == -1) { mDesc.mSelectedItem = -1; mDesc.mScrollPos = -1; break; } else { mDesc.mSelectedItem = 0; mDesc.mScrollPos = 0; } } } while (!mDesc.mItems[mDesc.mSelectedItem].Selectable() && mDesc.mSelectedItem != startedAt); break; case MKEY_PageUp: if (mDesc.mScrollPos > 0) { mDesc.mScrollPos -= VisBottom - mDesc.mScrollPos - mDesc.mScrollTop; if (mDesc.mScrollPos < 0) { mDesc.mScrollPos = 0; } if (mDesc.mSelectedItem != -1) { mDesc.mSelectedItem = mDesc.mScrollTop + mDesc.mScrollPos + 1; while (!mDesc.mItems[mDesc.mSelectedItem].Selectable()) { if (++mDesc.mSelectedItem >= mDesc.mItems.Size()) { mDesc.mSelectedItem = 0; } } if (mDesc.mScrollPos > mDesc.mSelectedItem) { mDesc.mScrollPos = mDesc.mSelectedItem; } } } break; case MKEY_PageDown: if (CanScrollDown) { int pagesize = VisBottom - mDesc.mScrollPos - mDesc.mScrollTop; mDesc.mScrollPos += pagesize; if (mDesc.mScrollPos + mDesc.mScrollTop + pagesize > mDesc.mItems.Size()) { mDesc.mScrollPos = mDesc.mItems.Size() - mDesc.mScrollTop - pagesize; } if (mDesc.mSelectedItem != -1) { mDesc.mSelectedItem = mDesc.mScrollTop + mDesc.mScrollPos; while (!mDesc.mItems[mDesc.mSelectedItem].Selectable()) { if (++mDesc.mSelectedItem >= mDesc.mItems.Size()) { mDesc.mSelectedItem = 0; } } if (mDesc.mScrollPos > mDesc.mSelectedItem) { mDesc.mScrollPos = mDesc.mSelectedItem; } } } break; case MKEY_Enter: if (mDesc.mSelectedItem >= 0 && mDesc.mItems[mDesc.mSelectedItem].Activate()) { return true; } // fall through to default default: if (mDesc.mSelectedItem >= 0 && mDesc.mItems[mDesc.mSelectedItem].MenuEvent(mkey, fromcontroller)) return true; return Super.MenuEvent(mkey, fromcontroller); } if (mDesc.mSelectedItem != startedAt) { MenuSound ("menu/cursor"); } return true; } //============================================================================= // // // //============================================================================= override bool MouseEvent(int type, int x, int y) { y = (y / CleanYfac_1) - mDesc.mDrawTop; if (mFocusControl) { mFocusControl.MouseEvent(type, x, y); return true; } else { int yline = (y / OptionMenuSettings.mLinespacing); if (yline >= mDesc.mScrollTop) { yline += mDesc.mScrollPos; } if (yline >= 0 && yline < mDesc.mItems.Size() && mDesc.mItems[yline].Selectable()) { if (yline != mDesc.mSelectedItem) { mDesc.mSelectedItem = yline; } mDesc.mItems[yline].MouseEvent(type, x, y); return true; } } mDesc.mSelectedItem = -1; return Super.MouseEvent(type, x, y); } //============================================================================= // // // //============================================================================= override void Ticker () { Super.Ticker(); for(int i = 0; i < mDesc.mItems.Size(); i++) { mDesc.mItems[i].Ticker(); } } //============================================================================= // // // //============================================================================= virtual int GetIndent() { int indent = max(0, (mDesc.mIndent + 40) - CleanWidth_1 / 2); return screen.GetWidth() / 2 + indent * CleanXfac_1; } //============================================================================= // // draws and/or measures the caption. // //============================================================================= virtual int DrawCaption(String title, int y, bool drawit) { let font = menuDelegate.PickFont(mDesc.mFont); if (font && mDesc.mTitle.Length() > 0) { return menuDelegate.DrawCaption(title, font, y, drawit); } else { return y; } } //============================================================================= // // // //============================================================================= override void Drawer () { int y = mDesc.mPosition; if (y <= 0) { y = DrawCaption(mDesc.mTitle, -y, true); } mDesc.mDrawTop = y / CleanYfac_1; // mouse checks are done in clean space. int fontheight = OptionMenuSettings.mLinespacing * CleanYfac_1; int indent = GetIndent(); int ytop = y + mDesc.mScrollTop * 8 * CleanYfac_1; int lastrow = screen.GetHeight() - OptionHeight() * CleanYfac_1; int i; for (i = 0; i < mDesc.mItems.Size() && y <= lastrow; i++) { // Don't scroll the uppermost items if (i == mDesc.mScrollTop) { i += mDesc.mScrollPos; if (i >= mDesc.mItems.Size()) break; // skipped beyond end of menu } bool isSelected = mDesc.mSelectedItem == i; int cur_indent = mDesc.mItems[i].Draw(mDesc, y, indent, isSelected); if (cur_indent >= 0 && isSelected && mDesc.mItems[i].Selectable()) { if (((MenuTime() % 8) < 6) || GetCurrentMenu() != self) { DrawOptionText(cur_indent + 3 * CleanXfac_1, y, OptionMenuSettings.mFontColorSelection, "◄"); } } y += fontheight; } CanScrollUp = (mDesc.mScrollPos > 0); CanScrollDown = (i < mDesc.mItems.Size()); VisBottom = i - 1; if (CanScrollUp) { DrawOptionText(screen.GetWidth() - 11 * CleanXfac_1, ytop, OptionMenuSettings.mFontColorSelection, "▲"); } if (CanScrollDown) { DrawOptionText(screen.GetWidth() - 11 * CleanXfac_1 , y - 8*CleanYfac_1, OptionMenuSettings.mFontColorSelection, "▼"); } Super.Drawer(); } //============================================================================= // // // //============================================================================= override void SetFocus(MenuItemBase fc) { mFocusControl = OptionMenuItem(fc); } override bool CheckFocus(MenuItemBase fc) { return mFocusControl == fc; } override void ReleaseFocus() { mFocusControl = NULL; } } class GLTextureGLOptions : OptionMenu { private int mWarningIndex; private string mWarningLabel; override void Init(Menu parent, OptionMenuDescriptor desc) { super.Init(parent, desc); // Find index of warning item placeholder mWarningIndex = -1; mWarningLabel = "!HQRESIZE_WARNING!"; for (int i=0; i < mDesc.mItems.Size(); ++i) { if (mDesc.mItems[i].mLabel == mWarningLabel) { mWarningIndex = i; break; } } } override void OnDestroy() { // Restore warning item placeholder if (mWarningIndex >= 0) { mDesc.mItems[mWarningIndex].mLabel = mWarningLabel; } Super.OnDestroy(); } override void Ticker() { Super.Ticker(); if (mWarningIndex >= 0) { string message; if (gl_texture_hqresizemult > 1 && gl_texture_hqresizemode > 0) { int multiplier = gl_texture_hqresizemult * gl_texture_hqresizemult; message = StringTable.Localize("$GLTEXMNU_HQRESIZEWARN"); string mult = String.Format("%d", multiplier); message.Replace("%d", mult); } mDesc.mItems[mWarningIndex].mLabel = Font.TEXTCOLOR_CYAN .. message; } } } /* ** optionmenuitems.txt ** Control items for option menus ** **--------------------------------------------------------------------------- ** Copyright 2010-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ class OptionMenuItem : MenuItemBase { String mLabel; bool mCentered; protected void Init(String label, String command, bool center = false) { Super.Init(0, 0, command); mLabel = label; mCentered = center; } protected void drawText(int x, int y, int color, String text, bool grayed = false) { Menu.DrawOptionText(x, y, color, text, grayed); } protected int drawLabel(int indent, int y, int color, bool grayed = false) { String label = Stringtable.Localize(mLabel); int x; int w = Menu.OptionWidth(label) * CleanXfac_1; if (!mCentered) x = indent - w; else x = (screen.GetWidth() - w) / 2; Menu.DrawOptionText(x, y, color, label, grayed); return x; } protected void drawValue(int indent, int y, int color, String text, bool grayed = false, bool localize = true) { Menu.DrawOptionText(indent + CursorSpace(), y, color, text, grayed, localize); } int CursorSpace() { return (14 * CleanXfac_1); } override bool Selectable() { return true; } override int GetIndent() { if (mCentered) return 0; if (screen.GetWidth() < 640) return screen.GetWidth() / 2; return Menu.OptionWidth(Stringtable.Localize(mLabel)); } override bool MouseEvent(int type, int x, int y) { if (Selectable() && type == Menu.MOUSE_Release) { return Menu.GetCurrentMenu().MenuEvent(Menu.MKEY_Enter, true); } return false; } } //============================================================================= // // opens a submenu, command is a submenu name // //============================================================================= class OptionMenuItemSubmenu : OptionMenuItem { int mParam; OptionMenuItemSubmenu Init(String label, Name command, int param = 0, bool centered = false) { Super.init(label, command, centered); mParam = param; return self; } override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { int x = drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColorMore); if (mCentered) { return x - 16*CleanXfac_1; } return indent; } override bool Activate() { Menu.MenuSound("menu/advance"); Menu.SetMenu(mAction, mParam); return true; } } //============================================================================= // // opens a submenu, command is a submenu name // //============================================================================= class OptionMenuItemLabeledSubmenu : OptionMenuItemSubmenu { CVar mLabelCVar; OptionMenuItemSubmenu Init(String label, CVar labelcvar, Name command, int param = 0) { Super.init(label, command, false); mLabelCVar = labelcvar; return self; } override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor); String text = mLabelCVar.GetString(); if (text.Length() == 0) text = Stringtable.Localize("$notset"); drawValue(indent, y, OptionMenuSettings.mFontColorValue, text); return indent; } } //============================================================================= // // Executes a CCMD, command is a CCMD name // //============================================================================= class OptionMenuItemCommand : OptionMenuItemSubmenu { private String ccmd; // do not allow access to this from the outside. bool mCloseOnSelect; private bool mUnsafe; OptionMenuItemCommand Init(String label, Name command, bool centered = false, bool closeonselect = false) { Super.Init(label, command, 0, centered); ccmd = command; mCloseOnSelect = closeonselect; mUnsafe = true; return self; } private native static void DoCommand(String cmd, bool unsafe); // This is very intentionally limited to this menu item to prevent abuse. override bool Activate() { // This needs to perform a few checks to prevent abuse by malicious modders. if (GetClass() != "OptionMenuItemSafeCommand") { let m = OptionMenu(Menu.GetCurrentMenu()); // don't execute if no menu is active if (m == null) return false; // don't execute if this item cannot be found in the current menu. if (m.GetItem(mAction) != self) return false; } else mUnsafe = false; Menu.MenuSound("menu/choose"); DoCommand(ccmd, mUnsafe); if (mCloseOnSelect) { let curmenu = Menu.GetCurrentMenu(); if (curmenu != null) curmenu.Close(); } return true; } } //============================================================================= // // Executes a CCMD after confirmation, command is a CCMD name // //============================================================================= class OptionMenuItemSafeCommand : OptionMenuItemCommand { String mPrompt; OptionMenuItemSafeCommand Init(String label, Name command, String prompt = "") { Super.Init(label, command); mPrompt = prompt; return self; } override bool MenuEvent (int mkey, bool fromcontroller) { if (mkey == Menu.MKEY_MBYes) { Super.Activate(); return true; } return Super.MenuEvent(mkey, fromcontroller); } override bool Activate() { String msg = mPrompt.Length() > 0 ? mPrompt : "$SAFEMESSAGE"; msg = StringTable.Localize(msg); String actionLabel = StringTable.localize(mLabel); String FullString; FullString = String.Format("%s%s%s\n\n%s", TEXTCOLOR_WHITE, actionLabel, TEXTCOLOR_NORMAL, msg); Menu.StartMessage(FullString, 0); return true; } } //============================================================================= // // Base class for option lists // //============================================================================= class OptionMenuItemOptionBase : OptionMenuItem { // command is a CVAR Name mValues; // Entry in OptionValues table CVar mGrayCheck; int mCenter; const OP_VALUES = 0x11001; protected void Init(String label, Name command, Name values, CVar graycheck, int center) { Super.Init(label, command); mValues = values; mGrayCheck = graycheck; mCenter = center; } override bool SetString(int i, String newtext) { if (i == OP_VALUES) { int cnt = OptionValues.GetCount(mValues); if (cnt >= 0) { mValues = newtext; int s = GetSelection(); if (s >= cnt) s = 0; SetSelection(s); // readjust the CVAR if its value is outside the range now return true; } } return false; } //============================================================================= virtual int GetSelection() { return 0; } virtual void SetSelection(int Selection) { } //============================================================================= override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { if (mCenter) { indent = (screen.GetWidth() / 2); } drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor, isGrayed()); int Selection = GetSelection(); String text = StringTable.Localize(OptionValues.GetText(mValues, Selection)); if (text.Length() == 0) text = StringTable.Localize("$TXT_UNKNOWN"); drawValue(indent, y, OptionMenuSettings.mFontColorValue, text, isGrayed()); return indent; } //============================================================================= override bool MenuEvent (int mkey, bool fromcontroller) { int cnt = OptionValues.GetCount(mValues); if (cnt > 0) { int Selection = GetSelection(); if (mkey == Menu.MKEY_Left) { if (Selection == -1) Selection = 0; else if (--Selection < 0) Selection = cnt - 1; } else if (mkey == Menu.MKEY_Right || mkey == Menu.MKEY_Enter) { if (++Selection >= cnt) Selection = 0; } else { return Super.MenuEvent(mkey, fromcontroller); } SetSelection(Selection); Menu.MenuSound("menu/change"); } else { return Super.MenuEvent(mkey, fromcontroller); } return true; } virtual bool isGrayed() { return mGrayCheck != null && !mGrayCheck.GetInt(); } override bool Selectable() { return !isGrayed(); } } //============================================================================= // // Change a CVAR, command is the CVAR name // //============================================================================= class OptionMenuItemOption : OptionMenuItemOptionBase { CVar mCVar; private static native void SetCVarDescription(CVar cv, String label); OptionMenuItemOption Init(String label, Name command, Name values, CVar graycheck = null, int center = 0) { Super.Init(label, command, values, graycheck, center); mCVar = CVar.FindCVar(mAction); if (mCVar) SetCVarDescription(mCVar, label); return self; } //============================================================================= override int GetSelection() { int Selection = -1; int cnt = OptionValues.GetCount(mValues); if (cnt > 0 && mCVar != null) { if (OptionValues.GetTextValue(mValues, 0).Length() == 0) { let f = mCVar.GetFloat(); for(int i = 0; i < cnt; i++) { if (f ~== OptionValues.GetValue(mValues, i)) { Selection = i; break; } } } else { String cv = mCVar.GetString(); for(int i = 0; i < cnt; i++) { if (cv ~== OptionValues.GetTextValue(mValues, i)) { Selection = i; break; } } } } return Selection; } override void SetSelection(int Selection) { int cnt = OptionValues.GetCount(mValues); if (cnt > 0 && mCVar != null) { if (OptionValues.GetTextValue(mValues, 0).Length() == 0) { mCVar.SetFloat(OptionValues.GetValue(mValues, Selection)); } else { mCVar.SetString(OptionValues.GetTextValue(mValues, Selection)); } } } } //============================================================================= // // This class is used to capture the key to be used as the new key binding // for a control item // //============================================================================= class EnterKey : Menu { OptionMenuItemControlBase mOwner; void Init(Menu parent, OptionMenuItemControlBase owner) { Super.Init(parent); mOwner = owner; SetMenuMessage(1); menuactive = Menu.WaitKey; // There should be a better way to disable GUI capture... } override bool TranslateKeyboardEvents() { return false; } private void SetMenuMessage(int which) { let parent = OptionMenu(mParentMenu); if (parent != null) { let it = parent.GetItem('Controlmessage'); if (it != null) { it.SetValue(0, which); } } } override bool OnInputEvent(InputEvent ev) { // This menu checks raw keys, not GUI keys because it needs the raw codes for binding. if (ev.type == InputEvent.Type_KeyDown) { mOwner.SendKey(ev.KeyScan); menuactive = Menu.On; SetMenuMessage(0); Close(); mParentMenu.MenuEvent((ev.KeyScan == InputEvent.KEY_ESCAPE)? Menu.MKEY_Abort : Menu.MKEY_Input, 0); return true; } return false; } override void Drawer() { mParentMenu.Drawer(); } } //============================================================================= // // // Edit a key binding, Action is the CCMD to bind // //============================================================================= class OptionMenuItemControlBase : OptionMenuItem { KeyBindings mBindings; int mInput; bool mWaiting; protected void Init(String label, Name command, KeyBindings bindings) { Super.init(label, command); mBindings = bindings; mWaiting = false; } //============================================================================= override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { drawLabel(indent, y, mWaiting ? OptionMenuSettings.mFontColorHighlight : (selected ? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor)); String description; Array keys; mBindings.GetAllKeysForCommand(keys, mAction); description = KeyBindings.NameAllKeys(keys); if (description.Length() > 0) { drawValue(indent, y, Font.CR_WHITE, description); } else { drawValue(indent, y, Font.CR_BLACK, "---"); } return indent; } //============================================================================= override bool MenuEvent(int mkey, bool fromcontroller) { if (mkey == Menu.MKEY_Input) { mWaiting = false; mBindings.SetBind(mInput, mAction); return true; } else if (mkey == Menu.MKEY_Clear) { mBindings.UnbindACommand(mAction); return true; } else if (mkey == Menu.MKEY_Abort) { mWaiting = false; return true; } return false; } void SendKey(int key) { mInput = key; } override bool Activate() { Menu.MenuSound("menu/choose"); mWaiting = true; let input = new("EnterKey"); input.Init(Menu.GetCurrentMenu(), self); input.ActivateMenu(); return true; } } class OptionMenuItemControl : OptionMenuItemControlBase { OptionMenuItemControl Init(String label, Name command) { Super.Init(label, command, Bindings); return self; } } class OptionMenuItemMapControl : OptionMenuItemControlBase { OptionMenuItemMapControl Init(String label, Name command) { Super.Init(label, command, AutomapBindings); return self; } } //============================================================================= // // // //============================================================================= class OptionMenuItemStaticText : OptionMenuItem { int mColor; // this function is only for use from MENUDEF, it needs to do some strange things with the color for backwards compatibility. OptionMenuItemStaticText Init(String label, int cr = -1) { Super.Init(label, 'None', true); mColor = OptionMenuSettings.mFontColor; if ((cr & 0xffff0000) == 0x12340000) mColor = cr & 0xffff; else if (cr > 0) mColor = OptionMenuSettings.mFontColorHeader; return self; } OptionMenuItemStaticText InitDirect(String label, int cr) { Super.Init(label, 'None', true); mColor = cr; return self; } override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { drawLabel(indent, y, mColor); return -1; } override bool Selectable() { return false; } } //============================================================================= // // // //============================================================================= class OptionMenuItemStaticTextSwitchable : OptionMenuItem { int mColor; String mAltText; int mCurrent; // this function is only for use from MENUDEF, it needs to do some strange things with the color for backwards compatibility. OptionMenuItemStaticTextSwitchable Init(String label, String label2, Name command, int cr = -1) { Super.Init(label, command, true); mAltText = label2; mCurrent = 0; mColor = OptionMenuSettings.mFontColor; if ((cr & 0xffff0000) == 0x12340000) mColor = cr & 0xffff; else if (cr > 0) mColor = OptionMenuSettings.mFontColorHeader; return self; } OptionMenuItemStaticTextSwitchable InitDirect(String label, String label2, Name command, int cr) { Super.Init(label, command, true); mColor = cr; mAltText = label2; mCurrent = 0; return self; } override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { String txt = StringTable.Localize(mCurrent? mAltText : mLabel); int w = Menu.OptionWidth(txt) * CleanXfac_1; int x = (screen.GetWidth() - w) / 2; drawText(x, y, mColor, txt); return -1; } override bool SetValue(int i, int val) { if (i == 0) { mCurrent = val; return true; } return false; } override bool SetString(int i, String newtext) { if (i == 0) { mAltText = newtext; return true; } return false; } override bool Selectable() { return false; } } //============================================================================= // // // //============================================================================= class OptionMenuSliderBase : OptionMenuItem { // command is a CVAR double mMin, mMax, mStep; int mShowValue; int mDrawX; int mSliderShort; CVar mGrayCheck; protected void Init(String label, double min, double max, double step, int showval, Name command = 'none', CVar graycheck = NULL) { Super.Init(label, command); mMin = min; mMax = max; mStep = step; mShowValue = showval; mDrawX = 0; mSliderShort = 0; mGrayCheck = graycheck; } virtual double GetSliderValue() { return 0; } virtual void SetSliderValue(double val) { } virtual bool IsGrayed(void) { return mGrayCheck != NULL && !mGrayCheck.GetInt(); } override bool Selectable(void) { return !IsGrayed(); } //============================================================================= // // Draw a slider. Set fracdigits negative to not display the current value numerically. // //============================================================================= private void DrawSliderElement (int color, int x, int y, String str, bool grayed = false) { int overlay = grayed? Color(96, 48, 0, 0) : 0; screen.DrawText (ConFont, color, x, y, str, DTA_CellX, 16 * CleanXfac_1, DTA_CellY, 16 * CleanYfac_1, DTA_ColorOverlay, overlay); } protected void DrawSlider (int x, int y, double min, double max, double cur, int fracdigits, int indent, bool grayed = false) { String formater = String.format("%%.%df", fracdigits); // The format function cannot do the '%.*f' syntax. String textbuf; double range; int maxlen = 0; int right = x + (12*16 + 4) * CleanXfac_1; // length of slider. This uses the old ConFont and int cy = y + CleanYFac; range = max - min; double ccur = clamp(cur, min, max) - min; if (fracdigits >= 0) { textbuf = String.format(formater, max); maxlen = Menu.OptionWidth(textbuf) * CleanXfac_1; } mSliderShort = right + maxlen > screen.GetWidth(); if (!mSliderShort) { DrawSliderElement(Font.FindFontColor(gameinfo.mSliderBackColor), x, cy, "\x10\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x12", grayed); DrawSliderElement(Font.FindFontColor(gameinfo.mSliderColor), x + int((5 + ((ccur * 78) / range)) * 2 * CleanXfac_1), cy, "\x13", grayed); } else { // On 320x200 we need a shorter slider DrawSliderElement(Font.FindFontColor(gameinfo.mSliderBackColor), x, cy, "\x10\x11\x11\x11\x11\x11\x12", grayed); DrawSliderElement(Font.FindFontColor(gameinfo.mSliderColor), x + int((5 + ((ccur * 38) / range)) * 2 * CleanXfac_1), cy, "\x13", grayed); right -= 5*8*CleanXfac; } if (fracdigits >= 0 && right + maxlen <= screen.GetWidth()) { textbuf = String.format(formater, cur); drawText(right, y, Font.CR_DARKGRAY, textbuf, grayed); } } //============================================================================= override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor, IsGrayed()); mDrawX = indent + CursorSpace(); DrawSlider (mDrawX, y, mMin, mMax, GetSliderValue(), mShowValue, indent, IsGrayed()); return indent; } //============================================================================= override bool MenuEvent (int mkey, bool fromcontroller) { double value = GetSliderValue(); if (mkey == Menu.MKEY_Left) { value -= mStep; } else if (mkey == Menu.MKEY_Right) { value += mStep; } else { return OptionMenuItem.MenuEvent(mkey, fromcontroller); } if (value ~== 0) value = 0; // This is to prevent formatting anomalies with very small values SetSliderValue(clamp(value, mMin, mMax)); Menu.MenuSound("menu/change"); return true; } override bool MouseEvent(int type, int x, int y) { let lm = OptionMenu(Menu.GetCurrentMenu()); if (type != Menu.MOUSE_Click) { if (!lm.CheckFocus(self)) return false; } if (type == Menu.MOUSE_Release) { lm.ReleaseFocus(); } int slide_left = mDrawX+16*CleanXfac_1; int slide_right = slide_left + (10*16*CleanXfac_1 >> mSliderShort); // 10 char cells with 16 pixels each. if (type == Menu.MOUSE_Click) { if (x < slide_left || x >= slide_right) return true; } x = clamp(x, slide_left, slide_right); double v = mMin + ((x - slide_left) * (mMax - mMin)) / (slide_right - slide_left); if (v != GetSliderValue()) { SetSliderValue(v); //Menu.MenuSound("menu/change"); } if (type == Menu.MOUSE_Click) { lm.SetFocus(self); } return true; } } //============================================================================= // // // //============================================================================= class OptionMenuItemSlider : OptionMenuSliderBase { CVar mCVar; OptionMenuItemSlider Init(String label, Name command, double min, double max, double step, int showval = 1, CVar graycheck = NULL) { Super.Init(label, min, max, step, showval, command, graycheck); mCVar =CVar.FindCVar(command); return self; } override double GetSliderValue() { if (mCVar != null) { return mCVar.GetFloat(); } else { return 0; } } override void SetSliderValue(double val) { if (mCVar != null) { mCVar.SetFloat(val); } } } //============================================================================= // // // Edit a key binding, Action is the CCMD to bind // //============================================================================= class OptionMenuItemColorPicker : OptionMenuItem { CVar mCVar; const CPF_RESET = 0x20001; OptionMenuItemColorPicker Init(String label, Name command) { Super.Init(label, command); CVar cv = CVar.FindCVar(command); if (cv != null && cv.GetRealType() != CVar.CVAR_Color) cv = null; mCVar = cv; return self; } //============================================================================= override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor); if (mCVar != null) { int box_x = indent + CursorSpace(); int box_y = y + CleanYfac_1; screen.Clear (box_x, box_y, box_x + 32*CleanXfac_1, box_y + OptionMenuSettings.mLinespacing*CleanYfac_1, mCVar.GetInt() | 0xff000000); } return indent; } override bool SetValue(int i, int v) { if (i == CPF_RESET && mCVar != null) { mCVar.ResetToDefault(); return true; } return false; } override bool Activate() { if (mCVar != null) { Menu.MenuSound("menu/choose"); // This code is a bit complicated because it should allow subclassing the // colorpicker menu. // New color pickers must inherit from the internal one to work here. let desc = MenuDescriptor.GetDescriptor('Colorpickermenu'); if (desc != NULL && (desc.mClass == null || desc.mClass is "ColorPickerMenu")) { let odesc = OptionMenuDescriptor(desc); if (odesc != null) { let cls = desc.mClass; if (cls == null) cls = "ColorpickerMenu"; let picker = ColorpickerMenu(new(cls)); picker.Init(Menu.GetCurrentMenu(), mLabel, odesc, mCVar); picker.ActivateMenu(); return true; } } } return false; } } //============================================================================= // // [TP] OptionMenuFieldBase // // Base class for input fields // //============================================================================= class OptionMenuFieldBase : OptionMenuItem { void Init (String label, Name command, CVar graycheck = null) { Super.Init(label, command); mCVar = CVar.FindCVar(mAction); mGrayCheck = graycheck; } String GetCVarString() { if (mCVar == null) return ""; return mCVar.GetString(); } virtual String Represent() { return GetCVarString(); } override int Draw (OptionMenuDescriptor d, int y, int indent, bool selected) { bool grayed = mGrayCheck != null && !mGrayCheck.GetInt(); drawLabel(indent, y, selected ? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor, grayed); drawValue(indent, y, OptionMenuSettings.mFontColorValue, Represent(), grayed, false); return indent; } override bool, String GetString (int i) { if (i == 0) { return true, GetCVarString(); } return false, ""; } override bool SetString (int i, String s) { if (i == 0) { if (mCVar) mCVar.SetString(s); return true; } return false; } override bool Selectable() { return mGrayCheck == null || mGrayCheck.GetInt() != 0; } CVar mCVar; CVar mGrayCheck; } //============================================================================= // // [TP] OptionMenuTextField // // A text input field widget, for use with string CVars. // //============================================================================= class OptionMenuItemTextField : OptionMenuFieldBase { TextEnterMenu mEnter; OptionMenuItemTextField Init (String label, Name command, CVar graycheck = null) { Super.Init(label, command, graycheck); mEnter = null; return self; } override String Represent() { if (mEnter) return mEnter.GetText() .. Menu.OptionFont().GetCursor(); else { bool b; String s; [b, s] = GetString(0); return s; } } override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { if (mEnter) { // reposition the text so that the cursor is visible when in entering mode. String text = Represent(); int tlen = Menu.OptionWidth(text, false) * CleanXfac_1; int newindent = screen.GetWidth() - tlen - CursorSpace(); if (newindent < indent) indent = newindent; } return Super.Draw(desc, y, indent, selected); } override bool MenuEvent (int mkey, bool fromcontroller) { if (mkey == Menu.MKEY_Enter) { bool b; String s; [b, s] = GetString(0); Menu.MenuSound("menu/choose"); mEnter = TextEnterMenu.OpenTextEnter(Menu.GetCurrentMenu(), Menu.OptionFont(), s, -1, fromcontroller); mEnter.ActivateMenu(); return true; } else if (mkey == Menu.MKEY_Input) { SetString(0, mEnter.GetText()); mEnter = null; return true; } else if (mkey == Menu.MKEY_Abort) { mEnter = null; return true; } return Super.MenuEvent(mkey, fromcontroller); } } //============================================================================= // // [TP] FOptionMenuNumberField // // A numeric input field widget, for use with number CVars where sliders are inappropriate (i.e. // where the user is interested in the exact value specifically) // //============================================================================= class OptionMenuItemNumberField : OptionMenuFieldBase { OptionMenuItemNumberField Init (String label, Name command, float minimum = 0, float maximum = 100, float step = 1, CVar graycheck = null) { Super.Init(label, command, graycheck); mMinimum = min(minimum, maximum); mMaximum = max(minimum, maximum); mStep = max(1, step); return self; } override String Represent() { if (mCVar == null) return ""; return String.format("%.3f", mCVar.GetFloat()); } override bool MenuEvent (int mkey, bool fromcontroller) { if (mCVar) { float value = mCVar.GetFloat(); if (mkey == Menu.MKEY_Left) { value -= mStep; if (value < mMinimum) value = mMaximum; } else if (mkey == Menu.MKEY_Right || mkey == Menu.MKEY_Enter) { value += mStep; if (value > mMaximum) value = mMinimum; } else return Super.MenuEvent(mkey, fromcontroller); mCVar.SetFloat(value); Menu.MenuSound("menu/change"); } else return Super.MenuEvent(mkey, fromcontroller); return true; } float mMinimum; float mMaximum; float mStep; } //============================================================================= // // A special slider that displays plain text for special settings related // to scaling. // //============================================================================= class OptionMenuItemScaleSlider : OptionMenuItemSlider { String TextZero; String TextNegOne; int mClickVal; OptionMenuItemScaleSlider Init(String label, Name command, double min, double max, double step, String zero, String negone = "") { Super.Init(label, command, min, max, step, 0); mCVar =CVar.FindCVar(command); TextZero = zero; TextNEgOne = negone; mClickVal = -10; return self; } //============================================================================= override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor); int Selection = int(GetSliderValue()); if ((Selection == 0 || Selection == -1) && mClickVal <= 0) { String text = Selection == 0? TextZero : Selection == -1? TextNegOne : ""; drawValue(indent, y, OptionMenuSettings.mFontColorValue, text); } else { mDrawX = indent + CursorSpace(); DrawSlider (mDrawX, y, mMin, mMax, GetSliderValue(), mShowValue, indent); } return indent; } override bool MouseEvent(int type, int x, int y) { int value = int(GetSliderValue()); switch (type) { case Menu.MOUSE_Click: mClickVal = value; if (value <= 0) return false; return Super.MouseEvent(type, x, y); case Menu.MOUSE_Move: if (mClickVal <= 0) return false; return Super.MouseEvent(type, x, y); case Menu.MOUSE_Release: if (mClickVal <= 0) { mClickVal = -10; SetSliderValue(value + 1); return true; } mClickVal = -10; return Super.MouseEvent(type, x, y); } return false; } } //============================================================================= // // Flag option by Accensus // //============================================================================= class OptionMenuItemFlagOption : OptionMenuItemOption { int mBitShift; OptionMenuItemFlagOption Init(String label, Name command, Name values, int bitShift, CVar greycheck = null, int center = 0) { Super.Init(label, command, values, greycheck, center); mBitShift = bitShift; return self; } override int GetSelection() { int Selection = 0; int cnt = OptionValues.GetCount(mValues); if (cnt > 0 && mCVar != null) { if (OptionValues.GetTextValue(mValues, 0).Length() == 0) { int CurrentFlags = mCVar.GetInt(); for (int i = 0; i < cnt; i++) { int OptionValue = int(OptionValues.GetValue(mValues, i)); if (CurrentFlags & (OptionValue << mBitShift)) { Selection = i; break; } } } } return Selection; } override void SetSelection(int Selection) { int cnt = OptionValues.GetCount(mValues); if (cnt > 0 && mCVar != null) { if (OptionValues.GetTextValue(mValues, 0).Length() == 0) { int OptionValue = int(OptionValues.GetValue(mValues, Selection)); int CurrentFlags = mCVar.GetInt(); switch (OptionValue) { case 0: CurrentFlags &= ~(1 << mBitShift); break; case 1: CurrentFlags |= (1 << mBitShift); break; } mCVar.SetInt(CurrentFlags); } } } } // Oracle ------------------------------------------------------------------- class Oracle : Actor { Default { Health 1; Radius 15; Height 56; Monster; +NOTDMATCH +NOBLOOD +NEVERRESPAWN DamageFactor "Fire", 0.5; DamageFactor "SpectralLow", 0; MaxDropoffHeight 32; Tag "$TAG_ORACLE"; DropItem "Meat"; } States { Spawn: ORCL A -1; Stop; Death: ORCL BCDEFGHIJK 5; ORCL L 5 A_NoBlocking; ORCL M 5; ORCL N 5 A_WakeOracleSpectre; ORCL OP 5; ORCL Q -1; Stop; } void A_WakeOracleSpectre () { ThinkerIterator it = ThinkerIterator.Create("AlienSpectre3"); Actor spectre = Actor(it.Next()); if (spectre != NULL && spectre.health > 0 && self.target != spectre) { spectre.CurSector.SoundTarget = spectre.LastHeard = self.LastHeard; spectre.target = self.target; spectre.SetState (spectre.SeeState); } } } //=========================================================================== // // Pain Elemental // //=========================================================================== class PainElemental : Actor { Default { Health 400; Radius 31; Height 56; Mass 400; Speed 8; PainChance 128; Monster; +FLOAT +NOGRAVITY SeeSound "pain/sight"; PainSound "pain/pain"; DeathSound "pain/death"; ActiveSound "pain/active"; Tag "$FN_PAIN"; } States { Spawn: PAIN A 10 A_Look; Loop; See: PAIN AABBCC 3 A_Chase; Loop; Missile: PAIN D 5 A_FaceTarget; PAIN E 5 A_FaceTarget; PAIN F 5 BRIGHT A_FaceTarget; PAIN F 0 BRIGHT A_PainAttack; Goto See; Pain: PAIN G 6; PAIN G 6 A_Pain; Goto See; Death: PAIN H 8 BRIGHT; PAIN I 8 BRIGHT A_Scream; PAIN JK 8 BRIGHT; PAIN L 8 BRIGHT A_PainDie; PAIN M 8 BRIGHT; Stop; Raise: PAIN MLKJIH 8; Goto See; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== extend class Actor { // // A_PainShootSkull // Spawn a lost soul and launch it at the target // void A_PainShootSkull(Class spawntype, double angle, int flags = 0, int limit = -1) { // Don't spawn if we get massacred. if (DamageType == 'Massacre') return; if (spawntype == null) spawntype = "LostSoul"; // [RH] check to make sure it's not too close to the ceiling if (pos.z + height + 8 > ceilingz) { if (bFloat) { Vel.Z -= 2; bInFloat = true; bVFriction = true; } return; } // [RH] make this optional if (limit < 0 && (Level.compatflags & COMPATF_LIMITPAIN)) limit = 21; if (limit > 0) { // count total number of skulls currently on the level // if there are already 21 skulls on the level, don't spit another one int count = limit; ThinkerIterator it = ThinkerIterator.Create(spawntype); Thinker othink; while ( (othink = it.Next ()) ) { if (--count == 0) return; } } // okay, there's room for another one double otherradius = GetDefaultByType(spawntype).radius; double prestep = 4 + (radius + otherradius) * 1.5; Vector2 move = AngleToVector(angle, prestep); Vector3 spawnpos = pos + (0,0,8); Vector3 destpos = spawnpos + move; Actor other = Spawn(spawntype, spawnpos, ALLOW_REPLACE); // Now check if the spawn is legal. Unlike Boom's hopeless attempt at fixing it, let's do it the same way // P_XYMovement solves the line skipping: Spawn the Lost Soul near the PE's center and then use multiple // smaller steps to get it to its intended position. This will also result in proper clipping, but // it will avoid all the problems of the Boom method, which checked too many lines that weren't even touched // and despite some adjustments never worked with portals. if (other != null) { double maxmove = other.radius - 1; if (maxmove <= 0) maxmove = 16; double xspeed = abs(move.X); double yspeed = abs(move.Y); int steps = 1; if (xspeed > yspeed) { if (xspeed > maxmove) { steps = int(1 + xspeed / maxmove); } } else { if (yspeed > maxmove) { steps = int(1 + yspeed / maxmove); } } Vector2 stepmove = move / steps; bool savedsolid = bSolid; bool savednoteleport = other.bNoTeleport; // make the PE nonsolid for the check and the LS non-teleporting so that P_TryMove doesn't do unwanted things. bSolid = false; other.bNoTeleport = true; for (int i = 0; i < steps; i++) { Vector2 ptry = other.pos.xy + stepmove; double oldangle = other.angle; if (!other.TryMove(ptry, 0)) { // kill it immediately other.ClearCounters(); other.DamageMobj(self, self, TELEFRAG_DAMAGE, 'None'); bSolid = savedsolid; other.bNoTeleport = savednoteleport; return; } if (other.pos.xy != ptry) { // If the new position does not match the desired position, the player // must have gone through a portal. // For that we need to adjust the movement vector for the following steps. double anglediff = deltaangle(oldangle, other.angle); if (anglediff != 0) { stepmove = RotateVector(stepmove, anglediff); } } } bSolid = savedsolid; other.bNoTeleport = savednoteleport; // [RH] Lost souls hate the same things as their pain elementals other.CopyFriendliness (self, !(flags & PAF_NOTARGET)); if (!(flags & PAF_NOSKULLATTACK)) { other.A_SkullAttack(); } } } void A_PainAttack(class spawntype = "LostSoul", double addangle = 0, int flags = 0, int limit = -1) { if (target) { A_FaceTarget(); A_PainShootSkull(spawntype, angle + addangle, flags, limit); } } void A_DualPainAttack(class spawntype = "LostSoul") { if (target) { A_FaceTarget(); A_PainShootSkull(spawntype, angle + 45); A_PainShootSkull(spawntype, angle - 45); } } void A_PainDie(class spawntype = "LostSoul") { if (target && IsFriend(target)) { // And I thought you were my friend! bFriendly = false; } A_NoBlocking(); A_PainShootSkull(spawntype, angle + 90); A_PainShootSkull(spawntype, angle + 180); A_PainShootSkull(spawntype, angle + 270); } } // Peasant Base Class ------------------------------------------------------- class Peasant : StrifeHumanoid { Default { Health 31; PainChance 200; Speed 8; Radius 20; Height 56; Monster; +NEVERTARGET -COUNTKILL +NOSPLASHALERT +FLOORCLIP +JUSTHIT MinMissileChance 150; MaxStepHeight 16; MaxDropoffHeight 32; Tag "$TAG_PEASANT"; SeeSound "peasant/sight"; AttackSound "peasant/attack"; PainSound "peasant/pain"; DeathSound "peasant/death"; HitObituary "$OB_PEASANT"; } States { Spawn: PEAS A 10 A_Look2; Loop; See: PEAS AABBCCDD 5 A_Wander; Goto Spawn; Melee: PEAS E 10 A_FaceTarget; PEAS F 8 A_CustomMeleeAttack(2*random[PeasantAttack](1,5)+2); PEAS E 8; Goto See; Pain: PEAS O 3; PEAS O 3 A_Pain; Goto Melee; Wound: PEAS G 5; PEAS H 10 A_GetHurt; PEAS I 6; Goto Wound+1; Death: PEAS G 5; PEAS H 5 A_Scream; PEAS I 6; PEAS J 5 A_NoBlocking; PEAS K 5; PEAS L 6; PEAS M 8; PEAS N 1400; GIBS U 5; GIBS V 1400; Stop; XDeath: GIBS M 5 A_TossGib; GIBS N 5 A_XScream; GIBS O 5 A_NoBlocking; GIBS PQRS 4 A_TossGib; Goto Death+8; } } // Peasant Variant 1 -------------------------------------------------------- class Peasant1 : Peasant { Default { Speed 4; } } class Peasant2 : Peasant { Default { Speed 5; } } class Peasant3 : Peasant { Default { Speed 5; } } class Peasant4 : Peasant { Default { Translation 0; Speed 7; } } class Peasant5 : Peasant { Default { Translation 0; Speed 7; } } class Peasant6 : Peasant { Default { Translation 0; Speed 7; } } class Peasant7 : Peasant { Default { Translation 2; } } class Peasant8 : Peasant { Default { Translation 2; } } class Peasant9 : Peasant { Default { Translation 2; } } class Peasant10 : Peasant { Default { Translation 1; } } class Peasant11 : Peasant { Default { Translation 1; } } class Peasant12 : Peasant { Default { Translation 1; } } class Peasant13 : Peasant { Default { Translation 3; } } class Peasant14 : Peasant { Default { Translation 3; } } class Peasant15 : Peasant { Default { Translation 3; } } class Peasant16 : Peasant { Default { Translation 5; } } class Peasant17 : Peasant { Default { Translation 5; } } class Peasant18 : Peasant { Default { Translation 5; } } class Peasant19 : Peasant { Default { Translation 4; } } class Peasant20 : Peasant { Default { Translation 4; } } class Peasant21 : Peasant { Default { Translation 4; } } class Peasant22 : Peasant { Default { Translation 6; } } // Snout puff --------------------------------------------------------------- class SnoutPuff : Actor { Default { +NOBLOCKMAP +NOGRAVITY Renderstyle "Translucent"; Alpha 0.6; } States { Spawn: FHFX STUVW 4; Stop; } } // Snout -------------------------------------------------------------------- class Snout : Weapon { Default { Weapon.SelectionOrder 10000; +WEAPON.DONTBOB +WEAPON.MELEEWEAPON Weapon.Kickback 150; Weapon.YAdjust 10; } States { Ready: WPIG A 1 A_WeaponReady; Loop; Deselect: WPIG A 1 A_Lower; Loop; Select: WPIG A 1 A_Raise; Fire: WPIG A 4 A_SnoutAttack; WPIG B 8 A_SnoutAttack; Goto Ready; Grunt: WPIG B 8; Goto Ready; } //============================================================================ // // A_SnoutAttack // //============================================================================ action void A_SnoutAttack () { FTranslatedLineTarget t; if (player == null) { return; } int damage = random[SnoutAttack](3, 6); double ang = angle; double slope = AimLineAttack(ang, DEFMELEERANGE); Actor puff = LineAttack(ang, DEFMELEERANGE, slope, damage, 'Melee', "SnoutPuff", true, t); A_StartSound("PigActive", CHAN_VOICE); if(t.linetarget) { AdjustPlayerAngle(t); if(puff != null) { // Bit something A_StartSound("PigAttack", CHAN_VOICE); } } } } // Pig player --------------------------------------------------------------- class PigPlayer : PlayerPawn { Default { Health 30; ReactionTime 0; PainChance 255; Radius 16; Height 24; Speed 1; +WINDTHRUST +NOSKIN -PICKUP PainSound "PigPain"; DeathSound "PigDeath"; Player.JumpZ 6; Player.Viewheight 28; Player.ForwardMove 0.96, 0.98; Player.SideMove 0.95833333, 0.975; Player.SpawnClass "Pig"; Player.SoundClass "Pig"; Player.DisplayName "Pig"; Player.MorphWeapon "Snout"; } States { Spawn: PIGY A -1; Stop; See: PIGY ABCD 3; Loop; Pain: PIGY D 4 A_PigPain; Goto Spawn; Melee: Missile: PIGY A 12; Goto Spawn; Death: PIGY E 4 A_Scream; PIGY F 3 A_NoBlocking; PIGY G 4; PIGY H 3; PIGY IJK 4; PIGY L -1; Stop; Ice: PIGY M 5 A_FreezeDeath; PIGY M 1 A_FreezeDeathChunks; Wait; } override void MorphPlayerThink () { if (player.morphTics & 15) { return; } if(Vel.X == 0 && Vel.Y == 0 && random[PigPlayerThink]() < 64) { // Snout sniff if (player.ReadyWeapon != null) { player.SetPsprite(PSP_WEAPON, player.ReadyWeapon.FindState('Grunt')); } A_StartSound ("PigActive1", CHAN_VOICE); // snort return; } if (random[PigPlayerThink]() < 48) { A_StartSound ("PigActive", CHAN_VOICE); // snort } } } // Pig (non-player) --------------------------------------------------------- class Pig : MorphedMonster { Default { Health 25; Painchance 128; Speed 10; Radius 12; Height 22; Mass 60; Monster; -COUNTKILL +WINDTHRUST +DONTMORPH SeeSound "PigActive1"; PainSound "PigPain"; DeathSound "PigDeath"; ActiveSound "PigActive1"; } States { Spawn: PIGY B 10 A_Look; Loop; See: PIGY ABCD 3 A_Chase; Loop; Pain: PIGY D 4 A_PigPain; Goto See; Melee: PIGY A 5 A_FaceTarget; PIGY A 10 A_CustomMeleeAttack(random[PigAttack](2,3), "PigAttack"); Goto See; Death: PIGY E 4 A_Scream; PIGY F 3 A_NoBlocking; PIGY G 4 A_QueueCorpse; PIGY H 3; PIGY IJK 4; PIGY L -1; Stop; Ice: PIGY M 5 A_FreezeDeath; PIGY M 1 A_FreezeDeathChunks; Wait; } } extend class Actor { //============================================================================ // // A_PigPain // //============================================================================ void A_PigPain () { A_Pain(); if (pos.z <= floorz) { Vel.Z = 3.5; } } } struct UserCmd native { native uint buttons; native int16 pitch; // up/down native int16 yaw; // left/right native int16 roll; // "tilt" native int16 forwardmove; native int16 sidemove; native int16 upmove; } class PlayerPawn : Actor { const CROUCHSPEED = (1./12); // [RH] # of ticks to complete a turn180 const TURN180_TICKS = ((TICRATE / 4) + 1); // 16 pixels of bob const MAXBOB = 16.; int crouchsprite; int MaxHealth; int BonusHealth; int MugShotMaxHealth; int RunHealth; private int PlayerFlags; clearscope Inventory InvFirst; // first inventory item displayed on inventory bar clearscope Inventory InvSel; // selected inventory item Name SoundClass; // Sound class Name Portrait; Name Slot[10]; double HexenArmor[5]; // [GRB] Player class properties double JumpZ; double GruntSpeed; double FallingScreamMinSpeed, FallingScreamMaxSpeed; double ViewHeight; double ForwardMove1, ForwardMove2; double SideMove1, SideMove2; TextureID ScoreIcon; int SpawnMask; Name MorphWeapon; double AttackZOffset; // attack height, relative to player center double UseRange; // [NS] Distance at which player can +use double AirCapacity; // Multiplier for air supply underwater. Class FlechetteType; color DamageFade; // [CW] Fades for when you are being damaged. double FlyBob; // [B] Fly bobbing mulitplier double ViewBob; // [SP] ViewBob Multiplier double ViewBobSpeed; // [AA] ViewBob speed multiplier double WaterClimbSpeed; // [B] Speed when climbing up walls in water double FullHeight; double curBob; double prevBob; meta Name HealingRadiusType; meta Name InvulMode; meta Name Face; meta int TeleportFreezeTime; meta int ColorRangeStart; // Skin color range meta int ColorRangeEnd; property prefix: Player; property HealRadiusType: HealingradiusType; property InvulnerabilityMode: InvulMode; property AttackZOffset: AttackZOffset; property JumpZ: JumpZ; property GruntSpeed: GruntSpeed; property FallingScreamSpeed: FallingScreamMinSpeed, FallingScreamMaxSpeed; property ViewHeight: ViewHeight; property UseRange: UseRange; property AirCapacity: AirCapacity; property MaxHealth: MaxHealth; property MugshotMaxHealth: MugshotMaxHealth; property RunHealth: RunHealth; property MorphWeapon: MorphWeapon; property FlechetteType: FlechetteType; property Portrait: Portrait; property TeleportFreezeTime: TeleportFreezeTime; property FlyBob: FlyBob; property ViewBob: ViewBob; property ViewBobSpeed: ViewBobSpeed; property WaterClimbSpeed : WaterClimbSpeed; flagdef NoThrustWhenInvul: PlayerFlags, 0; flagdef CanSuperMorph: PlayerFlags, 1; flagdef CrouchableMorph: PlayerFlags, 2; flagdef WeaponLevel2Ended: PlayerFlags, 3; enum EPrivatePlayerFlags { PF_VOODOO_ZOMBIE = 1<<4, } Default { Health 100; Radius 16; Height 56; Mass 100; Painchance 255; Speed 1; +SOLID +SHOOTABLE +DROPOFF +PICKUP +NOTDMATCH +FRIENDLY +SLIDESONWALLS +CANPASS +CANPUSHWALLS +FLOORCLIP +WINDTHRUST +TELESTOMP +NOBLOCKMONST Player.AttackZOffset 8; Player.JumpZ 8; Player.GruntSpeed 12; Player.FallingScreamSpeed 35,40; Player.ViewHeight 41; Player.UseRange 64; Player.ForwardMove 1,1; Player.SideMove 1,1; Player.ColorRange 0,0; Player.SoundClass "player"; Player.DamageScreenColor "ff 00 00"; Player.MugShotMaxHealth 0; Player.FlechetteType "ArtiPoisonBag3"; Player.AirCapacity 1; Player.FlyBob 1; Player.ViewBob 1; Player.ViewBobSpeed 20; Player.WaterClimbSpeed 3.5; Player.TeleportFreezeTime 18; Obituary "$OB_MPDEFAULT"; } //=========================================================================== // // PlayerPawn :: Tick // //=========================================================================== override void Tick() { if (player != NULL && player.mo == self && CanCrouch() && player.playerstate != PST_DEAD) { Height = FullHeight * player.crouchfactor; } else { if (health > 0) Height = FullHeight; } if (player && bWeaponLevel2Ended) { bWeaponLevel2Ended = false; if (player.ReadyWeapon != NULL && player.ReadyWeapon.bPowered_Up) { player.ReadyWeapon.EndPowerup (); } if (player.PendingWeapon != NULL && player.PendingWeapon != WP_NOCHANGE && player.PendingWeapon.bPowered_Up && player.PendingWeapon.SisterWeapon != NULL) { player.PendingWeapon = player.PendingWeapon.SisterWeapon; } } Super.Tick(); } //=========================================================================== // // // //=========================================================================== override void BeginPlay() { Super.BeginPlay (); ChangeStatNum (STAT_PLAYER); FullHeight = Height; if (!SetupCrouchSprite(crouchsprite)) crouchsprite = 0; } //=========================================================================== // // PlayerPawn :: PostBeginPlay // //=========================================================================== override void PostBeginPlay() { Super.PostBeginPlay(); WeaponSlots.SetupWeaponSlots(self); // Voodoo dolls: restore original floorz/ceilingz logic if (player == NULL || player.mo != self) { FindFloorCeiling(FFCF_ONLYSPAWNPOS|FFCF_NOPORTALS); SetZ(floorz); FindFloorCeiling(FFCF_ONLYSPAWNPOS); } else { player.SendPitchLimits(); } } //=========================================================================== // // PlayerPawn :: MarkPrecacheSounds // //=========================================================================== override void MarkPrecacheSounds() { Super.MarkPrecacheSounds(); MarkPlayerSounds(); } //---------------------------------------------------------------------------- // // // //---------------------------------------------------------------------------- virtual void PlayIdle () { if (InStateSequence(CurState, SeeState)) SetState (SpawnState); } virtual void PlayRunning () { if (InStateSequence(CurState, SpawnState) && SeeState != NULL) SetState (SeeState); } virtual void PlayAttacking () { if (MissileState != null) SetState (MissileState); } virtual void PlayAttacking2 () { if (MeleeState != null) SetState (MeleeState); } virtual void MorphPlayerThink() { } //---------------------------------------------------------------------------- // // // //---------------------------------------------------------------------------- virtual void OnRespawn() { if (sv_respawnprotect && (deathmatch || alwaysapplydmflags)) { let invul = Powerup(Spawn("PowerInvulnerable")); invul.EffectTics = 3 * TICRATE; invul.BlendColor = 0; // don't mess with the view invul.bUndroppable = true; // Don't drop self if (!invul.CallTryPickup(self)) { invul.Destroy(); return; } bRespawnInvul = true; // [RH] special effect } } //---------------------------------------------------------------------------- // // // //---------------------------------------------------------------------------- override String GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack) { if (victim.player != player && victim.IsTeammate(self)) { victim = self; return String.Format("$OB_FRIENDLY%d", random[Obituary](1, 4)); } else { if (mod == 'Telefrag') return "$OB_MPTELEFRAG"; String message; if (inflictor != NULL && inflictor != self) { message = inflictor.GetObituary(victim, inflictor, mod, playerattack); } if (message.Length() == 0 && playerattack && player.ReadyWeapon != NULL) { message = player.ReadyWeapon.GetObituary(victim, inflictor, mod, playerattack); } if (message.Length() == 0) { if (mod == 'BFGSplash') return "$OB_MPBFG_SPLASH"; if (mod == 'Railgun') return "$OB_RAILGUN"; message = Obituary; } return message; } } //---------------------------------------------------------------------------- // // This is for SBARINFO. // //---------------------------------------------------------------------------- clearscope int, int GetEffectTicsForItem(class item) const { let pg = (class)(item); if (pg != null) { let powerupType = (class)(GetDefaultByType(pg).PowerupType); let powerup = Powerup(FindInventory(powerupType)); if(powerup != null) { let maxtics = GetDefaultByType(pg).EffectTics; if (maxtics == 0) maxtics = powerup.default.EffectTics; return powerup.EffectTics, maxtics; } } return -1, -1; } //=========================================================================== // // PlayerPawn :: CheckWeaponSwitch // // Checks if weapons should be changed after picking up ammo // //=========================================================================== void CheckWeaponSwitch(Class ammotype) { let player = self.player; if (!player.GetNeverSwitch() && player.PendingWeapon == WP_NOCHANGE && (player.ReadyWeapon == NULL || player.ReadyWeapon.bWimpy_Weapon)) { let best = BestWeapon (ammotype); if (best != NULL && !best.bNoAutoSwitchTo && (player.ReadyWeapon == NULL || best.SelectionOrder < player.ReadyWeapon.SelectionOrder)) { player.PendingWeapon = best; } } } //--------------------------------------------------------------------------- // // PROC P_FireWeapon // //--------------------------------------------------------------------------- virtual void FireWeapon (State stat) { let player = self.player; let weapn = player.ReadyWeapon; if (weapn == null || !weapn.CheckAmmo (Weapon.PrimaryFire, true)) { return; } player.WeaponState &= ~WF_WEAPONBOBBING; PlayAttacking (); weapn.bAltFire = false; if (stat == null) { stat = weapn.GetAtkState(!!player.refire); } player.SetPsprite(PSP_WEAPON, stat); if (!weapn.bNoAlert) { SoundAlert (self, false); } } //--------------------------------------------------------------------------- // // PROC P_FireWeaponAlt // //--------------------------------------------------------------------------- virtual void FireWeaponAlt (State stat) { let weapn = player.ReadyWeapon; if (weapn == null || weapn.FindState('AltFire') == null || !weapn.CheckAmmo (Weapon.AltFire, true)) { return; } player.WeaponState &= ~WF_WEAPONBOBBING; PlayAttacking (); weapn.bAltFire = true; if (stat == null) { stat = weapn.GetAltAtkState(!!player.refire); } player.SetPsprite(PSP_WEAPON, stat); if (!weapn.bNoAlert) { SoundAlert (self, false); } } //--------------------------------------------------------------------------- // // PROC P_CheckWeaponFire // // The player can fire the weapon. // [RH] This was in A_WeaponReady before, but that only works well when the // weapon's ready frames have a one tic delay. // //--------------------------------------------------------------------------- void CheckWeaponFire () { let player = self.player; let weapon = player.ReadyWeapon; if (weapon == NULL) return; // Check for fire. Some weapons do not auto fire. if ((player.WeaponState & WF_WEAPONREADY) && (player.cmd.buttons & BT_ATTACK)) { if (!player.attackdown || !weapon.bNoAutofire) { player.attackdown = true; FireWeapon (NULL); return; } } else if ((player.WeaponState & WF_WEAPONREADYALT) && (player.cmd.buttons & BT_ALTATTACK)) { if (!player.attackdown || !weapon.bNoAutofire) { player.attackdown = true; FireWeaponAlt (NULL); return; } } else { player.attackdown = false; } } //--------------------------------------------------------------------------- // // PROC P_CheckWeaponChange // // The player can change to another weapon at self time. // [GZ] This was cut from P_CheckWeaponFire. // //--------------------------------------------------------------------------- virtual void CheckWeaponChange () { let player = self.player; if (!player) return; if ((player.WeaponState & WF_DISABLESWITCH) || // Weapon changing has been disabled. player.morphTics != 0) // Morphed classes cannot change weapons. { // ...so throw away any pending weapon requests. player.PendingWeapon = WP_NOCHANGE; } // Put the weapon away if the player has a pending weapon or has died, and // we're at a place in the state sequence where dropping the weapon is okay. if ((player.PendingWeapon != WP_NOCHANGE || player.health <= 0) && player.WeaponState & WF_WEAPONSWITCHOK) { DropWeapon(); } } //------------------------------------------------------------------------ // // PROC P_MovePsprites // // Called every tic by player thinking routine // //------------------------------------------------------------------------ virtual void TickPSprites() { let player = self.player; let pspr = player.psprites; while (pspr) { // Destroy the psprite if it's from a weapon that isn't currently selected by the player // or if it's from an inventory item that the player no longer owns. if ((pspr.Caller == null || (pspr.Caller is "Inventory" && Inventory(pspr.Caller).Owner != pspr.Owner.mo) || (pspr.Caller is "Weapon" && pspr.Caller != pspr.Owner.ReadyWeapon))) { pspr.Destroy(); } else { pspr.Tick(); } pspr = pspr.Next; } if ((health > 0) || (player.ReadyWeapon != null && !player.ReadyWeapon.bNoDeathInput)) { if (player.ReadyWeapon == null) { if (player.PendingWeapon != WP_NOCHANGE) player.mo.BringUpWeapon(); } else { CheckWeaponChange(); if (player.WeaponState & (WF_WEAPONREADY | WF_WEAPONREADYALT)) { CheckWeaponFire(); } // Check custom buttons CheckWeaponButtons(); } } } /* ================== = = P_CalcHeight = = Calculate the walking / running height adjustment = ================== */ virtual void CalcHeight() { let player = self.player; double angle; double bob; bool still = false; // Regular movement bobbing // (needs to be calculated for gun swing even if not on ground) // killough 10/98: Make bobbing depend only on player-applied motion. // // Note: don't reduce bobbing here if on ice: if you reduce bobbing here, // it causes bobbing jerkiness when the player moves from ice to non-ice, // and vice-versa. if (player.cheats & CF_NOCLIP2) { player.bob = 0; } else if (bNoGravity && !player.onground) { player.bob = min(abs(0.5 * FlyBob), MAXBOB); } else { player.bob = player.Vel dot player.Vel; if (player.bob == 0) { still = true; } else { player.bob *= player.GetMoveBob(); if (player.bob > MAXBOB) player.bob = MAXBOB; } } double defaultviewheight = ViewHeight + player.crouchviewdelta; if (player.cheats & CF_NOVELOCITY) { player.viewz = pos.Z + defaultviewheight; if (player.viewz > ceilingz-4) player.viewz = ceilingz-4; return; } if (bFly && !GetCVar("FViewBob")) { bob = 0; } else if (still) { if (player.health > 0) { angle = Level.maptime / (120 * TICRATE / 35.) * 360.; bob = player.GetStillBob() * sin(angle); } else { bob = 0; } } else { angle = Level.maptime / (ViewBobSpeed * TICRATE / 35.) * 360.; bob = player.bob * sin(angle) * (waterlevel > 1 ? 0.25f : 0.5f); } // move viewheight if (player.playerstate == PST_LIVE) { player.viewheight += player.deltaviewheight; if (player.viewheight > defaultviewheight) { player.viewheight = defaultviewheight; player.deltaviewheight = 0; } else if (player.viewheight < (defaultviewheight/2)) { player.viewheight = defaultviewheight/2; if (player.deltaviewheight <= 0) player.deltaviewheight = 1 / 65536.; } if (player.deltaviewheight) { player.deltaviewheight += 0.25; if (!player.deltaviewheight) player.deltaviewheight = 1/65536.; } } if (player.morphTics) { bob = 0; } player.viewz = pos.Z + player.viewheight + (bob * clamp(ViewBob, 0. , 1.5)); // [SP] Allow DECORATE changes to view bobbing speed. if (Floorclip && player.playerstate != PST_DEAD && pos.Z <= floorz) { player.viewz -= Floorclip; } if (player.viewz > ceilingz - 4) { player.viewz = ceilingz - 4; } if (player.viewz < floorz + 4) { player.viewz = floorz + 4; } } //========================================================================== // // P_DeathThink // //========================================================================== virtual void DeathThink () { let player = self.player; int dir; double delta; player.Uncrouch(); TickPSprites(); player.onground = (pos.Z <= floorz); if (self is "PlayerChunk") { // Flying bloody skull or flying ice chunk player.viewheight = 6; player.deltaviewheight = 0; if (player.onground) { if (Pitch > -19.) { double lookDelta = (-19. - Pitch) / 8; Pitch += lookDelta; } } } else if (!bIceCorpse) { // Fall to ground (if not frozen) player.deltaviewheight = 0; if (player.viewheight > 6) { player.viewheight -= 1; } if (player.viewheight < 6) { player.viewheight = 6; } if (Pitch < 0) { Pitch += 3; } else if (Pitch > 0) { Pitch -= 3; } if (abs(Pitch) < 3) { Pitch = 0.; } } player.mo.CalcHeight (); if (player.attacker && player.attacker != self) { // Watch killer double diff = deltaangle(angle, AngleTo(player.attacker)); double delta = abs(diff); if (delta < 10) { // Looking at killer, so fade damage and poison counters if (player.damagecount) { player.damagecount--; } if (player.poisoncount) { player.poisoncount--; } } delta /= 8; Angle += clamp(diff, -5., 5.); } else { if (player.damagecount) { player.damagecount--; } if (player.poisoncount) { player.poisoncount--; } } if ((player.cmd.buttons & BT_USE || ((deathmatch || alwaysapplydmflags) && sv_forcerespawn)) && !sv_norespawn) { if (Level.maptime >= player.respawn_time || ((player.cmd.buttons & BT_USE) && player.Bot == NULL)) { player.cls = NULL; // Force a new class if the player is using a random class player.playerstate = (multiplayer || level.AllowRespawn || sv_singleplayerrespawn || G_SkillPropertyInt(SKILLP_PlayerRespawn)) ? PST_REBORN : PST_ENTER; if (special1 > 2) { special1 = 0; } } } } //=========================================================================== // // PlayerPawn :: Die // //=========================================================================== override void Die (Actor source, Actor inflictor, int dmgflags, Name MeansOfDeath) { Super.Die (source, inflictor, dmgflags, MeansOfDeath); if (player != NULL && player.mo == self) player.bonuscount = 0; // [RL0] To allow voodoo zombies, don't kill the player together with voodoo dolls if the compat flag is enabled if (player != NULL && player.mo != self && !(Level.compatflags2 & COMPATF2_VOODOO_ZOMBIES)) { // Make the real player die, too player.mo.Die (source, inflictor, dmgflags, MeansOfDeath); } else { // [RL0] player.mo == self will always be true if COMPATF2_VOODOO_ZOMBIES is false, so there's no need to check the compatflag here too, just self if (player != NULL && sv_weapondrop && player.mo == self) { // Voodoo dolls don't drop weapons let weap = player.ReadyWeapon; if (weap != NULL) { // kgDROP - start - modified copy from a_action.cpp let di = weap.GetDropItems(); if (di != NULL) { while (di != NULL) { if (di.Name != 'None') { class ti = di.Name; if (ti) A_DropItem (ti, di.Amount, di.Probability); } di = di.Next; } } else if (weap.SpawnState != NULL && weap.SpawnState != GetDefaultByType('Actor').SpawnState) { let weapitem = Weapon(A_DropItem (weap.GetClass(), -1, 256)); if (weapitem) { if (weap.AmmoGive1 && weap.Ammo1) { weapitem.AmmoGive1 = weap.Ammo1.Amount; } if (weap.AmmoGive2 && weap.Ammo2) { weapitem.AmmoGive2 = weap.Ammo2.Amount; } weapitem.bIgnoreSkill = true; } } else { let item = Inventory(A_DropItem (weap.AmmoType1, -1, 256)); if (item != NULL) { item.Amount = weap.Ammo1.Amount; item.bIgnoreSkill = true; } item = Inventory(A_DropItem (weap.AmmoType2, -1, 256)); if (item != NULL) { item.Amount = weap.Ammo2.Amount; item.bIgnoreSkill = true; } } } } if (!multiplayer && level.deathsequence != 'None') { level.StartIntermission(level.deathsequence, FSTATE_EndingGame); } } } //=========================================================================== // // PlayerPawn :: FilterCoopRespawnInventory // // When respawning in coop, this function is called to walk through the dead // player's inventory and modify it according to the current game flags so // that it can be transferred to the new live player. This player currently // has the default inventory, and the oldplayer has the inventory at the time // of death. // //=========================================================================== void FilterCoopRespawnInventory (PlayerPawn oldplayer) { // If we're losing everything, this is really simple. if (sv_cooploseinventory) { oldplayer.DestroyAllInventory(); return; } // Walk through the old player's inventory and destroy or modify // according to dmflags. Inventory next; for (Inventory item = oldplayer.Inv; item != NULL; item = next) { next = item.Inv; // If this item is part of the default inventory, we never want // to destroy it, although we might want to copy the default // inventory amount. let defitem = FindInventory (item.GetClass()); if (sv_cooplosekeys && defitem == NULL && item is 'Key') { item.Destroy(); } else if (sv_cooploseweapons && defitem == NULL && item is 'Weapon') { item.Destroy(); } else if (sv_cooplosearmor && item is 'Armor') { if (defitem == NULL) { item.Destroy(); } else if (item is 'BasicArmor') { BasicArmor(item).SavePercent = BasicArmor(defitem).SavePercent; item.Amount = defitem.Amount; } else if (item is 'HexenArmor') { let to = HexenArmor(item); let from = HexenArmor(defitem); to.Slots[0] = from.Slots[0]; to.Slots[1] = from.Slots[1]; to.Slots[2] = from.Slots[2]; to.Slots[3] = from.Slots[3]; } } else if (sv_cooplosepowerups && defitem == NULL && item is 'Powerup') { item.Destroy(); } else if ((sv_cooploseammo || sv_coophalveammo) && item is 'Ammo') { if (defitem == NULL) { if (sv_cooploseammo) { // Do NOT destroy the ammo, because a weapon might reference it. item.Amount = 0; } else if (item.Amount > 1) { item.Amount /= 2; } } else { // When set to lose ammo, you get to keep all your starting ammo. // When set to halve ammo, you won't be left with less than your starting amount. if (sv_cooploseammo) { item.Amount = defitem.Amount; } else if (item.Amount > 1) { item.Amount = MAX(item.Amount / 2, defitem.Amount); } } } } // Now destroy the default inventory this player is holding and move // over the old player's remaining inventory. DestroyAllInventory(); ObtainInventory (oldplayer); player.ReadyWeapon = NULL; PickNewWeapon (NULL); } //---------------------------------------------------------------------------- // // PROC P_CheckFOV // //---------------------------------------------------------------------------- virtual void CheckFOV() { let player = self.player; if (!player) return; // [RH] Zoom the player's FOV float desired = player.DesiredFOV; // Adjust FOV using on the currently held weapon. if (player.playerstate != PST_DEAD && // No adjustment while dead. player.ReadyWeapon != NULL && // No adjustment if no weapon. player.ReadyWeapon.FOVScale != 0) // No adjustment if the adjustment is zero. { // A negative scale is used to prevent G_AddViewAngle/G_AddViewPitch // from scaling with the FOV scale. desired *= abs(player.ReadyWeapon.FOVScale); } if (player.FOV != desired) { if (abs(player.FOV - desired) < 7.) { player.FOV = desired; } else { float zoom = MAX(7., abs(player.FOV - desired) * 0.025); if (player.FOV > desired) { player.FOV = player.FOV - zoom; } else { player.FOV = player.FOV + zoom; } } } } //---------------------------------------------------------------------------- // // PROC P_CheckCheats // //---------------------------------------------------------------------------- virtual void CheckCheats() { let player = self.player; // No-clip cheat if ((player.cheats & (CF_NOCLIP | CF_NOCLIP2)) == CF_NOCLIP2) { // No noclip2 without noclip player.cheats &= ~CF_NOCLIP2; } bNoClip = (player.cheats & (CF_NOCLIP | CF_NOCLIP2) || Default.bNoClip); if (player.cheats & CF_NOCLIP2) { bNoGravity = true; } else if (!bFly && !Default.bNoGravity) { bNoGravity = false; } } //---------------------------------------------------------------------------- // // PROC P_CheckFrozen // //---------------------------------------------------------------------------- virtual bool CheckFrozen() { let player = self.player; UserCmd cmd = player.cmd; bool totallyfrozen = player.IsTotallyFrozen(); // [RH] Being totally frozen zeros out most input parameters. if (totallyfrozen) { if (gamestate == GS_TITLELEVEL) { cmd.buttons = 0; } else { cmd.buttons &= BT_USE; } cmd.pitch = 0; cmd.yaw = 0; cmd.roll = 0; cmd.forwardmove = 0; cmd.sidemove = 0; cmd.upmove = 0; player.turnticks = 0; } else if (player.cheats & CF_FROZEN) { cmd.forwardmove = 0; cmd.sidemove = 0; cmd.upmove = 0; } return totallyfrozen; } virtual bool CanCrouch() const { return player.morphTics == 0 || bCrouchableMorph; } //---------------------------------------------------------------------------- // // PROC P_CrouchMove // //---------------------------------------------------------------------------- virtual void CrouchMove(int direction) { let player = self.player; double defaultheight = FullHeight; double savedheight = Height; double crouchspeed = direction * CROUCHSPEED; double oldheight = player.viewheight; player.crouchdir = direction; player.crouchfactor += crouchspeed; // check whether the move is ok Height = defaultheight * player.crouchfactor; if (!TryMove(Pos.XY, false, NULL)) { Height = savedheight; if (direction > 0) { // doesn't fit player.crouchfactor -= crouchspeed; return; } } Height = savedheight; player.crouchfactor = clamp(player.crouchfactor, 0.5, 1.); player.viewheight = ViewHeight * player.crouchfactor; player.crouchviewdelta = player.viewheight - ViewHeight; // Check for eyes going above/below fake floor due to crouching motion. CheckFakeFloorTriggers(pos.Z + oldheight, true); } //---------------------------------------------------------------------------- // // PROC P_CheckCrouch // //---------------------------------------------------------------------------- virtual void CheckCrouch(bool totallyfrozen) { let player = self.player; UserCmd cmd = player.cmd; if (cmd.buttons & BT_JUMP) { cmd.buttons &= ~BT_CROUCH; } if (CanCrouch() && player.health > 0 && level.IsCrouchingAllowed()) { if (!totallyfrozen) { int crouchdir = player.crouching; if (crouchdir == 0) { crouchdir = (cmd.buttons & BT_CROUCH) ? -1 : 1; } else if (cmd.buttons & BT_CROUCH) { player.crouching = 0; } if (crouchdir == 1 && player.crouchfactor < 1 && pos.Z + height < ceilingz) { CrouchMove(1); } else if (crouchdir == -1 && player.crouchfactor > 0.5) { CrouchMove(-1); } } } else { player.Uncrouch(); } player.crouchoffset = -(ViewHeight) * (1 - player.crouchfactor); } //---------------------------------------------------------------------------- // // P_Thrust // // moves the given origin along a given angle // //---------------------------------------------------------------------------- void ForwardThrust (double move, double angle) { if ((waterlevel || bNoGravity) && Pitch != 0 && !player.GetClassicFlight()) { double zpush = move * sin(Pitch); if (waterlevel && waterlevel < 2 && zpush < 0) zpush = 0; Vel.Z -= zpush; move *= cos(Pitch); } Thrust(move, angle); } //---------------------------------------------------------------------------- // // P_Bob // Same as P_Thrust, but only affects bobbing. // // killough 10/98: We apply thrust separately between the real physical player // and the part which affects bobbing. This way, bobbing only comes from player // motion, nothing external, avoiding many problems, e.g. bobbing should not // occur on conveyors, unless the player walks on one, and bobbing should be // reduced at a regular rate, even on ice (where the player coasts). // //---------------------------------------------------------------------------- void Bob (double angle, double move, bool forward) { if (forward && (waterlevel || bNoGravity) && Pitch != 0) { move *= cos(Pitch); } player.Vel += AngleToVector(angle, move); } //=========================================================================== // // PlayerPawn :: TweakSpeeds // //=========================================================================== virtual double, double TweakSpeeds (double forward, double side) { // Strife's player can't run when its health is below 10 if (health <= RunHealth) { forward = clamp(forward, -gameinfo.normforwardmove[0]*256, gameinfo.normforwardmove[0]*256); side = clamp(side, -gameinfo.normsidemove[0]*256, gameinfo.normsidemove[0]*256); } // [GRB] if (abs(forward) < 0x3200) { forward *= ForwardMove1; } else { forward *= ForwardMove2; } if (abs(side) < 0x2800) { side *= SideMove1; } else { side *= SideMove2; } if (!player.morphTics) { double factor = 1.; for(let it = Inv; it != null; it = it.Inv) { factor *= it.GetSpeedFactor (); } forward *= factor; side *= factor; } return forward, side; } //---------------------------------------------------------------------------- // // PROC P_MovePlayer // //---------------------------------------------------------------------------- virtual void MovePlayer () { let player = self.player; UserCmd cmd = player.cmd; // [RH] 180-degree turn overrides all other yaws if (player.turnticks) { player.turnticks--; Angle += (180. / TURN180_TICKS); } else { Angle += cmd.yaw * (360./65536.); } player.onground = (pos.z <= floorz) || bOnMobj || bMBFBouncer || (player.cheats & CF_NOCLIP2); // killough 10/98: // // We must apply thrust to the player and bobbing separately, to avoid // anomalies. The thrust applied to bobbing is always the same strength on // ice, because the player still "works just as hard" to move, while the // thrust applied to the movement varies with 'movefactor'. if (cmd.forwardmove | cmd.sidemove) { double forwardmove, sidemove; double bobfactor; double friction, movefactor; double fm, sm; [friction, movefactor] = GetFriction(); bobfactor = friction < ORIG_FRICTION ? movefactor : ORIG_FRICTION_FACTOR; if (!player.onground && !bNoGravity && !waterlevel) { // [RH] allow very limited movement if not on ground. movefactor *= level.aircontrol; bobfactor*= level.aircontrol; } fm = cmd.forwardmove; sm = cmd.sidemove; [fm, sm] = TweakSpeeds (fm, sm); fm *= Speed / 256; sm *= Speed / 256; // When crouching, speed and bobbing have to be reduced if (CanCrouch() && player.crouchfactor != 1) { fm *= player.crouchfactor; sm *= player.crouchfactor; bobfactor *= player.crouchfactor; } forwardmove = fm * movefactor * (35 / TICRATE); sidemove = sm * movefactor * (35 / TICRATE); if (forwardmove) { Bob(Angle, cmd.forwardmove * bobfactor / 256., true); ForwardThrust(forwardmove, Angle); } if (sidemove) { let a = Angle - 90; Bob(a, cmd.sidemove * bobfactor / 256., false); Thrust(sidemove, a); } if (!(player.cheats & CF_PREDICTING) && (forwardmove != 0 || sidemove != 0)) { PlayRunning (); } if (player.cheats & CF_REVERTPLEASE) { player.cheats &= ~CF_REVERTPLEASE; player.camera = player.mo; } } } //---------------------------------------------------------------------------- // // PROC P_CheckPitch // //---------------------------------------------------------------------------- virtual void CheckPitch() { let player = self.player; // [RH] Look up/down stuff if (!level.IsFreelookAllowed()) { Pitch = 0.; } else { // The player's view pitch is clamped between -32 and +56 degrees, // which translates to about half a screen height up and (more than) // one full screen height down from straight ahead when view panning // is used. int clook = player.cmd.pitch; if (clook != 0) { if (clook == -32768) { // center view player.centering = true; } else if (!player.centering) { // no more overflows with floating point. Yay! :) Pitch = clamp(Pitch - clook * (360. / 65536.), player.MinPitch, player.MaxPitch); } } } if (player.centering) { if (abs(Pitch) > 2.) { Pitch *= (2. / 3.); } else { Pitch = 0.; player.centering = false; if (PlayerNumber() == consoleplayer) { LocalViewPitch = 0; } } } } //---------------------------------------------------------------------------- // // PROC P_CheckJump // //---------------------------------------------------------------------------- virtual void CheckJump() { let player = self.player; // [RH] check for jump if (player.cmd.buttons & BT_JUMP) { if (player.crouchoffset != 0) { // Jumping while crouching will force an un-crouch but not jump player.crouching = 1; } else if (waterlevel >= 2) { Vel.Z = 4 * Speed; } else if (bNoGravity) { Vel.Z = 3.; } else if (level.IsJumpingAllowed() && player.onground && player.jumpTics == 0) { double jumpvelz = JumpZ * 35 / TICRATE; double jumpfac = 0; // [BC] If the player has the high jump power, double his jump velocity. // (actually, pick the best factors from all active items.) for (let p = Inv; p != null; p = p.Inv) { let pp = PowerHighJump(p); if (pp) { double f = pp.Strength; if (f > jumpfac) jumpfac = f; } } if (jumpfac > 0) jumpvelz *= jumpfac; Vel.Z += jumpvelz; bOnMobj = false; player.jumpTics = -1; if (!(player.cheats & CF_PREDICTING)) A_StartSound("*jump", CHAN_BODY); } } } //---------------------------------------------------------------------------- // // PROC P_CheckMoveUpDown // //---------------------------------------------------------------------------- virtual void CheckMoveUpDown() { let player = self.player; UserCmd cmd = player.cmd; if (cmd.upmove == -32768) { // Only land if in the air if (bNoGravity && waterlevel < 2) { bNoGravity = false; } } else if (cmd.upmove != 0) { // Clamp the speed to some reasonable maximum. cmd.upmove = clamp(cmd.upmove, -0x300, 0x300); if (waterlevel >= 2 || bFly || (player.cheats & CF_NOCLIP2)) { Vel.Z = Speed * cmd.upmove / 128.; if (waterlevel < 2 && !bNoGravity) { bFly = true; bNoGravity = true; if ((Vel.Z <= -39) && !(player.cheats & CF_PREDICTING)) { // Stop falling scream A_StopSound(CHAN_VOICE); } } } else if (cmd.upmove > 0 && !(player.cheats & CF_PREDICTING)) { let fly = FindInventory("ArtiFly"); if (fly != NULL) { UseInventory(fly); } } } } //---------------------------------------------------------------------------- // // PROC P_HandleMovement // //---------------------------------------------------------------------------- virtual void HandleMovement() { let player = self.player; // [RH] Check for fast turn around if (player.cmd.buttons & BT_TURN180 && !(player.oldbuttons & BT_TURN180)) { player.turnticks = TURN180_TICKS; } // Handle movement if (reactiontime) { // Player is frozen reactiontime--; } else { MovePlayer(); CheckJump(); CheckMoveUpDown(); } } //---------------------------------------------------------------------------- // // PROC P_CheckUndoMorph // //---------------------------------------------------------------------------- virtual void CheckUndoMorph() { let player = self.player; // Morph counter if (player.morphTics) { if (player.chickenPeck) { // Chicken attack counter player.chickenPeck -= 3; } if (!--player.morphTics) { // Attempt to undo the chicken/pig player.mo.UndoPlayerMorph(player, MRF_UNDOBYTIMEOUT); } } } //---------------------------------------------------------------------------- // // PROC P_CheckPoison // //---------------------------------------------------------------------------- virtual void CheckPoison() { let player = self.player; if (player.poisoncount && !(Level.maptime & 15)) { player.poisoncount -= 5; if (player.poisoncount < 0) { player.poisoncount = 0; } player.PoisonDamage(player.poisoner, 1, true); } } //---------------------------------------------------------------------------- // // PROC P_CheckDegeneration // //---------------------------------------------------------------------------- virtual void CheckDegeneration() { // Apply degeneration. if (sv_degeneration) { let player = self.player; int maxhealth = GetMaxHealth(true); if ((Level.maptime % TICRATE) == 0 && player.health > maxhealth) { if (player.health - 5 < maxhealth) player.health = maxhealth; else player.health--; health = player.health; } } } //---------------------------------------------------------------------------- // // PROC P_CheckAirSupply // //---------------------------------------------------------------------------- virtual void CheckAirSupply() { // Handle air supply //if (level.airsupply > 0) { let player = self.player; if (waterlevel < 3 || (bInvulnerable) || (player.cheats & (CF_GODMODE | CF_NOCLIP2)) || (player.cheats & CF_GODMODE2)) { ResetAirSupply(); } else if (player.air_finished <= Level.maptime && !(Level.maptime & 31)) { DamageMobj(NULL, NULL, 2 + ((Level.maptime - player.air_finished) / TICRATE), 'Drowning'); } } } //---------------------------------------------------------------------------- // // PROC P_PlayerThink // //---------------------------------------------------------------------------- virtual void PlayerThink() { let player = self.player; UserCmd cmd = player.cmd; // [RL0] Mark players that became zombies (this stays even if they 'revive' by healing, until a level change) if((Level.compatflags2 & COMPATF2_VOODOO_ZOMBIES) && player.health <= 0 && player.mo.health > 0) { PlayerFlags |= PF_VOODOO_ZOMBIE; } CheckFOV(); if (player.inventorytics) { player.inventorytics--; } CheckCheats(); if (bJustAttacked) { // Chainsaw/Gauntlets attack auto forward motion cmd.yaw = 0; cmd.forwardmove = 0xc800/2; cmd.sidemove = 0; bJustAttacked = false; } bool totallyfrozen = CheckFrozen(); // Handle crouching CheckCrouch(totallyfrozen); CheckMusicChange(); if (player.playerstate == PST_DEAD) { DeathThink (); return; } if (player.jumpTics != 0) { player.jumpTics--; if (player.onground && player.jumpTics < -18) { player.jumpTics = 0; } } if (player.morphTics && !(player.cheats & CF_PREDICTING)) { MorphPlayerThink (); } CheckPitch(); HandleMovement(); CalcHeight (); if (!(player.cheats & CF_PREDICTING)) { CheckEnvironment(); // Note that after this point the PlayerPawn may have changed due to getting unmorphed or getting its skull popped so 'self' is no longer safe to use. // This also must not read mo into a local variable because several functions in this block can change the attached PlayerPawn. player.mo.CheckUse(); player.mo.CheckUndoMorph(); // Cycle psprites. player.mo.TickPSprites(); // Other Counters if (player.damagecount) player.damagecount--; if (player.bonuscount) player.bonuscount--; if (player.hazardcount) { player.hazardcount--; if (player.hazardinterval <= 0) player.hazardinterval = 32; // repair invalid hazardinterval if (!(Level.maptime % player.hazardinterval) && player.hazardcount > 16*TICRATE) player.mo.DamageMobj (NULL, NULL, 5, player.hazardtype); } player.mo.CheckPoison(); player.mo.CheckDegeneration(); player.mo.CheckAirSupply(); } } //--------------------------------------------------------------------------- // // PROC P_BringUpWeapon // // Starts bringing the pending weapon up from the bottom of the screen. // This is only called to start the rising, not throughout it. // //--------------------------------------------------------------------------- void BringUpWeapon () { // [RL0] Don't bring up weapon when in a voodoo zombie state if(PlayerFlags & PF_VOODOO_ZOMBIE) return; let player = self.player; if (player.PendingWeapon == WP_NOCHANGE) { if (player.ReadyWeapon != null) { let psp = player.GetPSprite(PSP_WEAPON); if (psp) { psp.y = WEAPONTOP; player.ReadyWeapon.ResetPSprite(psp); } player.SetPsprite(PSP_WEAPON, player.ReadyWeapon.GetReadyState()); } return; } let weapon = player.PendingWeapon; // If the player has a tome of power, use self weapon's powered up // version, if one is available. if (weapon != null && weapon.SisterWeapon && weapon.SisterWeapon.bPowered_Up && player.mo.FindInventory ('PowerWeaponLevel2', true)) { weapon = weapon.SisterWeapon; } player.PendingWeapon = WP_NOCHANGE; player.ReadyWeapon = weapon; player.mo.weaponspecial = 0; if (weapon != null) { weapon.PlayUpSound(self); player.refire = 0; let psp = player.GetPSprite(PSP_WEAPON); if (psp) psp.y = player.cheats & CF_INSTANTWEAPSWITCH? WEAPONTOP : WEAPONBOTTOM; // make sure that the previous weapon's flash state is terminated. // When coming here from a weapon drop it may still be active. player.SetPsprite(PSP_FLASH, null); player.SetPsprite(PSP_WEAPON, weapon.GetUpState()); } } //=========================================================================== // // PlayerPawn :: BestWeapon // // Returns the best weapon a player has, possibly restricted to a single // type of ammo. // //=========================================================================== Weapon BestWeapon(Class ammotype) { Weapon bestMatch = NULL; int bestOrder = int.max; Inventory item; bool tomed = !!FindInventory ('PowerWeaponLevel2', true); // Find the best weapon the player has. for (item = Inv; item != NULL; item = item.Inv) { let weap = Weapon(item); if (weap == null) continue; // Don't select it if it's worse than what was already found. if (weap.SelectionOrder > bestOrder) continue; // Don't select it if its primary fire doesn't use the desired ammo. if (ammotype != NULL && (weap.Ammo1 == NULL || weap.Ammo1.GetClass() != ammotype)) continue; // Don't select it if the Tome is active and self isn't the powered-up version. if (tomed && weap.SisterWeapon != NULL && weap.SisterWeapon.bPowered_Up) continue; // Don't select it if it's powered-up and the Tome is not active. if (!tomed && weap.bPowered_Up) continue; // Don't select it if there isn't enough ammo to use its primary fire. if (!(weap.bAMMO_OPTIONAL) && !weap.CheckAmmo (Weapon.PrimaryFire, false)) continue; // Don't select if if there isn't enough ammo as determined by the weapon's author. if (weap.MinSelAmmo1 > 0 && (weap.Ammo1 == NULL || weap.Ammo1.Amount < weap.MinSelAmmo1)) continue; if (weap.MinSelAmmo2 > 0 && (weap.Ammo2 == NULL || weap.Ammo2.Amount < weap.MinSelAmmo2)) continue; // This weapon is usable! bestOrder = weap.SelectionOrder; bestMatch = weap; } return bestMatch; } //--------------------------------------------------------------------------- // // PROC P_DropWeapon // // The player died, so put the weapon away. // //--------------------------------------------------------------------------- void DropWeapon () { let player = self.player; if (player == null) { return; } // Since the weapon is dropping, stop blocking switching. player.WeaponState &= ~WF_DISABLESWITCH; Weapon weap = player.ReadyWeapon; if ((weap != null) && (player.health > 0 || !weap.bNoDeathDeselect)) { player.SetPsprite(PSP_WEAPON, weap.GetDownState()); } } //=========================================================================== // // PlayerPawn :: PickNewWeapon // // Picks a new weapon for this player. Used mostly for running out of ammo, // but it also works when an ACS script explicitly takes the ready weapon // away or the player picks up some ammo they had previously run out of. // //=========================================================================== Weapon PickNewWeapon(Class ammotype) { Weapon best = BestWeapon (ammotype); if (best != NULL) { player.PendingWeapon = best; if (player.ReadyWeapon != NULL) { DropWeapon(); } else if (player.PendingWeapon != WP_NOCHANGE) { BringUpWeapon (); } } return best; } //=========================================================================== // // PlayerPawn :: GiveDefaultInventory // //=========================================================================== virtual void GiveDefaultInventory () { let player = self.player; if (player == NULL) return; // HexenArmor must always be the first item in the inventory because // it provides player class based protection that should not affect // any other protection item. let myclass = GetClass(); GiveInventoryType('HexenArmor'); let harmor = HexenArmor(FindInventory('HexenArmor')); harmor.Slots[4] = self.HexenArmor[0]; for (int i = 0; i < 4; ++i) { harmor.SlotsIncrement[i] = self.HexenArmor[i + 1]; } // BasicArmor must come right after that. It should not affect any // other protection item as well but needs to process the damage // before the HexenArmor does. GiveInventoryType('BasicArmor'); // Now add the items from the DECORATE definition let di = GetDropItems(); while (di) { Class ti = di.Name; if (ti) { let tinv = (class)(ti); if (!tinv) { Console.Printf(TEXTCOLOR_ORANGE .. "%s is not an inventory item and cannot be given to a player as start item.\n", di.Name); } else { let item = FindInventory(tinv); if (item != NULL) { item.Amount = clamp( item.Amount + (di.Amount ? di.Amount : item.default.Amount), 0, item.MaxAmount); } else { item = Inventory(Spawn(ti)); item.bIgnoreSkill = true; // no skill multipliers here item.Amount = di.Amount; let weap = Weapon(item); if (weap) { // To allow better control any weapon is emptied of // ammo before being given to the player. weap.AmmoGive1 = weap.AmmoGive2 = 0; } bool res; Actor check; [res, check] = item.CallTryPickup(self); if (!res) { item.Destroy(); item = NULL; } else if (check != self) { // Player was morphed. This is illegal at game start. // This problem is only detectable when it's too late to do something about it... ThrowAbortException("Cannot give morph item '%s' when starting a game!", di.Name); } } let weap = Weapon(item); if (weap != NULL && weap.CheckAmmo(Weapon.EitherFire, false)) { player.ReadyWeapon = player.PendingWeapon = weap; } } } di = di.Next; } } //=========================================================================== // // PlayerPawn :: GiveDeathmatchInventory // // Gives players items they should have in addition to their default // inventory when playing deathmatch. (i.e. all keys) // //=========================================================================== virtual void GiveDeathmatchInventory() { for ( int i = 0; i < AllActorClasses.Size(); ++i) { let cls = (class)(AllActorClasses[i]); if (cls) { let keyobj = GetDefaultByType(cls); if (keyobj.special1 != 0) { GiveInventoryType(cls); } } } } //=========================================================================== // // // //=========================================================================== override int GetMaxHealth(bool withupgrades) const { int ret = MaxHealth > 0? MaxHealth : ((Level.compatflags & COMPATF_DEHHEALTH)? 100 : deh.MaxHealth); if (withupgrades) ret += stamina + BonusHealth; return ret; } //=========================================================================== // // // //=========================================================================== virtual int GetTeleportFreezeTime() { if (TeleportFreezeTime <= 0) return 0; let item = inv; while (item != null) { if (item.GetNoTeleportFreeze()) return 0; item = item.inv; } return TeleportFreezeTime; } //=========================================================================== // // G_PlayerFinishLevel // Called when a player completes a level. // // flags is checked for RESETINVENTORY and RESETHEALTH only. // //=========================================================================== void PlayerFinishLevel (int mode, int flags) { // [RL0] Handle player exit behavior for voodoo zombies if(PlayerFlags & PF_VOODOO_ZOMBIE) { if(player.health > 0) { PlayerFlags &= ~PF_VOODOO_ZOMBIE; } else { bShootable = false; bKilled = true; } } Inventory item, next; let p = player; if (p.morphTics != 0) { // Undo morph Unmorph(self, 0, true); } // 'self' will be no longer valid from here on in case of an unmorph let me = p.mo; // Strip all current powers, unless moving in a hub and the power is okay to keep. item = me.Inv; while (item != NULL) { next = item.Inv; if (item is 'Powerup') { if (deathmatch || ((mode != FINISH_SameHub || !item.bHUBPOWER) && !item.bPERSISTENTPOWER)) // Keep persistent powers in non-deathmatch games { item.Destroy (); } } item = next; } let ReadyWeapon = p.ReadyWeapon; if (ReadyWeapon != NULL && ReadyWeapon.bPOWERED_UP && p.PendingWeapon == ReadyWeapon.SisterWeapon) { // Unselect powered up weapons if the unpowered counterpart is pending p.ReadyWeapon = p.PendingWeapon; } // reset invisibility to default me.RestoreRenderStyle(); p.extralight = 0; // cancel gun flashes p.fixedcolormap = PlayerInfo.NOFIXEDCOLORMAP; // cancel ir goggles p.fixedlightlevel = -1; p.damagecount = 0; // no palette changes p.bonuscount = 0; p.poisoncount = 0; p.inventorytics = 0; if (mode != FINISH_SameHub) { // Take away flight and keys (and anything else with IF_INTERHUBSTRIP set) item = me.Inv; while (item != NULL) { next = item.Inv; if (item.InterHubAmount < 1) { item.DepleteOrDestroy (); } item = next; } } if (mode == FINISH_NoHub && !level.KEEPFULLINVENTORY) { // Reduce all owned (visible) inventory to defined maximum interhub amount Array todelete; for (item = me.Inv; item != NULL; item = item.Inv) { // If the player is carrying more samples of an item than allowed, reduce amount accordingly if (item.bINVBAR && item.Amount > item.InterHubAmount) { item.Amount = item.InterHubAmount; if (level.REMOVEITEMS && !item.bUNDROPPABLE && !item.bUNCLEARABLE) { todelete.Push(item); } } } for (int i = 0; i < toDelete.Size(); i++) { let it = toDelete[i]; if (!it.bDestroyed) { it.DepleteOrDestroy(); } } } // Resets player health to default if not dead. if ((flags & CHANGELEVEL_RESETHEALTH) && p.playerstate != PST_DEAD) { p.health = me.health = me.SpawnHealth(); } // Clears the entire inventory and gives back the defaults for starting a game if ((flags & CHANGELEVEL_RESETINVENTORY) && p.playerstate != PST_DEAD) { me.ClearInventory(); me.GiveDefaultInventory(); } // [MK] notify self and inventory that we're about to travel // this must be called here so these functions can still have a // chance to alter the world before a snapshot is done in hubs me.PreTravelled(); for (item = me.Inv; item != NULL; item = item.Inv) { item.PreTravelled(); } } //=========================================================================== // // FWeaponSlot :: PickWeapon // // Picks a weapon from this slot. If no weapon is selected in this slot, // or the first weapon in this slot is selected, returns the last weapon. // Otherwise, returns the previous weapon in this slot. This means // precedence is given to the last weapon in the slot, which by convention // is probably the strongest. Does not return weapons you have no ammo // for or which you do not possess. // //=========================================================================== virtual Weapon PickWeapon(int slot, bool checkammo) { int i, j; let player = self.player; int Size = player.weapons.SlotSize(slot); // Does this slot even have any weapons? if (Size == 0) { return player.ReadyWeapon; } let ReadyWeapon = player.ReadyWeapon; if (ReadyWeapon != null) { for (i = 0; i < Size; i++) { let weapontype = player.weapons.GetWeapon(slot, i); if (weapontype == ReadyWeapon.GetClass() || (ReadyWeapon.bPOWERED_UP && ReadyWeapon.SisterWeapon != null && ReadyWeapon.SisterWeapon.GetClass() == weapontype)) { for (j = (i == 0 ? Size - 1 : i - 1); j != i; j = (j == 0 ? Size - 1 : j - 1)) { let weapontype2 = player.weapons.GetWeapon(slot, j); let weap = Weapon(player.mo.FindInventory(weapontype2)); if (weap != null) { if (!checkammo || weap.CheckAmmo(Weapon.EitherFire, false)) { return weap; } } } } } } for (i = Size - 1; i >= 0; i--) { let weapontype = player.weapons.GetWeapon(slot, i); let weap = Weapon(player.mo.FindInventory(weapontype)); if (weap != null) { if (!checkammo || weap.CheckAmmo(Weapon.EitherFire, false)) { return weap; } } } return ReadyWeapon; } //=========================================================================== // // FindMostRecentWeapon // // Locates the slot and index for the most recently selected weapon. If the // player is in the process of switching to a new weapon, that is the most // recently selected weapon. Otherwise, the current weapon is the most recent // weapon. // //=========================================================================== bool, int, int FindMostRecentWeapon() { let player = self.player; let ReadyWeapon = player.ReadyWeapon; if (player.PendingWeapon != WP_NOCHANGE) { // Workaround for the current inability bool found; int slot; int index; [found, slot, index] = player.weapons.LocateWeapon(player.PendingWeapon.GetClass()); return found, slot, index; } else if (ReadyWeapon != null) { bool found; int slot; int index; [found, slot, index] = player.weapons.LocateWeapon(ReadyWeapon.GetClass()); if (!found) { // If the current weapon wasn't found and is powered up, // look for its non-powered up version. if (ReadyWeapon.bPOWERED_UP && ReadyWeapon.SisterWeaponType != null) { [found, slot, index] = player.weapons.LocateWeapon(ReadyWeapon.SisterWeaponType); return found, slot, index; } return false, 0, 0; } return true, slot, index; } else { return false, 0, 0; } } //=========================================================================== // // FWeaponSlots :: PickNextWeapon // // Returns the "next" weapon for this player. If the current weapon is not // in a slot, then it just returns that weapon, since there's nothing to // consider it relative to. // //=========================================================================== const NUM_WEAPON_SLOTS = 10; virtual Weapon PickNextWeapon() { let player = self.player; bool found; int startslot, startindex; int slotschecked = 0; [found, startslot, startindex] = FindMostRecentWeapon(); let ReadyWeapon = player.ReadyWeapon; if (ReadyWeapon == null || found) { int slot; int index; if (ReadyWeapon == null) { startslot = NUM_WEAPON_SLOTS - 1; startindex = player.weapons.SlotSize(startslot) - 1; } slot = startslot; index = startindex; do { if (++index >= player.weapons.SlotSize(slot)) { index = 0; slotschecked++; if (++slot >= NUM_WEAPON_SLOTS) { slot = 0; } } let type = player.weapons.GetWeapon(slot, index); let weap = Weapon(FindInventory(type)); if (weap != null && weap.CheckAmmo(Weapon.EitherFire, false)) { return weap; } } while ((slot != startslot || index != startindex) && slotschecked <= NUM_WEAPON_SLOTS); } return ReadyWeapon; } //=========================================================================== // // FWeaponSlots :: PickPrevWeapon // // Returns the "previous" weapon for this player. If the current weapon is // not in a slot, then it just returns that weapon, since there's nothing to // consider it relative to. // //=========================================================================== virtual Weapon PickPrevWeapon() { let player = self.player; int startslot, startindex; bool found; int slotschecked = 0; [found, startslot, startindex] = FindMostRecentWeapon(); if (player.ReadyWeapon == null || found) { int slot; int index; if (player.ReadyWeapon == null) { startslot = 0; startindex = 0; } slot = startslot; index = startindex; do { if (--index < 0) { slotschecked++; if (--slot < 0) { slot = NUM_WEAPON_SLOTS - 1; } index = player.weapons.SlotSize(slot) - 1; } let type = player.weapons.GetWeapon(slot, index); let weap = Weapon(FindInventory(type)); if (weap != null && weap.CheckAmmo(Weapon.EitherFire, false)) { return weap; } } while ((slot != startslot || index != startindex) && slotschecked <= NUM_WEAPON_SLOTS); } return player.ReadyWeapon; } //============================================================================ // // P_BobWeapon // // [RH] Moved this out of A_WeaponReady so that the weapon can bob every // tic and not just when A_WeaponReady is called. Not all weapons execute // A_WeaponReady every tic, and it looks bad if they don't bob smoothly. // // [XA] Added new bob styles and exposed bob properties. Thanks, Ryan Cordell! // [SP] Added new user option for bob speed // //============================================================================ virtual Vector2 BobWeapon (double ticfrac) { Vector2 p1, p2, r; Vector2 result; let player = self.player; if (!player) return (0, 0); let weapon = player.ReadyWeapon; if (weapon == null || weapon.bDontBob) { return (0, 0); } // [XA] Get the current weapon's bob properties. int bobstyle = weapon.BobStyle; double BobSpeed = (weapon.BobSpeed * 128); double Rangex = weapon.BobRangeX; double Rangey = weapon.BobRangeY; for (int i = 0; i < 2; i++) { // Bob the weapon based on movement speed. ([SP] And user's bob speed setting) double angle = (BobSpeed * player.GetWBobSpeed() * 35 / TICRATE*(Level.maptime - 1 + i)) * (360. / 8192.); // [RH] Smooth transitions between bobbing and not-bobbing frames. // This also fixes the bug where you can "stick" a weapon off-center by // shooting it when it's at the peak of its swing. if (curbob != player.bob) { if (abs(player.bob - curbob) <= 1) { curbob = player.bob; } else { double zoom = MAX(1., abs(curbob - player.bob) / 40); if (curbob > player.bob) { curbob -= zoom; } else { curbob += zoom; } } } // The weapon bobbing intensity while firing can be adjusted by the player. double BobIntensity = (player.WeaponState & WF_WEAPONBOBBING) ? 1. : player.GetWBobFire(); if (curbob != 0) { double bobVal = player.bob; if (i == 0) { bobVal = prevBob; } //[SP] Added in decorate player.viewbob checks double bobx = (bobVal * BobIntensity * Rangex * ViewBob); double boby = (bobVal * BobIntensity * Rangey * ViewBob); switch (bobstyle) { case Bob_Normal: r.X = bobx * cos(angle); r.Y = boby * abs(sin(angle)); break; case Bob_Inverse: r.X = bobx*cos(angle); r.Y = boby * (1. - abs(sin(angle))); break; case Bob_Alpha: r.X = bobx * sin(angle); r.Y = boby * abs(sin(angle)); break; case Bob_InverseAlpha: r.X = bobx * sin(angle); r.Y = boby * (1. - abs(sin(angle))); break; case Bob_Smooth: r.X = bobx*cos(angle); r.Y = 0.5f * (boby * (1. - (cos(angle * 2)))); break; case Bob_InverseSmooth: r.X = bobx*cos(angle); r.Y = 0.5f * (boby * (1. + (cos(angle * 2)))); } } else { r = (0, 0); } if (i == 0) p1 = r; else p2 = r; } return p1 * (1. - ticfrac) + p2 * ticfrac; } virtual Vector3 /*translation*/ , Vector3 /*rotation*/ BobWeapon3D (double ticfrac) { Vector2 oldBob = BobWeapon(ticfrac); return (0, 0, 0) , ( oldBob.x / 4, oldBob.y / -4, 0); } //---------------------------------------------------------------------------- // // // //---------------------------------------------------------------------------- virtual clearscope color GetPainFlash() const { Color painFlash = GetPainFlashForType(DamageTypeReceived); if (painFlash == 0) painFlash = DamageFade; return painFlash; } //=========================================================================== // // PlayerPawn :: ResetAirSupply // // Gives the player a full "tank" of air. If they had previously completely // run out of air, also plays the *gasp sound. Returns true if the player // was drowning. // //=========================================================================== virtual bool ResetAirSupply (bool playgasp = true) { let player = self.player; bool wasdrowning = (player.air_finished < Level.maptime); if (playgasp && wasdrowning) { A_StartSound("*gasp", CHAN_VOICE); } if (Level.airsupply > 0 && AirCapacity > 0) player.air_finished = Level.maptime + int(Level.airsupply * AirCapacity); else player.air_finished = int.max; return wasdrowning; } //=========================================================================== // // PlayerPawn :: PreTravelled // // Called before the player moves to another map, in case it needs to do // special clean-up. This is called right before all carried items // execute their respective PreTravelled() virtuals. // //=========================================================================== virtual void PreTravelled() {} //=========================================================================== // // PlayerPawn :: Travelled // // Called when the player moves to another map, in case it needs to do // special reinitialization. This is called after all carried items have // executed their respective Travelled() virtuals too. // //=========================================================================== virtual void Travelled() {} //---------------------------------------------------------------------------- // // // //---------------------------------------------------------------------------- native clearscope static String GetPrintableDisplayName(Class cls); native void CheckMusicChange(); native void CheckEnvironment(); native void CheckUse(); native void CheckWeaponButtons(); native void MarkPlayerSounds(); private native int SetupCrouchSprite(int c); private native clearscope Color GetPainFlashForType(Name type); } extend class Actor { //---------------------------------------------------------------------------- // // PROC A_SkullPop // This should really be in PlayerPawn but cannot be. // //---------------------------------------------------------------------------- void A_SkullPop(class skulltype = "BloodySkull") { // [GRB] Parameterized version if (skulltype == NULL || !(skulltype is "PlayerChunk")) { skulltype = "BloodySkull"; if (skulltype == NULL) return; } bSolid = false; let mo = PlayerPawn(Spawn (skulltype, Pos + (0, 0, 48), NO_REPLACE)); //mo.target = self; mo.Vel.X = Random2[SkullPop]() / 128.; mo.Vel.Y = Random2[SkullPop]() / 128.; mo.Vel.Z = 2. + (Random[SkullPop]() / 1024.); // Attach player mobj to bloody skull let player = self.player; self.player = NULL; mo.ObtainInventory (self); mo.player = player; mo.health = health; mo.Angle = Angle; if (player != NULL) { player.mo = mo; player.damagecount = 32; } for (int i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i] && players[i].camera == self) { players[i].camera = mo; } } } } class PlayerChunk : PlayerPawn { Default { +NOSKIN -SOLID -SHOOTABLE -PICKUP -NOTDMATCH -FRIENDLY -SLIDESONWALLS -CANPUSHWALLS -FLOORCLIP -WINDTHRUST -TELESTOMP } } class PSprite : Object native play { enum PSPLayers { STRIFEHANDS = -1, WEAPON = 1, FLASH = 1000, TARGETCENTER = 0x7fffffff - 2, TARGETLEFT, TARGETRIGHT, }; native readonly State CurState; native Actor Caller; native readonly PSprite Next; native readonly PlayerInfo Owner; native SpriteID Sprite; native int Frame; //native readonly int RenderStyle; had to be blocked because the internal representation was not ok. Renderstyle is still pending a proper solution. native readonly int ID; native Bool processPending; native double x; native double y; native double oldx; native double oldy; native Vector2 baseScale; native Vector2 pivot; native Vector2 scale; native double rotation; native int HAlign, VAlign; native Vector2 Coord0; // [MC] Not the actual coordinates. Just the offsets by A_OverlayVertexOffset. native Vector2 Coord1; native Vector2 Coord2; native Vector2 Coord3; native double alpha; native Bool firstTic; native bool InterpolateTic; native int Tics; native uint Translation; native bool bAddWeapon; native bool bAddBob; native bool bPowDouble; native bool bCVarFast; native bool bFlip; native bool bMirror; native bool bPlayerTranslated; native bool bPivotPercent; native bool bInterpolate; native void SetState(State newstate, bool pending = false); //------------------------------------------------------------------------ // // // //------------------------------------------------------------------------ void Tick() { if (processPending) { // drop tic count and possibly change state if (Tics != -1) // a -1 tic count never changes { Tics--; // [BC] Apply double firing speed. if (bPowDouble && Tics && (Owner.mo.FindInventory ("PowerDoubleFiringSpeed", true))) Tics--; if (!Tics && Caller != null) SetState(CurState.NextState); } } } void ResetInterpolation() { oldx = x; oldy = y; } } enum EPlayerState { PST_LIVE, // Playing or camping. PST_DEAD, // Dead on the ground, view follows killer. PST_REBORN, // Ready to restart/respawn??? PST_ENTER, // [BC] Entered the game PST_GONE // Player has left the game } enum EPlayerGender { GENDER_MALE, GENDER_FEMALE, GENDER_NEUTRAL, GENDER_OTHER } struct PlayerInfo native play // self is what internally is known as player_t { // technically engine constants but the only part of the playsim using them is the player. const NOFIXEDCOLORMAP = -1; const NUMCOLORMAPS = 32; native PlayerPawn mo; native uint8 playerstate; native readonly uint buttons; native uint original_oldbuttons; native Class cls; native float DesiredFOV; native float FOV; native double viewz; native double viewheight; native double deltaviewheight; native double bob; native vector2 vel; native bool centering; native uint8 turnticks; native bool attackdown; native bool usedown; native uint oldbuttons; native int health; native clearscope int inventorytics; native uint8 CurrentPlayerClass; native int frags[MAXPLAYERS]; native int fragcount; native int lastkilltime; native uint8 multicount; native uint8 spreecount; native uint16 WeaponState; native Weapon ReadyWeapon; native Weapon PendingWeapon; native PSprite psprites; native int cheats; native int timefreezer; native int16 refire; native int16 inconsistent; native bool waiting; native int killcount; native int itemcount; native int secretcount; native uint damagecount; native uint bonuscount; native int hazardcount; native int hazardinterval; native Name hazardtype; native int poisoncount; native Name poisontype; native Name poisonpaintype; native Actor poisoner; native Actor attacker; native int extralight; native int16 fixedcolormap; native int16 fixedlightlevel; native int morphtics; native ClassMorphedPlayerClass; native int MorphStyle; native Class MorphExitFlash; native Weapon PremorphWeapon; native int chickenPeck; native int jumpTics; native bool onground; native int respawn_time; native Actor camera; native int air_finished; native Name LastDamageType; native Actor MUSINFOactor; native int8 MUSINFOtics; native bool settings_controller; native int8 crouching; native int8 crouchdir; native Bot bot; native float BlendR; native float BlendG; native float BlendB; native float BlendA; native String LogText; native double MinPitch; native double MaxPitch; native double crouchfactor; native double crouchoffset; native double crouchviewdelta; native Actor ConversationNPC; native Actor ConversationPC; native double ConversationNPCAngle; native bool ConversationFaceTalker; native @WeaponSlots weapons; native @UserCmd cmd; native readonly @UserCmd original_cmd; native bool PoisonPlayer(Actor poisoner, Actor source, int poison); native void PoisonDamage(Actor source, int damage, bool playPainSound); native void SetPsprite(int id, State stat, bool pending = false); native void SetSafeFlash(Weapon weap, State flashstate, int index); native PSprite GetPSprite(int id) const; native PSprite FindPSprite(int id) const; native void SetLogNumber (int text); native void SetLogText (String text); native void SetSubtitleNumber (int text, Sound sound_id = 0); native bool Resurrect(); native clearscope String GetUserName() const; native clearscope Color GetColor() const; native clearscope Color GetDisplayColor() const; native clearscope int GetColorSet() const; native clearscope int GetPlayerClassNum() const; native clearscope int GetSkin() const; native clearscope bool GetNeverSwitch() const; native clearscope int GetGender() const; native clearscope int GetTeam() const; native clearscope float GetAutoaim() const; native clearscope bool GetNoAutostartMap() const; native double GetWBobSpeed() const; native double GetWBobFire() const; native double GetMoveBob() const; native bool GetFViewBob() const; native double GetStillBob() const; native void SetFOV(float fov); native clearscope bool GetClassicFlight() const; native void SendPitchLimits(); native clearscope bool HasWeaponsInSlot(int slot) const; // The actual implementation is on PlayerPawn where it can be overridden. Use that directly in the future. deprecated("3.7", "MorphPlayer() should be used on a PlayerPawn object") bool MorphPlayer(playerinfo p, Class spawntype, int duration, int style, Class enter_flash = null, Class exit_flash = null) { if (mo != null) { return mo.MorphPlayer(p, spawntype, duration, style, enter_flash, exit_flash); } return false; } // This somehow got its arguments mixed up. 'self' should have been the player to be unmorphed, not the activator deprecated("3.7", "UndoPlayerMorph() should be used on a PlayerPawn object") bool UndoPlayerMorph(playerinfo player, int unmorphflag = 0, bool force = false) { if (player.mo != null) { return player.mo.UndoPlayerMorph(self, unmorphflag, force); } return false; } deprecated("3.7", "DropWeapon() should be used on a PlayerPawn object") void DropWeapon() { if (mo != null) { mo.DropWeapon(); } } deprecated("3.7", "BringUpWeapon() should be used on a PlayerPawn object") void BringUpWeapon() { if (mo) mo.BringUpWeapon(); } clearscope bool IsTotallyFrozen() const { return gamestate == GS_TITLELEVEL || (cheats & CF_TOTALLYFROZEN) || mo.isFrozen(); } void Uncrouch() { if (crouchfactor != 1) { crouchfactor = 1; crouchoffset = 0; crouchdir = 0; crouching = 0; crouchviewdelta = 0; viewheight = mo.ViewHeight; } } clearscope int fragSum () const { int i; int allfrags = 0; int playernum = mo.PlayerNumber(); for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] && i!=playernum) { allfrags += frags[i]; } } // JDC hack - negative frags. allfrags -= frags[playernum]; return allfrags; } double GetDeltaViewHeight() { return (mo.ViewHeight + crouchviewdelta - viewheight) / 8; } } struct PlayerClass native { native class Type; native uint Flags; native Array Skins; native bool CheckSkin(int skin); native void EnumColorsets(out Array data); native Name GetColorsetName(int setnum); } struct PlayerSkin native { native readonly String SkinName; native readonly String Face; native readonly uint8 gender; native readonly uint8 range0start; native readonly uint8 range0end; native readonly bool othergame; native readonly Vector2 Scale; native readonly int sprite; native readonly int crouchsprite; native readonly int namespc; }; struct Team native { const NoTeam = 255; const Max = 16; native String mName; } /* ** playermenu.txt ** The player setup menu ** **--------------------------------------------------------------------------- ** Copyright 2001-2010 Randy Heit ** Copyright 2010-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ //============================================================================= // // items for the player menu // //============================================================================= class ListMenuItemPlayerNameBox : ListMenuItemSelectable { String mText; Font mFont; int mFontColor; int mFrameSize; String mPlayerName; TextEnterMenu mEnter; //============================================================================= // // Player's name // //============================================================================= void Init(ListMenuDescriptor desc, String text, int frameofs, Name command) { Super.Init(desc.mXpos, desc.mYpos, desc.mLinespacing, command); mText = text; mFont = desc.mFont; mFontColor = desc.mFontColor; mFrameSize = frameofs; mPlayerName = ""; mEnter = null; } //============================================================================= // // Player's name // //============================================================================= void InitDirect(double x, double y, int height, int frameofs, String text, Font font, int color, Name command) { Super.Init(x, y, height, command); mText = text; mFont = font; mFontColor = color; mFrameSize = frameofs; mPlayerName = ""; mEnter = null; } //============================================================================= // // // //============================================================================= override bool SetString(int i, String s) { if (i == 0) { mPlayerName = s; return true; } return false; } override bool, String GetString(int i) { if (i == 0) { return true, mPlayerName; } return false, ""; } //============================================================================= // // [RH] Width of the border is variable // //============================================================================= protected void DrawBorder (double x, double y, int len) { let left = TexMan.CheckForTexture("M_LSLEFT", TexMan.Type_MiscPatch); let mid = TexMan.CheckForTexture("M_LSCNTR", TexMan.Type_MiscPatch); let right = TexMan.CheckForTexture("M_LSRGHT", TexMan.Type_MiscPatch); if (left.IsValid() && right.IsValid() && mid.IsValid()) { int i; screen.DrawTexture (left, false, x-8, y+7, DTA_Clean, true); for (i = 0; i < len; i++) { screen.DrawTexture (mid, false, x, y+7, DTA_Clean, true); x += 8; } screen.DrawTexture (right, false, x, y+7, DTA_Clean, true); } else { let slot = TexMan.CheckForTexture("M_FSLOT", TexMan.Type_MiscPatch); if (slot.IsValid()) { screen.DrawTexture (slot, false, x, y+1, DTA_Clean, true); } else { int xx = int(x - 160) * CleanXfac + screen.GetWidth()/2; int yy = int(y - 100) * CleanXfac + screen.GetHeight()/2; screen.Clear(xx, yy, xx + len*CleanXfac, yy + SmallFont.GetHeight() * CleanYfac * 3/2, 0); } } } //============================================================================= // // // //============================================================================= override void Drawer(bool selected) { String text = StringTable.Localize(mText); if (text.Length() > 0) { screen.DrawText(mFont, selected? OptionMenuSettings.mFontColorSelection : mFontColor, mXpos, mYpos, text, DTA_Clean, true); } // Draw player name box double x = mXpos + mFont.StringWidth(text) + 16 + mFrameSize; DrawBorder (x, mYpos - mFrameSize, 16); // This creates a 128 pixel wide text box. if (!mEnter) { screen.DrawText (SmallFont, Font.CR_UNTRANSLATED, x + mFrameSize, mYpos, mPlayerName, DTA_Clean, true); } else { let printit = mEnter.GetText() .. SmallFont.GetCursor(); screen.DrawText (SmallFont, Font.CR_UNTRANSLATED, x + mFrameSize, mYpos, printit, DTA_Clean, true); } } //============================================================================= // // // //============================================================================= override bool MenuEvent(int mkey, bool fromcontroller) { if (mkey == Menu.MKEY_Enter) { Menu.MenuSound ("menu/choose"); mEnter = TextEnterMenu.OpenTextEnter(Menu.GetCurrentMenu(), Menu.OptionFont(), mPlayerName, 128, fromcontroller); mEnter.ActivateMenu(); return true; } else if (mkey == Menu.MKEY_Input) { mPlayerName = mEnter.GetText(); mEnter = null; return true; } else if (mkey == Menu.MKEY_Abort) { mEnter = null; return true; } return false; } } //============================================================================= // // items for the player menu // //============================================================================= class ListMenuItemValueText : ListMenuItemSelectable { Array mSelections; String mText; int mSelection; Font mFont; int mFontColor; int mFontColor2; //============================================================================= // // items for the player menu // //============================================================================= void Init(ListMenuDescriptor desc, String text, Name command, Name values = 'None') { Super.Init(desc.mXpos, desc.mYpos, desc.mLinespacing, command); mText = text; mFont = desc.mFont; mFontColor = desc.mFontColor; mFontColor2 = desc.mFontColor2; mSelection = 0; let cnt = OptionValues.GetCount(values); for(int i = 0; i < cnt; i++) { SetString(i, OptionValues.GetText(values, i)); } } //============================================================================= // // items for the player menu // //============================================================================= void InitDirect(double x, double y, int height, String text, Font font, int color, int valuecolor, Name command, Name values) { Super.Init(x, y, height, command); mText = text; mFont = font; mFontColor = color; mFontColor2 = valuecolor; mSelection = 0; let cnt = OptionValues.GetCount(values); for(int i = 0; i < cnt; i++) { SetString(i, OptionValues.GetText(values, i)); } } //============================================================================= // // // //============================================================================= override bool SetString(int i, String s) { // should actually use the index... if (i==0) mSelections.Clear(); mSelections.Push(s); return true; } //============================================================================= // // // //============================================================================= override bool SetValue(int i, int value) { if (i == 0) { mSelection = value; return true; } return false; } override bool, int GetValue(int i) { if (i == 0) { return true, mSelection; } return false, 0; } //============================================================================= // // // //============================================================================= override bool MenuEvent (int mkey, bool fromcontroller) { if (mSelections.Size() > 1) { if (mkey == Menu.MKEY_Left) { Menu.MenuSound("menu/change"); if (--mSelection < 0) mSelection = mSelections.Size() - 1; return true; } else if (mkey == Menu.MKEY_Right || mkey == Menu.MKEY_Enter) { Menu.MenuSound("menu/change"); if (++mSelection >= mSelections.Size()) mSelection = 0; return true; } } return (mkey == Menu.MKEY_Enter); // needs to eat enter keys so that Activate won't get called } //============================================================================= // // // //============================================================================= override void Drawer(bool selected) { String text = Stringtable.Localize(mText); screen.DrawText(mFont, selected? OptionMenuSettings.mFontColorSelection : mFontColor, mXpos, mYpos, text, DTA_Clean, true); double x = mXpos + mFont.StringWidth(text) + 8; if (mSelections.Size() > 0) { screen.DrawText(mFont, mFontColor2, x, mYpos, mSelections[mSelection], DTA_Clean, true); } } } //============================================================================= // // items for the player menu // //============================================================================= class ListMenuItemSlider : ListMenuItemSelectable { String mText; Font mFont; int mFontColor; int mMinrange, mMaxrange; int mStep; int mSelection; int mDrawX; //============================================================================= // // items for the player menu // //============================================================================= void Init(ListMenuDescriptor desc, String text, Name command, int min, int max, int step) { Super.Init(desc.mXpos, desc.mYpos, desc.mLinespacing, command); mText = text; mFont = desc.mFont; mFontColor = desc.mFontColor; mSelection = 0; mMinrange = min; mMaxrange = max; mStep = step; mDrawX = 0; } //============================================================================= // // items for the player menu // //============================================================================= void InitDirect(double x, double y, int height, String text, Font font, int color, Name command, int min, int max, int step) { Super.Init(x, y, height, command); mText = text; mFont = font; mFontColor = color; mSelection = 0; mMinrange = min; mMaxrange = max; mStep = step; mDrawX = 0; } //============================================================================= // // // //============================================================================= override bool SetValue(int i, int value) { if (i == 0) { mSelection = value; return true; } return false; } override bool, int GetValue(int i) { if (i == 0) { return true, mSelection; } return false, 0; } //============================================================================= // // // //============================================================================= override bool MenuEvent (int mkey, bool fromcontroller) { if (mkey == Menu.MKEY_Left) { Menu.MenuSound("menu/change"); if ((mSelection -= mStep) < mMinrange) mSelection = mMinrange; return true; } else if (mkey == Menu.MKEY_Right || mkey == Menu.MKEY_Enter) { Menu.MenuSound("menu/change"); if ((mSelection += mStep) > mMaxrange) mSelection = mMaxrange; return true; } return false; } //============================================================================= // // // //============================================================================= override bool MouseEvent(int type, int x, int y) { let lm = Menu.GetCurrentMenu(); if (type != Menu.MOUSE_Click) { if (!lm.CheckFocus(self)) return false; } if (type == Menu.MOUSE_Release) { lm.ReleaseFocus(); } int slide_left = mDrawX + 8; int slide_right = slide_left + 10*8; // 12 char cells with 8 pixels each. if (type == Menu.MOUSE_Click) { if (x < slide_left || x >= slide_right) return true; } x = clamp(x, slide_left, slide_right); int v = mMinrange + (x - slide_left) * (mMaxrange - mMinrange) / (slide_right - slide_left); if (v != mSelection) { mSelection = v; Menu.MenuSound("menu/change"); } if (type == Menu.MOUSE_Click) { lm.SetFocus(self); } return true; } //============================================================================= // // // //============================================================================= protected void DrawSlider (double x, double y) { int range = mMaxrange - mMinrange; int cur = mSelection - mMinrange; x = (x - 160) * CleanXfac + screen.GetWidth() / 2; y = (y - 100) * CleanYfac + screen.GetHeight() / 2; screen.DrawText (ConFont, Font.FindFontColor(gameinfo.mSliderBackColor), x, y, "\x10\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x12", DTA_CellX, 8 * CleanXfac, DTA_CellY, 8 * CleanYfac); screen.DrawText (ConFont, Font.FindFontColor(gameinfo.mSliderColor), x + (5 + (int)((cur * 78) / range)) * CleanXfac, y, "\x13", DTA_CellX, 8 * CleanXfac, DTA_CellY, 8 * CleanYfac); } //============================================================================= // // // //============================================================================= override void Drawer(bool selected) { String text = StringTable.Localize(mText); screen.DrawText(mFont, selected? OptionMenuSettings.mFontColorSelection : mFontColor, mXpos, mYpos, text, DTA_Clean, true); double x = SmallFont.StringWidth ("Green") + 8 + mXpos; double x2 = SmallFont.StringWidth (text) + 8 + mXpos; mDrawX = int(MAX(x2, x)); DrawSlider (mDrawX, mYpos); } } /* ** playerdisplay.cpp ** The player display for the player setup and class selection screen ** **--------------------------------------------------------------------------- ** Copyright 2010-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ //============================================================================= // // the player sprite window // //============================================================================= class ListMenuItemPlayerDisplay : ListMenuItem { ListMenuDescriptor mOwner; TextureID mBackdrop; PlayerClass mPlayerClass; State mPlayerState; int mPlayerTics; bool mNoportrait; int8 mRotation; int8 mMode; // 0: automatic (used by class selection), 1: manual (used by player setup) int8 mTranslate; int mSkin; int mRandomClass; int mRandomTimer; int mClassNum; Color mBaseColor; Color mAddColor; enum EPDFlags { PDF_ROTATION = 0x10001, PDF_SKIN = 0x10002, PDF_CLASS = 0x10003, PDF_MODE = 0x10004, PDF_TRANSLATE = 0x10005, }; //============================================================================= // // // //============================================================================= void Init(ListMenuDescriptor menu, int x, int y, Color c1, Color c2, bool np = false, Name command = 'None' ) { Super.Init(x, y, command); mOwner = menu; mBaseColor = c1; mAddColor = c2; mBackdrop = TexMan.CheckForTexture("B@CKDROP", TexMan.Type_MiscPatch); // The weird name is to avoid clashes with mods. mPlayerClass = NULL; mPlayerState = NULL; mNoportrait = np; mMode = 0; mRotation = 0; mTranslate = false; mSkin = 0; mRandomClass = 0; mRandomTimer = 0; mClassNum = -1; } private void UpdatePlayer(int classnum) { mPlayerClass = PlayerClasses[classnum]; mPlayerState = GetDefaultByType (mPlayerClass.Type).SeeState; if (mPlayerState == NULL) { // No see state, so try spawn state. mPlayerState = GetDefaultByType (mPlayerClass.Type).SpawnState; } mPlayerTics = mPlayerState != NULL ? mPlayerState.Tics : -1; } //============================================================================= // // // //============================================================================= private void UpdateRandomClass() { if (--mRandomTimer < 0) { if (++mRandomClass >= PlayerClasses.Size ()) mRandomClass = 0; UpdatePlayer(mRandomClass); mPlayerTics = mPlayerState != NULL ? mPlayerState.Tics : -1; mRandomTimer = 6; // Since the newly displayed class may use a different translation // range than the old one, we need to update the translation, too. Translation.SetPlayerTranslation(TRANSLATION_Players, MAXPLAYERS, consoleplayer, mPlayerClass); } } //============================================================================= // // // //============================================================================= void SetPlayerClass(int classnum, bool force = false) { if (classnum < 0 || classnum >= PlayerClasses.Size ()) { if (mClassNum != -1) { mClassNum = -1; mRandomTimer = 0; UpdateRandomClass(); } } else if (mPlayerClass != PlayerClasses[classnum] || force) { UpdatePlayer(classnum); mClassNum = classnum; } } //============================================================================= // // // //============================================================================= bool UpdatePlayerClass() { if (mOwner && mOwner.mSelectedItem >= 0) { int classnum; Name seltype; [seltype, classnum] = mOwner.mItems[mOwner.mSelectedItem].GetAction(); if (seltype != 'Episodemenu') return false; if (PlayerClasses.Size() == 0) return false; SetPlayerClass(classnum); return true; } return false; } //============================================================================= // // // //============================================================================= override bool SetValue(int i, int value) { switch (i) { case PDF_MODE: mMode = value; return true; case PDF_ROTATION: mRotation = value; return true; case PDF_TRANSLATE: mTranslate = value; case PDF_CLASS: SetPlayerClass(value, true); break; case PDF_SKIN: mSkin = value; break; } return false; } //============================================================================= // // // //============================================================================= override void Ticker() { if (mClassNum < 0) UpdateRandomClass(); if (mPlayerState != NULL && mPlayerState.Tics != -1 && mPlayerState.NextState != NULL) { if (--mPlayerTics <= 0) { mPlayerState = mPlayerState.NextState; mPlayerTics = mPlayerState.Tics; } } } //============================================================================= // // // //============================================================================= override void Draw(bool selected, ListMenuDescriptor desc) { if (mMode == 0 && !UpdatePlayerClass()) { return; } let playdef = GetDefaultByType((class)(mPlayerClass.Type)); Name portrait = playdef.Portrait; if (portrait != 'None' && !mNoportrait) { TextureID texid = TexMan.CheckForTexture(portrait, TexMan.Type_MiscPatch); DrawTexture (desc, texid, mXpos, mYpos); } else { // Here we need to calculate the coordinates manually because Screen.DrawFrame only works in window coordinates and have to match the rest to it. int x, y; int w = desc.DisplayWidth(); int h = desc.DisplayHeight(); double sx, sy; if (w == ListMenuDescriptor.CleanScale) { x = int(mXpos - 160) * CleanXfac + (screen.GetWidth() >> 1); y = int(mYpos - 100) * CleanYfac + (screen.GetHeight() >> 1); sx = CleanXfac; sy = CleanYfac; } else { double fx, fy, fw, fh; [fx, fy, fw, fh] = Screen.GetFullscreenRect(w, h, FSMode_ScaleToFit43); sx = fw / w; sy = fh / h; x = int(fx + mXpos * sx); y = int(fy + mYpos * sy); } int r = mBaseColor.r + mAddColor.r; int g = mBaseColor.g + mAddColor.g; int b = mBaseColor.b + mAddColor.b; int m = max(r, g, b); r = r * 255 / m; g = g * 255 / m; b = b * 255 / m; Color c = Color(255, r, g, b); screen.DrawTexture(mBackdrop, false, x, y - 1, DTA_DestWidthF, 72. * sx, DTA_DestHeightF, 80. * sy, DTA_Color, c, DTA_Masked, true); Screen.DrawFrame (x, y, int(72*sx), int(80*sy-1)); if (mPlayerState != NULL) { Vector2 Scale; TextureID sprite; bool flip; [sprite, flip, Scale] = mPlayerState.GetSpriteTexture(mRotation, mSkin, playdef.Scale); if (sprite.IsValid()) { int trans = mTranslate? Translation.MakeID(TRANSLATION_Players, MAXPLAYERS) : 0; let tscale = TexMan.GetScaledSize(sprite); Scale.X *= sx * tscale.X; Scale.Y *= sy * tscale.Y; screen.DrawTexture (sprite, false, x + 36*sx, y + 71*sy, DTA_DestWidthF, Scale.X, DTA_DestHeightF, Scale.Y, DTA_TranslationIndex, trans, DTA_FlipX, flip); } } } } } //============================================================================= // // // //============================================================================= class PlayerMenuPlayerDisplay : ListMenuItemPlayerDisplay { void Init(Color c1, Color c2) { Super.Init(null, 0, 0, c1, c2, true, 'none'); } override void Drawer(bool selected) { int x = screen.GetWidth()/2 + NewPlayerMenu.PLAYERDISPLAY_X * CleanXfac_1; int y = NewPlayerMenu.PLAYERDISPLAY_Y * CleanYfac_1; int r = mBaseColor.r + mAddColor.r; int g = mBaseColor.g + mAddColor.g; int b = mBaseColor.b + mAddColor.b; int m = max(r, g, b); r = r * 255 / m; g = g * 255 / m; b = b * 255 / m; Color c = Color(255, r, g, b); screen.DrawTexture(mBackdrop, false, x, y - 1, DTA_DestWidth, NewPlayerMenu.PLAYERDISPLAY_W * CleanXfac_1, DTA_DestHeight, NewPlayerMenu.PLAYERDISPLAY_H * CleanYfac_1, DTA_Color, c, DTA_KeepRatio, mNoPortrait, DTA_Masked, true); Screen.DrawFrame (x, y, NewPlayerMenu.PLAYERDISPLAY_W*CleanXfac_1, NewPlayerMenu.PLAYERDISPLAY_H*CleanYfac_1-1); if (mPlayerState != NULL) { Vector2 Scale; TextureID sprite; bool flip; let playdef = GetDefaultByType((class)(mPlayerClass.Type)); [sprite, flip, Scale] = mPlayerState.GetSpriteTexture(mRotation, mSkin, playdef.Scale); if (sprite.IsValid()) { int trans = mTranslate? Translation.MakeID(TRANSLATION_Players, MAXPLAYERS) : 0; let tscale = TexMan.GetScaledSize(sprite); Scale.X *= CleanXfac_1 * tscale.X * 2; Scale.Y *= CleanYfac_1 * tscale.Y * 2; screen.DrawTexture (sprite, false, x + (NewPlayerMenu.PLAYERDISPLAY_W/2) * CleanXfac_1, y + (NewPlayerMenu.PLAYERDISPLAY_H-16) * CleanYfac_1, DTA_DestWidthF, Scale.X, DTA_DestHeightF, Scale.Y, DTA_TranslationIndex, trans, DTA_KeepRatio, mNoPortrait, DTA_FlipX, flip); } } } } /* ** playermenu.cpp ** The player setup menu ** **--------------------------------------------------------------------------- ** Copyright 2001-2010 Randy Heit ** Copyright 2010-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ extend class Menu { static native void StartGameDirect(bool hasPlayerClass, bool randomPlayerClass, Class playerClass, int Episode, int Skill); } class PlayerMenu : ListMenu { int mRotation; int PlayerClassIndex; PlayerClass mPlayerClass; Array PlayerColorSets; Array mPlayerSkins; // All write function for the player config are native to prevent abuse. static native void AutoaimChanged(float val); static native void TeamChanged(int val); static native void AlwaysRunChanged(int val); static native void GenderChanged(int val); static native void SwitchOnPickupChanged(int val); static native void ColorChanged(int red, int green, int blue); static native void ColorSetChanged(int red); static native void PlayerNameChanged(String name); static native void SkinChanged (int val); static native void ClassChanged(int sel, PlayerClass cls); //============================================================================= // // // //============================================================================= protected void UpdateTranslation() { Translation.SetPlayerTranslation(TRANSLATION_Players, MAXPLAYERS, consoleplayer, mPlayerClass); } protected void SendNewColor (int red, int green, int blue) { ColorChanged(red, green, blue); UpdateTranslation(); } //============================================================================= // // // //============================================================================= override void Init(Menu parent, ListMenuDescriptor desc) { MenuItemBase li; PlayerInfo p = players[consoleplayer]; Super.Init(parent, desc); PickPlayerClass(); mRotation = 0; li = GetItem('Playerdisplay'); if (li != NULL) { li.SetValue(ListMenuItemPlayerDisplay.PDF_ROTATION, 0); li.SetValue(ListMenuItemPlayerDisplay.PDF_MODE, 1); li.SetValue(ListMenuItemPlayerDisplay.PDF_TRANSLATE, 1); li.SetValue(ListMenuItemPlayerDisplay.PDF_CLASS, p.GetPlayerClassNum()); if (mPlayerClass != NULL && !(GetDefaultByType (mPlayerClass.Type).bNoSkin) && p.GetPlayerClassNum() != -1) { li.SetValue(ListMenuItemPlayerDisplay.PDF_SKIN, p.GetSkin()); } } li = GetItem('Playerbox'); if (li != NULL) { li.SetString(0, p.GetUserName()); } li = GetItem('Team'); if (li != NULL) { li.SetString(0, "None"); for(int i=0;i= 0 ? pclass : pclass + 1); } } UpdateSkins(); li = GetItem('Gender'); if (li != NULL) { li.SetValue(0, p.GetGender()); } li = GetItem('Autoaim'); if (li != NULL) { li.SetValue(0, int(p.GetAutoaim())); } li = GetItem('Switch'); if (li != NULL) { li.SetValue(0, p.GetNeverSwitch()); } li = GetItem('AlwaysRun'); if (li != NULL) { li.SetValue(0, cl_run); } if (mDesc.mSelectedItem < 0) mDesc.mSelectedItem = 1; } //============================================================================= // // // //============================================================================= protected void PickPlayerClass(int pick = -100) { int pclass = 0; // [GRB] Pick a class from player class list if (PlayerClasses.Size () > 1) { pclass = pick == -100? players[consoleplayer].GetPlayerClassNum() : pick; if (pclass < 0) { pclass = (MenuTime() >> 7) % PlayerClasses.Size (); } } PlayerClassIndex = pclass; mPlayerClass = PlayerClasses[PlayerClassIndex]; UpdateTranslation(); } //============================================================================= // // // //============================================================================= protected void UpdateColorsets() { let li = GetItem('Color'); if (li != NULL) { int sel = 0; mPlayerClass.EnumColorSets(PlayerColorSets); li.SetString(0, "Custom"); for(int i = 0; i < PlayerColorSets.Size(); i++) { let cname = mPlayerClass.GetColorSetName(PlayerColorSets[i]); li.SetString(i+1, cname); } int mycolorset = players[consoleplayer].GetColorSet(); if (mycolorset != -1) { for(int i = 0; i < PlayerColorSets.Size(); i++) { if (PlayerColorSets[i] == mycolorset) { sel = i + 1; } } } li.SetValue(0, sel); } } //============================================================================= // // // //============================================================================= protected void UpdateSkins() { int sel = 0; int skin; let li = GetItem('Skin'); if (li != NULL) { if (GetDefaultByType (mPlayerClass.Type).bNoSkin || players[consoleplayer].GetPlayerClassNum() == -1) { li.SetString(0, "Base"); li.SetValue(0, 0); skin = 0; } else { mPlayerSkins.Clear(); for (int i = 0; i < PlayerSkins.Size(); i++) { if (mPlayerClass.CheckSkin(i)) { int j = mPlayerSkins.Push(i); li.SetString(j, PlayerSkins[i].SkinName); if (players[consoleplayer].GetSkin() == i) { sel = j; } } } li.SetValue(0, sel); skin = mPlayerSkins[sel]; } li = GetItem('Playerdisplay'); if (li != NULL) { li.SetValue(ListMenuItemPlayerDisplay.PDF_SKIN, skin); } } UpdateTranslation(); } //============================================================================= // // // //============================================================================= void ChangeClass (MenuItemBase li) { if (PlayerClasses.Size () == 1) { return; } bool res; int sel; [res, sel] = li.GetValue(0); if (res) { PickPlayerClass(gameinfo.norandomplayerclass ? sel : sel-1); ClassChanged(sel, mPlayerClass); UpdateSkins(); UpdateColorsets(); UpdateTranslation(); li = GetItem('Playerdisplay'); if (li != NULL) { li.SetValue(ListMenuItemPlayerDisplay.PDF_CLASS, players[consoleplayer].GetPlayerClassNum()); } } } //============================================================================= // // // //============================================================================= protected void ChangeSkin (MenuItemBase li) { if (GetDefaultByType (mPlayerClass.Type).bNoSkin || players[consoleplayer].GetPlayerClassNum() == -1) { return; } bool res; int sel; [res, sel] = li.GetValue(0); if (res) { sel = mPlayerSkins[sel]; SkinChanged(sel); UpdateTranslation(); li = GetItem('Playerdisplay'); if (li != NULL) { li.SetValue(ListMenuItemPlayerDisplay.PDF_SKIN, sel); } } } //============================================================================= // // // //============================================================================= override bool OnUIEvent(UIEvent ev) { if (ev.Type == UIEvent.Type_Char && ev.KeyChar == 32) { // turn the player sprite around mRotation = 8 - mRotation; MenuItemBase li = GetItem('Playerdisplay'); if (li != NULL) { li.SetValue(ListMenuItemPlayerDisplay.PDF_ROTATION, mRotation); } return true; } return Super.OnUIEvent(ev); } //============================================================================= // // // //============================================================================= override bool MenuEvent (int mkey, bool fromcontroller) { int v; bool res; String s; if (mDesc.mSelectedItem >= 0) { let li = mDesc.mItems[mDesc.mSelectedItem]; if (li.MenuEvent(mkey, fromcontroller)) { Name ctrl = li.GetAction(); switch(ctrl) { // item specific handling comes here case 'Playerbox': if (mkey == MKEY_Input) { [res, s] = li.GetString(0); if (res) PlayerNameChanged(s); } break; case 'Team': [res, v] = li.GetValue(0); if (res) TeamChanged(v); break; case 'Color': [res, v] = li.GetValue(0); if (res) { int mycolorset = -1; if (v > 0) mycolorset = PlayerColorSets[v - 1]; let red = GetItem('Red'); let green = GetItem('Green'); let blue = GetItem('Blue'); // disable the sliders if a valid colorset is selected if (red != NULL) red.Enable(mycolorset == -1); if (green != NULL) green.Enable(mycolorset == -1); if (blue != NULL) blue.Enable(mycolorset == -1); ColorSetChanged(v - 1); UpdateTranslation(); } break; case 'Red': [res, v] = li.GetValue(0); if (res) { Color colr = players[consoleplayer].GetColor(); SendNewColor (v, colr.g, colr.b); } break; case 'Green': [res, v] = li.GetValue(0); if (res) { Color colr = players[consoleplayer].GetColor(); SendNewColor (colr.r, v, colr.b); } break; case 'Blue': [res, v] = li.GetValue(0); if (res) { Color colr = players[consoleplayer].GetColor(); SendNewColor (colr.r, colr.g, v); } break; case 'Class': [res, v] = li.GetValue(0); if (res) { ChangeClass(li); } break; case 'Skin': ChangeSkin(li); break; case 'Gender': [res, v] = li.GetValue(0); if (res) { GenderChanged(v); } break; case 'Autoaim': [res, v] = li.GetValue(0); if (res) { AutoaimChanged(v); } break; case 'Switch': [res, v] = li.GetValue(0); if (res) { SwitchOnPickupChanged(v); } break; case 'AlwaysRun': [res, v] = li.GetValue(0); if (res) { AlwaysRunChanged(v); } break; default: break; } return true; } } return Super.MenuEvent(mkey, fromcontroller); } //============================================================================= // // // //============================================================================= override bool MouseEvent(int type, int x, int y) { let li = mFocusControl; bool res = Super.MouseEvent(type, x, y); if (li == NULL) li = mFocusControl; if (li != NULL) { // Check if the colors have changed Name ctrl = li.GetAction(); bool resv; int v; [resv, v]= li.GetValue(0); switch(ctrl) { case 'Red': if (resv) { Color colr = players[consoleplayer].GetColor(); SendNewColor (v, colr.g, colr.b); } break; case 'Green': if (resv) { Color colr = players[consoleplayer].GetColor(); SendNewColor (colr.r, v, colr.b); } break; case 'Blue': if (resv) { Color colr = players[consoleplayer].GetColor(); SendNewColor (colr.r, colr.g, v); } break; case 'Autoaim': AutoaimChanged(v); break; } } return res; } //============================================================================= // // // //============================================================================= override void Drawer () { Super.Drawer(); String str = Stringtable.Localize("$PLYRMNU_PRESSSPACE"); screen.DrawText (SmallFont, Font.CR_GOLD, 320 - 32 - 32 - SmallFont.StringWidth (str)/2, 130, str, DTA_Clean, true); str = Stringtable.Localize(mRotation ? "$PLYRMNU_SEEFRONT" : "$PLYRMNU_SEEBACK"); screen.DrawText (SmallFont, Font.CR_GOLD, 320 - 32 - 32 - SmallFont.StringWidth (str)/2, 130 + SmallFont.GetHeight (), str, DTA_Clean, true); } } /* ** player_cheat.txt ** **--------------------------------------------------------------------------- ** Copyright 1999-2016 Randy Heit ** Copyright 2006-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ extend class PlayerPawn { enum EAll { ALL_NO, ALL_YES, ALL_YESYES } native void CheatSuicide(); private bool CheckArtifact(class type) { return !(type is "PuzzleItem") && !(type is "Powerup") && !(type is "Ammo") && !(type is "Armor") && !(type is "Key") && !(type is "Weapon"); } virtual void CheatGive (String name, int amount) { int i; Class type; let player = self.player; if (player.mo == NULL || player.health <= 0) { return; } int giveall = ALL_NO; if (name ~== "all") { giveall = ALL_YES; } else if (name ~== "everything") { giveall = ALL_YESYES; } if (name ~== "health") { if (amount > 0) { health += amount; player.health = health; } else { player.health = health = GetMaxHealth(true); } } if (giveall || name ~== "backpack") { // Select the correct type of backpack based on the game type = (class)(gameinfo.backpacktype); if (type != NULL) { GiveInventory(type, 1, true); } if (!giveall) return; } if (giveall || name ~== "ammo") { // Find every unique type of ammo. Give it to the player if // he doesn't have it already, and set each to its maximum. for (i = 0; i < AllActorClasses.Size(); ++i) { let ammotype = (class)(AllActorClasses[i]); if (ammotype && GetDefaultByType(ammotype).GetParentAmmo() == ammotype) { let ammoitem = FindInventory(ammotype); if (ammoitem == NULL) { ammoitem = Inventory(Spawn (ammotype)); ammoitem.AttachToOwner (self); ammoitem.Amount = ammoitem.MaxAmount; } else if (ammoitem.Amount < ammoitem.MaxAmount) { ammoitem.Amount = ammoitem.MaxAmount; } } } if (!giveall) return; } if (giveall || name ~== "armor") { if (gameinfo.gametype != GAME_Hexen) { let armoritem = BasicArmorPickup(Spawn("BasicArmorPickup")); armoritem.SaveAmount = 100*deh.BlueAC; armoritem.SavePercent = gameinfo.Armor2Percent > 0 ? gameinfo.Armor2Percent * 100 : 50; if (!armoritem.CallTryPickup (self)) { armoritem.Destroy (); } } else { for (i = 0; i < 4; ++i) { let armoritem = Inventory(Spawn("HexenArmor")); armoritem.health = i; armoritem.Amount = 0; if (!armoritem.CallTryPickup (self)) { armoritem.Destroy (); } } } if (!giveall) return; } if (giveall || name ~== "keys") { for (int i = 0; i < AllActorClasses.Size(); ++i) { if (AllActorClasses[i] is "Key") { let keyitem = GetDefaultByType (AllActorClasses[i]); if (keyitem.special1 != 0) { let item = Inventory(Spawn(AllActorClasses[i])); if (!item.CallTryPickup (self)) { item.Destroy (); } } } } if (!giveall) return; } if (giveall || name ~== "weapons") { let savedpending = player.PendingWeapon; for (i = 0; i < AllActorClasses.Size(); ++i) { let type = (class)(AllActorClasses[i]); if (type != null && type != "Weapon" && !type.isAbstract()) { // Don't give replaced weapons unless the replacement was done by Dehacked. let rep = GetReplacement(type); if (rep == type || rep is "DehackedPickup") { // Give the weapon only if it is set in a weapon slot. if (player.weapons.LocateWeapon(type)) { readonly def = GetDefaultByType (type); if (giveall == ALL_YESYES || !def.bCheatNotWeapon) { GiveInventory(type, 1, true); } } } } } player.PendingWeapon = savedpending; if (!giveall) return; } if (giveall || name ~== "artifacts") { for (i = 0; i < AllActorClasses.Size(); ++i) { type = (class)(AllActorClasses[i]); if (type!= null) { let def = GetDefaultByType (type); if (def.Icon.isValid() && (def.MaxAmount > 1 || def.bAutoActivate == false) && CheckArtifact(type)) { // Do not give replaced items unless using "give everything" if (giveall == ALL_YESYES || GetReplacement(type) == type) { GiveInventory(type, amount <= 0 ? def.MaxAmount : amount, true); } } } } if (!giveall) return; } if (giveall || name ~== "puzzlepieces") { for (i = 0; i < AllActorClasses.Size(); ++i) { let type = (class)(AllActorClasses[i]); if (type != null) { let def = GetDefaultByType (type); if (def.Icon.isValid()) { // Do not give replaced items unless using "give everything" if (giveall == ALL_YESYES || GetReplacement(type) == type) { GiveInventory(type, amount <= 0 ? def.MaxAmount : amount, true); } } } } if (!giveall) return; } if (giveall) return; type = name; if (type == NULL) { if (PlayerNumber() == consoleplayer) A_Log(String.Format("Unknown item \"%s\"\n", name)); } else { GiveInventory(type, amount, true); } return; } void CheatTakeType(class deletetype) { for (int i = 0; i < AllActorClasses.Size(); ++i) { let type = (class)(AllActorClasses[i]); if (type != null && type is deletetype) { let pack = FindInventory(type); if (pack) pack.DepleteOrDestroy(); } } } virtual void CheatTake (String name, int amount) { bool takeall; Class type; let player = self.player; if (player.mo == NULL || player.health <= 0) { return; } takeall = name ~== "all"; if (!takeall && name ~== "health") { if (player.mo.health - amount <= 0 || player.health - amount <= 0 || amount == 0) { CheatSuicide (); if (PlayerNumber() == consoleplayer) Console.HideConsole (); return; } if (amount > 0) { if (player.mo) { player.mo.health -= amount; player.health = player.mo.health; } else { player.health -= amount; } } if (!takeall) return; } if (takeall || name ~== "backpack") { CheatTakeType("BackpackItem"); if (!takeall) return; } if (takeall || name ~== "ammo") { CheatTakeType("Ammo"); if (!takeall) return; } if (takeall || name ~== "armor") { CheatTakeType("Armor"); if (!takeall) return; } if (takeall || name ~== "keys") { CheatTakeType("Key"); if (!takeall) return; } if (takeall || name ~== "weapons") { CheatTakeType("Weapon"); CheatTakeType("WeaponHolder"); player.ReadyWeapon = null; player.PendingWeapon = WP_NOCHANGE; if (!takeall) return; } if (takeall || name ~== "artifacts") { for (int i = 0; i < AllActorClasses.Size(); ++i) { type = (class)(AllActorClasses[i]); if (type!= null && CheckArtifact(type)) { let pack = FindInventory(type); if (pack) pack.Destroy(); } } if (!takeall) return; } if (takeall || name ~== "puzzlepieces") { CheatTakeType("PuzzleItem"); if (!takeall) return; } if (takeall) return; type = name; if (type == NULL) { if (PlayerNumber() == consoleplayer) A_Log(String.Format("Unknown item \"%s\"\n", name)); } else { TakeInventory(type, max(amount, 1)); } return; } virtual void CheatSetInv(String strng, int amount, bool beyond) { if (!(strng ~== "health")) { if (amount <= 0) { CheatSuicide(); return; } if (!beyond) amount = MIN(amount, player.mo.GetMaxHealth(true)); player.health = player.mo.health = amount; } else { class item = strng; if (item != null) { player.mo.SetInventory(item, amount, beyond); return; } Console.Printf("Unknown item \"%s\"\n", strng); } } virtual String CheatMorph(class morphClass, bool quickundo) { let oldclass = GetClass(); // Set the standard morph style for the current game int style = MRF_UNDOBYTOMEOFPOWER; if (gameinfo.gametype == GAME_Hexen) style |= MRF_UNDOBYCHAOSDEVICE; if (player.morphTics) { if (UndoPlayerMorph (player)) { if (!quickundo && oldclass != morphclass && MorphPlayer (player, morphclass, 0, style)) { return StringTable.Localize("$TXT_STRANGER"); } return StringTable.Localize("$TXT_NOTSTRANGE"); } } else if (MorphPlayer (player, morphclass, 0, style)) { return StringTable.Localize("$TXT_STRANGE"); } return ""; } virtual void CheatTakeWeaps() { if (player.morphTics || health <= 0) { return; } // Do not mass-delete directly from the linked list. That can cause problems. Array collect; // Take away all weapons that are either non-wimpy or use ammo. for(let item = Inv; item; item = item.Inv) { let weap = Weapon(item); if (weap && (!weap.bWimpy_Weapon || weap.AmmoType1 != null)) { collect.Push(item); } } // Destroy them in a second loop. We have to look out for indirect destructions here as will happen with powered up weapons. for(int i = 0; i < collect.Size(); i++) { let item = collect[i]; if (item) item.Destroy(); } } } struct AutoUseHealthInfo play { Array collectedItems[2]; int collectedHealth[2]; void AddItemToList(Inventory item, int list) { collectedItems[list].Push(item); collectedHealth[list] += Item.Amount * Item.health; } int UseHealthItems(int list, in out int saveHealth) { int saved = 0; while (collectedItems[list].Size() > 0 && saveHealth > 0) { int maxhealth = 0; int index = -1; // Find the largest item in the list for(int i = 0; i < collectedItems[list].Size(); i++) { // Workaround for a deficiency in the expression resolver. let item = list == 0? collectedItems[0][i] : collectedItems[1][i]; if (Item.health > maxhealth) { index = i; maxhealth = Item.health; } } // Now apply the health items, using the same logic as Heretic and Hexen. int count = (saveHealth + maxhealth-1) / maxhealth; for(int i = 0; i < count; i++) { saved += maxhealth; saveHealth -= maxhealth; let item = list == 0? collectedItems[0][index] : collectedItems[1][index]; if (--item.Amount == 0) { item.DepleteOrDestroy (); collectedItems[list].Delete(index); break; } } } return saved; } } extend class PlayerPawn { //=========================================================================== // // // //=========================================================================== ui void InvNext() { Inventory next; let old = InvSel; if (InvSel != NULL) { if ((next = InvSel.NextInv()) != NULL) { InvSel = next; } else { // Select the first item in the inventory InvSel = FirstInv(); } if (InvSel) InvSel.DisplayNameTag(); } player.inventorytics = 5*TICRATE; if (old != InvSel) { A_StartSound("misc/invchange", CHAN_AUTO, CHANF_DEFAULT, 1., ATTN_NONE); } } //=========================================================================== // // PlayerPawn :: InvPrev // //=========================================================================== ui void InvPrev() { Inventory item, newitem; let old = InvSel; if (InvSel != NULL) { if ((item = InvSel.PrevInv()) != NULL) { InvSel = item; } else { // Select the last item in the inventory item = InvSel; while ((newitem = item.NextInv()) != NULL) { item = newitem; } InvSel = item; } if (InvSel) InvSel.DisplayNameTag(); } player.inventorytics = 5*TICRATE; if (old != InvSel) { A_StartSound("misc/invchange", CHAN_AUTO, CHANF_DEFAULT, 1., ATTN_NONE); } } //=========================================================================== // // PlayerPawn :: AddInventory // //=========================================================================== override void AddInventory (Inventory item) { // Adding inventory to a voodoo doll should add it to the real player instead. if (player != NULL && player.mo != self && player.mo != NULL) { player.mo.AddInventory (item); return; } Super.AddInventory (item); // If nothing is selected, select this item. if (InvSel == NULL && item.bInvBar) { InvSel = item; } } //=========================================================================== // // PlayerPawn :: RemoveInventory // //=========================================================================== override void RemoveInventory (Inventory item) { bool pickWeap = false; // Since voodoo dolls aren't supposed to have an inventory, there should be // no need to redirect them to the real player here as there is with AddInventory. // If the item removed is the selected one, select something else, either the next // item, if there is one, or the previous item. if (player != NULL) { if (InvSel == item) { InvSel = item.NextInv (); if (InvSel == NULL) { InvSel = item.PrevInv (); } } if (InvFirst == item) { InvFirst = item.NextInv (); if (InvFirst == NULL) { InvFirst = item.PrevInv (); } } if (item == player.PendingWeapon) { player.PendingWeapon = WP_NOCHANGE; } if (item == player.ReadyWeapon) { // If the current weapon is removed, clear the refire counter and pick a new one. pickWeap = true; player.ReadyWeapon = NULL; player.refire = 0; } } Super.RemoveInventory (item); if (pickWeap && player.mo == self && player.PendingWeapon == WP_NOCHANGE) { PickNewWeapon (NULL); } } //=========================================================================== // // PlayerPawn :: UseInventory // //=========================================================================== override bool UseInventory (Inventory item) { let itemtype = item.GetClass(); if (player.cheats & CF_TOTALLYFROZEN) { // You can't use items if you're totally frozen return false; } if (isFrozen()) { // Time frozen return false; } if (!Super.UseInventory (item)) { // Heretic and Hexen advance the inventory cursor if the use failed. // Should this behavior be retained? return false; } if (player == players[consoleplayer]) { A_StartSound(item.UseSound, CHAN_ITEM); StatusBar.FlashItem (itemtype); // Fixme: This shouldn't be called from here, because it is in the UI. } return true; } //--------------------------------------------------------------------------- // // PROC P_AutoUseHealth // //--------------------------------------------------------------------------- void AutoUseHealth(int saveHealth) { AutoUseHealthInfo collector; for(Inventory inv = self.Inv; inv != NULL; inv = inv.Inv) { let hp = HealthPickup(inv); if (hp && hp.Amount > 0) { int mode = hp.autousemode; if (mode == 1 || mode == 2) collector.AddItemToList(inv, mode-1); } } bool skilluse = !!G_SkillPropertyInt(SKILLP_AutoUseHealth); if (skilluse && collector.collectedHealth[0] >= saveHealth) { // Use quartz flasks player.health += collector.UseHealthItems(0, saveHealth); } else if (collector.collectedHealth[1] >= saveHealth) { // Use mystic urns player.health += collector.UseHealthItems(1, saveHealth); } else if (skilluse && collector.collectedHealth[0] + collector.collectedHealth[1] >= saveHealth) { // Use mystic urns and quartz flasks player.health += collector.UseHealthItems(0, saveHealth); if (saveHealth > 0) player.health += collector.UseHealthItems(1, saveHealth); } health = player.health; } //============================================================================ // // P_AutoUseStrifeHealth // //============================================================================ void AutoUseStrifeHealth () { Array Items; for(Inventory inv = self.Inv; inv != NULL; inv = inv.Inv) { let hp = HealthPickup(inv); if (hp && hp.Amount > 0) { if (hp.autousemode == 3) Items.Push(inv); } } if (!sv_disableautohealth) { while (Items.Size() > 0) { int maxhealth = 0; int index = -1; // Find the largest item in the list for(int i = 0; i < Items.Size(); i++) { if (Items[i].health > maxhealth) { index = i; maxhealth = Items[i].Amount; } } while (player.health < 50) { let item = Items[index]; if (item == null || !UseInventory (item)) break; } if (player.health >= 50) return; // Using all of this item was not enough so delete it and restart with the next best one Items.Delete(index); } } } //============================================================================ // // Helper for 'useflechette' CCMD. // //============================================================================ protected virtual Inventory GetFlechetteItem() { // Select from one of arti_poisonbag1-3, whichever the player has static const Class bagtypes[] = { "ArtiPoisonBag3", // use type 3 first because that's the default when the player has none specified. "ArtiPoisonBag1", "ArtiPoisonBag2" }; if (FlechetteType != NULL) { let item = FindInventory(FlechetteType); if (item != null) { return item; } } // The default flechette could not be found, or the player had no default. Try all 3 types then. for (int j = 0; j < 3; ++j) { let item = FindInventory(bagtypes[j]); if (item != null) { return item; } } return null; } } extend class PlayerPawn { private native void Substitute(PlayerPawn replacement); //=========================================================================== // // EndAllPowerupEffects // // Calls EndEffect() on every Powerup in the inventory list. // //=========================================================================== void InitAllPowerupEffects() { let item = Inv; while (item != null) { let power = Powerup(item); if (power != null) { power.InitEffect(); } item = item.Inv; } } //=========================================================================== // // EndAllPowerupEffects // // Calls EndEffect() on every Powerup in the inventory list. // //=========================================================================== void EndAllPowerupEffects() { let item = Inv; while (item != null) { let power = Powerup(item); if (power != null) { power.EndEffect(); } item = item.Inv; } } //=========================================================================== // // // //=========================================================================== virtual void ActivateMorphWeapon () { class morphweaponcls = MorphWeapon; player.PendingWeapon = WP_NOCHANGE; if (player.ReadyWeapon != null) { let psp = player.GetPSprite(PSP_WEAPON); if (psp) { psp.y = WEAPONTOP; player.ReadyWeapon.ResetPSprite(psp); } } if (morphweaponcls == null || !(morphweaponcls is 'Weapon')) { // No weapon at all while morphed! player.ReadyWeapon = null; } else { player.ReadyWeapon = Weapon(FindInventory (morphweaponcls)); if (player.ReadyWeapon == null) { player.ReadyWeapon = Weapon(GiveInventoryType (morphweaponcls)); if (player.ReadyWeapon != null) { player.ReadyWeapon.GivenAsMorphWeapon = true; // flag is used only by new beastweap semantics in UndoPlayerMorph } } if (player.ReadyWeapon != null) { player.SetPsprite(PSP_WEAPON, player.ReadyWeapon.GetReadyState()); } } if (player.ReadyWeapon != null) { player.SetPsprite(PSP_FLASH, null); } player.PendingWeapon = WP_NOCHANGE; } //--------------------------------------------------------------------------- // // MorphPlayer // // Returns true if the player gets turned into a chicken/pig. // // TODO: Allow morphed players to receive weapon sets (not just one weapon), // since they have their own weapon slots now. // //--------------------------------------------------------------------------- virtual bool MorphPlayer(playerinfo activator, Class spawntype, int duration, int style, Class enter_flash = null, Class exit_flash = null) { if (bDontMorph) { return false; } if (bInvulnerable && (player != activator || !(style & MRF_WHENINVULNERABLE))) { // Immune when invulnerable unless this is a power we activated return false; } if (player.morphTics) { // Player is already a beast if ((GetClass() == spawntype) && bCanSuperMorph && (player.morphTics < (((duration) ? duration : DEFMORPHTICS) - TICRATE)) && FindInventory('PowerWeaponLevel2', true) == null) { // Make a super chicken GiveInventoryType ('PowerWeaponLevel2'); } return false; } if (health <= 0) { // Dead players cannot morph return false; } if (spawntype == null) { return false; } if (!(spawntype is 'PlayerPawn')) { return false; } if (spawntype == GetClass()) { return false; } let morphed = PlayerPawn(Spawn (spawntype, Pos, NO_REPLACE)); // Use GetClass in the event someone actually allows replacements. PreMorph(morphed, false); morphed.PreMorph(self, true); EndAllPowerupEffects(); Substitute(morphed); if ((style & MRF_TRANSFERTRANSLATION) && !morphed.bDontTranslate) { morphed.Translation = Translation; } if (tid != 0 && (style & MRF_NEWTIDBEHAVIOUR)) { morphed.ChangeTid(tid); ChangeTid(0); } morphed.Angle = Angle; morphed.target = target; morphed.tracer = tracer; morphed.alternative = self; morphed.FriendPlayer = FriendPlayer; morphed.DesignatedTeam = DesignatedTeam; morphed.Score = Score; player.PremorphWeapon = player.ReadyWeapon; morphed.special2 = bSolid * 2 + bShootable * 4 + bInvisible * 0x40; // The factors are for savegame compatibility morphed.player = player; if (morphed.ViewHeight > player.viewheight && player.deltaviewheight == 0) { // If the new view height is higher than the old one, start moving toward it. player.deltaviewheight = player.GetDeltaViewHeight(); } morphed.bShadow |= bShadow; morphed.bNoGravity |= bNoGravity; morphed.bFly |= bFly; morphed.bGhost |= bGhost; if (enter_flash == null) enter_flash = 'TeleportFog'; let eflash = Spawn(enter_flash, Pos + (0, 0, gameinfo.telefogheight), ALLOW_REPLACE); let p = player; player = null; alternative = morphed; bSolid = false; bShootable = false; bUnmorphed = true; bInvisible = true; p.morphTics = (duration) ? duration : DEFMORPHTICS; // [MH] Used by SBARINFO to speed up face drawing p.MorphedPlayerClass = spawntype; p.MorphStyle = style; if (exit_flash == null) exit_flash = 'TeleportFog'; p.MorphExitFlash = exit_flash; p.health = morphed.health; p.mo = morphed; p.vel = (0, 0); morphed.ObtainInventory (self); // Remove all armor for (Inventory item = morphed.Inv; item != null; ) { let next = item.Inv; if (item is 'Armor') { item.DepleteOrDestroy(); } item = next; } morphed.InitAllPowerupEffects(); morphed.ActivateMorphWeapon (); if (p.camera == self) // can this happen? { p.camera = morphed; } morphed.ClearFOVInterpolation(); morphed.ScoreIcon = ScoreIcon; // [GRB] if (eflash) eflash.target = morphed; PostMorph(morphed, false); // No longer the current body morphed.PostMorph(self, true); // This is the current body return true; } //---------------------------------------------------------------------------- // // FUNC UndoPlayerMorph // //---------------------------------------------------------------------------- virtual bool UndoPlayerMorph(playerinfo activator, int unmorphflag = 0, bool force = false) { if (alternative == null) { return false; } let player = self.player; bool DeliberateUnmorphIsOkay = !!(MRF_STANDARDUNDOING & unmorphflag); if ((bInvulnerable) // If the player is invulnerable && ((player != activator) // and either did not decide to unmorph, || (!((player.MorphStyle & MRF_WHENINVULNERABLE) // or the morph style does not allow it || (DeliberateUnmorphIsOkay))))) // (but standard morph styles always allow it), { // Then the player is immune to the unmorph. return false; } let altmo = PlayerPawn(alternative); altmo.SetOrigin (Pos, false); altmo.bSolid = true; bSolid = false; if (!force && !altmo.TestMobjLocation()) { // Didn't fit altmo.bSolid = false; bSolid = true; player.morphTics = 2*TICRATE; return false; } PreUnmorph(altmo, false); // This body's about to be left. altmo.PreUnmorph(self, true); // This one's about to become current. // No longer using tracer as morph storage. That is what 'alternative' is for. // If the tracer has changed on the morph, change the original too. altmo.target = target; altmo.tracer = tracer; self.player = null; altmo.alternative = alternative = null; // Remove the morph power if the morph is being undone prematurely. for (Inventory item = Inv; item != null;) { let next = item.Inv; if (item is "PowerMorph") { item.Destroy(); } item = next; } EndAllPowerupEffects(); altmo.ObtainInventory (self); Substitute(altmo); if ((tid != 0) && (player.MorphStyle & MRF_NEWTIDBEHAVIOUR)) { altmo.ChangeTid(tid); } altmo.Angle = Angle; altmo.player = player; altmo.reactiontime = 18; altmo.bSolid = !!(special2 & 2); altmo.bShootable = !!(special2 & 4); altmo.bInvisible = !!(special2 & 0x40); altmo.Vel = (0, 0, Vel.Z); player.Vel = (0, 0); altmo.floorz = floorz; altmo.bShadow = bShadow; altmo.bNoGravity = bNoGravity; altmo.bGhost = bGhost; altmo.bUnmorphed = false; altmo.Score = Score; altmo.InitAllPowerupEffects(); let exit_flash = player.MorphExitFlash; bool correctweapon = !!(player.MorphStyle & MRF_LOSEACTUALWEAPON); bool undobydeathsaves = !!(player.MorphStyle & MRF_UNDOBYDEATHSAVES); player.morphTics = 0; player.MorphedPlayerClass = null; player.MorphStyle = 0; player.MorphExitFlash = null; player.viewheight = altmo.ViewHeight; Inventory level2 = altmo.FindInventory("PowerWeaponLevel2", true); if (level2 != null) { level2.Destroy (); } if ((player.health > 0) || undobydeathsaves) { player.health = altmo.health = altmo.SpawnHealth(); } else // killed when morphed so stay dead { altmo.health = player.health; } player.mo = altmo; if (player.camera == self) { player.camera = altmo; } altmo.ClearFOVInterpolation(); // [MH] // If the player that was morphed is the one // taking events, reset up the face, if any; // this is only needed for old-skool skins // and for the original DOOM status bar. if (player == players[consoleplayer]) { if (face != 'None') { // Assume root-level base skin to begin with let skinindex = 0; let skin = player.GetSkin(); // If a custom skin was in use, then reload it // or else the base skin for the player class. if (skin >= PlayerClasses.Size () && skin < PlayerSkins.Size()) { skinindex = skin; } else if (PlayerClasses.Size () > 1) { let whatami = altmo.GetClass(); for (int i = 0; i < PlayerClasses.Size (); ++i) { if (PlayerClasses[i].Type == whatami) { skinindex = i; break; } } } } } Actor eflash = null; if (exit_flash != null) { eflash = Spawn(exit_flash, Vec3Angle(20., altmo.Angle, gameinfo.telefogheight), ALLOW_REPLACE); if (eflash) eflash.target = altmo; } WeaponSlots.SetupWeaponSlots(altmo); // Use original class's weapon slots. let beastweap = player.ReadyWeapon; if (player.PremorphWeapon != null) { player.PremorphWeapon.PostMorphWeapon (); } else { player.ReadyWeapon = player.PendingWeapon = null; } if (correctweapon) { // Better "lose morphed weapon" semantics class morphweaponcls = MorphWeapon; if (morphweaponcls != null && morphweaponcls is 'Weapon') { let OriginalMorphWeapon = Weapon(altmo.FindInventory (morphweapon)); if ((OriginalMorphWeapon != null) && (OriginalMorphWeapon.GivenAsMorphWeapon)) { // You don't get to keep your morphed weapon. if (OriginalMorphWeapon.SisterWeapon != null) { OriginalMorphWeapon.SisterWeapon.Destroy (); } OriginalMorphWeapon.Destroy (); } } } else // old behaviour (not really useful now) { // Assumptions made here are no longer valid if (beastweap != null) { // You don't get to keep your morphed weapon. if (beastweap.SisterWeapon != null) { beastweap.SisterWeapon.Destroy (); } beastweap.Destroy (); } } PostUnmorph(altmo, false); // This body is no longer current. altmo.PostUnmorph(self, true); // altmo body is current. Destroy (); // Restore playerclass armor to its normal amount. let hxarmor = HexenArmor(altmo.FindInventory('HexenArmor')); if (hxarmor != null) { hxarmor.Slots[4] = altmo.HexenArmor[0]; } return true; } //=========================================================================== // // // //=========================================================================== override Actor, int, int MorphedDeath() { // Voodoo dolls should not unmorph the real player here. if (player && (player.mo == self) && (player.morphTics) && (player.MorphStyle & MRF_UNDOBYDEATH) && (alternative)) { Actor realme = alternative; int realstyle = player.MorphStyle; int realhealth = health; if (UndoPlayerMorph(player, 0, !!(player.MorphStyle & MRF_UNDOBYDEATHFORCED))) { return realme, realstyle, realhealth; } } return null, 0, 0; } } //=========================================================================== // // // //=========================================================================== class MorphProjectile : Actor { Class PlayerClass; Class MonsterClass, MorphFlash, UnMorphFlash; int Duration, MorphStyle; Default { Damage 1; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS } override int DoSpecialDamage (Actor target, int damage, Name damagetype) { if (target.player) { // Voodoo dolls forward this to the real player target.player.mo.MorphPlayer (NULL, PlayerClass, Duration, MorphStyle, MorphFlash, UnMorphFlash); } else { target.MorphMonster (MonsterClass, Duration, MorphStyle, MorphFlash, UnMorphFlash); } return -1; } } //=========================================================================== // // // //=========================================================================== class MorphedMonster : Actor { Actor UnmorphedMe; int UnmorphTime, MorphStyle; Class MorphExitFlash; int FlagsSave; Default { Monster; -COUNTKILL +FLOORCLIP } private native void Substitute(Actor replacement); override void OnDestroy () { if (UnmorphedMe != NULL) { UnmorphedMe.Destroy (); } Super.OnDestroy(); } override void Die (Actor source, Actor inflictor, int dmgflags, Name MeansOfDeath) { Super.Die (source, inflictor, dmgflags, MeansOfDeath); if (UnmorphedMe != NULL && UnmorphedMe.bUnmorphed) { UnmorphedMe.health = health; UnmorphedMe.Die (source, inflictor, dmgflags, MeansOfDeath); } } override void Tick () { if (UnmorphTime > level.time || !UndoMonsterMorph()) { Super.Tick(); } } //---------------------------------------------------------------------------- // // FUNC P_UndoMonsterMorph // // Returns true if the monster unmorphs. // //---------------------------------------------------------------------------- virtual bool UndoMonsterMorph(bool force = false) { if (UnmorphTime == 0 || UnmorphedMe == NULL || bStayMorphed || UnmorphedMe.bStayMorphed) { return false; } let unmorphed = UnmorphedMe; unmorphed.SetOrigin (Pos, false); unmorphed.bSolid = true; bSolid = false; bool save = bTouchy; bTouchy = false; if (!force && !unmorphed.TestMobjLocation ()) { // Didn't fit unmorphed.bSolid = false; bSolid = true; bTouchy = save; UnmorphTime = level.time + 5*TICRATE; // Next try in 5 seconds return false; } PreUnmorph(unmorphed, false); unmorphed.PreUnmorph(self, true); unmorphed.Angle = Angle; unmorphed.target = target; unmorphed.bShadow = bShadow; unmorphed.bGhost = bGhost; unmorphed.bSolid = !!(flagssave & 2); unmorphed.bShootable = !!(flagssave & 4); unmorphed.bInvisible = !!(flagssave & 0x40); unmorphed.health = unmorphed.SpawnHealth(); unmorphed.Vel = Vel; unmorphed.ChangeTid(tid); unmorphed.special = special; unmorphed.Score = Score; unmorphed.args[0] = args[0]; unmorphed.args[1] = args[1]; unmorphed.args[2] = args[2]; unmorphed.args[3] = args[3]; unmorphed.args[4] = args[4]; unmorphed.CopyFriendliness (self, true); unmorphed.bUnmorphed = false; PostUnmorph(unmorphed, false); // From is false here: Leaving the caller's body. unmorphed.PostUnmorph(self, true); // True here: Entering this body from here. UnmorphedMe = NULL; Substitute(unmorphed); Destroy (); let eflash = Spawn(MorphExitFlash, Pos + (0, 0, gameinfo.TELEFOGHEIGHT), ALLOW_REPLACE); if (eflash) eflash.target = unmorphed; return true; } //=========================================================================== // // // //=========================================================================== override Actor, int, int MorphedDeath() { let realme = UnmorphedMe; if (realme != NULL) { if ((UnmorphTime) && (MorphStyle & MRF_UNDOBYDEATH)) { int realstyle = MorphStyle; int realhealth = health; if (UndoMonsterMorph(!!(MorphStyle & MRF_UNDOBYDEATHFORCED))) { return realme, realstyle, realhealth; } } if (realme.bBossDeath) { realme.health = 0; // make sure that A_BossDeath considers it dead. realme.A_BossDeath(); } } return null, 0, 0; } } //=========================================================================== // // Zombie man // //=========================================================================== class ZombieMan : Actor { Default { Health 20; Radius 20; Height 56; Speed 8; PainChance 200; Monster; +FLOORCLIP SeeSound "grunt/sight"; AttackSound "grunt/attack"; PainSound "grunt/pain"; DeathSound "grunt/death"; ActiveSound "grunt/active"; Obituary "$OB_ZOMBIE"; Tag "$FN_ZOMBIE"; DropItem "Clip"; } States { Spawn: POSS AB 10 A_Look; Loop; See: POSS AABBCCDD 4 A_Chase; Loop; Missile: POSS E 10 A_FaceTarget; POSS F 8 A_PosAttack; POSS E 8; Goto See; Pain: POSS G 3; POSS G 3 A_Pain; Goto See; Death: POSS H 5; POSS I 5 A_Scream; POSS J 5 A_NoBlocking; POSS K 5; POSS L -1; Stop; XDeath: POSS M 5; POSS N 5 A_XScream; POSS O 5 A_NoBlocking; POSS PQRST 5; POSS U -1; Stop; Raise: POSS K 5; POSS JIH 5; Goto See; } } //=========================================================================== // // Sergeant / Shotgun guy // //=========================================================================== class ShotgunGuy : Actor { Default { Health 30; Radius 20; Height 56; Mass 100; Speed 8; PainChance 170; Monster; +FLOORCLIP SeeSound "shotguy/sight"; AttackSound "shotguy/attack"; PainSound "shotguy/pain"; DeathSound "shotguy/death"; ActiveSound "shotguy/active"; Obituary "$OB_SHOTGUY"; Tag "$FN_SHOTGUN"; DropItem "Shotgun"; } States { Spawn: SPOS AB 10 A_Look; Loop; See: SPOS AABBCCDD 3 A_Chase; Loop; Missile: SPOS E 10 A_FaceTarget; SPOS F 10 BRIGHT A_SposAttackUseAtkSound; SPOS E 10; Goto See; Pain: SPOS G 3; SPOS G 3 A_Pain; Goto See; Death: SPOS H 5; SPOS I 5 A_Scream; SPOS J 5 A_NoBlocking; SPOS K 5; SPOS L -1; Stop; XDeath: SPOS M 5; SPOS N 5 A_XScream; SPOS O 5 A_NoBlocking; SPOS PQRST 5; SPOS U -1; Stop; Raise: SPOS L 5; SPOS KJIH 5; Goto See; } } //=========================================================================== // // Chaingunner // //=========================================================================== class ChaingunGuy : Actor { Default { Health 70; Radius 20; Height 56; Mass 100; Speed 8; PainChance 170; Monster; +FLOORCLIP SeeSound "chainguy/sight"; PainSound "chainguy/pain"; DeathSound "chainguy/death"; ActiveSound "chainguy/active"; AttackSound "chainguy/attack"; Obituary "$OB_CHAINGUY"; Tag "$FN_HEAVY"; Dropitem "Chaingun"; } States { Spawn: CPOS AB 10 A_Look; Loop; See: CPOS AABBCCDD 3 A_Chase; Loop; Missile: CPOS E 10 A_FaceTarget; CPOS FE 4 BRIGHT A_CPosAttack; CPOS F 1 A_CPosRefire; Goto Missile+1; Pain: CPOS G 3; CPOS G 3 A_Pain; Goto See; Death: CPOS H 5; CPOS I 5 A_Scream; CPOS J 5 A_NoBlocking; CPOS KLM 5; CPOS N -1; Stop; XDeath: CPOS O 5; CPOS P 5 A_XScream; CPOS Q 5 A_NoBlocking; CPOS RS 5; CPOS T -1; Stop; Raise: CPOS N 5; CPOS MLKJIH 5; Goto See; } } //=========================================================================== // // SS Nazi // //=========================================================================== class WolfensteinSS : Actor { Default { Health 50; Radius 20; Height 56; Speed 8; PainChance 170; Monster; +FLOORCLIP SeeSound "wolfss/sight"; PainSound "wolfss/pain"; DeathSound "wolfss/death"; ActiveSound "wolfss/active"; AttackSound "wolfss/attack"; Obituary "$OB_WOLFSS"; Tag "$FN_WOLFSS"; Dropitem "Clip"; } States { Spawn: SSWV AB 10 A_Look; Loop; See: SSWV AABBCCDD 3 A_Chase; Loop; Missile: SSWV E 10 A_FaceTarget; SSWV F 10 A_FaceTarget; SSWV G 4 BRIGHT A_CPosAttack; SSWV F 6 A_FaceTarget; SSWV G 4 BRIGHT A_CPosAttack; SSWV F 1 A_CPosRefire; Goto Missile+1; Pain: SSWV H 3; SSWV H 3 A_Pain; Goto See; Death: SSWV I 5; SSWV J 5 A_Scream; SSWV K 5 A_NoBlocking; SSWV L 5; SSWV M -1; Stop; XDeath: SSWV N 5 ; SSWV O 5 A_XScream; SSWV P 5 A_NoBlocking; SSWV QRSTU 5; SSWV V -1; Stop; Raise: SSWV M 5; SSWV LKJI 5; Goto See ; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== extend class Actor { void A_PosAttack() { if (target) { A_FaceTarget(); double ang = angle; double slope = AimLineAttack(ang, MISSILERANGE); A_StartSound("grunt/attack", CHAN_WEAPON); ang += Random2[PosAttack]() * (22.5/256); int damage = Random[PosAttack](1, 5) * 3; LineAttack(ang, MISSILERANGE, slope, damage, "Hitscan", "Bulletpuff"); } } private void A_SPosAttackInternal() { if (target) { A_FaceTarget(); double bangle = angle; double slope = AimLineAttack(bangle, MISSILERANGE); for (int i=0 ; i<3 ; i++) { double ang = bangle + Random2[SPosAttack]() * (22.5/256); int damage = Random[SPosAttack](1, 5) * 3; LineAttack(ang, MISSILERANGE, slope, damage, "Hitscan", "Bulletpuff"); } } } void A_SPosAttackUseAtkSound() { if (target) { A_StartSound(AttackSound, CHAN_WEAPON); A_SPosAttackInternal(); } } // This version of the function, which uses a hard-coded sound, is meant for Dehacked only. void A_SPosAttack() { if (target) { A_StartSound("shotguy/attack", CHAN_WEAPON); A_SPosAttackInternal(); } } private void A_CPosAttackInternal(Sound snd) { if (target) { if (bStealth) visdir = 1; A_StartSound(snd, CHAN_WEAPON); A_FaceTarget(); double slope = AimLineAttack(angle, MISSILERANGE); double ang = angle + Random2[CPosAttack]() * (22.5/256); int damage = Random[CPosAttack](1, 5) * 3; LineAttack(ang, MISSILERANGE, slope, damage, "Hitscan", "Bulletpuff"); } } void A_CPosAttack() { A_CPosAttackInternal(AttackSound); } void A_CPosAttackDehacked() { A_CPosAttackInternal("chainguy/attack"); } void A_CPosRefire() { // keep firing unless target got out of sight A_FaceTarget(); if (Random[CPosRefire](0, 255) >= 40) { if (!target || HitFriend() || target.health <= 0 || !CheckSight(target, SF_SEEPASTBLOCKEVERYTHING|SF_SEEPASTSHOOTABLELINES)) { SetState(SeeState); } } } } class PowerupGiver : Inventory { Class PowerupType; int EffectTics; // Non-0 to override the powerup's default tics color BlendColor; // Non-0 to override the powerup's default blend Name Mode; // Meaning depends on powerup - used for Invulnerability and Invisibility double Strength; // Meaning depends on powerup - currently used only by Invisibility property prefix: Powerup; property Strength: Strength; property Mode: Mode; Default { Inventory.DefMaxAmount; +INVENTORY.INVBAR +INVENTORY.FANCYPICKUPSOUND Inventory.PickupSound "misc/p_pkup"; } //=========================================================================== // // APowerupGiver :: Use // //=========================================================================== override bool Use (bool pickup) { if (PowerupType == NULL) return true; // item is useless if (Owner == null) return true; let power = Powerup(Spawn (PowerupType)); if (EffectTics != 0) { power.EffectTics = EffectTics; } if (BlendColor != 0) { if (BlendColor != Powerup.SPECIALCOLORMAP_MASK | 65535) power.BlendColor = BlendColor; else power.BlendColor = 0; } if (Mode != 'None') { power.Mode = Mode; } if (Strength != 0) { power.Strength = Strength; } power.bAlwaysPickup |= bAlwaysPickup; power.bAdditiveTime |= bAdditiveTime; power.bNoTeleportFreeze |= bNoTeleportFreeze; if (power.CallTryPickup (Owner)) { return true; } power.GoAwayAndDie (); return false; } } class Powerup : Inventory { int EffectTics, MaxEffectTics; color BlendColor; Name Mode; // Meaning depends on powerup - used for Invulnerability and Invisibility double Strength; // Meaning depends on powerup - currently used only by Invisibility int Colormap; const SPECIALCOLORMAP_MASK = 0x00b60000; property Strength: Strength; property Mode: Mode; // Note, that while this is an inventory flag, it only has meaning on an active powerup. override bool GetNoTeleportFreeze() { return bNoTeleportFreeze; } //=========================================================================== // // APowerup :: Tick // //=========================================================================== override void Tick () { // Powerups cannot exist outside an inventory if (Owner == NULL) { Destroy (); } if (EffectTics == 0 || (EffectTics > 0 && --EffectTics == 0)) { Destroy (); } } //=========================================================================== // // APowerup :: HandlePickup // //=========================================================================== override bool HandlePickup (Inventory item) { if (item.GetClass() == GetClass()) { let power = Powerup(item); if (power.EffectTics == 0) { power.bPickupGood = true; return true; } // Color gets transferred if the new item has an effect. // Increase the effect's duration. if (power.bAdditiveTime) { EffectTics += power.EffectTics; MaxEffectTics = Max(EffectTics, MaxEffectTics); BlendColor = power.BlendColor; } // If it's not blinking yet, you can't replenish the power unless the // powerup is required to be picked up. else if (EffectTics > BLINKTHRESHOLD && !power.bAlwaysPickup) { return true; } // Reset the effect duration. else if (power.EffectTics > EffectTics) { EffectTics = MaxEffectTics = power.EffectTics; BlendColor = power.BlendColor; } power.bPickupGood = true; return true; } return false; } //=========================================================================== // // APowerup :: CreateCopy // //=========================================================================== override Inventory CreateCopy (Actor other) { // Get the effective effect time. EffectTics = MaxEffectTics = abs (EffectTics); // Abuse the Owner field to tell the // InitEffect method who started it; // this should be cleared afterwards, // as this powerup instance is not // properly attached to anything yet. Owner = other; // Actually activate the powerup. InitEffect (); // Clear the Owner field, unless it was // changed by the activation, for example, // if this instance is a morph powerup; // the flag tells the caller that the // ownership has changed so that they // can properly handle the situation. if (!bCreateCopyMoved) { Owner = NULL; } // All done. return self; } //=========================================================================== // // APowerup :: CreateTossable // // Powerups are never droppable, even without IF_UNDROPPABLE set. // //=========================================================================== override Inventory CreateTossable (int amount) { return NULL; } //=========================================================================== // // APowerup :: InitEffect // //=========================================================================== virtual void InitEffect() { // initialize this only once instead of recalculating repeatedly. Colormap = ((BlendColor & 0xFFFF0000) == SPECIALCOLORMAP_MASK)? BlendColor & 0xffff : PlayerInfo.NOFIXEDCOLORMAP; } //=========================================================================== // // APowerup :: DoEffect // //=========================================================================== override void DoEffect () { if (Owner == NULL || Owner.player == NULL) { return; } if (EffectTics > 0) { if (Colormap != PlayerInfo.NOFIXEDCOLORMAP) { if (!isBlinking()) { Owner.player.fixedcolormap = Colormap; } else if (Owner.player.fixedcolormap == Colormap) { // only unset if the fixed colormap comes from this item Owner.player.fixedcolormap = PlayerInfo.NOFIXEDCOLORMAP; } } } } //=========================================================================== // // APowerup :: EndEffect // //=========================================================================== virtual void EndEffect () { if (colormap != PlayerInfo.NOFIXEDCOLORMAP && Owner && Owner.player && Owner.player.fixedcolormap == colormap) { // only unset if the fixed colormap comes from this item Owner.player.fixedcolormap = PlayerInfo.NOFIXEDCOLORMAP; } } //=========================================================================== // // APowerup :: Destroy // //=========================================================================== override void OnDestroy () { EndEffect (); Super.OnDestroy(); } //=========================================================================== // // APowerup :: GetBlend // //=========================================================================== override color GetBlend () { if (Colormap != Player.NOFIXEDCOLORMAP) return 0; if (isBlinking()) return 0; return BlendColor; } //=========================================================================== // // Inventory :: GetPowerupIcon // // Returns the icon that should be drawn for an active powerup. // //=========================================================================== virtual clearscope version("2.5") TextureID GetPowerupIcon() const { return Icon; } //=========================================================================== // // APowerup :: isBlinking // //=========================================================================== virtual clearscope bool isBlinking() const { return (EffectTics <= BLINKTHRESHOLD && (EffectTics & 8) && !bNoScreenBlink); } //=========================================================================== // // APowerup :: OwnerDied // // Powerups don't last beyond death. // //=========================================================================== override void OwnerDied () { Destroy (); } } //=========================================================================== // // Invulnerable // //=========================================================================== class PowerInvulnerable : Powerup { Default { Powerup.Duration -30; inventory.icon "SPSHLD0"; } //=========================================================================== // // APowerInvulnerable :: InitEffect // //=========================================================================== override void InitEffect () { Super.InitEffect(); Owner.bRespawnInvul = false; Owner.bInvulnerable = true; if (Mode == 'None' && Owner is "PlayerPawn") { Mode = PlayerPawn(Owner).InvulMode; } if (Mode == 'Reflective') { Owner.bReflective = true; } } //=========================================================================== // // APowerInvulnerable :: DoEffect // //=========================================================================== override void DoEffect () { Super.DoEffect (); if (Owner == NULL) { return; } Owner.bInvulnerable = true; if (Mode == 'Reflective') { Owner.bReflective = true; } if (Mode == 'Ghost') { if (!Owner.bShadow) { // Don't mess with the translucency settings if an // invisibility powerup is active. let alpha = Owner.Alpha; if (!(Level.maptime & 7) && alpha > 0 && alpha < 1) { if (alpha == HX_SHADOW) { alpha = HX_ALTSHADOW; } else { alpha = 0; Owner.bNonShootable = true; } } if (!(Level.maptime & 31)) { if (alpha == 0) { Owner.bNonShootable = false; alpha = HX_ALTSHADOW; } else { alpha = HX_SHADOW; } } Owner.A_SetRenderStyle(alpha, STYLE_Translucent); } else { Owner.bNonShootable = false; } } } //=========================================================================== // // APowerInvulnerable :: EndEffect // //=========================================================================== override void EndEffect () { Super.EndEffect(); if (Owner == NULL) { return; } Owner.bRespawnInvul = false; Owner.bInvulnerable = false; if (Mode == 'Ghost') { Owner.bNonShootable = false; if (!bShadow) { // Don't mess with the translucency settings if an // invisibility powerup is active. Owner.A_SetRenderStyle(1, STYLE_Normal); } } else if (Mode == 'Reflective') { Owner.bReflective = false; } if (Owner.player != NULL) { Owner.player.fixedcolormap = PlayerInfo.NOFIXEDCOLORMAP; } } //=========================================================================== // // APowerInvulnerable :: AlterWeaponSprite // //=========================================================================== override void AlterWeaponSprite (VisStyle vis, in out int changed) { if (Owner != NULL) { if (Mode == 'Ghost' && !(Owner.bShadow)) { vis.Alpha = min(0.25 + Owner.Alpha * 0.75, 1.); } } } } //=========================================================================== // // Strength // //=========================================================================== class PowerStrength : Powerup { Default { Powerup.Duration 1; Powerup.Color "ff 00 00", 0.5; +INVENTORY.HUBPOWER } override bool HandlePickup (Inventory item) { if (item.GetClass() == GetClass()) { // Setting EffectTics to 0 will force Powerup's HandlePickup() // method to reset the tic count so you get the red flash again. EffectTics = 0; } return Super.HandlePickup (item); } //=========================================================================== // // APowerStrength :: DoEffect // //=========================================================================== override void Tick () { // Strength counts up to diminish the fade. EffectTics += 2; Super.Tick(); } //=========================================================================== // // APowerStrength :: GetBlend // //=========================================================================== override color GetBlend () { // slowly fade the berserk out int cnt = 128 - (EffectTics>>3); if (cnt > 0) { return Color(BlendColor.a*cnt/256, BlendColor.r, BlendColor.g, BlendColor.b); } return 0; } } //=========================================================================== // // Invisibility // //=========================================================================== class PowerInvisibility : Powerup { Default { +SHADOW; Powerup.Duration -60; Powerup.Strength 80; Powerup.Mode "Fuzzy"; } //=========================================================================== // // APowerInvisibility :: InitEffect // //=========================================================================== override void InitEffect () { Super.InitEffect(); let Owner = self.Owner; if (Owner != NULL) { let savedShadow = Owner.bShadow; let savedGhost = Owner.bGhost; let savedCantSeek = Owner.bCantSeek; Owner.bShadow = bShadow; Owner.bGhost = bGhost; Owner.bCantSeek = bCantSeek; bShadow = savedShadow; bGhost = savedGhost; bCantSeek = savedCantSeek; DoEffect(); } } //=========================================================================== // // APowerInvisibility :: DoEffect // //=========================================================================== override void DoEffect () { Super.DoEffect(); // Due to potential interference with other PowerInvisibility items // the effect has to be refreshed each tic. double ts = (Strength / 100.) * (special1 + 1); if (ts > 1.) ts = 1.; let newAlpha = clamp((1. - ts), 0., 1.); int newStyle; switch (Mode) { case 'Fuzzy': newStyle = STYLE_OptFuzzy; break; case 'Opaque': newStyle = STYLE_Normal; break; case 'Additive': newStyle = STYLE_Add; break; case 'Stencil': newStyle = STYLE_Stencil; break; case 'AddStencil' : newStyle = STYLE_AddStencil; break; case 'TranslucentStencil': newStyle = STYLE_TranslucentStencil; break; case 'None' : case 'Cumulative': case 'Translucent': newStyle = STYLE_Translucent; break; default: // Something's wrong newStyle = STYLE_Normal; newAlpha = 1.; break; } Owner.A_SetRenderStyle(newAlpha, newStyle); } //=========================================================================== // // APowerInvisibility :: EndEffect // //=========================================================================== override void EndEffect () { Super.EndEffect(); if (Owner != NULL) { Owner.bShadow = bShadow; Owner.bGhost = bGhost; Owner.bCantSeek = bCantSeek; Owner.A_SetRenderStyle(1, STYLE_Normal); // Check whether there are other invisibility items and refresh their effect. // If this isn't done there will be one incorrectly drawn frame when this // item expires. for(let item = Owner.Inv; item != null; item = item.Inv) { if (item != self && item is 'PowerInvisibility') { item.DoEffect(); } } } } //=========================================================================== // // APowerInvisibility :: AlterWeaponSprite // //=========================================================================== override void AlterWeaponSprite (VisStyle vis, in out int changed) { // Blink if the powerup is wearing off if (changed == 0 && EffectTics < 4*32 && !(EffectTics & 8)) { vis.RenderStyle = STYLE_Normal; vis.Alpha = 1.f; changed = 1; return; } else if (changed == 1) { // something else set the weapon sprite back to opaque but this item is still active. float ts = float((Strength / 100) * (special1 + 1)); vis.Alpha = clamp((1. - ts), 0., 1.); switch (Mode) { case 'Fuzzy': vis.RenderStyle = STYLE_OptFuzzy; break; case 'Opaque': vis.RenderStyle = STYLE_Normal; break; case 'Additive': vis.RenderStyle = STYLE_Add; break; case 'Stencil': vis.RenderStyle = STYLE_Stencil; break; case 'TranslucentStencil': vis.RenderStyle = STYLE_TranslucentStencil; break; case 'AddStencil': vis.RenderStyle = STYLE_AddStencil; break; case 'None': case 'Cumulative': case 'Translucent': default: vis.RenderStyle = STYLE_Translucent; break; } } // Handling of Strife-like cumulative invisibility powerups, the weapon itself shouldn't become invisible if ((vis.Alpha < 0.25f && special1 > 0) || (vis.Alpha == 0)) { vis.Alpha = clamp((1. - Strength/100.), 0., 1.); vis.invert = true; } changed = -1; // This item is valid so another one shouldn't reset the translucency } //=========================================================================== // // APowerInvisibility :: HandlePickup // // If the player already has the first stage of a cumulative powerup, getting // it again increases the player's alpha. (But shouldn't this be in Use()?) // //=========================================================================== override bool HandlePickup (Inventory item) { if (Mode == 'Cumulative' && ((Strength * special1) < 1.) && item.GetClass() == GetClass()) { let power = Powerup(item); if (power.EffectTics == 0) { power.bPickupGood = true; return true; } // Only increase the EffectTics, not decrease it. // Color also gets transferred only when the new item has an effect. if (power.EffectTics > EffectTics) { EffectTics = power.EffectTics; BlendColor = power.BlendColor; } special1++; // increases power power.bPickupGood = true; return true; } return Super.HandlePickup (item); } } class PowerGhost : PowerInvisibility { Default { +GHOST; Powerup.Duration -60; Powerup.Strength 60; Powerup.Mode "None"; } } class PowerShadow : PowerInvisibility { Default { +INVENTORY.HUBPOWER Powerup.Duration -55; Powerup.Strength 75; Powerup.Mode "Cumulative"; } } //=========================================================================== // // IronFeet // //=========================================================================== class PowerIronFeet : Powerup { Default { Powerup.Duration -60; Powerup.Color "00 ff 00", 0.125; Powerup.Mode "Normal"; } override void AbsorbDamage (int damage, Name damageType, out int newdamage, Actor inflictor, Actor source, int flags) { if (damageType == 'Drowning') { newdamage = 0; } } override void DoEffect () { if (Owner.player != NULL) { Owner.player.mo.ResetAirSupply (); } } } //=========================================================================== // // Mask // //=========================================================================== class PowerMask : PowerIronFeet { Default { Powerup.Duration -80; Powerup.Color "00 00 00", 0; +INVENTORY.HUBPOWER Inventory.Icon "I_MASK"; } override void AbsorbDamage (int damage, Name damageType, out int newdamage, Actor inflictor, Actor source, int flags) { if (damageType == 'Fire' || damageType == 'Drowning') { newdamage = 0; } } override void DoEffect () { Super.DoEffect (); if (!(Level.maptime & 0x3f)) { Owner.A_StartSound ("misc/mask", CHAN_AUTO); } } } //=========================================================================== // // LightAmp // //=========================================================================== class PowerLightAmp : Powerup { Default { Powerup.Duration -120; } //=========================================================================== // // APowerLightAmp :: DoEffect // //=========================================================================== override void DoEffect () { Super.DoEffect (); let player = Owner.player; if (player != NULL && player.fixedcolormap < PlayerInfo.NUMCOLORMAPS) { if (!isBlinking()) { player.fixedlightlevel = 1; } else { player.fixedlightlevel = -1; } } } //=========================================================================== // // APowerLightAmp :: EndEffect // //=========================================================================== override void EndEffect () { Super.EndEffect(); if (Owner != NULL && Owner.player != NULL && Owner.player.fixedcolormap < PlayerInfo.NUMCOLORMAPS) { Owner.player.fixedlightlevel = -1; } } } //=========================================================================== // // Torch // //=========================================================================== class PowerTorch : PowerLightAmp { int NewTorch, NewTorchDelta; override void DoEffect () { if (Owner == NULL || Owner.player == NULL) { return; } let player = Owner.player; if (EffectTics <= BLINKTHRESHOLD || player.fixedcolormap >= PlayerInfo.NUMCOLORMAPS) { Super.DoEffect (); } else { Powerup.DoEffect (); if (!(Level.maptime & 16) && Owner.player != NULL) { if (NewTorch != 0) { if (player.fixedlightlevel + NewTorchDelta > 7 || player.fixedlightlevel + NewTorchDelta < 0 || NewTorch == player.fixedlightlevel) { NewTorch = 0; } else { player.fixedlightlevel += NewTorchDelta; } } else { NewTorch = random[torch](1, 8); NewTorchDelta = (NewTorch == Owner.player.fixedlightlevel) ? 0 : ((NewTorch > player.fixedlightlevel) ? 1 : -1); } } } } } //=========================================================================== // // Flight // //=========================================================================== class PowerFlight : Powerup { Default { Powerup.Duration -60; +INVENTORY.HUBPOWER } clearscope bool HitCenterFrame; //=========================================================================== // // APowerFlight :: InitEffect // //=========================================================================== override void InitEffect () { Super.InitEffect(); Owner.bFly = true; Owner.bNoGravity = true; if (Owner.pos.Z <= Owner.floorz) { Owner.Vel.Z = 4; // thrust the player in the air a bit } if (Owner.Vel.Z <= -35) { // stop falling scream Owner.A_StopSound (CHAN_VOICE); } } //=========================================================================== // // APowerFlight :: DoEffect // //=========================================================================== override void Tick () { // The Wings of Wrath only expire in multiplayer and non-hub games if (!multiplayer && level.infinite_flight) { EffectTics++; } Super.Tick (); } //=========================================================================== // // APowerFlight :: EndEffect // //=========================================================================== override void EndEffect () { Super.EndEffect(); if (Owner == NULL || Owner.player == NULL) { return; } if (!(Owner.bFlyCheat)) { if (Owner.pos.Z != Owner.floorz) { Owner.player.centering = true; } Owner.bFly = false; Owner.bNoGravity = false; } } //=========================================================================== // // APowerFlight :: DrawPowerup // //=========================================================================== override TextureID GetPowerupIcon () { // If this item got a valid icon use that instead of the default spinning wings. if (Icon.isValid()) { return Icon; } TextureID picnum = TexMan.CheckForTexture ("SPFLY0", TexMan.Type_MiscPatch); int frame = (Level.maptime/3) & 15; if (!picnum.isValid()) { return picnum; } if (Owner.bNoGravity) { if (HitCenterFrame && (frame != 15 && frame != 0)) { return picnum + 15; } else { HitCenterFrame = false; return picnum + frame; } } else { if (!HitCenterFrame && (frame != 15 && frame != 0)) { HitCenterFrame = false; return picnum + frame; } else { HitCenterFrame = true; return picnum+15; } } } } //=========================================================================== // // WeaponLevel2 // //=========================================================================== class PowerWeaponLevel2 : Powerup { Default { Powerup.Duration -40; Inventory.Icon "SPINBK0"; +INVENTORY.NOTELEPORTFREEZE } //=========================================================================== // // APowerWeaponLevel2 :: InitEffect // //=========================================================================== override void InitEffect () { Super.InitEffect(); let player = Owner.player; if (player == null) return; let weap = player.ReadyWeapon; if (weap == null) return; let sister = weap.SisterWeapon; if (sister == null) return; if (!sister.bPowered_Up) return; let ready = sister.GetReadyState(); if (weap.GetReadyState() != ready) { player.ReadyWeapon = sister; player.SetPsprite(PSP_WEAPON, ready); } else { PSprite psp = player.FindPSprite(PSprite.WEAPON); if (psp != null && psp.Caller == player.ReadyWeapon) { // If the weapon changes but the state does not, we have to manually change the PSprite's caller here. psp.Caller = sister; player.ReadyWeapon = sister; } else { // Something went wrong. Initiate a regular weapon change. player.PendingWeapon = sister; } } } //=========================================================================== // // APowerWeaponLevel2 :: EndEffect // //=========================================================================== override void EndEffect () { Super.EndEffect(); if (Owner == null) return; let player = Owner.player; if (player != NULL && player.mo != null) { player.mo.bWeaponLevel2Ended = true; } } } //=========================================================================== // // Speed // //=========================================================================== class PowerSpeed : Powerup { int NoTrail; Property NoTrail: NoTrail; FlagDef NoTrail: NoTrail, 0; // This was once a flag, not a property. Default { Powerup.Duration -45; Speed 1.5; Inventory.Icon "SPBOOT0"; +INVENTORY.NOTELEPORTFREEZE } override double GetSpeedFactor() { return Speed; } //=========================================================================== // // APowerSpeed :: DoEffect // //=========================================================================== override void DoEffect () { Super.DoEffect (); if (Owner == NULL || Owner.player == NULL) return; if (Owner.player.cheats & CF_PREDICTING) return; if (NoTrail) return; if (Level.maptime & 1) return; // Check if another speed item is present to avoid multiple drawing of the speed trail. // Only the last PowerSpeed without PSF_NOTRAIL set will actually draw the trail. for (Inventory item = Inv; item != NULL; item = item.Inv) { let sitem = PowerSpeed(item); if (sitem != null && !NoTrail) { return; } } if (Owner.Vel.Length() <= 12) return; Actor speedMo = Spawn("PlayerSpeedTrail", Owner.Pos, NO_REPLACE); if (speedMo) { speedMo.Angle = Owner.Angle; speedMo.Translation = Owner.Translation; speedMo.target = Owner; speedMo.sprite = Owner.sprite; speedMo.frame = Owner.frame; speedMo.Floorclip = Owner.Floorclip; // [BC] Also get the scale from the owner. speedMo.Scale = Owner.Scale; if (Owner == players[consoleplayer].camera && !(Owner.player.cheats & CF_CHASECAM)) { speedMo.bInvisible = true; } } } } // Player Speed Trail (used by the Speed Powerup) ---------------------------- class PlayerSpeedTrail : Actor { Default { +NOBLOCKMAP +NOGRAVITY Alpha 0.6; RenderStyle "Translucent"; } override void Tick() { Alpha -= .6 / 8; if (Alpha <= 0) { Destroy (); } } } //=========================================================================== // // Minotaur // //=========================================================================== class PowerMinotaur : Powerup { Default { Powerup.Duration -25; Inventory.Icon "SPMINO0"; } } //=========================================================================== // // Targeter // //=========================================================================== class PowerTargeter : Powerup { Default { Powerup.Duration -160; +INVENTORY.HUBPOWER } States { Targeter: TRGT A -1; Stop; TRGT B -1; Stop; TRGT C -1; Stop; } override void Travelled () { InitEffect (); } const POS_X = 160 - 3; const POS_Y = 100 - 3; override void InitEffect () { // Why is this called when the inventory isn't even attached yet // in APowerup.CreateCopy? if (!Owner.FindInventory(GetClass(), true)) return; let player = Owner.player; Super.InitEffect(); if (player == null) return; let stat = FindState("Targeter"); if (stat != null) { player.SetPsprite(PSprite.TARGETCENTER, stat); player.SetPsprite(PSprite.TARGETLEFT, stat + 1); player.SetPsprite(PSprite.TARGETRIGHT, stat + 2); } PSprite center = player.GetPSprite(PSprite.TARGETCENTER); if (center) { center.x = POS_X; center.y = POS_Y; } PositionAccuracy (); } override void AttachToOwner(Actor other) { Super.AttachToOwner(other); // Let's actually properly call this for the targeters. InitEffect(); } override bool HandlePickup(Inventory item) { if (Super.HandlePickup(item)) { InitEffect(); // reset the HUD sprites return true; } return false; } override void DoEffect () { Super.DoEffect (); if (Owner != null && Owner.player != null) { let player = Owner.player; PositionAccuracy (); if (EffectTics < 5*TICRATE) { let stat = FindState("Targeter"); if (stat != null) { if (EffectTics & 32) { player.SetPsprite(PSprite.TARGETRIGHT, null); player.SetPsprite(PSprite.TARGETLEFT, stat + 1); } else if (EffectTics & 16) { player.SetPsprite(PSprite.TARGETRIGHT, stat + 2); player.SetPsprite(PSprite.TARGETLEFT, null); } } } } } override void EndEffect () { Super.EndEffect(); if (Owner != null && Owner.player != null) { // Calling GetPSprite here could crash if we're creating a new game. // This is because P_SetupLevel nulls the player's mo before destroying // every DThinker which in turn ends up calling this. // However P_SetupLevel is only called after G_NewInit which calls // every player's dtor which destroys all their psprites. let player = Owner.player; PSprite pspr; if ((pspr = player.FindPSprite(PSprite.TARGETCENTER)) != null) pspr.SetState(null); if ((pspr = player.FindPSprite(PSprite.TARGETLEFT)) != null) pspr.SetState(null); if ((pspr = player.FindPSprite(PSprite.TARGETRIGHT)) != null) pspr.SetState(null); } } private void PositionAccuracy () { let player = Owner.player; if (player != null) { PSprite left = player.GetPSprite(PSprite.TARGETLEFT); if (left) { left.x = POS_X - (100 - player.mo.accuracy); left.y = POS_Y; } PSprite right = player.GetPSprite(PSprite.TARGETRIGHT); if (right) { right.x = POS_X + (100 - player.mo.accuracy); right.y = POS_Y; } } } } //=========================================================================== // // Frightener // //=========================================================================== class PowerFrightener : Powerup { Default { Powerup.Duration -60; } override void InitEffect () { Super.InitEffect(); if (Owner== null || Owner.player == null) return; Owner.player.cheats |= CF_FRIGHTENING; } override void EndEffect () { Super.EndEffect(); if (Owner== null || Owner.player == null) return; Owner.player.cheats &= ~CF_FRIGHTENING; } } //=========================================================================== // // Buddha // //=========================================================================== class PowerBuddha : Powerup { Default { Powerup.Duration -60; } } //=========================================================================== // // Scanner (this is active just by being present) // //=========================================================================== class PowerScanner : Powerup { Default { Powerup.Duration -80; +INVENTORY.HUBPOWER } } //=========================================================================== // // TimeFreezer // //=========================================================================== class PowerTimeFreezer : Powerup { Default { Powerup.Duration -12; } //=========================================================================== // // InitEffect // //=========================================================================== override void InitEffect() { int freezemask; Super.InitEffect(); if (Owner == null || Owner.player == null) return; // When this powerup is in effect, pause the music. S_PauseSound(false, false); // Give the player and his teammates the power to move when time is frozen. freezemask = 1 << Owner.PlayerNumber(); Owner.player.timefreezer |= freezemask; for (int i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] && players[i].mo != null && players[i].mo.IsTeammate(Owner) ) { players[i].timefreezer |= freezemask; } } // [RH] The effect ends one tic after the counter hits zero, so make // sure we start at an odd count. EffectTics += !(EffectTics & 1); if ((EffectTics & 1) == 0) { EffectTics++; } // Make sure the effect starts and ends on an even tic. if ((Level.maptime & 1) == 0) { Level.SetFrozen(true); } else { // Compensate for skipped tic, but beware of overflow. if(EffectTics < 0x7fffffff) EffectTics++; } } //=========================================================================== // // APowerTimeFreezer :: DoEffect // //=========================================================================== override void DoEffect() { Super.DoEffect(); // [RH] Do not change LEVEL_FROZEN on odd tics, or the Revenant's tracer // will get thrown off. // [ED850] Don't change it if the player is predicted either. if (Level.maptime & 1 || (Owner != null && Owner.player != null && Owner.player.cheats & CF_PREDICTING)) { return; } // [RH] The "blinking" can't check against EffectTics exactly or it will // never happen, because InitEffect ensures that EffectTics will always // be odd when Level.maptime is even. Level.SetFrozen ( EffectTics > 4*32 || (( EffectTics > 3*32 && EffectTics <= 4*32 ) && ((EffectTics + 1) & 15) != 0 ) || (( EffectTics > 2*32 && EffectTics <= 3*32 ) && ((EffectTics + 1) & 7) != 0 ) || (( EffectTics > 32 && EffectTics <= 2*32 ) && ((EffectTics + 1) & 3) != 0 ) || (( EffectTics > 0 && EffectTics <= 1*32 ) && ((EffectTics + 1) & 1) != 0 )); } //=========================================================================== // // APowerTimeFreezer :: EndEffect // //=========================================================================== override void EndEffect() { Super.EndEffect(); // If there is an owner, remove the timefreeze flag corresponding to // her from all players. if (Owner != null && Owner.player != null) { int freezemask = ~(1 << Owner.PlayerNumber()); for (int i = 0; i < MAXPLAYERS; ++i) { players[i].timefreezer &= freezemask; } } // Are there any players who still have timefreezer bits set? for (int i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i] && players[i].timefreezer != 0) { return; } } // No, so allow other actors to move about freely once again. Level.SetFrozen(false); // Also, turn the music back on. S_ResumeSound(false); } } //=========================================================================== // // Damage // //=========================================================================== class PowerDamage : Powerup { Default { Powerup.Duration -25; } //=========================================================================== // // InitEffect // //=========================================================================== override void InitEffect() { Super.InitEffect(); if (Owner != null) { Owner.A_StartSound(SeeSound, CHAN_5, CHANF_DEFAULT, 1.0, ATTN_NONE); } } //=========================================================================== // // EndEffect // //=========================================================================== override void EndEffect() { Super.EndEffect(); if (Owner != null) { Owner.A_StartSound(DeathSound, CHAN_5, CHANF_DEFAULT, 1.0, ATTN_NONE); } } //=========================================================================== // // ModifyDamage // //=========================================================================== override void ModifyDamage(int damage, Name damageType, out int newdamage, bool passive, Actor inflictor, Actor source, int flags) { if (!passive && damage > 0) { newdamage = max(1, ApplyDamageFactors(GetClass(), damageType, damage, damage * 4)); if (Owner != null && newdamage > damage) Owner.A_StartSound(ActiveSound, CHAN_AUTO, CHANF_DEFAULT, 1.0, ATTN_NONE); } } } //=========================================================================== // // Protection // //=========================================================================== class PowerProtection : Powerup { Default { Powerup.Duration -25; } //=========================================================================== // // InitEffect // //=========================================================================== override void InitEffect() { Super.InitEffect(); let o = Owner; // copy to a local variable for quicker access. if (o != null) { o.A_StartSound(SeeSound, CHAN_AUTO, CHANF_DEFAULT, 1.0, ATTN_NONE); // Transfer various protection flags if owner does not already have them. // If the owner already has the flag, clear it from the powerup. // If the powerup still has a flag set, add it to the owner. bNoRadiusDmg &= !o.bNoRadiusDmg; o.bNoRadiusDmg |= bNoRadiusDmg; bDontMorph &= !o.bDontMorph; o.bDontMorph |= bDontMorph; bDontSquash &= !o.bDontSquash; o.bDontSquash |= bDontSquash; bDontBlast &= !o.bDontBlast; o.bDontBlast |= bDontBlast; bNoTeleOther &= !o.bNoTeleOther; o.bNoTeleOther |= bNoTeleOther; bNoPain &= !o.bNoPain; o.bNoPain |= bNoPain; bDontRip &= !o.bDontRip; o.bDontRip |= bDontRip; } } //=========================================================================== // // EndEffect // //=========================================================================== override void EndEffect() { Super.EndEffect(); let o = Owner; // copy to a local variable for quicker access. if (o != null) { o.A_StartSound(DeathSound, CHAN_AUTO, CHANF_DEFAULT, 1.0, ATTN_NONE); o.bNoRadiusDmg &= !bNoRadiusDmg; o.bDontMorph &= !bDontMorph; o.bDontSquash &= !bDontSquash; o.bDontBlast &= !bDontBlast; o.bNoTeleOther &= !bNoTeleOther; o.bNoPain &= !bNoPain; o.bDontRip &= !bDontRip; } } //=========================================================================== // // AbsorbDamage // //=========================================================================== override void ModifyDamage(int damage, Name damageType, out int newdamage, bool passive, Actor inflictor, Actor source, int flags) { if (passive && damage > 0) { newdamage = max(0, ApplyDamageFactors(GetClass(), damageType, damage, damage / 4)); if (Owner != null && newdamage < damage) Owner.A_StartSound(ActiveSound, CHAN_AUTO, CHANF_DEFAULT, 1.0, ATTN_NONE); } } } //=========================================================================== // // Drain // //=========================================================================== class PowerDrain : Powerup { Default { Powerup.Strength 0.5; Powerup.Duration -60; } } //=========================================================================== // // Regeneration // //=========================================================================== class PowerRegeneration : Powerup { Default { Powerup.Duration -120; Powerup.Strength 5; } override void DoEffect() { Super.DoEffect(); if (Owner != null && Owner.health > 0 && (Level.maptime & 31) == 0) { if (Owner.GiveBody(int(Strength))) { Owner.A_StartSound("*regenerate", CHAN_ITEM); } } } } //=========================================================================== // // HighJump // //=========================================================================== class PowerHighJump : Powerup { Default { Powerup.Strength 2; } } //=========================================================================== // // DoubleFiringSpeed // //=========================================================================== class PowerDoubleFiringSpeed : Powerup { Default { Powerup.Duration -40; } } //=========================================================================== // // InfiniteAmmo // //=========================================================================== class PowerInfiniteAmmo : Powerup { Default { Powerup.Duration -30; } } //=========================================================================== // // InfiniteAmmo // //=========================================================================== class PowerReflection : Powerup { // if 1, reflects the damage type as well. bool ReflectType; property ReflectType : ReflectType; Default { Powerup.Duration -60; DamageFactor 0.5; } } //=========================================================================== // // PowerMorph // //=========================================================================== class PowerMorph : Powerup { Class PlayerClass; Class MorphFlash, UnMorphFlash; int MorphStyle; PlayerInfo MorphedPlayer; Default { Powerup.Duration -40; } //=========================================================================== // // InitEffect // //=========================================================================== override void InitEffect() { Super.InitEffect(); if (Owner != null && Owner.player != null && PlayerClass != null) { let realplayer = Owner.player; // Remember the identity of the player if (realplayer.mo.MorphPlayer(realplayer, PlayerClass, 0x7fffffff/*INDEFINITELY*/, MorphStyle, MorphFlash, UnMorphFlash)) { Owner = realplayer.mo; // Replace the new owner in our owner; safe because we are not attached to anything yet bCreateCopyMoved = true; // Let the caller know the "real" owner has changed (to the morphed actor) MorphedPlayer = realplayer; // Store the player identity (morphing clears the unmorphed actor's "player" field) } else // morph failed - give the caller an opportunity to fail the pickup completely { bInitEffectFailed = true; // Let the caller know that the activation failed (can fail the pickup if appropriate) } } } //=========================================================================== // // EndEffect // //=========================================================================== override void EndEffect() { Super.EndEffect(); // Abort if owner already destroyed or unmorphed if (Owner == null || MorphedPlayer == null || Owner.alternative == null) { return; } // Abort if owner is dead; their Die() method will // take care of any required unmorphing on death. if (MorphedPlayer.health <= 0) { return; } int savedMorphTics = MorphedPlayer.morphTics; MorphedPlayer.mo.UndoPlayerMorph (MorphedPlayer, 0, !!(MorphedPlayer.MorphStyle & MRF_UNDOALWAYS)); MorphedPlayer = null; } } struct PPShader native { native clearscope static void SetEnabled(string shaderName, bool enable); native clearscope static void SetUniform1f(string shaderName, string uniformName, float value); native clearscope static void SetUniform2f(string shaderName, string uniformName, vector2 value); native clearscope static void SetUniform3f(string shaderName, string uniformName, vector3 value); native clearscope static void SetUniform1i(string shaderName, string uniformName, int value); } // Programmer --------------------------------------------------------------- class Programmer : Actor { Default { Health 1100; PainChance 50; Speed 26; FloatSpeed 5; Radius 45; Height 60; Mass 800; Damage 4; Monster; +NOGRAVITY +FLOAT +NOBLOOD +NOTDMATCH +DONTMORPH +NOBLOCKMONST +LOOKALLAROUND +NOICEDEATH +NOTARGETSWITCH DamageFactor "Fire", 0.5; MinMissileChance 150; Tag "$TAG_PROGRAMMER"; AttackSound "programmer/attack"; PainSound "programmer/pain"; DeathSound "programmer/death"; ActiveSound "programmer/active"; Obituary "$OB_PROGRAMMER"; DropItem "Sigil1"; } States { Spawn: PRGR A 5 A_Look; PRGR A 1 A_SentinelBob; Loop; See: PRGR A 160 A_SentinelBob; PRGR BCD 5 A_SentinelBob; PRGR EF 2 A_SentinelBob; PRGR EF 3 A_Chase; Goto See+4; Melee: PRGR E 2 A_SentinelBob; PRGR F 3 A_SentinelBob; PRGR E 3 A_FaceTarget; PRGR F 4 A_ProgrammerMelee; Goto See+4; Missile: PRGR G 5 A_FaceTarget; PRGR H 5 A_SentinelBob; PRGR I 5 Bright A_FaceTarget; PRGR J 5 Bright A_SpotLightning; Goto See+4; Pain: PRGR K 5 A_Pain; PRGR L 5 A_SentinelBob; Goto See+4; Death: PRGR L 7 Bright A_TossGib; PRGR M 7 Bright A_Scream; PRGR N 7 Bright A_TossGib; PRGR O 7 Bright A_NoBlocking; PRGR P 7 Bright A_TossGib; PRGR Q 7 Bright A_SpawnProgrammerBase; PRGR R 7 Bright; PRGR S 6 Bright; PRGR TUVW 5 Bright; PRGR X 32 Bright; PRGR X -1 Bright A_ProgrammerDeath; Stop; } //============================================================================ // // A_ProgrammerMelee // //============================================================================ void A_ProgrammerMelee () { if (target == null) return; A_FaceTarget (); if (!CheckMeleeRange ()) return; A_StartSound("programmer/clank", CHAN_WEAPON); int damage = random[Programmer](1, 10) * 6; int newdam = target.DamageMobj (self, self, damage, 'Melee'); target.TraceBleed (newdam > 0 ? newdam : damage, self); } //============================================================================ // // A_SpawnProgrammerBase // //============================================================================ void A_SpawnProgrammerBase () { Actor foo = Spawn("ProgrammerBase", Pos + (0,0,24), ALLOW_REPLACE); if (foo != null) { foo.Angle = Angle + 180. + Random2[Programmer]() * (360. / 1024.); foo.VelFromAngle(); foo.Vel.Z = random[Programmer]() / 128.; } } //============================================================================ // // A_ProgrammerDeath // //============================================================================ void A_ProgrammerDeath () { if (!CheckBossDeath ()) return; for (int i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i] && players[i].health > 0) { players[i].mo.GiveInventoryType ("ProgLevelEnder"); break; } } // the sky change scripts are now done as special actions in MAPINFO A_BossDeath(); } //============================================================================ // // A_SpotLightning // //============================================================================ void A_SpotLightning() { if (target == null) return; Actor spot = Spawn("SpectralLightningSpot", (target.pos.xy, target.floorz), ALLOW_REPLACE); if (spot != null) { spot.threshold = 25; spot.target = self; spot.FriendPlayer = 0; spot.tracer = target; } } } // The Programmer's base for when he dies ----------------------------------- class ProgrammerBase : Actor { Default { +NOBLOCKMAP +NOCLIP +NOBLOOD } States { Spawn: BASE A 5 Bright A_Explode(32,32,1,1); BASE BCD 5 Bright; BASE EFG 5; BASE H -1; Stop; } } // The Programmer level ending thing ---------------------------------------- class ProgLevelEnder : Inventory { Default { +INVENTORY.UNDROPPABLE } //============================================================================ // // AProgLevelEnder :: Tick // // Fade to black, end the level, then unfade. // //============================================================================ override void Tick () { if (special2 == 0) { // fade out over .66 second special1 += 255 / (TICRATE*2/3); if (++special1 >= 255) { special1 = 255; special2 = 1; Level.ExitLevel(0, false); } } else { // fade in over two seconds special1 -= 255 / (TICRATE*2); if (special1 <= 0) { Destroy (); } } } //============================================================================ // // AProgLevelEnder :: GetBlend // //============================================================================ override Color GetBlend () { return Color(special1, 0, 0, 0); } } // Yorick's Skull ----------------------------------------------------------- class PuzzSkull : PuzzleItem { Default { PuzzleItem.Number 0; Inventory.Icon "ARTISKLL"; Inventory.PickupMessage "$TXT_ARTIPUZZSKULL"; Tag "$TAG_ARTIPUZZSKULL"; } States { Spawn: ASKU A -1; Stop; } } // Heart of D'Sparil -------------------------------------------------------- class PuzzGemBig : PuzzleItem { Default { PuzzleItem.Number 1; Inventory.Icon "ARTIBGEM"; Inventory.PickupMessage "$TXT_ARTIPUZZGEMBIG"; Tag "$TAG_ARTIPUZZGEMBIG"; } States { Spawn: ABGM A -1; Stop; } } // Red Gem (Ruby Planet) ---------------------------------------------------- class PuzzGemRed : PuzzleItem { Default { PuzzleItem.Number 2; Inventory.Icon "ARTIGEMR"; Inventory.PickupMessage "$TXT_ARTIPUZZGEMRED"; Tag "$TAG_ARTIPUZZGEMRED"; } States { Spawn: AGMR A -1; Stop; } } // Green Gem 1 (Emerald Planet) --------------------------------------------- class PuzzGemGreen1 : PuzzleItem { Default { PuzzleItem.Number 3; Inventory.Icon "ARTIGEMG"; Inventory.PickupMessage "$TXT_ARTIPUZZGEMGREEN1"; Tag "$TAG_ARTIPUZZGEMGREEN1"; } States { Spawn: AGMG A -1; Stop; } } // Green Gem 2 (Emerald Planet) --------------------------------------------- class PuzzGemGreen2 : PuzzleItem { Default { PuzzleItem.Number 4; Inventory.Icon "ARTIGMG2"; Inventory.PickupMessage "$TXT_ARTIPUZZGEMGREEN2"; Tag "$TAG_ARTIPUZZGEMGREEN2"; } States { Spawn: AGG2 A -1; Stop; } } // Blue Gem 1 (Sapphire Planet) --------------------------------------------- class PuzzGemBlue1 : PuzzleItem { Default { PuzzleItem.Number 5; Inventory.Icon "ARTIGEMB"; Inventory.PickupMessage "$TXT_ARTIPUZZGEMBLUE1"; Tag "$TAG_ARTIPUZZGEMBLUE1"; } States { Spawn: AGMB A -1; Stop; } } // Blue Gem 2 (Sapphire Planet) --------------------------------------------- class PuzzGemBlue2 : PuzzleItem { Default { PuzzleItem.Number 6; Inventory.Icon "ARTIGMB2"; Inventory.PickupMessage "$TXT_ARTIPUZZGEMBLUE2"; Tag "$TAG_ARTIPUZZGEMBLUE2"; } States { Spawn: AGB2 A -1; Stop; } } // Book 1 (Daemon Codex) ---------------------------------------------------- class PuzzBook1 : PuzzleItem { Default { PuzzleItem.Number 7; Inventory.Icon "ARTIBOK1"; Inventory.PickupMessage "$TXT_ARTIPUZZBOOK1"; Tag "$TAG_ARTIPUZZBOOK1"; } States { Spawn: ABK1 A -1; Stop; } } // Book 2 (Liber Oscura) ---------------------------------------------------- class PuzzBook2 : PuzzleItem { Default { PuzzleItem.Number 8; Inventory.Icon "ARTIBOK2"; Inventory.PickupMessage "$TXT_ARTIPUZZBOOK2"; Tag "$TAG_ARTIPUZZBOOK2"; } States { Spawn: ABK2 A -1; Stop; } } // Flame Mask --------------------------------------------------------------- class PuzzFlameMask : PuzzleItem { Default { PuzzleItem.Number 9; Inventory.Icon "ARTISKL2"; Inventory.PickupMessage "$TXT_ARTIPUZZSKULL2"; Tag "$TAG_ARTIPUZZSKULL2"; } States { Spawn: ASK2 A -1; Stop; } } // Fighter Weapon (Glaive Seal) --------------------------------------------- class PuzzFWeapon : PuzzleItem { Default { PuzzleItem.Number 10; Inventory.Icon "ARTIFWEP"; Inventory.PickupMessage "$TXT_ARTIPUZZFWEAPON"; Tag "$TAG_ARTIPUZZFWEAPON"; } States { Spawn: AFWP A -1; Stop; } } // Cleric Weapon (Holy Relic) ----------------------------------------------- class PuzzCWeapon : PuzzleItem { Default { PuzzleItem.Number 11; Inventory.Icon "ARTICWEP"; Inventory.PickupMessage "$TXT_ARTIPUZZCWEAPON"; Tag "$TAG_ARTIPUZZCWEAPON"; } States { Spawn: ACWP A -1; Stop; } } // Mage Weapon (Sigil of the Magus) ----------------------------------------- class PuzzMWeapon : PuzzleItem { Default { PuzzleItem.Number 12; Inventory.Icon "ARTIMWEP"; Inventory.PickupMessage "$TXT_ARTIPUZZMWEAPON"; Tag "$TAG_ARTIPUZZMWEAPON"; } States { Spawn: AMWP A -1; Stop; } } // Clock Gear 1 ------------------------------------------------------------- class PuzzGear1 : PuzzleItem { Default { PuzzleItem.Number 13; Inventory.Icon "ARTIGEAR"; Inventory.PickupMessage "$TXT_ARTIPUZZGEAR"; Tag "$TAG_ARTIPUZZGEAR1"; } States { Spawn: AGER ABCDEFGH 4 Bright; Loop; } } // Clock Gear 2 ------------------------------------------------------------- class PuzzGear2 : PuzzleItem { Default { PuzzleItem.Number 14; Inventory.Icon "ARTIGER2"; Inventory.PickupMessage "$TXT_ARTIPUZZGEAR"; Tag "$TAG_ARTIPUZZGEAR2"; } States { Spawn: AGR2 ABCDEFGH 4 Bright; Loop; } } // Clock Gear 3 ------------------------------------------------------------- class PuzzGear3 : PuzzleItem { Default { PuzzleItem.Number 15; Inventory.Icon "ARTIGER3"; Inventory.PickupMessage "$TXT_ARTIPUZZGEAR"; Tag "$TAG_ARTIPUZZGEAR3"; } States { Spawn: AGR3 ABCDEFGH 4 Bright; Loop; } } // Clock Gear 4 ------------------------------------------------------------- class PuzzGear4 : PuzzleItem { Default { PuzzleItem.Number 16; Inventory.Icon "ARTIGER4"; Inventory.PickupMessage "$TXT_ARTIPUZZGEAR"; Tag "$TAG_ARTIPUZZGEAR4"; } States { Spawn: AGR4 ABCDEFGH 4 Bright; Loop; } } //============================================================================= // // Option Search Query class represents a search query. // A search query consists constists of one or more terms (words). // // Query matching deponds on "os_is_any_of" variable. // If this variable is "true", the text matches the query if any of the terms // matches the query. // If this variable is "false", the text matches the query only if all the // terms match the query. // //============================================================================= class os_Query { static os_Query fromString(string str) { let query = new("os_Query"); str.Split(query.mQueryParts, " ", TOK_SKIPEMPTY); return query; } bool matches(string text, bool isSearchForAny) { return isSearchForAny ? matchesAny(text) : matchesAll(text); } // private: ////////////////////////////////////////////////////////////////// private bool matchesAny(string text) { int nParts = mQueryParts.size(); for (int i = 0; i < nParts; ++i) { string queryPart = mQueryParts[i]; if (contains(text, queryPart)) { return true; } } return false; } private bool matchesAll(string text) { int nParts = mQueryParts.size(); for (int i = 0; i < nParts; ++i) { string queryPart = mQueryParts[i]; if (!contains(text, queryPart)) { return false; } } return true; } private static bool contains(string str, string substr) { let lowerstr = str .MakeLower(); let lowersubstr = substr.MakeLower(); bool contains = (lowerstr.IndexOf(lowersubstr) != -1); return contains; } private Array mQueryParts; } /* * Quest Item Usage: * * 1 You got Beldin's ring * 2 You got the Chalice * 3 You got 300 gold, so it's time to visit Irale and the governor * 4 Accepted the governor's power coupling mission * 5 Accepted the governor's mission to kill Derwin * 6 You broke the Front's power coupling * 7 You took out the scanning team * 8 You got the broken power coupling * 9 You got the ear * 10 You got the prison pass * 11 You got the prison key * 12 You got the severed hand * 13 You've freed the prisoners! * 14 You've Blown Up the Crystal * 15 You got the guard uniform * 16 You've Blown Up the Gates (/Piston); * 17 You watched the Sigil slideshow on map10; * 18 You got the Oracle pass * 19 You met Quincy and talked to him about the Bishop * 20; * 21 You Killed the Bishop! * 22 The Oracle has told you to kill Macil * 23 You've Killed The Oracle! * 24 You Killed Macil! * 25 You've destroyed the Converter! * 26 You've Killed The Loremaster! * 27 You've Blown Up the Computer * 28 You got the catacomb key * 29 You destroyed the mind control device in the mines * 30; * 31; */ class QuestItem : Inventory { States { Spawn: TOKN A -1; Stop; } } // Quest Items ------------------------------------------------------------- class QuestItem1 : QuestItem { } class QuestItem2 : QuestItem { } class QuestItem3 : QuestItem { } class QuestItem4 : QuestItem { Default { Tag "$TAG_QUEST4"; } } class QuestItem5 : QuestItem { Default { Tag "$TAG_QUEST5"; } } class QuestItem6 : QuestItem { Default { Tag "TAG_QUEST6"; } } class QuestItem7 : QuestItem { } class QuestItem8 : QuestItem { } class QuestItem9 : QuestItem { } class QuestItem10 : QuestItem { } class QuestItem11 : QuestItem { } class QuestItem12 : QuestItem { } class QuestItem13 : QuestItem { } class QuestItem14 : QuestItem { } class QuestItem15 : QuestItem { } class QuestItem16 : QuestItem { } class QuestItem17 : QuestItem { } class QuestItem18 : QuestItem { } class QuestItem19 : QuestItem { } class QuestItem20 : QuestItem { } class QuestItem21 : QuestItem { } class QuestItem22 : QuestItem { } class QuestItem23 : QuestItem { } class QuestItem24 : QuestItem { } class QuestItem25 : QuestItem { } class QuestItem26 : QuestItem { } class QuestItem27 : QuestItem { } class QuestItem28 : QuestItem { } class QuestItem29 : QuestItem { } class QuestItem30 : QuestItem { } class QuestItem31 : QuestItem { } // Random spawner ---------------------------------------------------------- class RandomSpawner : Actor { const MAX_RANDOMSPAWNERS_RECURSION = 32; // Should be largely more than enough, honestly. Default { +NOBLOCKMAP +NOSECTOR +NOGRAVITY +THRUACTORS } virtual void PostSpawn(Actor spawned) {} static bool IsMonster(DropItem di) { class pclass = di.Name; if (null == pclass) { return false; } return GetDefaultByType(pclass).bIsMonster; } // Override this to decide what to spawn in some other way. // Return the class name, or 'None' to spawn nothing, or 'Unknown' to spawn an error marker. virtual Name ChooseSpawn() { DropItem di; // di will be our drop item list iterator DropItem drop; // while drop stays as the reference point. int n = 0; bool nomonsters = sv_nomonsters || level.nomonsters; drop = di = GetDropItems(); if (di != null) { while (di != null) { bool shouldSkip = (di.Name == 'None') || (nomonsters && IsMonster(di)); if (!shouldSkip) { int amt = di.Amount; if (amt < 0) amt = 1; // default value is -1, we need a positive value. n += amt; // this is how we can weight the list. } di = di.Next; } if (n == 0) { // Nothing left to spawn. They must have all been monsters, and monsters are disabled. return 'None'; } // Then we reset the iterator to the start position... di = drop; // Take a random number... n = random[randomspawn](0, n-1); // And iterate in the array up to the random number chosen. while (n > -1 && di != null) { if (di.Name != 'None' && (!nomonsters || !IsMonster(di))) { int amt = di.Amount; if (amt < 0) amt = 1; n -= amt; if ((di.Next != null) && (n > -1)) di = di.Next; else n = -1; } else { di = di.Next; } } if (di == null) { return 'Unknown'; } else if (random[randomspawn]() <= di.Probability) // prob 255 = always spawn, prob 0 = almost never spawn. { return di.Name; } else { return 'None'; } } else { return 'None'; } } // To handle "RandomSpawning" missiles, the code has to be split in two parts. // If the following code is not done in BeginPlay, missiles will use the // random spawner's velocity (0...) instead of their own. override void BeginPlay() { Super.BeginPlay(); let s = ChooseSpawn(); if (s == 'Unknown') // Spawn error markers immediately. { Spawn(s, Pos, NO_REPLACE); Destroy(); } else if (s == 'None') // ChooseSpawn chose to spawn nothing. { Destroy(); } else { // So now we can spawn the dropped item. // Handle replacement here so as to get the proper speed and flags for missiles Class cls = s; if (cls != null) { Class rep = GetReplacement(cls); if (rep != null) { cls = rep; } } if (cls != null) { Species = Name(cls); readonly defmobj = GetDefaultByType(cls); Speed = defmobj.Speed; bMissile |= defmobj.bMissile; bSeekerMissile |= defmobj.bSeekerMissile; bSpectral |= defmobj.bSpectral; } else { A_Log(TEXTCOLOR_RED .. "Unknown item class ".. s .." to drop from a random spawner\n"); Species = 'None'; } } } // The second half of random spawning. Now that the spawner is initialized, the // real actor can be created. If the following code were in BeginPlay instead, // missiles would not have yet obtained certain information that is absolutely // necessary to them -- such as their source and destination. override void PostBeginPlay() { Super.PostBeginPlay(); if (bouncecount >= MAX_RANDOMSPAWNERS_RECURSION) // Prevents infinite recursions { Spawn("Unknown", Pos, NO_REPLACE); // Show that there's a problem. Destroy(); return; } Actor newmobj = null; bool boss = false; if (Species == 'None') { Destroy(); return; } Class cls = Species; if (bMissile && target && target.target) // Attempting to spawn a missile. { if ((tracer == null) && bSeekerMissile) { tracer = target.target; } newmobj = target.SpawnMissileXYZ(Pos, target.target, cls, false); } else { newmobj = Spawn(cls, Pos, NO_REPLACE); } if (newmobj != null) { // copy everything relevant newmobj.SpawnAngle = SpawnAngle; newmobj.Angle = Angle; newmobj.Pitch = Pitch; newmobj.Roll = Roll; newmobj.SpawnPoint = SpawnPoint; newmobj.special = special; newmobj.args[0] = args[0]; newmobj.args[1] = args[1]; newmobj.args[2] = args[2]; newmobj.args[3] = args[3]; newmobj.args[4] = args[4]; newmobj.special1 = special1; newmobj.special2 = special2; newmobj.SpawnFlags = SpawnFlags & ~MTF_SECRET; // MTF_SECRET needs special treatment to avoid incrementing the secret counter twice. It had already been processed for the spawner itself. newmobj.HandleSpawnFlags(); newmobj.SpawnFlags = SpawnFlags; newmobj.bCountSecret = SpawnFlags & MTF_SECRET; // "Transfer" count secret flag to spawned actor newmobj.ChangeTid(tid); newmobj.Vel = Vel; newmobj.master = master; // For things such as DamageMaster/DamageChildren, transfer mastery. newmobj.target = target; newmobj.tracer = tracer; newmobj.CopyFriendliness(self, false); // This handles things such as projectiles with the MF4_SPECTRAL flag that have // a health set to -2 after spawning, for internal reasons. if (health != SpawnHealth()) newmobj.health = health; if (!bDropped) newmobj.bDropped = false; // Handle special altitude flags if (newmobj.bSpawnCeiling) { newmobj.SetZ(newmobj.ceilingz - newmobj.Height - SpawnPoint.Z); } else if (newmobj.bSpawnFloat) { double space = newmobj.ceilingz - newmobj.Height - newmobj.floorz; if (space > 48) { space -= 40; newmobj.SetZ((space * random[randomspawn]()) / 256. + newmobj.floorz + 40); } newmobj.AddZ(SpawnPoint.Z); } if (newmobj.bMissile && !(newmobj is 'RandomSpawner')) newmobj.CheckMissileSpawn(0); // Bouncecount is used to count how many recursions we're in. if (newmobj is 'RandomSpawner') newmobj.bouncecount = ++bouncecount; // If the spawned actor has either of those flags, it's a boss. if (newmobj.bBossDeath || newmobj.bBoss) boss = true; // If a replaced actor has either of those same flags, it's also a boss. readonly rep = GetDefaultByType(GetReplacee(GetClass())); if (rep && (rep.bBossDeath || rep.bBoss)) boss = true; PostSpawn(newmobj); } if (boss) tracer = newmobj; else // "else" because a boss-replacing spawner must wait until it can call A_BossDeath. Destroy(); } override void Tick() // This function is needed for handling boss replacers { Super.Tick(); if (tracer == null || tracer.health <= 0) { A_BossDeath(); Destroy(); } } } class RatBuddy : Actor { Default { Health 5; Speed 13; Radius 10; Height 16; +NOBLOOD +FLOORCLIP +CANPASS +ISMONSTER +INCOMBAT MinMissileChance 150; MaxStepHeight 16; MaxDropoffHeight 32; Tag "$TAG_RATBUDDY"; SeeSound "rat/sight"; DeathSound "rat/death"; ActiveSound "rat/active"; } States { Spawn: RATT A 10 A_Look; Loop; See: RATT AABB 4 A_Chase; Loop; Melee: RATT A 8 A_Wander; RATT B 4 A_Wander; Goto See; Death: MEAT Q 700; Stop; } } // Wind --------------------------------------------------------------------- class SoundWind : Actor { Default { +NOBLOCKMAP +NOSECTOR +DONTSPLASH } States { Spawn: TNT1 A 2 A_StartSound("world/wind", CHAN_6, CHANF_LOOPING); Loop; } } class SoundWindHexen : SoundWind { } // Waterfall ---------------------------------------------------------------- class SoundWaterfall : Actor { Default { +NOBLOCKMAP +NOSECTOR +DONTSPLASH } States { Spawn: TNT1 A 2 A_StartSound("world/waterfall", CHAN_6, CHANF_LOOPING); Loop; } } // Health ------------------------------------------------------------------- class ArtiHealth : HealthPickup { Default { Health 25; +COUNTITEM +FLOATBOB Inventory.PickupFlash "PickupFlash"; +INVENTORY.FANCYPICKUPSOUND Inventory.Icon "ARTIPTN2"; Inventory.PickupSound "misc/p_pkup"; Inventory.PickupMessage "$TXT_ARTIHEALTH"; Tag "$TAG_ARTIHEALTH"; HealthPickup.Autouse 1; } States { Spawn: PTN2 ABC 4; Loop; } } // Super health ------------------------------------------------------------- class ArtiSuperHealth : HealthPickup { Default { Health 100; +COUNTITEM +FLOATBOB Inventory.PickupFlash "PickupFlash"; +INVENTORY.FANCYPICKUPSOUND Inventory.Icon "ARTISPHL"; Inventory.PickupSound "misc/p_pkup"; Inventory.PickupMessage "$TXT_ARTISUPERHEALTH"; Tag "$TAG_ARTISUPERHEALTH"; HealthPickup.Autouse 2; } States { Spawn: SPHL A 350; Loop; } } // Flight ------------------------------------------------------------------- class ArtiFly : PowerupGiver { Default { +COUNTITEM +FLOATBOB Inventory.PickupFlash "PickupFlash"; Inventory.InterHubAmount 0; Inventory.RespawnTics 4230; Inventory.Icon "ARTISOAR"; Inventory.PickupMessage "$TXT_ARTIFLY"; Tag "$TAG_ARTIFLY"; Powerup.Type "PowerFlight"; } States { Spawn: SOAR ABCB 5; Loop; } } // Invulnerability Heretic (Ring of invincibility) -------------------------- class ArtiInvulnerability : PowerupGiver { Default { +COUNTITEM +FLOATBOB +Inventory.BIGPOWERUP Inventory.PickupFlash "PickupFlash"; Inventory.RespawnTics 4230; Inventory.Icon "ARTIINVU"; Inventory.PickupMessage "$TXT_ARTIINVULNERABILITY"; Tag "$TAG_ARTIINVULNERABILITY"; Powerup.Type "PowerInvulnerable"; Powerup.Color "GoldMap"; } States { Spawn: INVU ABCD 3; Loop; } } // Invulnerability Hexen (Icon of the defender) ----------------------------- class ArtiInvulnerability2 : PowerupGiver { Default { +COUNTITEM +FLOATBOB +Inventory.BIGPOWERUP Inventory.PickupFlash "PickupFlash"; Inventory.RespawnTics 4230; Inventory.Icon "ARTIDEFN"; Inventory.PickupMessage "$TXT_ARTIINVULNERABILITY2"; Powerup.Type "PowerInvulnerable"; Tag "$TAG_ARTIDEFENDER"; } States { Spawn: DEFN ABCD 3; Loop; } } // Torch -------------------------------------------------------------------- class ArtiTorch : PowerupGiver { Default { +COUNTITEM +FLOATBOB Inventory.PickupFlash "PickupFlash"; Inventory.Icon "ARTITRCH"; Inventory.PickupMessage "$TXT_ARTITORCH"; Tag "$TAG_ARTITORCH"; Powerup.Type "PowerTorch"; } States { Spawn: TRCH ABC 3 Bright; Loop; } } class CrystalVial : Health { Default { +FLOATBOB Inventory.Amount 10; Inventory.PickupMessage "$TXT_ITEMHEALTH"; } States { Spawn: PTN1 ABC 3; Loop; } } /* ** readthis.cpp ** Help screens ** **--------------------------------------------------------------------------- ** Copyright 2001-2010 Randy Heit ** Copyright 2010 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ class ReadThisMenu : GenericMenu { int mScreen; int mInfoTic; //============================================================================= // // // //============================================================================= override void Init(Menu parent) { Super.Init(parent); mScreen = 1; mInfoTic = gametic; } override void Drawer() { double alpha; TextureID tex, prevpic; // Did the mapper choose a custom help page via MAPINFO? if (Level.F1Pic.Length() != 0) { tex = TexMan.CheckForTexture(Level.F1Pic, TexMan.Type_MiscPatch); mScreen = 1; } if (!tex.IsValid()) { tex = TexMan.CheckForTexture(gameinfo.infoPages[mScreen-1], TexMan.Type_MiscPatch); } if (mScreen > 1) { prevpic = TexMan.CheckForTexture(gameinfo.infoPages[mScreen-2], TexMan.Type_MiscPatch); } screen.Dim(0, 1.0, 0,0, screen.GetWidth(), screen.GetHeight()); alpha = MIN((gametic - mInfoTic) * (3. / GameTicRate), 1.); if (alpha < 1. && prevpic.IsValid()) { screen.DrawTexture (prevpic, false, 0, 0, DTA_Fullscreen, true); } else alpha = 1; screen.DrawTexture (tex, false, 0, 0, DTA_Fullscreen, true, DTA_Alpha, alpha); } //============================================================================= // // // //============================================================================= override bool MenuEvent(int mkey, bool fromcontroller) { if (mkey == MKEY_Enter) { MenuSound("menu/choose"); mScreen++; mInfoTic = gametic; if (Level.F1Pic.Length() != 0 || mScreen > gameinfo.infoPages.Size()) { Close(); } return true; } else return Super.MenuEvent(mkey, fromcontroller); } //============================================================================= // // // //============================================================================= override bool MouseEvent(int type, int x, int y) { if (type == MOUSE_Click) { return MenuEvent(MKEY_Enter, true); } return false; } } class Reaver : Actor { Default { Health 150; Painchance 128; Speed 12; Radius 20; Height 60; Monster; +NOBLOOD +INCOMBAT MinMissileChance 150; MaxDropoffHeight 32; Mass 500; Tag "$TAG_REAVER"; SeeSound "reaver/sight"; PainSound "reaver/pain"; DeathSound "reaver/death"; ActiveSound "reaver/active"; HitObituary "$OB_REAVERHIT"; Obituary "$OB_REAVER"; } States { Spawn: ROB1 A 10 A_Look; Loop; See: ROB1 BBCCDDEE 3 A_Chase; Loop; Melee: ROB1 H 6 Slow A_FaceTarget; ROB1 I 8 Slow A_CustomMeleeAttack(random[ReaverMelee](1,8)*3, "reaver/blade"); ROB1 H 6 Slow; Goto See; Missile: ROB1 F 8 Slow A_FaceTarget; ROB1 G 11 Slow BRIGHT A_ReaverRanged; Goto See; Pain: ROB1 A 2 Slow; ROB1 A 2 A_Pain; Goto See; Death: ROB1 J 6; ROB1 K 6 A_Scream; ROB1 L 5; ROB1 M 5 A_NoBlocking; ROB1 NOP 5; ROB1 Q 6 A_Explode(32, 32, alert:true); ROB1 R -1; Stop; XDeath: ROB1 L 5 A_TossGib; ROB1 M 5 A_Scream; ROB1 N 5 A_TossGib; ROB1 O 5 A_NoBlocking; ROB1 P 5 A_TossGib; Goto Death+7; } } extend class Actor { // The Inquisitor also uses this function void A_ReaverRanged () { if (target != null) { A_FaceTarget (); A_StartSound ("reaver/attack", CHAN_WEAPON); double bangle = Angle; double pitch = AimLineAttack (bangle, MISSILERANGE); for (int i = 0; i < 3; ++i) { double ang = bangle + Random2[ReaverAttack]() * (22.5 / 256); int damage = random[ReaverAttack](1, 8) * 3; LineAttack (ang, MISSILERANGE, pitch, damage, 'Hitscan', "StrifePuff"); } } } } // Base class for the rebels ------------------------------------------------ class Rebel : StrifeHumanoid { Default { Health 60; Painchance 250; Speed 8; Radius 20; Height 56; Monster; +FRIENDLY -COUNTKILL +NOSPLASHALERT MinMissileChance 150; Tag "$TAG_REBEL"; SeeSound "rebel/sight"; PainSound "rebel/pain"; DeathSound "rebel/death"; ActiveSound "rebel/active"; Obituary "$OB_REBEL"; } States { Spawn: HMN1 P 5 A_Look2; Loop; HMN1 Q 8; Loop; HMN1 R 8; Loop; HMN1 ABCDABCD 6 A_Wander; Loop; See: HMN1 AABBCCDD 3 A_Chase; Loop; Missile: HMN1 E 10 A_FaceTarget; HMN1 F 10 BRIGHT A_ShootGun; HMN1 E 10 A_ShootGun; Goto See; Pain: HMN1 O 3; HMN1 O 3 A_Pain; Goto See; Death: HMN1 G 5; HMN1 H 5 A_Scream; HMN1 I 3 A_NoBlocking; HMN1 J 4; HMN1 KLM 3; HMN1 N -1; Stop; XDeath: RGIB A 4 A_TossGib; RGIB B 4 A_XScream; RGIB C 3 A_NoBlocking; RGIB DEF 3 A_TossGib; RGIB G 3; RGIB H 1400; Stop; } } // Rebel 1 ------------------------------------------------------------------ class Rebel1 : Rebel { Default { DropItem "ClipOfBullets"; } } // Rebel 2 ------------------------------------------------------------------ class Rebel2 : Rebel { } // Rebel 3 ------------------------------------------------------------------ class Rebel3 : Rebel { } // Rebel 4 ------------------------------------------------------------------ class Rebel4 : Rebel { } // Rebel 5 ------------------------------------------------------------------ class Rebel5 : Rebel { } // Rebel 6 ------------------------------------------------------------------ class Rebel6 : Rebel { } // Teleporter Beacon -------------------------------------------------------- class TeleporterBeacon : Inventory { Default { Health 5; Radius 16; Height 16; Inventory.MaxAmount 3; +DROPPED +INVENTORY.INVBAR Inventory.Icon "I_BEAC"; Tag "$TAG_TELEPORTERBEACON"; Inventory.PickupMessage "$TXT_BEACON"; } States { Spawn: BEAC A -1; Stop; Drop: BEAC A 30; BEAC A 160 A_Beacon; Wait; Death: BEAC A 1 A_FadeOut(0.015); Loop; } // Teleporter Beacon -------------------------------------------------------- override bool Use (bool pickup) { // Increase the amount by one so that when DropInventory decrements it, // the actor will have the same number of beacons that he started with. // When we return to UseInventory, it will take care of decrementing // Amount again and disposing of self item if there are no more. Amount++; Inventory drop = Owner.DropInventory (self); if (drop == null) { Amount--; return false; } else { drop.SetStateLabel("Drop"); drop.target = Owner; return true; } } void A_Beacon() { Actor owner = target; Actor rebel = Spawn("Rebel1", (pos.xy, floorz), ALLOW_REPLACE); if (rebel == null) { return; } if (!rebel.TryMove (rebel.Pos.xy, true)) { rebel.Destroy (); return; } // Once the rebels start teleporting in, you can't pick up the beacon anymore. bSpecial = false; Inventory(self).DropTime = 0; // Set up the new rebel. rebel.threshold = rebel.DefThreshold; rebel.target = null; rebel.bInCombat = true; rebel.LastHeard = owner; // Make sure the rebels look for targets if (deathmatch) { rebel.health *= 2; } if (owner != null) { // Rebels are the same color as their owner (but only in multiplayer) if (multiplayer) { rebel.Translation = owner.Translation; } rebel.SetFriendPlayer(owner.player); // Set the rebel's target to whatever last hurt the player, so long as it's not // one of the player's other rebels. if (owner.target != null && !rebel.IsFriend (owner.target)) { rebel.target = owner.target; } } rebel.SetState (rebel.SeeState); rebel.Angle = Angle; rebel.SpawnTeleportFog(rebel.Vec3Angle(20., Angle, 0), false, true); if (--health < 0) { SetStateLabel("Death"); } } } //=========================================================================== // // Revenant // //=========================================================================== class Revenant : Actor { Default { Health 300; Radius 20; Height 56; Mass 500; Speed 10; PainChance 100; Monster; MeleeThreshold 196; +MISSILEMORE +FLOORCLIP SeeSound "skeleton/sight"; PainSound "skeleton/pain"; DeathSound "skeleton/death"; ActiveSound "skeleton/active"; MeleeSound "skeleton/melee"; HitObituary "$OB_UNDEADHIT"; Obituary "$OB_UNDEAD"; Tag "$FN_REVEN"; } States { Spawn: SKEL AB 10 A_Look; Loop; See: SKEL AABBCCDDEEFF 2 A_Chase; Loop; Melee: SKEL G 0 A_FaceTarget; SKEL G 6 A_SkelWhoosh; SKEL H 6 A_FaceTarget; SKEL I 6 A_SkelFist; Goto See; Missile: SKEL J 0 BRIGHT A_FaceTarget; SKEL J 10 BRIGHT A_FaceTarget; SKEL K 10 A_SkelMissile; SKEL K 10 A_FaceTarget; Goto See; Pain: SKEL L 5; SKEL L 5 A_Pain; Goto See; Death: SKEL LM 7; SKEL N 7 A_Scream; SKEL O 7 A_NoBlocking; SKEL P 7; SKEL Q -1; Stop; Raise: SKEL Q 5; SKEL PONML 5; Goto See; } } //=========================================================================== // // Revenant Tracer // //=========================================================================== class RevenantTracer : Actor { Default { Radius 11; Height 8; Speed 10; Damage 10; Projectile; +SEEKERMISSILE +RANDOMIZE +ZDOOMTRANS SeeSound "skeleton/attack"; DeathSound "skeleton/tracex"; RenderStyle "Add"; } States { Spawn: FATB AB 2 BRIGHT A_Tracer; Loop; Death: FBXP A 8 BRIGHT; FBXP B 6 BRIGHT; FBXP C 4 BRIGHT; Stop; } } //=========================================================================== // // Revenant Tracer Smoke // //=========================================================================== class RevenantTracerSmoke : Actor { Default { +NOBLOCKMAP +NOGRAVITY +NOTELEPORT +ZDOOMTRANS RenderStyle "Translucent"; Alpha 0.5; } States { Spawn: PUFF ABABC 4; Stop; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== extend class Actor { void A_SkelMissile() { if (target == null) return; A_FaceTarget(); AddZ(16); Actor missile = SpawnMissile(target, "RevenantTracer"); AddZ(-16); if (missile != null) { missile.SetOrigin(missile.Vec3Offset(missile.Vel.X, missile.Vel.Y, 0.), false); missile.tracer = target; } } void A_SkelWhoosh() { if (target == null) return; A_FaceTarget(); A_StartSound("skeleton/swing", CHAN_WEAPON); } void A_SkelFist() { let targ = target; if (targ == null) return; A_FaceTarget(); if (CheckMeleeRange ()) { int damage = random[SkelFist](1, 10) * 6; A_StartSound("skeleton/melee", CHAN_WEAPON); int newdam = targ.DamageMobj (self, self, damage, 'Melee'); targ.TraceBleed (newdam > 0 ? newdam : damage, self); } } void A_Tracer2(double traceang = 19.6875) { double dist; double slope; Actor dest; // adjust direction dest = tracer; if (!dest || dest.health <= 0 || Speed == 0 || !CanSeek(dest)) return; // change angle double exact = AngleTo(dest); double diff = deltaangle(angle, exact); if (diff < 0) { angle -= traceang; if (deltaangle(angle, exact) > 0) angle = exact; } else if (diff > 0) { angle += traceang; if (deltaangle(angle, exact) < 0.) angle = exact; } VelFromAngle(); if (!bFloorHugger && !bCeilingHugger) { // change slope dist = DistanceBySpeed(dest, Speed); if (dest.Height >= 56.) { slope = (dest.pos.z + 40. - pos.z) / dist; } else { slope = (dest.pos.z + Height*(2./3) - pos.z) / dist; } if (slope < Vel.Z) Vel.Z -= 1. / 8; else Vel.Z += 1. / 8; } } void A_Tracer() { // killough 1/18/98: this is why some missiles do not have smoke // and some do. Also, internal demos start at random gametics, thus // the bug in which revenants cause internal demos to go out of sync. if (level.maptime & 3) return; // spawn a puff of smoke behind the rocket SpawnPuff ("BulletPuff", pos, angle, angle, 3); Actor smoke = Spawn ("RevenantTracerSmoke", Vec3Offset(-Vel.X, -Vel.Y, 0.), ALLOW_REPLACE); if (smoke != null) { smoke.Vel.Z = 1.; smoke.tics -= random[Tracer](0, 3); if (smoke.tics < 1) smoke.tics = 1; } // The rest of this function was identical with Strife's version, except for the angle being used. A_Tracer2(16.875); } } class ReverbEdit : OptionMenu { static native double GetValue(int index); static native double SetValue(int index, double value); static native bool GrayCheck(); static native string, int GetSelectedEnvironment(); static native void FillSelectMenu(String ccmd, OptionMenuDescriptor desc); static native void FillSaveMenu(OptionMenuDescriptor desc); static native int GetSaveSelection(int num); static native void ToggleSaveSelection(int num); override void Init(Menu parent, OptionMenuDescriptor desc) { super.Init(parent, desc); OnReturn(); } override void OnReturn() { string env; int id; [env, id] = GetSelectedEnvironment(); let li = GetItem('EvironmentName'); if (li != NULL) { if (id != -1) { li.SetValue(0, 1); li.SetString(0, env); } else { li.SetValue(0, 0); } } li = GetItem('EvironmentID'); if (li != NULL) { if (id != -1) { li.SetValue(0, 1); li.SetString(0, String.Format("%d, %d", (id >> 8) & 255, id & 255)); } else { li.SetValue(0, 0); } } } } class ReverbSelect : OptionMenu { //============================================================================= // // // //============================================================================= override void Init(Menu parent, OptionMenuDescriptor desc) { ReverbEdit.FillSelectMenu("selectenvironment", desc); super.Init(parent, desc); } } class ReverbSave : OptionMenu { //============================================================================= // // // //============================================================================= override void Init(Menu parent, OptionMenuDescriptor desc) { ReverbEdit.FillSaveMenu(desc); super.Init(parent, desc); } } //============================================================================= // // Change a CVAR, command is the CVAR name // //============================================================================= class OptionMenuItemReverbSaveSelect : OptionMenuItemOptionBase { int mValIndex; OptionMenuItemReverbSaveSelect Init(String label, int index, Name values) { Super.Init(label, 'None', values, null, 0); mValIndex = index; return self; } //============================================================================= override int GetSelection() { return ReverbEdit.GetSaveSelection(mValIndex); } override void SetSelection(int Selection) { ReverbEdit.ToggleSaveSelection(mValIndex); } } //============================================================================= // // opens a submenu, command is a submenu name // //============================================================================= class OptionMenuItemReverbSelect : OptionMenuItemSubMenu { OptionMenuItemReverbSelect Init(String label, Name command) { Super.init(label, command, 0, false); return self; } override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { int x = drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor); String text = ReverbEdit.GetSelectedEnvironment(); drawValue(indent, y, OptionMenuSettings.mFontColorValue, text); return indent; } } //============================================================================= // // // //============================================================================= class OptionMenuItemReverbOption : OptionMenuItemOptionBase { int mValIndex; OptionMenuItemReverbOption Init(String label, int valindex, Name values) { Super.Init(label, "", values, null, false); mValIndex = valindex; return self; } override bool isGrayed() { return ReverbEdit.GrayCheck(); } override int GetSelection() { return int(ReverbEdit.GetValue(mValIndex)); } override void SetSelection(int Selection) { ReverbEdit.SetValue(mValIndex, Selection); } } //============================================================================= // // // //============================================================================= class OptionMenuItemSliderReverbEditOption : OptionMenuSliderBase { int mValIndex; String mEditValue; TextEnterMenu mEnter; OptionMenuItemSliderReverbEditOption Init(String label, double min, double max, double step, int showval, int valindex) { Super.Init(label, min, max, step, showval); mValIndex = valindex; mEnter = null; return self; } override double GetSliderValue() { return ReverbEdit.GetValue(mValIndex); } override void SetSliderValue(double val) { ReverbEdit.SetValue(mValIndex, val); } override bool Selectable() { return !ReverbEdit.GrayCheck(); } virtual String Represent() { return mEnter.GetText() .. Menu.OptionFont().GetCursor(); } //============================================================================= override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) { drawLabel(indent, y, selected ? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor, ReverbEdit.GrayCheck()); mDrawX = indent + CursorSpace(); if (mEnter) { drawText(mDrawX, y, OptionMenuSettings.mFontColorValue, Represent()); } else { DrawSlider (mDrawX, y, mMin, mMax, GetSliderValue(), mShowValue, indent); } return indent; } override bool MenuEvent (int mkey, bool fromcontroller) { if (mkey == Menu.MKEY_Enter) { Menu.MenuSound("menu/choose"); mEnter = TextEnterMenu.OpenTextEnter(Menu.GetCurrentMenu(), Menu.OptionFont(), String.Format("%.3f", GetSliderValue()), -1, fromcontroller); mEnter.ActivateMenu(); return true; } else if (mkey == Menu.MKEY_Input) { String val = mEnter.GetText(); SetSliderValue(val.toDouble()); mEnter = null; return true; } else if (mkey == Menu.MKEY_Abort) { mEnter = null; return true; } return Super.MenuEvent(mkey, fromcontroller); } } struct SBarInfo native ui { native void Destroy(); native void AttachToPlayer(PlayerInfo player); native void Draw(int state); native void NewGame(); native bool MustDrawLog(int state); native void Tick(); native void ShowPop(int popnum); native int GetProtrusion(double scalefac); } // The sole purpose of this wrapper is to eliminate the native dependencies of the status bar object // because those would seriously impede the script conversion of the base class. class SBarInfoWrapper : BaseStatusBar { private clearscope SBarInfo core; override void OnDestroy() { if (core != null) core.Destroy(); // note that the core is not a GC'd object! Super.OnDestroy(); } override void AttachToPlayer(PlayerInfo player) { Super.AttachToPlayer(player); core.AttachToPlayer(player); } override void Draw(int state, double TicFrac) { Super.Draw(state, TicFrac); core.Draw(state); } override void NewGame() { Super.NewGame(); if (CPlayer != NULL) { core.NewGame(); } } override bool MustDrawLog(int state) { return core.MustDrawLog(state); } override void Tick() { Super.Tick(); core.Tick(); } override void ShowPop(int popnum) { Super.ShowPop(popnum); core.ShowPop(popnum); } override int GetProtrusion(double scaleratio) const { return core.GetProtrusion(scaleratio); } } class ScreenJob : Object UI { int flags; float fadetime; // in milliseconds int fadestate; int ticks; int jobstate; bool skipover; bool nowipe; enum EJobState { running = 0, // normal operation skipped = 1, // finished by user skipping finished = 2, // finished by completing its sequence stopping = 3, // running ending animations / fadeout, etc. Will not accept more input. stopped = 4, // we're done here. }; enum EJobFlags { visible = 0, fadein = 1, fadeout = 2, stopmusic = 4, stopsound = 8, transition_shift = 4, transition_mask = 48, transition_melt = 16, transition_burn = 32, transition_crossfade = 48, }; void Init(int fflags = 0, float fadet = 250.f) { flags = fflags; fadetime = fadet; jobstate = running; } virtual bool ProcessInput() { return false; } virtual void Start() {} virtual bool OnEvent(InputEvent evt) { return false; } virtual void OnTick() {} virtual void Draw(double smoothratio) {} virtual void OnSkip() {} int DrawFrame(double smoothratio) { if (jobstate != running) smoothratio = 1; // this is necessary to avoid having a negative time span because the ticker won't be incremented anymore. Draw(smoothratio); if (jobstate == skipped) return -1; if (jobstate == finished) return 0; return 1; } int GetFadeState() { return fadestate; } override void OnDestroy() { if (flags & stopmusic) System.StopMusic(); if (flags & stopsound) System.StopAllSounds(); } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- class SkippableScreenJob : ScreenJob { void Init(int flags = 0, float fadet = 250.f) { Super.Init(flags, fadet); } override bool OnEvent(InputEvent evt) { if (evt.type == InputEvent.Type_KeyDown && !System.specialKeyEvent(evt)) { jobstate = skipped; OnSkip(); } return true; } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- class BlackScreen : ScreenJob { int wait; bool cleared; ScreenJob Init(int w, int flags = 0) { Super.Init(flags & ~(fadein|fadeout)); wait = w; cleared = false; return self; } static ScreenJob Create(int w, int flags = 0) { return new("BlackScreen").Init(w, flags); } override void OnTick() { if (cleared) { int span = ticks * 1000 / GameTicRate; if (span > wait) jobstate = finished; } } override void Draw(double smooth) { cleared = true; } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- class ImageScreen : SkippableScreenJob { int tilenum; int trans; int waittime; // in ms. bool cleared; TextureID texid; ScreenJob Init(TextureID tile, int fade = fadein | fadeout, int wait = 3000, int translation = 0) { Super.Init(fade); waittime = wait; texid = tile; trans = translation; cleared = false; return self; } ScreenJob InitNamed(String tex, int fade = fadein | fadeout, int wait = 3000, int translation = 0) { Super.Init(fade); waittime = wait; texid = TexMan.CheckForTexture(tex, TexMan.Type_Any, TexMan.TryAny | TexMan.ForceLookup); trans = translation; cleared = false; return self; } static ScreenJob Create(TextureID tile, int fade = fadein | fadeout, int wait = 3000, int translation = 0) { return new("ImageScreen").Init(tile, fade, wait, translation); } static ScreenJob CreateNamed(String tex, int fade = fadein | fadeout, int wait = 3000, int translation = 0) { return new("ImageScreen").InitNamed(tex, fade, wait, translation); } override void OnTick() { if (cleared) { int span = ticks * 1000 / GameTicRate; if (span > waittime) jobstate = finished; } } override void Draw(double smooth) { if (texid.IsValid()) Screen.DrawTexture(texid, true, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, DTA_TranslationIndex, trans); cleared = true; } } //--------------------------------------------------------------------------- // // internal polymorphic movie player object // //--------------------------------------------------------------------------- struct MoviePlayer native { enum EMovieFlags { NOSOUNDCUTOFF = 1, FIXEDVIEWPORT = 2, // Forces fixed 640x480 screen size like for Blood's intros. NOMUSICCUTOFF = 4, } native static MoviePlayer Create(String filename, Array soundinfo, int flags, int frametime, int firstframetime, int lastframetime); native void Start(); native bool Frame(double clock); native void Destroy(); native TextureID GetTexture(); } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- class MoviePlayerJob : SkippableScreenJob { MoviePlayer player; bool started; int flag; ScreenJob Init(MoviePlayer mp, int flags) { Super.Init(); flag = flags; player = mp; nowipe = true; // due to synchronization issues wipes must be disabled on any movie. return self; } override void Start() { if (!(flag & MoviePlayer.NOMUSICCUTOFF)) System.StopMusic(); } static ScreenJob CreateWithSoundInfo(String filename, Array soundinfo, int flags, int frametime, int firstframetime = -1, int lastframetime = -1) { let movie = MoviePlayer.Create(filename, soundinfo, flags, frametime, firstframetime, lastframetime); if (movie) return new("MoviePlayerJob").Init(movie, flags); return null; } static ScreenJob Create(String filename, int flags, int frametime = -1) { Array empty; return CreateWithSoundInfo(filename, empty, flags, frametime); } static ScreenJob CreateWithSound(String filename, Sound soundname, int flags, int frametime = -1) { Array empty; empty.Push(1); empty.Push(int(soundname)); return CreateWithSoundInfo(filename, empty, flags, frametime); } virtual void DrawFrame() { let tex = player.GetTexture(); let size = TexMan.GetScaledSize(tex); if (!(flag & MoviePlayer.FIXEDVIEWPORT) || (size.x <= 320 && size.y <= 200) || size.x >= 640 || size.y >= 480) { Screen.DrawTexture(tex, false, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_Masked, false); } else { Screen.DrawTexture(tex, false, 320, 240, DTA_VirtualWidth, 640, DTA_VirtualHeight, 480, DTA_CenterOffset, true, DTA_Masked, false); } } override void Draw(double smoothratio) { if (!player) { jobstate = stopped; return; } if (!started) { started = true; player.Start(); } double clock = (ticks + smoothratio) * 1000000000. / GameTicRate; if (jobstate == running && !player.Frame(clock)) { jobstate = finished; } DrawFrame(); } override void OnDestroy() { if (player) { player.Destroy(); } player = null; } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- class ScreenJobRunner : Object UI { enum ERunState { State_Clear, State_Run, State_Fadeout, } Array jobs; //CompletionFunc completion; int index; float screenfade; bool clearbefore; bool skipall; bool advance; int actionState; int terminateState; int fadeticks; int last_paused_tic; native static void setTransition(int type); void Init(bool clearbefore_, bool skipall_) { clearbefore = clearbefore_; skipall = skipall_; index = -1; fadeticks = 0; last_paused_tic = -1; } override void OnDestroy() { DeleteJobs(); } protected void DeleteJobs() { // Free all allocated resources now. for (int i = 0; i < jobs.Size(); i++) { if (jobs[i]) jobs[i].Destroy(); } jobs.Clear(); } void Append(ScreenJob job) { if (job != null) jobs.Push(job); } virtual bool Validate() { return jobs.Size() > 0; } bool CanWipe() { if (index < jobs.Size()) return !jobs[max(0, index)].nowipe; return true; } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- protected void AdvanceJob(bool skip) { if (index == jobs.Size()-1) { index++; return; // we need to retain the last element until the runner is done. } if (index >= 0) jobs[index].Destroy(); index++; while (index < jobs.Size() && (jobs[index] == null || (skip && jobs[index].skipover))) { if (jobs[index] != null && index < jobs.Size() - 1) jobs[index].Destroy(); // may not delete the last element - we still need it for shutting down. index++; } actionState = clearbefore ? State_Clear : State_Run; if (index < jobs.Size()) { jobs[index].fadestate = !paused && jobs[index].flags & ScreenJob.fadein? ScreenJob.fadein : ScreenJob.visible; jobs[index].Start(); if (jobs[index].flags & ScreenJob.transition_mask) { setTransition((jobs[index].flags & ScreenJob.transition_mask) >> ScreenJob.Transition_Shift); } } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- virtual int DisplayFrame(double smoothratio) { if (jobs.Size() == 0) { return 1; } int x = index >= jobs.Size()? jobs.Size()-1 : index; let job = jobs[x]; bool processed = job.ProcessInput(); if (job.fadestate == ScreenJob.fadein) { double ms = (job.ticks + smoothratio) * 1000 / GameTicRate / job.fadetime; double screenfade = clamp(ms, 0., 1.); Screen.SetScreenFade(screenfade); if (screenfade == 1.) job.fadestate = ScreenJob.visible; } int state = job.DrawFrame(smoothratio); Screen.SetScreenFade(1.); return state; } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- virtual int FadeoutFrame(double smoothratio) { int x = index >= jobs.Size()? jobs.Size()-1 : index; let job = jobs[x]; double ms = (fadeticks + smoothratio) * 1000 / GameTicRate / job.fadetime; float screenfade = 1. - clamp(ms, 0., 1.); Screen.SetScreenFade(screenfade); job.DrawFrame(1.); Screen.SetScreenFade(1.); return (screenfade > 0.); } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- virtual bool OnEvent(InputEvent ev) { if (paused || index < 0 || index >= jobs.Size()) return false; if (jobs[index].jobstate != ScreenJob.running) return false; return jobs[index].OnEvent(ev); } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- virtual bool OnTick() { if (paused) return false; if (index >= jobs.Size() || jobs.Size() == 0) return true; if (advance || index < 0) { advance = false; AdvanceJob(terminateState < 0); if (index >= jobs.Size()) { return true; } } if (jobs[index].jobstate == ScreenJob.running) { jobs[index].ticks++; jobs[index].OnTick(); } else if (jobs[index].jobstate == ScreenJob.stopping) { fadeticks++; } return false; } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- virtual bool RunFrame(double smoothratio) { if (index < 0) { AdvanceJob(false); } // ensure that we won't go back in time if the menu is dismissed without advancing our ticker if (index < jobs.Size()) { bool menuon = paused; if (menuon) last_paused_tic = jobs[index].ticks; else if (last_paused_tic == jobs[index].ticks) menuon = true; if (menuon) smoothratio = 1.; } else smoothratio = 1.; if (actionState == State_Clear) { actionState = State_Run; } else if (actionState == State_Run) { terminateState = DisplayFrame(smoothratio); if (terminateState < 1 && index < jobs.Size()) { if (jobs[index].flags & ScreenJob.fadeout) { jobs[index].fadestate = ScreenJob.fadeout; jobs[index].jobstate = ScreenJob.stopping; actionState = State_Fadeout; fadeticks = 0; } else { advance = true; } } } else if (actionState == State_Fadeout) { int ended = FadeoutFrame(smoothratio); if (ended < 1 && index < jobs.Size()) { jobs[index].jobstate = ScreenJob.stopped; advance = true; } } return true; } void AddGenericVideo(String fn, int snd, int framerate) { Array sounds; if (snd > 0) sounds.Pushv(1, snd); Append(MoviePlayerJob.CreateWithSoundInfo(fn, sounds, 0, framerate)); } } // Scriptable marine ------------------------------------------------------- class ScriptedMarine : Actor { const MARINE_PAIN_CHANCE = 160; enum EMarineWeapon { WEAPON_Dummy, WEAPON_Fist, WEAPON_BerserkFist, WEAPON_Chainsaw, WEAPON_Pistol, WEAPON_Shotgun, WEAPON_SuperShotgun, WEAPON_Chaingun, WEAPON_RocketLauncher, WEAPON_PlasmaRifle, WEAPON_Railgun, WEAPON_BFG }; struct WeaponStates { state melee; state missile; } int CurrentWeapon; SpriteID SpriteOverride; Default { Health 100; Radius 16; Height 56; Mass 100; Speed 8; Painchance MARINE_PAIN_CHANCE; MONSTER; -COUNTKILL Translation 0; Damage 100; DeathSound "*death"; PainSound "*pain50"; } States { Spawn: PLAY A 4 A_MarineLook; PLAY A 4 A_MarineNoise; Loop; Idle: PLAY A 4 A_MarineLook; PLAY A 4 A_MarineNoise; PLAY A 4 A_MarineLook; PLAY B 4 A_MarineNoise; PLAY B 4 A_MarineLook; PLAY B 4 A_MarineNoise; Loop; See: PLAY ABCD 4 A_MarineChase; Loop; Melee.Fist: PLAY E 4 A_FaceTarget; PLAY E 4 A_M_Punch(1); PLAY A 9; PLAY A 0 A_M_Refire(1, "FistEnd"); Loop; FistEnd: PLAY A 5 A_FaceTarget; Goto See; Melee.Berserk: PLAY E 4 A_FaceTarget; PLAY E 4 A_M_Punch(10); PLAY A 9; PLAY A 0 A_M_Refire(1, "FistEnd"); Loop; Melee.Chainsaw: PLAY E 4 A_MarineNoise; PLAY E 4 A_M_Saw; PLAY E 0 A_M_SawRefire; goto Melee.Chainsaw+1; Missile: Missile.None: PLAY E 12 A_FaceTarget; Goto Idle; PLAY F 6 BRIGHT; Loop; Missile.Pistol: PLAY E 4 A_FaceTarget; PLAY F 6 BRIGHT A_M_FirePistol(1); PLAY A 4 A_FaceTarget; PLAY A 0 A_M_Refire(0, "ShootEnd"); Goto Fireloop.Pistol; ShootEnd: PLAY A 5; Goto See; Fireloop.Pistol: PLAY F 6 BRIGHT A_M_FirePistol(0); PLAY A 4 A_FaceTarget; PLAY A 0 A_M_Refire(0, "ShootEnd"); Goto Fireloop.Pistol; Missile.Shotgun: PLAY E 3 A_M_CheckAttack; PLAY F 7 BRIGHT A_M_FireShotgun; Goto See; Missile.SSG: PLAY E 3 A_M_CheckAttack; PLAY F 7 BRIGHT A_M_FireShotgun2; Goto See; Missile.Chaingun: PLAY E 4 A_FaceTarget; PLAY FF 4 BRIGHT A_M_FireCGun(1); PLAY FF 4 BRIGHT A_M_FireCGun(0); PLAY A 0 A_M_Refire(0, "See"); Goto Missile.Chaingun+3; Missile.Rocket: PLAY E 8; PLAY F 6 BRIGHT A_M_FireMissile; PLAY E 6; PLAY A 0 A_M_Refire(0, "See"); Loop; Missile.Plasma: PLAY E 2 A_FaceTarget; PLAY E 0 A_FaceTarget; PLAY F 3 BRIGHT A_M_FirePlasma; PLAY A 0 A_M_Refire(0, "See"); Goto Missile.Plasma+1; Missile.Railgun: PLAY E 4 A_M_CheckAttack; PLAY F 6 BRIGHT A_M_FireRailgun; Goto See; Missile.BFG: PLAY E 5 A_M_BFGSound; PLAY EEEEE 5 A_FaceTarget; PLAY F 6 BRIGHT A_M_FireBFG; PLAY A 4 A_FaceTarget; PLAY A 0 A_M_Refire(0, "See"); Loop; SkipAttack: PLAY A 1; Goto See; Pain: PLAY G 4; PLAY G 4 A_Pain; Goto Idle; Death: PLAY H 10; PLAY I 10 A_Scream; PLAY J 10 A_NoBlocking; PLAY KLM 10; PLAY N -1; Stop; XDeath: PLAY O 5; PLAY P 5 A_XScream; PLAY Q 5 A_NoBlocking; PLAY RSTUV 5; PLAY W -1; Stop; Raise: PLAY MLKJIH 5; Goto See; } //============================================================================ // // // //============================================================================ private bool GetWeaponStates(int weap, out WeaponStates wstates) { static const statelabel MeleeNames[] = { "Melee.None", "Melee.Fist", "Melee.Berserk", "Melee.Chainsaw", "Melee.Pistol", "Melee.Shotgun", "Melee.SSG", "Melee.Chaingun", "Melee.Rocket", "Melee.Plasma", "Melee.Railgun", "Melee.BFG" }; static const statelabel MissileNames[] = { "Missile.None", "Missile.Fist", "Missile.Berserk", "Missile.Chainsaw", "Missile.Pistol", "Missile.Shotgun", "Missile.SSG", "Missile.Chaingun", "Missile.Rocket", "Missile.Plasma", "Missile.Railgun", "Missile.BFG" }; if (weap < WEAPON_Dummy || weap > WEAPON_BFG) weap = WEAPON_Dummy; wstates.melee = FindState(MeleeNames[weap], true); wstates.missile = FindState(MissileNames[weap], true); return wstates.melee != null || wstates.missile != null; } //============================================================================ // // // //============================================================================ override void BeginPlay () { Super.BeginPlay (); // Set the current weapon for(int i = WEAPON_Dummy; i <= WEAPON_BFG; i++) { WeaponStates wstates; if (GetWeaponStates(i, wstates)) { if (wstates.melee == MeleeState && wstates.missile == MissileState) { CurrentWeapon = i; } } } } //============================================================================ // // // //============================================================================ override void Tick () { Super.Tick (); // Override the standard sprite, if desired if (SpriteOverride != 0 && sprite == SpawnState.sprite) { sprite = SpriteOverride; } if (special1 != 0) { if (CurrentWeapon == WEAPON_SuperShotgun) { // Play SSG reload sounds int ticks = level.maptime - special1; if (ticks < 47) { switch (ticks) { case 14: A_StartSound ("weapons/sshoto", CHAN_WEAPON); break; case 28: A_StartSound ("weapons/sshotl", CHAN_WEAPON); break; case 41: A_StartSound ("weapons/sshotc", CHAN_WEAPON); break; } } else { special1 = 0; } } else { // Wait for a long refire time if (level.maptime >= special1) { special1 = 0; } else { bJustAttacked = true; } } } } //============================================================================ // // A_M_Refire // //============================================================================ void A_M_Refire (bool ignoremissile = false, statelabel jumpto = null) { if (target == null || target.health <= 0) { if (MissileState && random[SMarineRefire]() < 160) { // Look for a new target most of the time if (LookForPlayers (true) && CheckMissileRange ()) { // Found somebody new and in range, so don't stop shooting return; } } 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 { if (jumpto != null) SetStateLabel (jumpto); else SetState(CurState + 1); } } //============================================================================ // // A_M_SawRefire // //============================================================================ void A_M_SawRefire () { if (target == null || target.health <= 0 || !CheckMeleeRange ()) { SetStateLabel ("See"); } } //============================================================================ // // A_MarineNoise // //============================================================================ void A_MarineNoise () { if (CurrentWeapon == WEAPON_Chainsaw) { A_StartSound ("weapons/sawidle", CHAN_WEAPON); } } //============================================================================ // // A_MarineChase // //============================================================================ void A_MarineChase () { A_MarineNoise(); A_Chase (); } //============================================================================ // // A_MarineLook // //============================================================================ void A_MarineLook () { A_MarineNoise(); A_Look(); } //============================================================================ // // A_M_Punch (also used in the rocket attack.) // //============================================================================ void A_M_Punch(int damagemul) { FTranslatedLineTarget t; if (target == null) return; int damage = (random[SMarinePunch](1, 10) << 1) * damagemul; A_FaceTarget (); double ang = angle + random2[SMarinePunch]() * (5.625 / 256); double pitch = AimLineAttack (ang, DEFMELEERANGE); LineAttack (ang, DEFMELEERANGE, pitch, damage, 'Melee', "BulletPuff", true, t); // turn to face target if (t.linetarget) { A_StartSound ("*fist", CHAN_WEAPON); angle = t.angleFromSource; } } //============================================================================ // // P_GunShot2 // //============================================================================ private void GunShot2 (bool accurate, double pitch, class pufftype) { int damage = 5 * random[SMarineGunshot](1,3); double ang = angle; if (!accurate) { ang += Random2[SMarineGunshot]() * (5.625 / 256); } LineAttack (ang, MISSILERANGE, pitch, damage, 'Hitscan', pufftype); } //============================================================================ // // A_M_FirePistol // //============================================================================ void A_M_FirePistol (bool accurate) { if (target == null) return; A_StartSound ("weapons/pistol", CHAN_WEAPON); A_FaceTarget (); GunShot2 (accurate, AimLineAttack (angle, MISSILERANGE), "BulletPuff"); } //============================================================================ // // A_M_FireShotgun // //============================================================================ void A_M_FireShotgun () { if (target == null) return; A_StartSound ("weapons/shotgf", CHAN_WEAPON); A_FaceTarget (); double pitch = AimLineAttack (angle, MISSILERANGE); for (int i = 0; i < 7; ++i) { GunShot2 (false, pitch, "BulletPuff"); } special1 = level.maptime + 27; } //============================================================================ // // A_M_CheckAttack // //============================================================================ void A_M_CheckAttack () { if (special1 != 0 || target == null) { SetStateLabel ("SkipAttack"); } else { A_FaceTarget (); } } //============================================================================ // // A_M_FireShotgun2 // //============================================================================ void A_M_FireShotgun2 () { if (target == null) return; A_StartSound ("weapons/sshotf", CHAN_WEAPON); A_FaceTarget (); double pitch = AimLineAttack (angle, MISSILERANGE); for (int i = 0; i < 20; ++i) { int damage = 5*(random[SMarineFireSSG](1, 3)); double ang = angle + Random2[SMarineFireSSG]() * (11.25 / 256); LineAttack (ang, MISSILERANGE, pitch + Random2[SMarineFireSSG]() * (7.097 / 256), damage, 'Hitscan', "BulletPuff"); } special1 = level.maptime; } //============================================================================ // // A_M_FireCGun // //============================================================================ void A_M_FireCGun(bool accurate) { if (target == null) return; A_StartSound ("weapons/chngun", CHAN_WEAPON); A_FaceTarget (); GunShot2 (accurate, AimLineAttack (angle, MISSILERANGE), "BulletPuff"); } //============================================================================ // // A_M_FireMissile // // Giving a marine a rocket launcher is probably a bad idea unless you pump // up his health, because he's just as likely to kill himself as he is to // kill anything else with it. // //============================================================================ void A_M_FireMissile () { if (target == null) return; if (CheckMeleeRange ()) { // If too close, punch it A_M_Punch(1); } else { A_FaceTarget (); SpawnMissile (target, "Rocket"); } } //============================================================================ // // A_M_FireRailgun // //============================================================================ void A_M_FireRailgun () { if (target == null) return; A_MonsterRail(); special1 = level.maptime + 50; } //============================================================================ // // A_M_FirePlasma // //============================================================================ void A_M_FirePlasma () { if (target == null) return; A_FaceTarget (); SpawnMissile (target, "PlasmaBall"); special1 = level.maptime + 20; } //============================================================================ // // A_M_BFGsound // //============================================================================ void A_M_BFGsound () { if (target == null) return; if (special1 != 0) { SetState (SeeState); } else { A_FaceTarget (); A_StartSound ("weapons/bfgf", CHAN_WEAPON); // Don't interrupt the firing sequence PainChance = 0; } } //============================================================================ // // A_M_FireBFG // //============================================================================ void A_M_FireBFG () { if (target == null) return; A_FaceTarget (); SpawnMissile (target, "BFGBall"); special1 = level.maptime + 30; PainChance = MARINE_PAIN_CHANCE; } //--------------------------------------------------------------------------- final void SetWeapon (int type) { WeaponStates wstates; if (GetWeaponStates(type, wstates)) { static const class classes[] = { "ScriptedMarine", "MarineFist", "MarineBerserk", "MarineChainsaw", "MarinePistol", "MarineShotgun", "MarineSSG", "MarineChaingun", "MarineRocket", "MarinePlasma", "MarineRailgun", "MarineBFG" }; MeleeState = wstates.melee; MissileState = wstates.missile; DecalGenerator = GetDefaultByType(classes[type]).DecalGenerator; } } final void SetSprite (class source) { if (source == null) { // A valid actor class wasn't passed, so use the standard sprite SpriteOverride = sprite = SpawnState.sprite; // Copy the standard scaling Scale = Default.Scale; } else { // Use the same sprite and scaling the passed class spawns with readonly def = GetDefaultByType (source); SpriteOverride = sprite = def.SpawnState.sprite; Scale = def.Scale; } } } extend class Actor { //============================================================================ // // A_M_Saw (this is globally exported) // //============================================================================ void A_M_Saw(sound fullsound = "weapons/sawfull", sound hitsound = "weapons/sawhit", int damage = 2, class pufftype = "BulletPuff") { if (target == null) return; if (pufftype == null) pufftype = "BulletPuff"; if (damage == 0) damage = 2; A_FaceTarget (); if (CheckMeleeRange ()) { FTranslatedLineTarget t; damage *= random[SMarineSaw](1, 10); double ang = angle + Random2[SMarineSaw]() * (5.625 / 256); LineAttack (angle, SAWRANGE, AimLineAttack (angle, SAWRANGE), damage, 'Melee', pufftype, false, t); if (!t.linetarget) { A_StartSound (fullsound, 1, CHAN_WEAPON); return; } A_StartSound (hitsound, CHAN_WEAPON); // turn to face target ang = t.angleFromSource; double anglediff = deltaangle(angle, ang); if (anglediff < 0.0) { if (anglediff < -4.5) angle = ang + 90.0 / 21; else angle -= 4.5; } else { if (anglediff > 4.5) angle = ang - 90.0 / 21; else angle += 4.5; } } else { A_StartSound (fullsound, 1, CHAN_WEAPON); } } } //--------------------------------------------------------------------------- class MarineFist : ScriptedMarine { States { Melee: Goto Super::Melee.Fist; Missile: Stop; } } //--------------------------------------------------------------------------- class MarineBerserk : MarineFist { States { Melee: Goto Super::Melee.Berserk; Missile: Stop; } } //--------------------------------------------------------------------------- class MarineChainsaw : ScriptedMarine { States { Melee: Goto Super::Melee.Chainsaw; Missile: Stop; } } //--------------------------------------------------------------------------- class MarinePistol : ScriptedMarine { States { Missile: Goto Super::Missile.Pistol; } } //--------------------------------------------------------------------------- class MarineShotgun : ScriptedMarine { States { Missile: Goto Super::Missile.Shotgun; } } //--------------------------------------------------------------------------- class MarineSSG : ScriptedMarine { States { Missile: Goto Super::Missile.SSG; } } //--------------------------------------------------------------------------- class MarineChaingun : ScriptedMarine { States { Missile: Goto Super::Missile.Chaingun; } } //--------------------------------------------------------------------------- class MarineRocket : MarineFist { States { Missile: Goto Super::Missile.Rocket; } } //--------------------------------------------------------------------------- class MarinePlasma : ScriptedMarine { States { Missile: Goto Super::Missile.Plasma; } } //--------------------------------------------------------------------------- class MarineRailgun : ScriptedMarine { States { Missile: Goto Super::Missile.Railgun; } } //--------------------------------------------------------------------------- class MarineBFG : ScriptedMarine { States { Missile: Goto Super::Missile.BFG; } } // Fire Ball ---------------------------------------------------------------- class FireBall : Actor { Default { Speed 2; Radius 8; Height 8; Damage 4; DamageType "Fire"; +NOBLOCKMAP +NOGRAVITY +DROPOFF +MISSILE +NOTELEPORT +ZDOOMTRANS RenderStyle "Add"; DeathSound "Fireball"; } States { Spawn: FBL1 AB 4 Bright; Loop; Death: XPL1 ABCDEF 4 Bright; Stop; } } // Arrow -------------------------------------------------------------------- class Arrow : Actor { Default { Speed 6; Radius 8; Height 4; Damage 4; +NOBLOCKMAP +NOGRAVITY +DROPOFF +MISSILE +NOTELEPORT } States { Spawn: ARRW A -1; Stop; Death: ARRW A 1; Stop; } } // Dart --------------------------------------------------------------------- class Dart : Actor { Default { Speed 6; Radius 8; Height 4; Damage 2; +NOBLOCKMAP +NOGRAVITY +DROPOFF +MISSILE +NOTELEPORT } States { Spawn: DART A -1; Stop; Death: DART A 1; Stop; } } // Poison Dart -------------------------------------------------------------- class PoisonDart : Dart { Default { PoisonDamage 20; } } // Ripper Ball -------------------------------------------------------------- class RipperBall : Actor { Default { Speed 6; Radius 8; Damage 2; +NOBLOCKMAP +NOGRAVITY +DROPOFF +MISSILE +NOTELEPORT +RIPPER } States { Spawn: RIPP ABC 3; Loop; Death: CFCF Q 4 Bright; CFCF R 3 Bright; CFCF S 4 Bright; CFCF T 3 Bright; CFCF U 4 Bright; CFCF V 3 Bright; CFCF W 4 Bright; CFCF X 3 Bright; CFCF Y 4 Bright; CFCF Z 3 Bright; Stop; } } // Projectile Blade --------------------------------------------------------- class ProjectileBlade : Actor { Default { Speed 6; Radius 6; Height 6; Damage 3; +NOBLOCKMAP +NOGRAVITY +DROPOFF +MISSILE +NOTELEPORT } States { Spawn: BLAD A -1; Stop; Death: BLAD A 1; Stop; } } // Container for utility functions used by ACS and FraggleScript. class ScriptUtil play { //============================================================================ // // GiveInventory // // Gives an item to one or more actors. // //============================================================================ static void GiveInventory (Actor activator, Name type, int amount) { if (amount <= 0 || type == 'none') { return; } if (type == 'Armor') { type = "BasicArmorPickup"; } Class info = type; if (info == NULL) { Console.Printf ("GiveInventory: Unknown item type %s.\n", type); } else if (!(info is 'Inventory')) { Console.Printf ("GiveInventory: %s is not an inventory item.\n", type); } else if (activator == NULL) { for (int i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i]) players[i].mo.GiveInventory((class)(info), amount); } } else { activator.GiveInventory((class)(info), amount); } } //============================================================================ // // TakeInventory // // Takes an item from one or more actors. // //============================================================================ static void TakeInventory (Actor activator, Name type, int amount) { if (type == 'none') { return; } if (type == 'Armor') { type = "BasicArmor"; } if (amount <= 0) { return; } Class info = type; if (info == NULL) { return; } if (activator == NULL) { for (int i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i]) players[i].mo.TakeInventory(info, amount); } } else { activator.TakeInventory(info, amount); } } //============================================================================ // // ClearInventory // // Clears the inventory for one or more actors. // //============================================================================ static void ClearInventory (Actor activator) { if (activator == NULL) { for (int i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i]) players[i].mo.ClearInventory(); } } else { activator.ClearInventory(); } } //========================================================================== // // // //========================================================================== static int SetWeapon(Actor activator, class cls) { if(activator != NULL && activator.player != NULL && cls != null) { let item = Weapon(activator.FindInventory(cls)); if(item != NULL) { if(activator.player.ReadyWeapon == item) { // The weapon is already selected, so setweapon succeeds by default, // but make sure the player isn't switching away from it. activator.player.PendingWeapon = WP_NOCHANGE; return 1; } else { if(item.CheckAmmo(Weapon.EitherFire, false)) { // There's enough ammo, so switch to it. activator.player.PendingWeapon = item; return 1; } } } } return 0; } //========================================================================== // // // //========================================================================== static void SetMarineWeapon(LevelLocals Level, Actor activator, int tid, int marineweapontype) { if (tid != 0) { let it = Level.CreateActorIterator(tid, 'ScriptedMarine'); ScriptedMarine marine; while ((marine = ScriptedMarine(it.Next())) != NULL) { marine.SetWeapon(marineweapontype); } } else { let marine = ScriptedMarine(activator); if (marine != null) { marine.SetWeapon(marineweapontype); } } } //========================================================================== // // // //========================================================================== static void SetMarineSprite(LevelLocals Level, Actor activator, int tid, class type) { if (type != NULL) { if (tid != 0) { let it = Level.CreateActorIterator(tid, 'ScriptedMarine'); ScriptedMarine marine; while ((marine = ScriptedMarine(it.Next())) != NULL) { marine.SetSprite(type); } } else { let marine = ScriptedMarine(activator); if (marine != null) { marine.SetSprite(type); } } } else { Console.Printf ("Unknown actor type: %s\n", type.GetClassName()); } } //========================================================================== // // // //========================================================================== static int PlayerMaxAmmo(Actor activator, class type, int newmaxamount = int.min, int newbpmaxamount = int.min) { if (activator == null) return 0; let ammotype = (class)(type); if (ammotype == null) return 0; if (newmaxamount != int.min) { let iammo = Ammo(activator.FindInventory(ammotype)); if(newmaxamount < 0) newmaxamount = 0; if (!iammo) { activator.GiveAmmo(ammotype, 1); iammo = Ammo(activator.FindInventory(ammotype)); if (iammo) iammo.Amount = 0; } for (Inventory item = activator.Inv; item != NULL; item = item.Inv) { if (item is 'BackpackItem') { if (newbpmaxamount == int.min) newbpmaxamount = newmaxamount * 2; break; } } if (iammo) { iammo.MaxAmount = newmaxamount; iammo.BackpackMaxAmount = newbpmaxamount; } } let rammo = activator.FindInventory(ammotype); if (rammo) return rammo.maxamount; else return GetDefaultByType(ammotype).MaxAmount; } //========================================================================== // // // //========================================================================== static int PlayerAmmo(Actor activator, class type, int newamount = int.min) { if (activator == null) return 0; let ammotype = (class)(type); if (ammotype == null) return 0; if (newamount != int.min) { let iammo = activator.FindInventory(ammotype); newamount = max(newamount, 0); if (iammo) iammo.Amount = newamount; else activator.GiveAmmo(ammotype, newamount); } let iammo = activator.FindInventory(ammotype); if (iammo) return iammo.Amount; else return 0; } } //============================================================================= // // Option Search Field class. // // When the search query is entered, makes Search Menu perform a search. // //============================================================================= class os_SearchField : OptionMenuItemTextField { os_SearchField Init(String label, os_Menu menu, string query) { Super.Init(label, ""); mMenu = menu; mText = query; return self; } override bool MenuEvent(int mkey, bool fromcontroller) { if (mkey == Menu.MKEY_Enter) { Menu.MenuSound("menu/choose"); mEnter = TextEnterMenu.OpenTextEnter(Menu.GetCurrentMenu(), Menu.OptionFont(), mText, -1, fromcontroller); mEnter.ActivateMenu(); return true; } if (mkey == Menu.MKEY_Input) { mtext = mEnter.GetText(); mMenu.search(); } return Super.MenuEvent(mkey, fromcontroller); } override String Represent() { return mEnter ? mEnter.GetText() .. NewSmallFont.GetCursor() : mText; } String GetText() { return mText; } private os_Menu mMenu; private string mText; } class SecretTrigger : Actor { default { +NOBLOCKMAP +NOSECTOR +NOGRAVITY +DONTSPLASH +NOTONAUTOMAP } override void PostBeginPlay () { Super.PostBeginPlay (); level.total_secrets++; } override void Activate (Actor activator) { Level.GiveSecret(activator, args[0] <= 1, (args[0] == 0 || args[0] == 2)); Destroy (); } } class SectorAction : Actor { // self class uses health to define the activation type. enum EActivation { SECSPAC_Enter = 1<< 0, SECSPAC_Exit = 1<< 1, SECSPAC_HitFloor = 1<< 2, SECSPAC_HitCeiling = 1<< 3, SECSPAC_Use = 1<< 4, SECSPAC_UseWall = 1<< 5, SECSPAC_EyesDive = 1<< 6, SECSPAC_EyesSurface = 1<< 7, SECSPAC_EyesBelowC = 1<< 8, SECSPAC_EyesAboveC = 1<< 9, SECSPAC_HitFakeFloor = 1<<10, SECSPAC_DamageFloor = 1<<11, SECSPAC_DamageCeiling = 1<<12, SECSPAC_DeathFloor = 1<<13, SECSPAC_DeathCeiling = 1<<14, SECSPAC_Damage3D = 1<<15, SECSPAC_Death3D = 1<<16 }; default { +NOBLOCKMAP +NOSECTOR +NOGRAVITY +DONTSPLASH +NOTONAUTOMAP } override void OnDestroy () { if (CurSector != null) { // Remove ourself from self CurSector's list of actions if (CurSector.SecActTarget == self) { CurSector.SecActTarget = SectorAction(tracer); } else { Actor probe = CurSector.SecActTarget; if (null != probe) { while (probe.tracer != self && probe.tracer != null) { probe = probe.tracer; } if (probe.tracer == self) { probe.tracer = tracer; } } } } Super.OnDestroy(); } override void BeginPlay () { Super.BeginPlay (); // Add ourself to self CurSector's list of actions tracer = CurSector.SecActTarget; CurSector.SecActTarget = self; } override void Activate (Actor source) { bDormant = false; // Projectiles cannot trigger } override void Deactivate (Actor source) { bDormant = true; // Projectiles can trigger } virtual bool TriggerAction (Actor triggerer, int activationType) { if ((activationType & health) && CanTrigger(triggerer)) { return triggerer.A_CallSpecial(special, args[0], args[1], args[2], args[3], args[4]); } return false; } virtual bool CanTrigger (Actor triggerer) { return special && ((triggerer.player && !bFriendly) || (bAmbush && triggerer.bActivateMCross) || (bDormant && triggerer.bActivatePCross)); } } // Triggered when entering CurSector ------------------------------------------- class SecActEnter : SectorAction { Default { Health SECSPAC_Enter; } } // Triggered when leaving CurSector -------------------------------------------- class SecActExit : SectorAction { Default { Health SECSPAC_Exit; } } // Triggered when hitting CurSector's floor ------------------------------------ class SecActHitFloor : SectorAction { Default { Health SECSPAC_HitFloor; } } // Triggered when hitting CurSector's ceiling ---------------------------------- class SecActHitCeil : SectorAction { Default { Health SECSPAC_HitCeiling; } } // Triggered when using inside CurSector --------------------------------------- class SecActUse : SectorAction { Default { Health SECSPAC_Use; } } // Triggered when using a CurSector's wall ------------------------------------- class SecActUseWall : SectorAction { Default { Health SECSPAC_UseWall; } } // Triggered when eyes go below fake floor ---------------------------------- class SecActEyesDive : SectorAction { Default { Health SECSPAC_EyesDive; } } // Triggered when eyes go above fake floor ---------------------------------- class SecActEyesSurface : SectorAction { Default { Health SECSPAC_EyesSurface; } } // Triggered when eyes go below fake ceiling ---------------------------------- class SecActEyesBelowC : SectorAction { Default { Health SECSPAC_EyesBelowC; } } // Triggered when eyes go above fake ceiling ---------------------------------- class SecActEyesAboveC : SectorAction { Default { Health SECSPAC_EyesAboveC; } } // Triggered when hitting fake floor ---------------------------------- class SecActHitFakeFloor : SectorAction { Default { Health SECSPAC_HitFakeFloor; } } // Triggered when sector's floor is damaged ---------------------------------- class SecActDamageFloor : SectorAction { Default { Health SECSPAC_DamageFloor; } // [ZZ] damage is unconditional, so this as well override bool CanTrigger (Actor triggerer) { return !!special; } } // Triggered when sector's ceiling is damaged ---------------------------------- class SecActDamageCeiling : SectorAction { Default { Health SECSPAC_DamageCeiling; } // [ZZ] damage is unconditional, so this as well override bool CanTrigger (Actor triggerer) { return !!special; } } // Triggered when sector's floor is reduced to 0 hp ---------------------------------- class SecActDeathFloor : SectorAction { Default { Health SECSPAC_DeathFloor; } // [ZZ] damage is unconditional, so this as well override bool CanTrigger (Actor triggerer) { return !!special; } } // Triggered when sector's ceiling is reduced to 0 hp ---------------------------------- class SecActDeathCeiling : SectorAction { Default { Health SECSPAC_DeathCeiling; } // [ZZ] damage is unconditional, so this as well override bool CanTrigger (Actor triggerer) { return !!special; } } // Triggered when controlled 3d floor is damaged ---------------------------------- class SecActDamage3D : SectorAction { Default { Health SECSPAC_Damage3D; } // [ZZ] damage is unconditional, so this as well override bool CanTrigger (Actor triggerer) { return !!special; } } // Triggered when controlled 3d floor is reduced to 0 hp ---------------------------------- class SecActDeath3D : SectorAction { Default { Health SECSPAC_Death3D; } // [ZZ] damage is unconditional, so this as well override bool CanTrigger (Actor triggerer) { return !!special; } } //========================================================================== // // Music changer. Uses the sector action class to do its job // //========================================================================== class MusicChanger : SectorAction { override bool TriggerAction (Actor triggerer, int activationType) { if (activationType & SECSPAC_Enter && triggerer.player != null) { if (triggerer.player.MUSINFOactor != self) { triggerer.player.MUSINFOactor = self; triggerer.player.MUSINFOtics = 30; } } return false; } override void PostBeginPlay() { // The music changer should consider itself activated if the player // spawns in its sector as well as if it enters the sector during a P_TryMove. Super.PostBeginPlay(); for (int i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i] && players[i].mo && players[i].mo.CurSector == self.CurSector) { TriggerAction(players[i].mo, SECSPAC_Enter); } } } } // Sentinel ----------------------------------------------------------------- class Sentinel : Actor { Default { Health 100; Painchance 255; Speed 7; Radius 23; Height 53; Mass 300; Monster; +SPAWNCEILING +NOGRAVITY +DROPOFF +NOBLOOD +NOBLOCKMONST +INCOMBAT +MISSILEMORE +LOOKALLAROUND +NEVERRESPAWN MinMissileChance 150; Tag "$TAG_SENTINEL"; SeeSound "sentinel/sight"; DeathSound "sentinel/death"; ActiveSound "sentinel/active"; Obituary "$OB_SENTINEL"; } States { Spawn: SEWR A 10 A_Look; Loop; See: SEWR A 6 A_SentinelBob; SEWR A 6 A_Chase; Loop; Missile: SEWR B 4 A_FaceTarget; SEWR C 8 Bright A_SentinelAttack; SEWR C 4 Bright A_SentinelRefire; Goto Missile+1; Pain: SEWR D 5 A_Pain; Goto Missile+2; Death: SEWR D 7 A_Fall; SEWR E 8 Bright A_TossGib; SEWR F 5 Bright A_Scream; SEWR GH 4 Bright A_TossGib; SEWR I 4; SEWR J 5; Stop; } void A_SentinelAttack () { // [BB] Without a target the P_SpawnMissileZAimed call will crash. if (!target) { return; } Actor missile = SpawnMissileZAimed (pos.z + 32, target, "SentinelFX2"); if (missile != NULL && (missile.Vel.X != 0 || missile.Vel.Y != 0)) { for (int i = 8; i > 1; --i) { Actor trail = Spawn("SentinelFX1", Vec3Angle(missile.radius*i, missile.angle, 32 + missile.Vel.Z / 4 * i), ALLOW_REPLACE); if (trail != NULL) { trail.target = self; trail.Vel = missile.Vel; trail.CheckMissileSpawn (radius); } } missile.AddZ(missile.Vel.Z / 4); } } } // Sentinel FX 1 ------------------------------------------------------------ class SentinelFX1 : Actor { Default { Speed 40; Radius 10; Height 8; Damage 0; DamageType "Disintegrate"; Projectile; +STRIFEDAMAGE +ZDOOMTRANS MaxStepHeight 4; RenderStyle "Add"; } States { Spawn: SHT1 AB 4; Loop; Death: POW1 J 4; Stop; } } // Sentinel FX 2 ------------------------------------------------------------ class SentinelFX2 : SentinelFX1 { Default { SeeSound "sentinel/plasma"; Damage 1; } States { Death: POW1 FGHI 4; Goto Super::Death; } } extend class Actor { // These are used elsewhere, too. void A_SentinelBob() { if (bInFloat) { Vel.Z = 0; return; } if (threshold != 0) return; double maxz = ceilingz - Height - 16; double minz = floorz + 96; if (minz > maxz) { minz = maxz; } if (minz < pos.z) { Vel.Z -= 1; } else { Vel.Z += 1; } reactiontime = (minz >= pos.z) ? 4 : 0; } void A_SentinelRefire() { A_FaceTarget (); if (random[SentinelRefire]() >= 30) { if (target == NULL || target.health <= 0 || !CheckSight (target, SF_SEEPASTBLOCKEVERYTHING|SF_SEEPASTSHOOTABLELINES) || HitFriend() || (MissileState == NULL && !CheckMeleeRange()) || random[SentinelRefire]() < 40) { SetState (SeeState); } } } } // Serpent ------------------------------------------------------------------ class Serpent : Actor { Default { Health 90; PainChance 96; Speed 12; Radius 32; Height 70; Mass 0x7fffffff; Monster; -SHOOTABLE +NOBLOOD +CANTLEAVEFLOORPIC +NONSHOOTABLE +STAYMORPHED +DONTBLAST +NOTELEOTHER +INVISIBLE SeeSound "SerpentSight"; AttackSound "SerpentAttack"; PainSound "SerpentPain"; DeathSound "SerpentDeath"; HitObituary "$OB_SERPENTHIT"; Tag "$FN_SERPENT"; } States { Spawn: SSPT H 10 A_Look; Loop; See: SSPT HH 1 A_Chase("Melee", null, CHF_NIGHTMAREFAST|CHF_NOPLAYACTIVE); SSPT H 2 A_SerpentHumpDecide; Loop; Pain: SSPT L 5; SSPT L 5 A_Pain; Dive: SSDV ABC 4; SSDV D 4 A_UnSetShootable; SSDV E 3 A_StartSound("SerpentActive", CHAN_BODY); SSDV F 3; SSDV GH 4; SSDV I 3; SSDV J 3 A_SerpentHide; Goto See; Melee: SSPT A 1 A_UnHideThing; SSPT A 1 A_StartSound("SerpentBirth", CHAN_BODY); SSPT B 3 A_SetShootable; SSPT C 3; SSPT D 4 A_SerpentCheckForAttack; Goto Dive; Death: SSPT O 4; SSPT P 4 A_Scream; SSPT Q 4 A_NoBlocking; SSPT RSTUVWXYZ 4; Stop; XDeath: SSXD A 4; SSXD B 4 A_SpawnItemEx("SerpentHead", 0, 0, 45); SSXD C 4 A_NoBlocking; SSXD DE 4; SSXD FG 3; SSXD H 3 A_SerpentSpawnGibs; Stop; Ice: SSPT [ 5 A_FreezeDeath; SSPT [ 1 A_FreezeDeathChunks; Wait; Walk: SSPT IJI 5 A_Chase("Attack", null, CHF_NIGHTMAREFAST); SSPT J 5 A_SerpentCheckForAttack; Goto Dive; Hump: SSPT H 3 A_SerpentUnHide; SSPT EFGEF 3 A_SerpentRaiseHump; SSPT GEF 3; SSPT GEFGE 3 A_SerpentLowerHump; SSPT F 3 A_SerpentHide; Goto See; Attack: SSPT K 6 A_FaceTarget; SSPT L 5 A_SerpentChooseAttack; Goto MeleeAttack; MeleeAttack: SSPT N 5 A_SerpentMeleeAttack; Goto Dive; } //============================================================================ // // A_SerpentUnHide // //============================================================================ void A_SerpentUnHide() { bInvisible = false; Floorclip = 24; } //============================================================================ // // A_SerpentHide // //============================================================================ void A_SerpentHide() { bInvisible = true; Floorclip = 0; } //============================================================================ // // A_SerpentRaiseHump // // Raises the hump above the surface by raising the floorclip level //============================================================================ void A_SerpentRaiseHump() { Floorclip -= 4; } //============================================================================ // // A_SerpentLowerHump // //============================================================================ void A_SerpentLowerHump() { Floorclip += 4; } //============================================================================ // // A_SerpentHumpDecide // // Decided whether to hump up, or if the mobj is a serpent leader, // to missile attack //============================================================================ void A_SerpentHumpDecide() { if (MissileState != NULL) { if (random[SerpentHump]() > 30) { return; } else if (random[SerpentHump]() < 40) { // Missile attack SetState (MeleeState); return; } } else if (random[SerpentHump]() > 3) { return; } if (!CheckMeleeRange ()) { // The hump shouldn't occur when within melee range if (MissileState != NULL && random[SerpentHump]() < 128) { SetState (MeleeState); } else { SetStateLabel("Hump"); A_StartSound ("SerpentActive", CHAN_BODY); } } } //============================================================================ // // A_SerpentCheckForAttack // //============================================================================ void A_SerpentCheckForAttack() { if (!target) { return; } if (MissileState != NULL) { if (!CheckMeleeRange ()) { SetStateLabel ("Attack"); return; } } if (CheckMeleeRange2 ()) { SetStateLabel ("Walk"); } else if (CheckMeleeRange ()) { if (random[SerpentAttack]() < 32) { SetStateLabel ("Walk"); } else { SetStateLabel ("Attack"); } } } //============================================================================ // // A_SerpentChooseAttack // //============================================================================ void A_SerpentChooseAttack() { if (!target || CheckMeleeRange()) { return; } if (MissileState != NULL) { SetState (MissileState); } } //============================================================================ // // A_SerpentMeleeAttack // //============================================================================ void A_SerpentMeleeAttack() { let targ = target; if (!targ) { return; } if (CheckMeleeRange ()) { int damage = random[SerpentAttack](1, 8) * 5; int newdam = targ.DamageMobj (self, self, damage, 'Melee'); targ.TraceBleed (newdam > 0 ? newdam : damage, self); A_StartSound ("SerpentMeleeHit", CHAN_BODY); } if (random[SerpentAttack]() < 96) { A_SerpentCheckForAttack(); } } //============================================================================ // // A_SerpentSpawnGibs // //============================================================================ void A_SerpentSpawnGibs() { static const class GibTypes[] = { "SerpentGib3", "SerpentGib2", "SerpentGib1" }; for (int i = 2; i >= 0; --i) { double x = (random[SerpentGibs]() - 128) / 16.; double y = (random[SerpentGibs]() - 128) / 16.; Actor mo = Spawn (GibTypes[i], Vec2OffsetZ(x, y, floorz + 1), ALLOW_REPLACE); if (mo) { mo.Vel.X = (random[SerpentGibs]() - 128) / 1024.f; mo.Vel.Y = (random[SerpentGibs]() - 128) / 1024.f; mo.Floorclip = 6; } } } } extend class Actor { //---------------------------------------------------------------------------- // // FUNC P_CheckMeleeRange2 // // This belongs to the Serpent but was initially exported on Actor // so it needs to remain there. // //---------------------------------------------------------------------------- bool CheckMeleeRange2 () { Actor mo; double dist; if (!target || (CurSector.Flags & Sector.SECF_NOATTACK)) { return false; } mo = target; dist = mo.Distance2D (self); if (dist >= 128 || dist < meleerange + mo.radius) { return false; } if (mo.pos.Z > pos.Z + height) { // Target is higher than the attacker return false; } else if (pos.Z > mo.pos.Z + mo.height) { // Attacker is higher return false; } else if (IsFriend(mo)) { // killough 7/18/98: friendly monsters don't attack other friends return false; } return CheckSight(mo); } } // Serpent Leader ----------------------------------------------------------- class SerpentLeader : Serpent { Default { Mass 200; Obituary "$OB_SERPENT"; } States { Missile: SSPT N 5 A_SpawnProjectile("SerpentFX", 32, 0); Goto Dive; } } // Serpent Missile Ball ----------------------------------------------------- class SerpentFX : Actor { Default { Speed 15; Radius 8; Height 10; Damage 4; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS +ZDOOMTRANS RenderStyle "Add"; DeathSound "SerpentFXHit"; } States { Spawn: SSFX A 0; SSFX A 3 Bright A_StartSound("SerpentFXContinuous", CHAN_BODY, CHANF_LOOPING); SSFX BAB 3 Bright; Goto Spawn+1; Death: SSFX C 4 Bright A_StopSound(CHAN_BODY); SSFX DEFGH 4 Bright; Stop; } } // Serpent Head ------------------------------------------------------------- class SerpentHead : Actor { Default { Radius 5; Height 10; Gravity 0.125; +NOBLOCKMAP } States { Spawn: SSXD IJKLMNOP 4 A_SerpentHeadCheck; Loop; Death: SSXD S -1; Loop; } //============================================================================ // // A_SerpentHeadCheck // //============================================================================ void A_SerpentHeadCheck() { if (pos.z <= floorz) { if (GetFloorTerrain().IsLiquid) { HitFloor (); Destroy(); } else { SetStateLabel ("Death"); } } } } // Serpent Gib 1 ------------------------------------------------------------ class SerpentGib1 : Actor { Default { Radius 3; Height 3; +NOBLOCKMAP +NOGRAVITY } States { Spawn: SSXD Q 6; SSXD Q 6 A_FloatGib; SSXD QQ 8 A_FloatGib; SSXD QQ 12 A_FloatGib; SSXD Q 232 A_DelayGib; SSXD QQ 12 A_SinkGib; SSXD QQQ 8 A_SinkGib; Stop; } //============================================================================ // // A_FloatGib // //============================================================================ void A_FloatGib() { Floorclip -= 1; } //============================================================================ // // A_SinkGib // //============================================================================ void A_SinkGib() { Floorclip += 1; } //============================================================================ // // A_DelayGib // //============================================================================ void A_DelayGib() { tics -= random[DelayGib]() >> 2; } } // Serpent Gib 2 ------------------------------------------------------------ class SerpentGib2 : SerpentGib1 { States { Spawn: SSXD R 6; SSXD R 6 A_FloatGib; SSXD RR 8 A_FloatGib; SSXD RR 12 A_FloatGib; SSXD R 232 A_DelayGib; SSXD RR 12 A_SinkGib; SSXD RRR 8 A_SinkGib; Stop; } } // Serpent Gib 3 ------------------------------------------------------------ class SerpentGib3 : SerpentGib1 { States { Spawn: SSXD T 6; SSXD T 6 A_FloatGib; SSXD TT 8 A_FloatGib; SSXD TT 12 A_FloatGib; SSXD T 232 A_DelayGib; SSXD TT 12 A_SinkGib; SSXD TTT 8 A_SinkGib; Stop; } } /** * This is Service interface. */ class Service abstract { deprecated("4.6.1", "Use GetString() instead") virtual play String Get(String request) { return ""; } deprecated("4.6.1", "Use GetStringUI() instead") virtual ui String UiGet(String request) { return ""; } // Play variants virtual play String GetString(String request, string stringArg = "", int intArg = 0, double doubleArg = 0, Object objectArg = null, Name nameArg = '') { return ""; } virtual play int GetInt(String request, string stringArg = "", int intArg = 0, double doubleArg = 0, Object objectArg = null, Name nameArg = '') { return 0; } virtual play double GetDouble(String request, string stringArg = "", int intArg = 0, double doubleArg = 0, Object objectArg = null, Name nameArg = '') { return 0.0; } virtual play Object GetObject(String request, string stringArg = "", int intArg = 0, double doubleArg = 0, Object objectArg = null, Name nameArg = '') { return null; } virtual play Name GetName(String request, string stringArg = "", int intArg = 0, double doubleArg = 0, Object objectArg = null, Name nameArg = '') { return ''; } // UI variants virtual ui String GetStringUI(String request, string stringArg = "", int intArg = 0, double doubleArg = 0, Object objectArg = null, Name nameArg = '') { return ""; } virtual ui int GetIntUI(String request, string stringArg = "", int intArg = 0, double doubleArg = 0, Object objectArg = null, Name nameArg = '') { return 0; } virtual ui double GetDoubleUI(String request, string stringArg = "", int intArg = 0, double doubleArg = 0, Object objectArg = null, Name nameArg = '') { return 0.0; } virtual ui Object GetObjectUI(String request, string stringArg = "", int intArg = 0, double doubleArg = 0, Object objectArg = null, Name nameArg = '') { return null; } virtual ui Name GetNameUI(String request, string stringArg = "", int intArg = 0, double doubleArg = 0, Object objectArg = null, Name nameArg = '') { return ''; } // data/clearscope variants virtual clearscope String GetStringData(String request, string stringArg = "", int intArg = 0, double doubleArg = 0, Object objectArg = null, Name nameArg = '') { return ""; } virtual clearscope int GetIntData(String request, string stringArg = "", int intArg = 0, double doubleArg = 0, Object objectArg = null, Name nameArg = '') { return 0; } virtual clearscope double GetDoubleData(String request, string stringArg = "", int intArg = 0, double doubleArg = 0, Object objectArg = null, Name nameArg = '') { return 0.0; } virtual clearscope Object GetObjectData(String request, string stringArg = "", int intArg = 0, double doubleArg = 0, Object objectArg = null, Name nameArg = '') { return null; } virtual clearscope Name GetNameData(String request, string stringArg = "", int intArg = 0, double doubleArg = 0, Object objectArg = null, Name nameArg = '') { return ''; } static Service Find(class serviceName){ return AllServices.GetIfExists(serviceName.GetClassName()); } } /** * Use this class to find and iterate over services. * * Example usage: * * @code * ServiceIterator i = ServiceIterator.Find("MyService"); * * Service s; * while (s = i.Next()) * { * String request = ... * String answer = s.Get(request); * ... * } * @endcode * * If no services are found, the all calls to Next() will return NULL. */ class ServiceIterator { /** * Creates a Service iterator for a service name. It will iterate over all existing Services * with names that match @a serviceName or have it as a part of their names. * * Matching is case-independent. * * @param serviceName class name of service to find. */ static ServiceIterator Find(String serviceName) { let result = new("ServiceIterator"); result.mServiceName = serviceName.MakeLower(); result.it.Init(AllServices); return result; } /** * Gets the service and advances the iterator. * * @returns service instance, or NULL if no more services found. */ Service Next() { while(it.Next()) { String cName = it.GetKey(); if(cName.MakeLower().IndexOf(mServiceName) != -1) return it.GetValue(); } return null; } private MapIterator it; private String mServiceName; } class ColorSetter : Actor { default { +NOBLOCKMAP +NOGRAVITY +DONTSPLASH RenderStyle "None"; } override void PostBeginPlay() { Super.PostBeginPlay(); CurSector.SetColor(color(args[0], args[1], args[2]), args[3]); Destroy(); } } class FadeSetter : Actor { default { +NOBLOCKMAP +NOGRAVITY +DONTSPLASH RenderStyle "None"; } override void PostBeginPlay() { Super.PostBeginPlay(); CurSector.SetFade(color(args[0], args[1], args[2])); Destroy(); } } // Default class for unregistered doomednums ------------------------------- class Unknown : Actor { Default { Radius 32; Height 56; +NOGRAVITY +NOBLOCKMAP +DONTSPLASH } States { Spawn: UNKN A -1; Stop; } } // Route node for monster patrols ------------------------------------------- class PatrolPoint : Actor { Default { Radius 8; Height 8; Mass 10; +NOGRAVITY +NOBLOCKMAP +DONTSPLASH +NOTONAUTOMAP RenderStyle "None"; } } // A special to execute when a monster reaches a matching patrol point ------ class PatrolSpecial : Actor { Default { Radius 8; Height 8; Mass 10; +NOGRAVITY +NOBLOCKMAP +DONTSPLASH +NOTONAUTOMAP RenderStyle "None"; } } // Map spot ---------------------------------------------------------------- class MapSpot : Actor { Default { +NOBLOCKMAP +NOSECTOR +NOGRAVITY +DONTSPLASH +NOTONAUTOMAP RenderStyle "None"; CameraHeight 0; } } // same with different editor number for Legacy maps ----------------------- class FS_Mapspot : Mapspot { } // Map spot with gravity --------------------------------------------------- class MapSpotGravity : MapSpot { Default { -NOBLOCKMAP -NOSECTOR -NOGRAVITY +NOTONAUTOMAP } } // Point Pushers ----------------------------------------------------------- class PointPusher : Actor { Default { +NOBLOCKMAP +INVISIBLE +NOCLIP +NOTONAUTOMAP } } class PointPuller : Actor { Default { +NOBLOCKMAP +INVISIBLE +NOCLIP +NOTONAUTOMAP } } // Bloody gibs ------------------------------------------------------------- class RealGibs : Actor { Default { +DROPOFF +CORPSE +NOTELEPORT +DONTGIB } States { Spawn: goto GenericCrush; } } // Gibs that can be placed on a map. --------------------------------------- // // These need to be a separate class from the above, in case someone uses // a deh patch to change the gibs, since ZDoom actually creates a gib class // for actors that get crushed instead of changing their state as Doom did. class Gibs : RealGibs { Default { ClearFlags; } } // Needed for loading Build maps ------------------------------------------- class CustomSprite : Actor { Default { +NOBLOCKMAP +NOGRAVITY } States { Spawn: TNT1 A -1; Stop; } override void BeginPlay () { Super.BeginPlay (); String name = String.Format("BTIL%04d", args[0] & 0xffff); picnum = TexMan.CheckForTexture (name, TexMan.TYPE_Build); if (!picnum.Exists()) { Destroy(); return; } Scale.X = args[2] / 64.; Scale.Y = args[3] / 64.; int cstat = args[4]; if (cstat & 2) { A_SetRenderStyle((cstat & 512) ? 0.6666 : 0.3333, STYLE_Translucent); } if (cstat & 4) bXFlip = true; if (cstat & 8) bYFlip = true; if (cstat & 16) bWallSprite = true; if (cstat & 32) bFlatSprite = true; } } // SwitchableDecoration: Activate and Deactivate change state -------------- class SwitchableDecoration : Actor { override void Activate (Actor activator) { SetStateLabel("Active"); } override void Deactivate (Actor activator) { SetStateLabel("Inactive"); } } class SwitchingDecoration : SwitchableDecoration { override void Deactivate (Actor activator) { } } // Sector flag setter ------------------------------------------------------ class SectorFlagSetter : Actor { Default { +NOBLOCKMAP +NOGRAVITY +DONTSPLASH RenderStyle "None"; } override void BeginPlay () { Super.BeginPlay (); CurSector.Flags |= args[0]; Destroy(); } } // Marker for sounds : Actor ------------------------------------------------------- class SpeakerIcon : Unknown { States { Spawn: SPKR A -1 BRIGHT; Stop; } Default { Scale 0.125; } } // The Almighty Sigil! ------------------------------------------------------ class Sigil : Weapon { // NUmPieces gets stored in 'health', so that it can be quickly accessed by ACS's GetSigilPieces function. int downpieces; Default { Weapon.Kickback 100; Weapon.SelectionOrder 4000; Health 1; +FLOORCLIP +WEAPON.CHEATNOTWEAPON Inventory.PickupSound "weapons/sigilcharge"; Tag "$TAG_SIGIL"; Inventory.Icon "I_SGL1"; Inventory.PickupMessage "$TXT_SIGIL"; } States(Actor) { Spawn: SIGL A 1; SIGL A -1 A_SelectPiece; Stop; SIGL B -1; Stop; SIGL C -1; Stop; SIGL D -1; Stop; SIGL E -1; Stop; } States(Weapon) { Ready: SIGH A 0 Bright A_SelectSigilView; Wait; SIGH A 1 Bright A_WeaponReady; Wait; SIGH B 1 Bright A_WeaponReady; Wait; SIGH C 1 Bright A_WeaponReady; Wait; SIGH D 1 Bright A_WeaponReady; Wait; SIGH E 1 Bright A_WeaponReady; Wait; Deselect: SIGH A 1 Bright A_SelectSigilDown; Wait; SIGH A 1 Bright A_Lower; Wait; SIGH B 1 Bright A_Lower; Wait; SIGH C 1 Bright A_Lower; Wait; SIGH D 1 Bright A_Lower; Wait; SIGH E 1 Bright A_Lower; Wait; Select: SIGH A 1 Bright A_SelectSigilView; Wait; SIGH A 1 Bright A_Raise; Wait; SIGH B 1 Bright A_Raise; Wait; SIGH C 1 Bright A_Raise; Wait; SIGH D 1 Bright A_Raise; Wait; SIGH E 1 Bright A_Raise; Wait; Fire: SIGH A 0 Bright A_SelectSigilAttack; SIGH A 18 Bright A_SigilCharge; SIGH A 3 Bright A_GunFlash; SIGH A 10 A_FireSigil1; SIGH A 5; Goto Ready; SIGH B 18 Bright A_SigilCharge; SIGH B 3 Bright A_GunFlash; SIGH B 10 A_FireSigil2; SIGH B 5; Goto Ready; SIGH C 18 Bright A_SigilCharge; SIGH C 3 Bright A_GunFlash; SIGH C 10 A_FireSigil3; SIGH C 5; Goto Ready; SIGH D 18 Bright A_SigilCharge; SIGH D 3 Bright A_GunFlash; SIGH D 10 A_FireSigil4; SIGH D 5; Goto Ready; SIGH E 18 Bright A_SigilCharge; SIGH E 3 Bright A_GunFlash; SIGH E 10 A_FireSigil5; SIGH E 5; Goto Ready; Flash: SIGF A 4 Bright A_Light2; SIGF B 6 Bright A_LightInverse; SIGF C 4 Bright A_Light1; SIGF C 0 Bright A_Light0; Stop; } //============================================================================ // // ASigil :: HandlePickup // //============================================================================ override bool HandlePickup (Inventory item) { if (item is "Sigil") { int otherPieces = item.health; if (otherPieces > health) { item.bPickupGood = true; Icon = item.Icon; // If the player is holding the Sigil right now, drop it and bring // it back with the new piece(s) in view. if (Owner.player != null && Owner.player.ReadyWeapon == self) { DownPieces = health; Owner.player.PendingWeapon = self; } health = otherPieces; } return true; } return false; } //============================================================================ // // ASigil :: CreateCopy // //============================================================================ override Inventory CreateCopy (Actor other) { Sigil copy = Sigil(Spawn("Sigil")); copy.Amount = Amount; copy.MaxAmount = MaxAmount; copy.health = health; copy.Icon = Icon; GoAwayAndDie (); return copy; } //============================================================================ // // A_SelectPiece // // Decide which sprite frame self Sigil should use as an item, based on how // many pieces it represents. // //============================================================================ void A_SelectPiece () { int pieces = min (health, 5); if (pieces > 1) { SetState (FindState("Spawn") + pieces); } } //============================================================================ // // A_SelectSigilView // // Decide which first-person frame self Sigil should show, based on how many // pieces it represents. Strife did self by selecting a flash that looked like // the Sigil whenever you switched to it and at the end of an attack. I have // chosen to make the weapon sprite choose the correct frame and let the flash // be a regular flash. It means I need to use more states, but I think it's // worth it. // //============================================================================ action void A_SelectSigilView () { if (player == null) { return; } PSprite pspr = player.GetPSprite(PSP_WEAPON); if (pspr) pspr.SetState(pspr.CurState + invoker.health); invoker.downpieces = 0; } //============================================================================ // // A_SelectSigilDown // // Same as A_SelectSigilView, except it uses DownPieces. self is so that when // you pick up a Sigil, the old one will drop and *then* change to the new // one. // //============================================================================ action void A_SelectSigilDown () { if (player == null) { return; } PSprite pspr = player.GetPSprite(PSP_WEAPON); int pieces = invoker.downpieces; if (pieces < 1 || pieces > 5) pieces = invoker.health; if (pspr) pspr.SetState(pspr.CurState + pieces); } //============================================================================ // // A_SelectSigilAttack // // Same as A_SelectSigilView, but used just before attacking. // //============================================================================ action void A_SelectSigilAttack () { if (player == null) { return; } PSprite pspr = player.GetPSprite(PSP_WEAPON); if (pspr) pspr.SetState(pspr.CurState + (4 * invoker.health - 3)); } //============================================================================ // // A_SigilCharge // //============================================================================ action void A_SigilCharge () { A_StartSound ("weapons/sigilcharge", CHAN_WEAPON); if (player != null) { player.extralight = 2; } } //============================================================================ // // A_FireSigil1 // //============================================================================ action void A_FireSigil1 () { Actor spot = null; FTranslatedLineTarget t; if (player == null || player.ReadyWeapon == null) return; DamageMobj (self, null, 1*4, 'Sigil', DMG_NO_ARMOR); A_StartSound ("weapons/sigilcharge", CHAN_WEAPON); BulletSlope (t, ALF_PORTALRESTRICT); if (t.linetarget != null) { spot = Spawn("SpectralLightningSpot", (t.linetarget.pos.xy, t.linetarget.floorz), ALLOW_REPLACE); if (spot != null) { spot.tracer = t.linetarget; } } else { spot = Spawn("SpectralLightningSpot", Pos, ALLOW_REPLACE); if (spot != null) { spot.VelFromAngle(28., angle); } } if (spot != null) { spot.SetFriendPlayer(player); spot.target = self; } } //============================================================================ // // A_FireSigil2 // //============================================================================ action void A_FireSigil2 () { if (player == null || player.ReadyWeapon == null) return; DamageMobj (self, null, 2*4, 'Sigil', DMG_NO_ARMOR); A_StartSound ("weapons/sigilcharge", CHAN_WEAPON); SpawnPlayerMissile ("SpectralLightningH1"); } //============================================================================ // // A_FireSigil3 // //============================================================================ action void A_FireSigil3 () { if (player == null || player.ReadyWeapon == null) return; DamageMobj (self, null, 3*4, 'Sigil', DMG_NO_ARMOR); A_StartSound ("weapons/sigilcharge", CHAN_WEAPON); angle -= 90.; for (int i = 0; i < 20; ++i) { angle += 9.; Actor spot = SpawnSubMissile ("SpectralLightningBall1", self); if (spot != null) { spot.SetZ(pos.z + 32); } } angle -= 90.; } //============================================================================ // // A_FireSigil4 // //============================================================================ action void A_FireSigil4 () { FTranslatedLineTarget t; if (player == null || player.ReadyWeapon == null) return; DamageMobj (self, null, 4*4, 'Sigil', DMG_NO_ARMOR); A_StartSound ("weapons/sigilcharge", CHAN_WEAPON); BulletSlope (t, ALF_PORTALRESTRICT); if (t.linetarget != null) { Actor spot = SpawnPlayerMissile ("SpectralLightningBigV1", angle, pLineTarget: t, aimFlags: ALF_PORTALRESTRICT); if (spot != null) { spot.tracer = t.linetarget; } } else { Actor spot = SpawnPlayerMissile ("SpectralLightningBigV1"); if (spot != null) { spot.VelFromAngle(spot.Speed, angle); } } } //============================================================================ // // A_FireSigil5 // //============================================================================ action void A_FireSigil5 () { if (player == null || player.ReadyWeapon == null) return; DamageMobj (self, null, 5*4, 'Sigil', DMG_NO_ARMOR); A_StartSound ("weapons/sigilcharge", CHAN_WEAPON); SpawnPlayerMissile ("SpectralLightningBigBall1"); } //============================================================================ // // ASigil :: SpecialDropAction // // Monsters don't drop Sigil pieces. The Sigil pieces grab hold of the person // who killed the dropper and automatically enter their inventory. That's the // way it works if you believe Macil, anyway... // //============================================================================ override bool SpecialDropAction (Actor dropper) { // Give a Sigil piece to every player in the game for (int i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i] && players[i].mo != null) { GiveSigilPiece (players[i].mo); Destroy (); } } return true; } //============================================================================ // // ASigil :: GiveSigilPiece // // Gives the actor another Sigil piece, up to 5. Returns the number of Sigil // pieces the actor previously held. // //============================================================================ static int GiveSigilPiece (Actor receiver) { Sigil sigl = Sigil(receiver.FindInventory("Sigil")); if (sigl == null) { sigl = Sigil(Spawn("Sigil1")); if (!sigl.CallTryPickup (receiver)) { sigl.Destroy (); } return 0; } else if (sigl.health < 5) { ++sigl.health; static const class sigils[] = { "Sigil1", "Sigil2", "Sigil3", "Sigil4", "Sigil5" }; sigl.Icon = GetDefaultByType(sigils[clamp(sigl.health, 1, 5)-1]).Icon; // If the player has the Sigil out, drop it and bring it back up. if (sigl.Owner.player != null && sigl.Owner.player.ReadyWeapon == sigl) { sigl.Owner.player.PendingWeapon = sigl; sigl.DownPieces = sigl.health - 1; } return sigl.health - 1; } else { return 5; } } } // Sigil 1 ------------------------------------------------------------------ class Sigil1 : Sigil { Default { Inventory.Icon "I_SGL1"; Health 1; } } // Sigil 2 ------------------------------------------------------------------ class Sigil2 : Sigil { Default { Inventory.Icon "I_SGL2"; Health 2; } } // Sigil 3 ------------------------------------------------------------------ class Sigil3 : Sigil { Default { Inventory.Icon "I_SGL3"; Health 3; } } // Sigil 4 ------------------------------------------------------------------ class Sigil4 : Sigil { Default { Inventory.Icon "I_SGL4"; Health 4; } } // Sigil 5 ------------------------------------------------------------------ class Sigil5 : Sigil { Default { Inventory.Icon "I_SGL5"; Health 5; } } /* ** a_skies.cpp ** Skybox-related actors ** **--------------------------------------------------------------------------- ** Copyright 1998-2016 Randy Heit ** Copyright 2006-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, self list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, self list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from self software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ class SkyViewpoint : Actor { default { +NOSECTOR +NOBLOCKMAP +NOGRAVITY +DONTSPLASH } // arg0 = Visibility*4 for self skybox // If self actor has no TID, make it the default sky box override void BeginPlay () { Super.BeginPlay (); if (tid == 0 && level.sectorPortals[0].mSkybox == null) { level.sectorPortals[0].mSkybox = self; level.sectorPortals[0].mDestination = CurSector; } } override void OnDestroy () { // remove all sector references to ourselves. for (int i = 0; i < level.sectorPortals.Size(); i++) { SectorPortal s = level.sectorPortals[i]; if (s.mSkybox == self) { s.mSkybox = null; // This is necessary to entirely disable EE-style skyboxes // if their viewpoint gets deleted. s.mFlags |= SectorPortal.FLAG_SKYFLATONLY; } } Super.OnDestroy(); } } //--------------------------------------------------------------------------- // arg0 = tid of matching SkyViewpoint // A value of 0 means to use a regular stretched texture, in case // there is a default SkyViewpoint in the level. // // arg1 = 0: set both floor and ceiling skybox // = 1: set only ceiling skybox // = 2: set only floor skybox class SkyPicker : Actor { default { +NOSECTOR +NOBLOCKMAP +NOGRAVITY +DONTSPLASH } override void PostBeginPlay () { Actor box; Super.PostBeginPlay (); if (args[0] == 0) { box = null; } else { let it = Level.CreateActorIterator(args[0], "SkyViewpoint"); box = it.Next (); } if (box == null && args[0] != 0) { A_Log(String.Format("Can't find SkyViewpoint %d for sector %d\n", args[0], CurSector.Index())); } else { int boxindex = level.GetSkyboxPortal(box); // Do not override special portal types, only regular skies. if (0 == (args[1] & 2)) { if (CurSector.GetPortalType(sector.ceiling) == SectorPortal.TYPE_SKYVIEWPOINT) CurSector.Portals[sector.ceiling] = boxindex; } if (0 == (args[1] & 1)) { if (CurSector.GetPortalType(sector.floor) == SectorPortal.TYPE_SKYVIEWPOINT) CurSector.Portals[sector.floor] = boxindex; } } Destroy (); } } class SkyCamCompat : SkyViewpoint { override void BeginPlay () { // Skip SkyViewpoint's initialization, Actor's is not needed here. } } class StackPoint : SkyViewpoint { override void BeginPlay () { // Skip SkyViewpoint's initialization, Actor's is not needed here. } } class UpperStackLookOnly : StackPoint { } class LowerStackLookOnly : StackPoint { } class SectorSilencer : Actor { default { +NOBLOCKMAP +NOGRAVITY +DONTSPLASH RenderStyle "None"; } override void BeginPlay () { Super.BeginPlay (); CurSector.Flags |= Sector.SECF_SILENT; } override void OnDestroy () { if (CurSector != null) { CurSector.Flags &= ~Sector.SECF_SILENT; } Super.OnDestroy(); } } class Snake : Actor { Default { Health 280; Radius 22; Height 70; Speed 10; Painchance 48; Monster; +FLOORCLIP AttackSound "snake/attack"; SeeSound "snake/sight"; PainSound "snake/pain"; DeathSound "snake/death"; ActiveSound "snake/active"; Obituary "$OB_SNAKE"; Tag "$FN_SNAKE"; DropItem "PhoenixRodAmmo", 84, 5; } States { Spawn: SNKE AB 10 A_Look; Loop; See: SNKE ABCD 4 A_Chase; Loop; Missile: SNKE FF 5 A_FaceTarget; SNKE FFF 4 A_SpawnProjectile("SnakeProjA", 32, 0, 0, CMF_CHECKTARGETDEAD); SNKE FFF 5 A_FaceTarget; SNKE F 4 A_SpawnProjectile("SnakeProjB", 32, 0, 0, CMF_CHECKTARGETDEAD); Goto See; Pain: SNKE E 3; SNKE E 3 A_Pain; Goto See; Death: SNKE G 5; SNKE H 5 A_Scream; SNKE IJKL 5; SNKE M 5 A_NoBlocking; SNKE NO 5; SNKE P -1; Stop; } } // Snake projectile A ------------------------------------------------------- class SnakeProjA : Actor { Default { Radius 12; Height 8; Speed 14; FastSpeed 20; Damage 1; Projectile; -NOBLOCKMAP -ACTIVATEIMPACT -ACTIVATEPCROSS +WINDTHRUST +SPAWNSOUNDSOURCE +ZDOOMTRANS RenderStyle "Add"; SeeSound "snake/attack"; } States { Spawn: SNFX ABCD 5 Bright; Loop; Death: SNFX EF 5 Bright; SNFX G 4 Bright; SNFX HI 3 Bright; Stop; } } // Snake projectile B ------------------------------------------------------- class SnakeProjB : SnakeProjA { Default { Damage 3; +NOBLOCKMAP -WINDTHRUST } States { Spawn: SNFX JK 6 Bright; Loop; Death: SNFX LM 5 Bright; SNFX N 4 Bright; SNFX O 3 Bright; Stop; } } class SeqNode native { enum ESeqType { PLATFORM, DOOR, ENVIRONMENT, NUMSEQTYPES, NOTRANS }; native bool AreModesSameID(int sequence, int type, int mode1); native bool AreModesSame(Name name, int mode1); native Name GetSequenceName(); native void AddChoice (int seqnum, int type); native static Name GetSequenceSlot (int sequence, int type); native static void MarkPrecacheSounds(int sequence, int type); } class SoundEnvironment : Actor { default { +NOSECTOR +NOBLOCKMAP +NOGRAVITY +DONTSPLASH +NOTONAUTOMAP } override void PostBeginPlay () { Super.PostBeginPlay (); if (!bDormant) { Activate (self); } } override void Activate (Actor activator) { CurSector.SetEnvironmentID((args[0]<<8) | (args[1])); } // Deactivate just exists so that you can flag the thing as dormant in an editor // and not have it take effect. This is so you can use multiple environments in // a single zone, with only one set not-dormant, so you know which one will take // effect at the start. override void Deactivate (Actor deactivator) { bDormant = true; } } /* ** a_soundsequence.cpp ** Actors for independently playing sound sequences in a map. ** **--------------------------------------------------------------------------- ** Copyright 1998-2006 Randy Heit ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** ** A SoundSequence actor has two modes of operation: ** ** 1. If the sound sequence assigned to it has a slot, then a separate ** SoundSequenceSlot actor is spawned (if not already present), and ** this actor's sound sequence is added to its list of choices. This ** actor is then destroyed, never to be heard from again. The sound ** sequence for the slot is automatically played on the new ** SoundSequenceSlot actor, and it should at some point execute the ** randomsequence command so that it can pick one of the other ** sequences to play. The slot sequence should also end with restart ** so that more than one sequence will have a chance to play. ** ** In this mode, it is very much like world $ambient sounds defined ** in SNDINFO but more flexible. ** ** 2. If the sound sequence assigned to it has no slot, then it will play ** the sequence when activated and cease playing the sequence when ** deactivated. ** ** In this mode, it is very much like point $ambient sounds defined ** in SNDINFO but more flexible. ** ** To assign a sound sequence, set the SoundSequence's first argument to ** the ID of the corresponding environment sequence you want to use. If ** that sequence is a multiple-choice sequence, then the second argument ** selects which choice it picks. */ class AmbientSound : Actor { default { +NOBLOCKMAP +NOSECTOR +DONTSPLASH +NOTONAUTOMAP } native void MarkAmbientSounds(); override native void Tick(); override native void Activate(Actor activator); override native void Deactivate(Actor activator); override void BeginPlay () { Super.BeginPlay (); Activate (NULL); } override void MarkPrecacheSounds() { Super.MarkPrecacheSounds(); MarkAmbientSounds(); } } class AmbientSoundNoGravity : AmbientSound { default { +NOGRAVITY } } class SoundSequenceSlot : Actor { default { +NOSECTOR +NOBLOCKMAP +DONTSPLASH +NOTONAUTOMAP } SeqNode sequence; } class SoundSequence : Actor { default { +NOSECTOR +NOBLOCKMAP +DONTSPLASH +NOTONAUTOMAP } //========================================================================== // // ASoundSequence :: Destroy // //========================================================================== override void OnDestroy () { StopSoundSequence (); Super.OnDestroy(); } //========================================================================== // // ASoundSequence :: PostBeginPlay // //========================================================================== override void PostBeginPlay () { Name slot = SeqNode.GetSequenceSlot (args[0], SeqNode.ENVIRONMENT); if (slot != 'none') { // This is a slotted sound, so add it to the master for that slot SoundSequenceSlot master; let locator = ThinkerIterator.Create("SoundSequenceSlot"); while ((master = SoundSequenceSlot(locator.Next ()))) { if (master.Sequence.GetSequenceName() == slot) { break; } } if (master == NULL) { master = SoundSequenceSlot(Spawn("SoundSequenceSlot")); master.Sequence = master.StartSoundSequence (slot, 0); } master.Sequence.AddChoice (args[0], SeqNode.ENVIRONMENT); Destroy (); } } //========================================================================== // // ASoundSequence :: MarkPrecacheSounds // //========================================================================== override void MarkPrecacheSounds() { Super.MarkPrecacheSounds(); SeqNode.MarkPrecacheSounds(args[0], SeqNode.ENVIRONMENT); } //========================================================================== // // ASoundSequence :: Activate // //========================================================================== override void Activate (Actor activator) { StartSoundSequenceID (args[0], SeqNode.ENVIRONMENT, args[1]); } //========================================================================== // // ASoundSequence :: Deactivate // //========================================================================== override void Deactivate (Actor activator) { StopSoundSequence (); } } // Heretic Sound sequences ----------------------------------------------------------- class HereticSoundSequence1 : SoundSequence { default { Args 0; } } class HereticSoundSequence2 : SoundSequence { default { Args 1; } } class HereticSoundSequence3 : SoundSequence { default { Args 2; } } class HereticSoundSequence4 : SoundSequence { default { Args 3; } } class HereticSoundSequence5 : SoundSequence { default { Args 4; } } class HereticSoundSequence6 : SoundSequence { default { Args 5; } } class HereticSoundSequence7 : SoundSequence { default { Args 6; } } class HereticSoundSequence8 : SoundSequence { default { Args 7; } } class HereticSoundSequence9 : SoundSequence { default { Args 8; } } class HereticSoundSequence10 : SoundSequence { default { Args 9; } } class Spark : Actor { default { +NOSECTOR +NOBLOCKMAP +NOGRAVITY +DONTSPLASH } override void Activate (Actor activator) { Super.Activate (activator); DrawSplash (args[0] ? args[0] : 32, Angle, 1); A_StartSound ("world/spark", CHAN_AUTO, CHANF_DEFAULT, 1, ATTN_STATIC); } } class SpotState : Object native play { deprecated ("3.8") static SpotState GetSpotState(bool create = true) { return level.GetSpotState(create); } native SpecialSpot GetNextInList(class type, int skipcounter); native SpecialSpot GetSpotWithMinMaxDistance(Class type, double x, double y, double mindist, double maxdist); native SpecialSpot GetRandomSpot(class type, bool onlyonce); native void AddSpot(SpecialSpot spot); native void RemoveSpot(SpecialSpot spot); } class SpecialSpot : Actor { override void BeginPlay() { let sstate = Level.GetSpotState(); if (sstate != NULL) sstate.AddSpot(self); Super.BeginPlay(); } //---------------------------------------------------------------------------- // // // //---------------------------------------------------------------------------- override void OnDestroy() { let sstate = Level.GetSpotState(false); if (sstate != NULL) sstate.RemoveSpot(self); Super.OnDestroy(); } // Mace spawn spot ---------------------------------------------------------- // Every mace spawn spot will execute this action. The first one // will build a list of all mace spots in the level and spawn a // mace. The rest of the spots will do nothing. void A_SpawnSingleItem(class cls, int fail_sp = 0, int fail_co = 0, int fail_dm = 0) { Actor spot = NULL; let state = Level.GetSpotState(); if (state != NULL) spot = state.GetRandomSpot(GetClass(), true); if (spot == NULL) return; if (!multiplayer && random[SpawnMace]() < fail_sp) { // Sometimes doesn't show up if not in deathmatch return; } if (multiplayer && !deathmatch && random[SpawnMace]() < fail_co) { return; } if (deathmatch && random[SpawnMace]() < fail_dm) { return; } if (cls == NULL) { return; } let spawned = Spawn(cls, self.Pos, ALLOW_REPLACE); if (spawned) { // Setting z in two steps is necessary to proper initialize floorz before using it. spawned.SetOrigin (spot.Pos, false); spawned.SetZ(spawned.floorz); // We want this to respawn. if (!bDropped) { spawned.bDropped = false; } let inv = Inventory(spawned); if (inv) { inv.SpawnPointClass = GetClass(); } } } } // base for all spectral monsters which hurt when being touched-------------- class SpectralMonster : Actor { Default { Monster; +SPECIAL +SPECTRAL +NOICEDEATH } override void Touch (Actor toucher) { toucher.DamageMobj (self, self, 5, 'Melee'); } //============================================================================ void A_SpectreChunkSmall () { Actor foo = Spawn("AlienChunkSmall", pos + (0, 0, 10), ALLOW_REPLACE); if (foo != null) { int t; t = random[SpectreChunk](0, 7); foo.Vel.X = t - random[SpectreChunk](0, 15); t = random[SpectreChunk](0, 7); foo.Vel.Y = t - random[SpectreChunk](0, 15); foo.Vel.Z = random[SpectreChunk](0, 15); } } void A_SpectreChunkLarge () { Actor foo = Spawn("AlienChunkLarge", pos + (0, 0, 10), ALLOW_REPLACE); if (foo != null) { int t; t = random[SpectreChunk](0, 7); foo.Vel.X = t - random[SpectreChunk](0, 15); t = random[SpectreChunk](0, 7); foo.Vel.Y = t - random[SpectreChunk](0, 15); foo.Vel.Z = random[SpectreChunk](0, 7); } } void A_Spectre3Attack () { if (target == null) return; Actor foo = Spawn("SpectralLightningV2", Pos + (0, 0, 32), ALLOW_REPLACE); if (foo != null) { foo.Vel.Z = -12; foo.target = self; foo.FriendPlayer = 0; foo.tracer = target; } Angle -= 90.; for (int i = 0; i < 20; ++i) { Angle += 9.; SpawnSubMissile ("SpectralLightningBall2", self); } Angle -= 90.; } //============================================================================ // // A_SpotLightning // //============================================================================ void A_SpotLightning() { if (target == null) return; Actor spot = Spawn("SpectralLightningSpot", (target.pos.xy, target.floorz), ALLOW_REPLACE); if (spot != null) { spot.threshold = 25; spot.target = self; spot.FriendPlayer = 0; spot.tracer = target; } } } // Container for all spectral lightning deaths ------------------------------ class SpectralLightningBase : Actor { Default { +NOTELEPORT +ACTIVATEIMPACT +ACTIVATEPCROSS +STRIFEDAMAGE +ZDOOMTRANS MaxStepHeight 4; RenderStyle "Add"; SeeSound "weapons/sigil"; DeathSound "weapons/sigilhit"; } States { Death: ZAP1 B 3 A_Explode(32,32); ZAP1 A 3 A_AlertMonsters; ZAP1 BCDEFE 3; ZAP1 DCB 2; ZAP1 A 1; Stop; } } // Spectral Lightning death that does not explode --------------------------- class SpectralLightningDeath1 : SpectralLightningBase { States { Death: Goto Super::Death+1; } } // Spectral Lightning death that does not alert monsters -------------------- class SpectralLightningDeath2 : SpectralLightningBase { States { Death: Goto Super::Death+2; } } // Spectral Lightning death that is shorter than the rest ------------------- class SpectralLightningDeathShort : SpectralLightningBase { States { Death: Goto Super::Death+6; } } // Spectral Lightning (Ball Shaped #1) -------------------------------------- class SpectralLightningBall1 : SpectralLightningBase { Default { Speed 30; Radius 8; Height 16; Damage 70; Projectile; +SPECTRAL } States { Spawn: ZOT3 ABCDE 4 Bright; Loop; } } // Spectral Lightning (Ball Shaped #2) -------------------------------------- class SpectralLightningBall2 : SpectralLightningBall1 { Default { Damage 20; } } // Spectral Lightning (Horizontal #1) --------------------------------------- class SpectralLightningH1 : SpectralLightningBase { Default { Speed 30; Radius 8; Height 16; Damage 70; Projectile; +SPECTRAL } States { Spawn: ZAP6 A 4 Bright; ZAP6 BC 4 Bright A_SpectralLightningTail; Loop; } void A_SpectralLightningTail () { Actor foo = Spawn("SpectralLightningHTail", Vec3Offset(-Vel.X, -Vel.Y, 0.), ALLOW_REPLACE); if (foo != null) { foo.Angle = Angle; foo.FriendPlayer = FriendPlayer; } } } // Spectral Lightning (Horizontal #2) ------------------------------------- class SpectralLightningH2 : SpectralLightningH1 { Default { Damage 20; } } // Spectral Lightning (Horizontal #3) ------------------------------------- class SpectralLightningH3 : SpectralLightningH1 { Default { Damage 10; } } // ASpectralLightningHTail -------------------------------------------------- class SpectralLightningHTail : Actor { Default { +NOBLOCKMAP +NOGRAVITY +DROPOFF +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: ZAP6 ABC 5 Bright; Stop; } } // Spectral Lightning (Big Ball #1) ----------------------------------------- class SpectralLightningBigBall1 : SpectralLightningDeath2 { Default { Speed 18; Radius 20; Height 40; Damage 130; Projectile; +SPECTRAL } States { Spawn: ZAP7 AB 4 Bright A_SpectralBigBallLightning; ZAP7 CDE 6 Bright A_SpectralBigBallLightning; Loop; } void A_SpectralBigBallLightning () { Class cls = "SpectralLightningH3"; if (cls) { angle += 90.; SpawnSubMissile (cls, target); angle += 180.; SpawnSubMissile (cls, target); angle -= 270.; SpawnSubMissile (cls, target); } } } // Spectral Lightning (Big Ball #2 - less damaging) ------------------------- class SpectralLightningBigBall2 : SpectralLightningBigBall1 { Default { Damage 30; } } // Sigil Lightning (Vertical #1) -------------------------------------------- class SpectralLightningV1 : SpectralLightningDeathShort { Default { Speed 22; Radius 8; Height 24; Damage 100; Projectile; DamageType "SpectralLow"; +SPECTRAL } States { Spawn: ZOT1 AB 4 Bright; ZOT1 CDE 6 Bright; Loop; } } // Sigil Lightning (Vertical #2 - less damaging) ---------------------------- class SpectralLightningV2 : SpectralLightningV1 { Default { Damage 50; } } // Sigil Lightning Spot (roams around dropping lightning from above) -------- class SpectralLightningSpot : SpectralLightningDeath1 { Default { Speed 18; ReactionTime 70; +NOBLOCKMAP +NOBLOCKMONST +NODROPOFF RenderStyle "Translucent"; Alpha 0.6; } States { Spawn: ZAP5 A 4 Bright A_Countdown; ZAP5 B 4 Bright A_SpectralLightning; ZAP5 CD 4 Bright A_Countdown; Loop; } void A_SpectralLightning () { if (threshold != 0) --threshold; Vel.X += random2[Zap5](3); Vel.Y += random2[Zap5](3); double xo = random2[Zap5](3) * 50.; double yo = random2[Zap5](3) * 50.; class cls; if (threshold > 25) cls = "SpectralLightningV2"; else cls = "SpectralLightningV1"; Actor flash = Spawn (cls, Vec2OffsetZ(xo, yo, ONCEILINGZ), ALLOW_REPLACE); if (flash != null) { flash.target = target; flash.Vel.Z = -18; flash.FriendPlayer = FriendPlayer; } flash = Spawn("SpectralLightningV2", (pos.xy, ONCEILINGZ), ALLOW_REPLACE); if (flash != null) { flash.target = target; flash.Vel.Z = -18; flash.FriendPlayer = FriendPlayer; } } } // Sigil Lightning (Big Vertical #1) ---------------------------------------- class SpectralLightningBigV1 : SpectralLightningDeath1 { Default { Speed 28; Radius 8; Height 16; Damage 120; Projectile; +SPECTRAL } States { Spawn: ZOT2 ABCDE 4 Bright A_Tracer2; Loop; } } // Actor 90 ----------------------------------------------------------------- class SpectralLightningBigV2 : SpectralLightningBigV1 { Default { Damage 60; } } class ArtiSpeedBoots : PowerupGiver { Default { +FLOATBOB +COUNTITEM Inventory.PickupFlash "PickupFlash"; Inventory.Icon "ARTISPED"; Inventory.PickupMessage "$TXT_ARTISPEED"; Tag "$TAG_ARTISPEED"; Powerup.Type "PowerSpeed"; } States { Spawn: SPED ABCDEFGH 3 Bright; Loop; } } //=========================================================================== // // Spider boss // //=========================================================================== class SpiderMastermind : Actor { Default { Health 3000; Radius 128; Height 100; Mass 1000; Speed 12; PainChance 40; Monster; +BOSS +MISSILEMORE +FLOORCLIP +NORADIUSDMG +DONTMORPH +BOSSDEATH +E3M8BOSS +E4M8BOSS SeeSound "spider/sight"; AttackSound "spider/attack"; PainSound "spider/pain"; DeathSound "spider/death"; ActiveSound "spider/active"; Obituary "$OB_SPIDER"; Tag "$FN_SPIDER"; } States { Spawn: SPID AB 10 A_Look; Loop; See: SPID A 3 A_Metal; SPID ABB 3 A_Chase; SPID C 3 A_Metal; SPID CDD 3 A_Chase; SPID E 3 A_Metal; SPID EFF 3 A_Chase; Loop; Missile: SPID A 20 BRIGHT A_FaceTarget; SPID G 4 BRIGHT A_SPosAttackUseAtkSound; SPID H 4 BRIGHT A_SposAttackUseAtkSound; SPID H 1 BRIGHT A_SpidRefire; Goto Missile+1; Pain: SPID I 3; SPID I 3 A_Pain; Goto See; Death: SPID J 20 A_Scream; SPID K 10 A_NoBlocking; SPID LMNOPQR 10; SPID S 30; SPID S -1 A_BossDeath; Stop; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== extend class Actor { void A_SpidRefire() { // keep firing unless target got out of sight A_FaceTarget(); if (Random[CPosRefire](0, 255) >= 10) { if (!target || HitFriend() || target.health <= 0 || !CheckSight(target, SF_SEEPASTBLOCKEVERYTHING|SF_SEEPASTSHOOTABLELINES)) { SetState(SeeState); } } } void A_Metal() { A_StartSound("spider/walk", CHAN_BODY, CHANF_DEFAULT, 1, ATTN_IDLE); A_Chase(); } } // Dirt clump (spawned by spike) -------------------------------------------- class DirtClump : Actor { Default { +NOBLOCKMAP +NOTELEPORT } States { Spawn: TSPK C 20; Loop; } } // Spike (thrust floor) ----------------------------------------------------- class ThrustFloor : Actor { Default { Radius 20; Height 128; } States { ThrustRaising: TSPK A 2 A_ThrustRaise; Loop; BloodThrustRaising: TSPK B 2 A_ThrustRaise; Loop; ThrustLower: TSPK A 2 A_ThrustLower; Loop; BloodThrustLower: TSPK B 2 A_ThrustLower; Loop; ThrustInit1: TSPK A 3; TSPK A 4 A_ThrustInitDn; TSPK A -1; Loop; BloodThrustInit1: TSPK B 3; TSPK B 4 A_ThrustInitDn; TSPK B -1; Loop; ThrustInit2: TSPK A 3; TSPK A 4 A_ThrustInitUp; TSPK A 10; Loop; BloodThrustInit2: TSPK B 3; TSPK B 4 A_ThrustInitUp; TSPK B 10; Loop; ThrustRaise: TSPK A 8 A_ThrustRaise; TSPK A 6 A_ThrustRaise; TSPK A 4 A_ThrustRaise; TSPK A 3 A_SetSolid; TSPK A 2 A_ThrustImpale; Loop; BloodThrustRaise: TSPK B 8 A_ThrustRaise; TSPK B 6 A_ThrustRaise; TSPK B 4 A_ThrustRaise; TSPK B 3 A_SetSolid; TSPK B 2 A_ThrustImpale; Loop; } override void Activate (Actor activator) { if (args[0] == 0) { A_StartSound ("ThrustSpikeLower", CHAN_BODY); bInvisible = false; if (args[1]) SetStateLabel("BloodThrustRaise"); else SetStateLabel("ThrustRaise"); } } override void Deactivate (Actor activator) { if (args[0] == 1) { A_StartSound ("ThrustSpikeRaise", CHAN_BODY); if (args[1]) SetStateLabel("BloodThrustLower"); else SetStateLabel("ThrustLower"); } } //=========================================================================== // // Thrust floor stuff // // Thrust Spike Variables // master pointer to dirt clump actor // special2 speed of raise // args[0] 0 = lowered, 1 = raised // args[1] 0 = normal, 1 = bloody //=========================================================================== void A_ThrustInitUp() { special2 = 5; // Raise speed args[0] = 1; // Mark as up Floorclip = 0; bSolid = true; bNoTeleport = true; bFloorClip = true; special1 = 0; } void A_ThrustInitDn() { special2 = 5; // Raise speed args[0] = 0; // Mark as down Floorclip = Default.Height; bSolid = false; bNoTeleport = true; bFloorClip = true; bInvisible = true; master = Spawn("DirtClump", Pos, ALLOW_REPLACE); } void A_ThrustRaise() { if (RaiseMobj (special2)) { // Reached it's target height args[0] = 1; if (args[1]) SetStateLabel ("BloodThrustInit2", true); else SetStateLabel ("ThrustInit2", true); } // Lose the dirt clump if ((Floorclip < Height) && master) { master.Destroy (); master = null; } // Spawn some dirt if (random[Thrustraise]()<40) SpawnDirt (radius); special2++; // Increase raise speed } void A_ThrustLower() { if (SinkMobj (6)) { args[0] = 0; if (args[1]) SetStateLabel ("BloodThrustInit1", true); else SetStateLabel ("ThrustInit1", true); } } void A_ThrustImpale() { BlockThingsIterator it = BlockThingsIterator.Create(self); while (it.Next()) { let targ = it.thing; if (targ != null) { double blockdist = radius + targ.radius; if (abs(targ.pos.x - it.Position.X) >= blockdist || abs(targ.pos.y - it.Position.Y) >= blockdist) continue; // Q: Make this z-aware for everything? It never was before. if (targ.pos.z + targ.height < pos.z || targ.pos.z > pos.z + height) { if (CurSector.PortalGroup != targ.CurSector.PortalGroup) continue; } if (!targ.bShootable) continue; if (targ == self) continue; // don't clip against self int newdam = targ.DamageMobj (self, self, 10001, 'Crush'); targ.TraceBleed (newdam > 0 ? newdam : 10001, null); args[1] = 1; // Mark thrust thing as bloody } } } } // Spike up ----------------------------------------------------------------- class ThrustFloorUp : ThrustFloor { Default { +SOLID +NOTELEPORT +FLOORCLIP } States { Spawn: Goto ThrustInit2; } } // Spike down --------------------------------------------------------------- class ThrustFloorDown : ThrustFloor { Default { +NOTELEPORT +FLOORCLIP +INVISIBLE } States { Spawn: Goto ThrustInit1; } } // Water -------------------------------------------------------------------- class WaterSplash : Actor { default { Radius 2; Height 4; Gravity 0.125; +NOBLOCKMAP +MISSILE +DROPOFF +NOTELEPORT +CANNOTPUSH +DONTSPLASH +DONTBLAST } States { Spawn: SPSH ABC 8; SPSH D 16; Stop; Death: SPSH D 10; Stop; } } class WaterSplashBase : Actor { default { +NOBLOCKMAP +NOCLIP +NOGRAVITY +DONTSPLASH +DONTBLAST +MOVEWITHSECTOR } States { Spawn: SPSH EFGHIJK 5; Stop; } } // Lava --------------------------------------------------------------------- class LavaSplash : Actor { default { +NOBLOCKMAP +NOCLIP +NOGRAVITY +DONTSPLASH +DONTBLAST +MOVEWITHSECTOR } States { Spawn: LVAS ABCDEF 5 Bright; Stop; } } class LavaSmoke : Actor { default { +NOBLOCKMAP +NOCLIP +NOGRAVITY +DONTSPLASH RenderStyle "Translucent"; DefaultAlpha; } States { Spawn: LVAS GHIJK 5 Bright; Stop; } } // Sludge ------------------------------------------------------------------- class SludgeChunk : Actor { default { Radius 2; Height 4; Gravity 0.125; +NOBLOCKMAP +MISSILE +DROPOFF +NOTELEPORT +CANNOTPUSH +DONTSPLASH } States { Spawn: SLDG ABCD 8; Stop; Death: SLDG D 6; Stop; } } class SludgeSplash : Actor { default { +NOBLOCKMAP +NOCLIP +NOGRAVITY +DONTSPLASH +MOVEWITHSECTOR } States { Spawn: SLDG EFGH 6; Stop; } } /* * These next four classes are not used by me anywhere. * They are for people who want to use them in a TERRAIN lump. */ // Blood (water with a different sprite) ------------------------------------ class BloodSplash : Actor { default { Radius 2; Height 4; Gravity 0.125; +NOBLOCKMAP +MISSILE +DROPOFF +NOTELEPORT +CANNOTPUSH +DONTSPLASH +DONTBLAST } States { Spawn: BSPH ABC 8; BSPH D 16; Stop; Death: BSPH D 10; Stop; } } class BloodSplashBase : Actor { default { +NOBLOCKMAP +NOCLIP +NOGRAVITY +DONTSPLASH +DONTBLAST +MOVEWITHSECTOR } States { Spawn: BSPH EFGHIJK 5; Stop; } } // Slime (sludge with a different sprite) ----------------------------------- class SlimeChunk : Actor { default { Radius 2; Height 4; Gravity 0.125; +NOBLOCKMAP +MISSILE +DROPOFF +NOTELEPORT +CANNOTPUSH +DONTSPLASH } States { Spawn: SLIM ABCD 8; Stop; Death: SLIM D 6; Stop; } } class SlimeSplash : Actor { default { +NOBLOCKMAP +NOCLIP +NOGRAVITY +DONTSPLASH +MOVEWITHSECTOR } States { Spawn: SLIM EFGH 6; Stop; } } // Smoke trail for rocket ----------------------------------- class RocketSmokeTrail : Actor { default { RenderStyle "Translucent"; Alpha 0.4; VSpeed 1; +NOBLOCKMAP +NOCLIP +NOGRAVITY +DONTSPLASH +NOTELEPORT } States { Spawn: RSMK ABCDE 5; Stop; } } class GrenadeSmokeTrail : Actor { default { RenderStyle "Translucent"; Alpha 0.4; +NOBLOCKMAP +NOCLIP +DONTSPLASH +NOTELEPORT Gravity 0.1; VSpeed 0.5; Scale 0.6; } States { Spawn: RSMK ABCDE 4; Stop; } } // Stalker ------------------------------------------------------------------ class Stalker : Actor { Default { Health 80; Painchance 40; Speed 16; Radius 31; Height 25; Monster; +NOGRAVITY +DROPOFF +NOBLOOD +SPAWNCEILING +INCOMBAT +NOVERTICALMELEERANGE MaxDropOffHeight 32; MinMissileChance 150; Tag "$TAG_STALKER"; SeeSound "stalker/sight"; AttackSound "stalker/attack"; PainSound "stalker/pain"; DeathSound "stalker/death"; ActiveSound "stalker/active"; HitObituary "$OB_STALKER"; } States { Spawn: STLK A 1 A_StalkerLookInit; Loop; LookCeiling: STLK A 10 A_Look; Loop; LookFloor: STLK J 10 A_Look; Loop; See: STLK A 1 Slow A_StalkerChaseDecide; STLK ABB 3 Slow A_Chase; STLK C 3 Slow A_StalkerWalk; STLK C 3 Slow A_Chase; Loop; Melee: STLK J 3 Slow A_FaceTarget; STLK K 3 Slow A_StalkerAttack; SeeFloor: STLK J 3 A_StalkerWalk; STLK KK 3 A_Chase; STLK L 3 A_StalkerWalk; STLK L 3 A_Chase; Loop; Pain: STLK L 1 A_Pain; Goto See; Drop: STLK C 2 A_StalkerDrop; STLK IHGFED 3; Goto SeeFloor; Death: STLK O 4; STLK P 4 A_Scream; STLK QRST 4; STLK U 4 A_NoBlocking; STLK VW 4; STLK XYZ[ 4 Bright; Stop; } void A_StalkerChaseDecide () { if (!bNoGravity) { SetStateLabel("SeeFloor"); } else if (ceilingz > pos.z + height) { SetStateLabel("Drop"); } } void A_StalkerLookInit () { State st; if (bNoGravity) { st = FindState("LookCeiling"); } else { st = FindState("LookFloor"); } if (st != CurState.NextState) { SetState (st); } } void A_StalkerDrop () { bNoVerticalMeleeRange = false; bNoGravity = false; } void A_StalkerAttack () { if (bNoGravity) { SetStateLabel("Drop"); } else if (target != null) { A_FaceTarget (); if (CheckMeleeRange ()) { let targ = target; int damage = random[Stalker](1, 8) * 2; int newdam = targ.DamageMobj (self, self, damage, 'Melee'); targ.TraceBleed (newdam > 0 ? newdam : damage, self); } } } void A_StalkerWalk () { A_StartSound ("stalker/walk", CHAN_BODY); A_Chase (); } } class StateProvider : Inventory { //========================================================================== // // State jump function // //========================================================================== action state A_JumpIfNoAmmo(statelabel label) { if (stateinfo == null || stateinfo.mStateType != STATE_Psprite || player == null || player.ReadyWeapon == null || player.ReadyWeapon.CheckAmmo(player.ReadyWeapon.bAltFire, false, true)) { return null; } else return ResolveState(label); } //=========================================================================== // // Modified code pointer from Skulltag // //=========================================================================== action state A_CheckForReload(int count, statelabel jump, bool dontincrement = false) { if (stateinfo == null || stateinfo.mStateType != STATE_Psprite || player == null || player.ReadyWeapon == null) { return null; } state ret = null; let weapon = player.ReadyWeapon; int ReloadCounter = weapon.ReloadCounter; if (!dontincrement || ReloadCounter != 0) ReloadCounter = (weapon.ReloadCounter+1) % count; else // 0 % 1 = 1? So how do we check if the weapon was never fired? We should only do this when we're not incrementing the counter though. ReloadCounter = 1; // If we have not made our last shot... if (ReloadCounter != 0) { // Go back to the refire frames, instead of continuing on to the reload frames. ret = ResolveState(jump); } else { // We need to reload. However, don't reload if we're out of ammo. weapon.CheckAmmo(false, false); } if (!dontincrement) { weapon.ReloadCounter = ReloadCounter; } return ret; } //=========================================================================== // // Resets the counter for the above function // //=========================================================================== action void A_ResetReloadCounter() { if (stateinfo != null && stateinfo.mStateType == STATE_Psprite && player != null && player.ReadyWeapon != null) player.ReadyWeapon.ReloadCounter = 0; } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- action void A_FireBullets(double spread_xy, double spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", int flags = 1, double range = 0, class missile = null, double Spawnheight = 32, double Spawnofs_xy = 0) { let player = player; if (!player) return; let pawn = PlayerPawn(self); let weapon = player.ReadyWeapon; int i; double bangle; double bslope = 0.; int laflags = (flags & FBF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 0; FTranslatedLineTarget t; if ((flags & FBF_USEAMMO) && weapon && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { if (!weapon.DepleteAmmo(weapon.bAltFire, true)) return; // out of ammo } if (range == 0) range = PLAYERMISSILERANGE; if (!(flags & FBF_NOFLASH)) pawn.PlayAttacking2 (); if (!(flags & FBF_NOPITCH)) bslope = BulletSlope(); bangle = Angle; if (pufftype == NULL) pufftype = 'BulletPuff'; if (weapon != NULL) { A_StartSound(weapon.AttackSound, CHAN_WEAPON); } if ((numbullets == 1 && !player.refire) || numbullets == 0) { int damage = damageperbullet; if (!(flags & FBF_NORANDOM)) damage *= random[cabullet](1, 3); let puff = LineAttack(bangle, range, bslope, damage, 'Hitscan', pufftype, laflags, t); if (missile != null) { bool temp = false; double ang = Angle - 90; Vector2 ofs = AngleToVector(ang, Spawnofs_xy); Actor proj = SpawnPlayerMissile(missile, bangle, ofs.X, ofs.Y, Spawnheight); if (proj) { if (!puff) { temp = true; puff = LineAttack(bangle, range, bslope, 0, 'Hitscan', pufftype, laflags | LAF_NOINTERACT, t); } AimBulletMissile(proj, puff, flags, temp, false); if (t.unlinked) { // Arbitary portals will make angle and pitch calculations unreliable. // So use the angle and pitch we passed instead. proj.Angle = bangle; proj.Pitch = bslope; proj.Vel3DFromAngle(proj.Speed, proj.Angle, proj.Pitch); } } } } else { if (numbullets < 0) numbullets = 1; for (i = 0; i < numbullets; i++) { double pangle = bangle; double slope = bslope; if (flags & FBF_EXPLICITANGLE) { pangle += spread_xy; slope += spread_z; } else { pangle += spread_xy * Random2[cabullet]() / 255.; slope += spread_z * Random2[cabullet]() / 255.; } int damage = damageperbullet; if (!(flags & FBF_NORANDOM)) damage *= random[cabullet](1, 3); let puff = LineAttack(pangle, range, slope, damage, 'Hitscan', pufftype, laflags, t); if (missile != null) { bool temp = false; double ang = Angle - 90; Vector2 ofs = AngleToVector(ang, Spawnofs_xy); Actor proj = SpawnPlayerMissile(missile, bangle, ofs.X, ofs.Y, Spawnheight); if (proj) { if (!puff) { temp = true; puff = LineAttack(bangle, range, bslope, 0, 'Hitscan', pufftype, laflags | LAF_NOINTERACT, t); } AimBulletMissile(proj, puff, flags, temp, false); if (t.unlinked) { // Arbitary portals will make angle and pitch calculations unreliable. // So use the angle and pitch we passed instead. proj.Angle = bangle; proj.Pitch = bslope; proj.Vel3DFromAngle(proj.Speed, proj.Angle, proj.Pitch); } } } } } } //========================================================================== // // A_FireProjectile // //========================================================================== action Actor, Actor A_FireProjectile(class missiletype, double angle = 0, bool useammo = true, double spawnofs_xy = 0, double spawnheight = 0, int flags = 0, double pitch = 0) { let player = self.player; if (!player) return null, null; let weapon = player.ReadyWeapon; FTranslatedLineTarget t; // Only use ammo if called from a weapon if (useammo && weapon && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { if (!weapon.DepleteAmmo(weapon.bAltFire, true)) return null, null; // out of ammo } if (missiletype) { double ang = self.Angle - 90; Vector2 ofs = AngleToVector(ang, spawnofs_xy); double shootangle = self.Angle; if (flags & FPF_AIMATANGLE) shootangle += angle; // Temporarily adjusts the pitch double saved_player_pitch = self.Pitch; self.Pitch += pitch; Actor misl, realmisl; [misl, realmisl] = SpawnPlayerMissile (missiletype, shootangle, ofs.X, ofs.Y, spawnheight, t, false, (flags & FPF_NOAUTOAIM) != 0); self.Pitch = saved_player_pitch; if (realmisl && flags & FPF_TRANSFERTRANSLATION) realmisl.Translation = Translation; // automatic handling of seeker missiles if (misl) { if (t.linetarget && !t.unlinked && misl.bSeekerMissile) misl.tracer = t.linetarget; if (!(flags & FPF_AIMATANGLE)) { // This original implementation is to aim straight ahead and then offset // the angle from the resulting direction. misl.Angle += angle; misl.VelFromAngle(misl.Vel.XY.Length()); } } return misl, realmisl; } return null, null; } //========================================================================== // // A_CustomPunch // // Berserk is not handled here. That can be done with A_CheckIfInventory // //========================================================================== action void A_CustomPunch(int damage, bool norandom = false, int flags = CPF_USEAMMO, class pufftype = "BulletPuff", double range = 0, double lifesteal = 0, int lifestealmax = 0, class armorbonustype = "ArmorBonus", sound MeleeSound = 0, sound MissSound = "") { let player = self.player; if (!player) return; let weapon = player.ReadyWeapon; double angle; double pitch; FTranslatedLineTarget t; int actualdamage; if (!norandom) damage *= random[cwpunch](1, 8); angle = self.Angle + random2[cwpunch]() * (5.625 / 256); if (range == 0) range = DEFMELEERANGE; pitch = AimLineAttack (angle, range, t, 0., ALF_CHECK3D); // only use ammo when actually hitting something! if ((flags & CPF_USEAMMO) && t.linetarget && weapon && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { if (!weapon.DepleteAmmo(weapon.bAltFire, true)) return; // out of ammo } if (pufftype == NULL) pufftype = 'BulletPuff'; int puffFlags = LAF_ISMELEEATTACK | ((flags & CPF_NORANDOMPUFFZ) ? LAF_NORANDOMPUFFZ : 0); Actor puff; [puff, actualdamage] = LineAttack (angle, range, pitch, damage, 'Melee', pufftype, puffFlags, t); if (!t.linetarget) { if (MissSound) A_StartSound(MissSound, CHAN_WEAPON); } else { if (lifesteal > 0 && !(t.linetarget.bDontDrain)) { if (flags & CPF_STEALARMOR) { if (armorbonustype == NULL) { armorbonustype = 'ArmorBonus'; } if (armorbonustype != NULL) { let armorbonus = BasicArmorBonus(Spawn(armorbonustype)); if (armorbonus) { armorbonus.SaveAmount *= int(actualdamage * lifesteal); if (lifestealmax > 0) armorbonus.MaxSaveAmount = lifestealmax; armorbonus.bDropped = true; armorbonus.ClearCounters(); if (!armorbonus.CallTryPickup(self)) { armorbonus.Destroy (); } } } } else { GiveBody (int(actualdamage * lifesteal), lifestealmax); } } if (weapon != NULL) { if (MeleeSound) A_StartSound(MeleeSound, CHAN_WEAPON); else A_StartSound(weapon.AttackSound, CHAN_WEAPON); } if (!(flags & CPF_NOTURN)) { // turn to face target self.Angle = t.angleFromSource; } if (flags & CPF_PULLIN) self.bJustAttacked = true; if (flags & CPF_DAGGER) t.linetarget.DaggerAlert (self); } } //========================================================================== // // customizable railgun attack function // //========================================================================== action void A_RailAttack(int damage, int spawnofs_xy = 0, bool useammo = true, color color1 = 0, color color2 = 0, int flags = 0, double maxdiff = 0, class pufftype = "BulletPuff", double spread_xy = 0, double spread_z = 0, double range = 0, int duration = 0, double sparsity = 1.0, double driftspeed = 1.0, class spawnclass = "none", double spawnofs_z = 0, int spiraloffset = 270, int limit = 0) { if (range == 0) range = 8192; if (sparsity == 0) sparsity=1.0; let player = self.player; if (!player) return; let weapon = player.ReadyWeapon; if (useammo && weapon != NULL && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { if (!weapon.DepleteAmmo(weapon.bAltFire, true)) return; // out of ammo } if (!(flags & RGF_EXPLICITANGLE)) { spread_xy = spread_xy * Random2[crailgun]() / 255.; spread_z = spread_z * Random2[crailgun]() / 255.; } FRailParams p; p.damage = damage; p.offset_xy = spawnofs_xy; p.offset_z = spawnofs_z; p.color1 = color1; p.color2 = color2; p.maxdiff = maxdiff; p.flags = flags; p.puff = pufftype; p.angleoffset = spread_xy; p.pitchoffset = spread_z; p.distance = range; p.duration = duration; p.sparsity = sparsity; p.drift = driftspeed; p.spawnclass = spawnclass; p.SpiralOffset = SpiralOffset; p.limit = limit; self.RailAttack(p); } //--------------------------------------------------------------------------- // // PROC A_ReFire // // The player can re-fire the weapon without lowering it entirely. // //--------------------------------------------------------------------------- action void A_ReFire(statelabel flash = null) { let player = player; bool pending; if (NULL == player) { return; } pending = player.PendingWeapon != WP_NOCHANGE && (player.WeaponState & WF_REFIRESWITCHOK); if ((player.cmd.buttons & BT_ATTACK) && !player.ReadyWeapon.bAltFire && !pending && player.health > 0) { player.refire++; player.mo.FireWeapon(ResolveState(flash)); } else if ((player.cmd.buttons & BT_ALTATTACK) && player.ReadyWeapon.bAltFire && !pending && player.health > 0) { player.refire++; player.mo.FireWeaponAlt(ResolveState(flash)); } else { player.refire = 0; player.ReadyWeapon.CheckAmmo (player.ReadyWeapon.bAltFire? Weapon.AltFire : Weapon.PrimaryFire, true); } } action void A_ClearReFire() { if (NULL != player) player.refire = 0; } } class CustomInventory : StateProvider { Default { DefaultStateUsage SUF_ACTOR|SUF_OVERLAY|SUF_ITEM; } //--------------------------------------------------------------------------- // // //--------------------------------------------------------------------------- // This is only here, because these functions were originally exported on Inventory, despite only working for weapons, so this is here to satisfy some potential old mods having called it through CustomInventory. deprecated("2.3", "must be called from Weapon") action void A_GunFlash(statelabel flash = null, int flags = 0) {} deprecated("2.3", "must be called from Weapon") action void A_Lower() {} deprecated("2.3", "must be called from Weapon") action void A_Raise() {} deprecated("2.3", "must be called from Weapon") action void A_CheckReload() {} deprecated("3.7", "must be called from Weapon") action void A_WeaponReady(int flags = 0) {} // this was somehow missed in 2.3 ... native bool CallStateChain (Actor actor, State state); //=========================================================================== // // ACustomInventory :: SpecialDropAction // //=========================================================================== override bool SpecialDropAction (Actor dropper) { return CallStateChain (dropper, FindState('Drop')); } //=========================================================================== // // ACustomInventory :: Use // //=========================================================================== override bool Use (bool pickup) { return CallStateChain (Owner, FindState('Use')); } //=========================================================================== // // ACustomInventory :: TryPickup // //=========================================================================== override bool TryPickup (in out Actor toucher) { let pickupstate = FindState('Pickup'); bool useok = CallStateChain (toucher, pickupstate); if ((useok || pickupstate == NULL) && FindState('Use') != NULL) { useok = Super.TryPickup (toucher); } else if (useok) { GoAwayAndDie(); } return useok; } } // Note that the status screen needs to run in 'play' scope! class InterBackground native ui version("2.5") { native static InterBackground Create(wbstartstruct wbst); native virtual bool LoadBackground(bool isenterpic); native virtual void updateAnimatedBack(); native virtual void drawBackground(int CurState, bool drawsplat, bool snl_pointeron); } // This is obsolete. Hopefully this was never used... struct PatchInfo ui version("2.5") { Font mFont; deprecated("3.8") TextureID mPatch; int mColor; void Init(GIFont gifont) { // Replace with the VGA-Unicode font if needed. // The default settings for this are marked with a *. // If some mod changes this it is assumed that it doesn't provide any localization for the map name in a language not supported by the font. String s = gifont.fontname; if (s.Left(1) != "*") mFont = Font.GetFont(gifont.fontname); else if (generic_ui) mFont = NewSmallFont; else { s = s.Mid(1); mFont = Font.GetFont(s); } mColor = Font.FindFontColor(gifont.color); if (mFont == NULL) { mFont = BigFont; } } }; class StatusScreen : ScreenJob abstract version("2.5") { enum EValues { // GLOBAL LOCATIONS TITLEY = 5, // SINGPLE-PLAYER STUFF SP_STATSX = 50, SP_STATSY = 50, SP_TIMEX = 8, SP_TIMEY = (200 - 32), // NET GAME STUFF NG_STATSY = 50, }; enum EState { NoState = -1, StatCount, ShowNextLoc, LeavingIntermission }; // States for single-player enum ESPState { SP_KILLS = 0, SP_ITEMS = 2, SP_SECRET = 4, SP_FRAGS = 6, SP_TIME = 8, }; const SHOWNEXTLOCDELAY = 4; // in seconds InterBackground bg; int acceleratestage; // used to accelerate or skip a stage bool playerready[MAXPLAYERS]; int me; // wbs.pnum int bcnt; int CurState; // specifies current CurState wbstartstruct wbs; // contains information passed into intermission wbplayerstruct Plrs[MAXPLAYERS]; // wbs.plyr[] int otherkills; int cnt; // used for general timing int cnt_otherkills; int cnt_kills[MAXPLAYERS]; int cnt_items[MAXPLAYERS]; int cnt_secret[MAXPLAYERS]; int cnt_frags[MAXPLAYERS]; int cnt_deaths[MAXPLAYERS]; int cnt_time; int cnt_total_time; int cnt_par; int cnt_pause; int total_frags; int total_deaths; bool noautostartmap; int dofrags; int ng_state; float shadowalpha; PatchInfo mapname; PatchInfo finishedp; PatchInfo entering; PatchInfo content; PatchInfo author; TextureID p_secret; TextureID kills; TextureID secret; TextureID items; TextureID timepic; TextureID par; TextureID sucks; TextureID finishedPatch; TextureID enteringPatch; // [RH] Info to dynamically generate the level name graphics String lnametexts[2]; String authortexts[2]; bool snl_pointeron; int player_deaths[MAXPLAYERS]; int sp_state; int cWidth, cHeight; // size of the canvas int scalemode; int wrapwidth; // size used to word wrap level names int scaleFactorX, scaleFactorY; //==================================================================== // // Set fixed size mode. // //==================================================================== void SetSize(int width, int height, int wrapw = -1, int scalemode = FSMode_ScaleToFit43) { cwidth = width; cheight = height; scalemode = FSMode_ScaleToFit43; scalefactorx = 1; scalefactory = 1; wrapwidth = wrapw == -1 ? width : wrapw; } //==================================================================== // // Draws a single character with a shadow // //==================================================================== int DrawCharPatch(Font fnt, int charcode, int x, int y, int translation = Font.CR_UNTRANSLATED, bool nomove = false) { int width = fnt.GetCharWidth(charcode); if (scalemode == -1) screen.DrawChar(fnt, translation, x, y, charcode, nomove ? DTA_CleanNoMove : DTA_Clean, true); else screen.DrawChar(fnt, translation, x, y, charcode, DTA_FullscreenScale, scalemode, DTA_VirtualWidth, cwidth, DTA_VirtualHeight, cheight); return x - width; } //==================================================================== // // // //==================================================================== void DrawTexture(TextureID tex, double x, double y, bool nomove = false) { if (scalemode == -1) screen.DrawTexture(tex, true, x, y, nomove ? DTA_CleanNoMove : DTA_Clean, true); else screen.DrawTexture(tex, true, x, y, DTA_FullscreenScale, scalemode, DTA_VirtualWidth, cwidth, DTA_VirtualHeight, cheight); } //==================================================================== // // // //==================================================================== void DrawText(Font fnt, int color, double x, double y, String str, bool nomove = false, bool shadow = false) { if (scalemode == -1) screen.DrawText(fnt, color, x, y, str, nomove ? DTA_CleanNoMove : DTA_Clean, true, DTA_Shadow, shadow); else screen.DrawText(fnt, color, x, y, str, DTA_FullscreenScale, scalemode, DTA_VirtualWidth, cwidth, DTA_VirtualHeight, cheight, DTA_Shadow, shadow); } //==================================================================== // // Draws a level name with the big font // // x is no longer passed as a parameter because the text is now broken into several lines // if it is too long // //==================================================================== int DrawName(int y, TextureID tex, String levelname) { // draw if (tex.isValid()) { let size = TexMan.GetScaledSize(tex); DrawTexture(tex, (cwidth - size.X * scaleFactorX) /2, y, true); if (size.Y > 50) { // Fix for Deus Vult II and similar wads that decide to make these hugely tall // patches with vast amounts of empty space at the bottom. size.Y = TexMan.CheckRealHeight(tex); } return y + int(Size.Y) * scaleFactorY; } else if (levelname.Length() > 0) { int h = 0; int lumph = mapname.mFont.GetHeight() * scaleFactorY; BrokenLines lines = mapname.mFont.BreakLines(levelname, wrapwidth / scaleFactorX); int count = lines.Count(); for (int i = 0; i < count; i++) { DrawText(mapname.mFont, mapname.mColor, (cwidth - lines.StringWidth(i) * scaleFactorX) / 2, y + h, lines.StringAt(i), true); h += lumph; } return y + h; } return 0; } //==================================================================== // // Draws a level author's name with the given font // //==================================================================== int DrawAuthor(int y, String levelname) { if (levelname.Length() > 0) { int h = 0; int lumph = author.mFont.GetHeight() * scaleFactorY; BrokenLines lines = author.mFont.BreakLines(levelname, wrapwidth / scaleFactorX); int count = lines.Count(); for (int i = 0; i < count; i++) { DrawText(author.mFont, author.mColor, (cwidth - lines.StringWidth(i) * scaleFactorX) / 2, y + h, lines.StringAt(i), true); h += lumph; } return y + h; } return y; } //==================================================================== // // Only kept so that mods that were accessing it continue to compile // //==================================================================== deprecated("3.8") int DrawPatchText(int y, PatchInfo pinfo, String stringname) { String string = Stringtable.Localize(stringname); int midx = screen.GetWidth() / 2; screen.DrawText(pinfo.mFont, pinfo.mColor, midx - pinfo.mFont.StringWidth(string) * CleanXfac/2, y, string, DTA_CleanNoMove, true); return y + pinfo.mFont.GetHeight() * CleanYfac; } //==================================================================== // // Draws a text, either as patch or as string from the string table // //==================================================================== int DrawPatchOrText(int y, PatchInfo pinfo, TextureID patch, String stringname) { String string = Stringtable.Localize(stringname); int midx = cwidth / 2; if (TexMan.OkForLocalization(patch, stringname)) { let size = TexMan.GetScaledSize(patch); DrawTexture(patch, midx - size.X * scaleFactorX/2, y, true); return y + int(size.Y * scaleFactorY); } else { DrawText(pinfo.mFont, pinfo.mColor, midx - pinfo.mFont.StringWidth(string) * scaleFactorX/2, y, string, true); return y + pinfo.mFont.GetHeight() * scaleFactorY; } } //==================================================================== // // Draws " Finished!" // // Either uses the specified patch or the big font // A level name patch can be specified for all games now, not just Doom. // //==================================================================== virtual int drawLF () { bool ispatch = wbs.LName0.isValid(); int oldy = TITLEY * scaleFactorY; int h; if (!ispatch) { let asc = mapname.mFont.GetMaxAscender(lnametexts[1]); if (asc > TITLEY - 2) { oldy = (asc+2) * scaleFactorY; } } int y = DrawName(oldy, wbs.LName0, lnametexts[0]); // If the displayed info is made of patches we need some additional offsetting here. if (ispatch) { int disp = 0; // The offset getting applied here must at least be as tall as the largest ascender in the following text to avoid overlaps. if (authortexts[0].length() == 0) { int h1 = BigFont.GetHeight() - BigFont.GetDisplacement(); int h2 = (y - oldy) / scaleFactorY / 4; disp = min(h1, h2); if (!TexMan.OkForLocalization(finishedPatch, "$WI_FINISHED")) { disp += finishedp.mFont.GetMaxAscender("$WI_FINISHED"); } } else { disp += author.mFont.GetMaxAscender(authortexts[0]); } y += disp * scaleFactorY; } y = DrawAuthor(y, authortexts[0]); // draw "Finished!" int statsy = multiplayer? NG_STATSY : SP_STATSY * scaleFactorY; if (y < (statsy - finishedp.mFont.GetHeight()*3/4) * scaleFactorY) { // don't draw 'finished' if the level name is too tall y = DrawPatchOrText(y, finishedp, finishedPatch, "$WI_FINISHED"); } return y; } //==================================================================== // // Draws "Entering " // // Either uses the specified patch or the big font // A level name patch can be specified for all games now, not just Doom. // //==================================================================== virtual void drawEL () { bool ispatch = TexMan.OkForLocalization(enteringPatch, "$WI_ENTERING"); int oldy = TITLEY * scaleFactorY; if (!ispatch) { let asc = entering.mFont.GetMaxAscender("$WI_ENTERING"); if (asc > TITLEY - 2) { oldy = (asc+2) * scaleFactorY; } } int y = DrawPatchOrText(oldy, entering, enteringPatch, "$WI_ENTERING"); // If the displayed info is made of patches we need some additional offsetting here. if (ispatch) { int h1 = BigFont.GetHeight() - BigFont.GetDisplacement(); let size = TexMan.GetScaledSize(enteringPatch); int h2 = int(size.Y); let disp = min(h1, h2) / 4; // The offset getting applied here must at least be as tall as the largest ascender in the following text to avoid overlaps. if (!wbs.LName1.isValid()) { disp += mapname.mFont.GetMaxAscender(lnametexts[1]); } y += disp * scaleFactorY; } y = DrawName(y, wbs.LName1, lnametexts[1]); if (wbs.LName1.isValid() && authortexts[1].length() > 0) { // Consdider the ascender height of the following text. y += author.mFont.GetMaxAscender(authortexts[1]) * scaleFactorY; } DrawAuthor(y, authortexts[1]); } //==================================================================== // // Draws a number. // If digits > 0, then use that many digits minimum, // otherwise only use as many as necessary. // x is the right edge of the number. // Returns new x position, that is, the left edge of the number. // //==================================================================== int drawNum (Font fnt, int x, int y, int n, int digits, bool leadingzeros = true, int translation = Font.CR_UNTRANSLATED, bool nomove = false) { int fntwidth = fnt.StringWidth("3"); String text; int len; if (nomove && scalemode == -1) { fntwidth *= scaleFactorX; } text = String.Format("%d", n); len = text.Length(); if (leadingzeros) { int filldigits = digits - len; for(int i = 0; i < filldigits; i++) { text = "0" .. text; } len = text.Length(); } for(int text_p = len-1; text_p >= 0; text_p--) { // Digits are centered in a box the width of the '3' character. // Other characters (specifically, '-') are right-aligned in their cell. int c = text.ByteAt(text_p); if (c >= "0" && c <= "9") { x -= fntwidth; DrawCharPatch(fnt, c, x + (fntwidth - fnt.GetCharWidth(c)) / 2, y, translation, nomove); } else { DrawCharPatch(fnt, c, x - fnt.GetCharWidth(c), y, translation, nomove); x -= fntwidth; } } if (len < digits) { x -= fntwidth * (digits - len); } return x; } //==================================================================== // // // //==================================================================== void drawPercent (Font fnt, int x, int y, int p, int b, bool show_total = true, int color = Font.CR_UNTRANSLATED, bool nomove = false) { if (p < 0) return; if (wi_percents) { if (nomove && scalemode == -1) { x -= fnt.StringWidth("%") * scaleFactorX; } else { x -= fnt.StringWidth("%"); } DrawText(fnt, color, x, y, "%", nomove); if (nomove) { x -= 2*CleanXfac; } drawNum(fnt, x, y, b == 0 ? 100 : p * 100 / b, -1, false, color, nomove); } else { if (show_total) { x = drawNum(fnt, x, y, b, 2, false, color, nomove); x -= fnt.StringWidth("/"); DrawText (fnt, color, x, y, "/", nomove); } drawNum (fnt, x, y, p, -1, false, color, nomove); } } //==================================================================== // // Display level completion time and par, or "sucks" message if overflow. // //==================================================================== void drawTimeFont (Font printFont, int x, int y, int t, int color) { bool sucky; if (t < 0) return; int hours = t / 3600; t -= hours * 3600; int minutes = t / 60; t -= minutes * 60; int seconds = t; // Why were these offsets hard coded? Half the WADs with custom patches // I tested screwed up miserably in this function! int num_spacing = printFont.GetCharWidth("3"); int colon_spacing = printFont.GetCharWidth(":"); x = drawNum (printFont, x, y, seconds, 2, true, color) - 1; DrawCharPatch (printFont, ":", x -= colon_spacing, y, color); x = drawNum (printFont, x, y, minutes, 2, hours!=0, color); if (hours) { DrawCharPatch (printFont, ":", x -= colon_spacing, y, color); drawNum (printFont, x, y, hours, 2, false, color); } } void drawTime (int x, int y, int t, bool no_sucks=false) { drawTimeFont(IntermissionFont, x, y, t, Font.CR_UNTRANSLATED); } //==================================================================== // // the 'scaled' drawers are for the multiplayer scoreboard // //==================================================================== void drawTextScaled (Font fnt, double x, double y, String text, double scale, int translation = Font.CR_UNTRANSLATED) { screen.DrawText(fnt, translation, x / scale, y / scale, text, DTA_VirtualWidthF, screen.GetWidth() / scale, DTA_VirtualHeightF, screen.GetHeight() / scale); } //==================================================================== // // //==================================================================== void drawNumScaled (Font fnt, int x, int y, double scale, int n, int digits, int translation = Font.CR_UNTRANSLATED) { String s = String.Format("%d", n); drawTextScaled(fnt, x - fnt.StringWidth(s) * scale, y, s, scale, translation); } //==================================================================== // // // //==================================================================== void drawPercentScaled (Font fnt, int x, int y, int p, int b, double scale, bool show_total = true, int color = Font.CR_UNTRANSLATED) { if (p < 0) return; String s; if (wi_percents) { s = String.Format("%d%%", b == 0 ? 100 : p * 100 / b); } else if (show_total) { s = String.Format("%d/%3d", p, b); } else { s = String.Format("%d", p); } drawTextScaled(fnt, x - fnt.StringWidth(s) * scale, y, s, scale, color); } //==================================================================== // // Display the completed time scaled // //==================================================================== void drawTimeScaled (Font fnt, int x, int y, int t, double scale, int color = Font.CR_UNTRANSLATED) { if (t < 0) return; int hours = t / 3600; t -= hours * 3600; int minutes = t / 60; t -= minutes * 60; int seconds = t; String s = (hours > 0 ? String.Format("%d:", hours) : "") .. String.Format("%02d:%02d", minutes, seconds); drawTextScaled(fnt, x - fnt.StringWidth(s) * scale, y, s, scale, color); } //==================================================================== // // // //==================================================================== virtual void End () { CurState = LeavingIntermission; } //==================================================================== // // // //==================================================================== bool autoSkip() { return wi_autoadvance > 0 && bcnt > (wi_autoadvance * GameTicRate); } //==================================================================== // // // //==================================================================== protected virtual void initNoState () { CurState = NoState; acceleratestage = 0; cnt = 10; } //==================================================================== // // // //==================================================================== protected virtual void updateNoState () { if (acceleratestage) { cnt = 0; } else { bool noauto = noautostartmap; for (int i = 0; !noauto && i < MAXPLAYERS; ++i) { if (playeringame[i]) { noauto |= players[i].GetNoAutostartMap(); } } if (!noauto || autoSkip()) { cnt--; } } if (cnt == 0) { End(); } } //==================================================================== // // // //==================================================================== protected virtual void initShowNextLoc () { if (wbs.next == "") { // Last map in episode - there is no next location! jobstate = finished; return; } CurState = ShowNextLoc; acceleratestage = 0; cnt = SHOWNEXTLOCDELAY * GameTicRate; noautostartmap = bg.LoadBackground(true); } //==================================================================== // // // //==================================================================== protected virtual void updateShowNextLoc () { if (!--cnt || acceleratestage) initNoState(); else snl_pointeron = (cnt & 31) < 20; } //==================================================================== // // // //==================================================================== protected virtual void drawShowNextLoc(void) { bg.drawBackground(CurState, true, snl_pointeron); // draws which level you are entering.. drawEL (); } //==================================================================== // // // //==================================================================== protected virtual void drawNoState () { snl_pointeron = true; drawShowNextLoc(); } //==================================================================== // // // //==================================================================== protected int fragSum (int playernum) { int i; int frags = 0; for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] && i!=playernum) { frags += Plrs[playernum].frags[i]; } } // JDC hack - negative frags. frags -= Plrs[playernum].frags[playernum]; return frags; } //==================================================================== // // // //==================================================================== static void PlaySound(Sound snd) { S_StartSound(snd, CHAN_VOICE, CHANF_MAYBE_LOCAL|CHANF_UI, 1, ATTN_NONE); } // ==================================================================== // // Purpose: See if the player has hit either the attack or use key // or mouse button. If so we set acceleratestage to 1 and // all those display routines above jump right to the end. // Args: none // Returns: void // // ==================================================================== override bool OnEvent(InputEvent evt) { if (evt.type == InputEvent.Type_KeyDown) { accelerateStage = 1; return true; } return false; } void nextStage() { accelerateStage = 1; } // this one is no longer used, but still needed for old content referencing them. deprecated("4.8") void checkForAccelerate() { } // ==================================================================== // Ticker // Purpose: Do various updates every gametic, for stats, animation, // checking that intermission music is running, etc. // Args: none // Returns: void // // ==================================================================== virtual void StartMusic() { Level.SetInterMusic(wbs.next); } //==================================================================== // // Two stage interface to allow redefining this class as a screen job // //==================================================================== protected virtual void Ticker() { // counter for general background animation bcnt++; if (bcnt == 1) { StartMusic(); } bg.updateAnimatedBack(); switch (CurState) { case StatCount: updateStats(); break; case ShowNextLoc: updateShowNextLoc(); break; case NoState: updateNoState(); break; case LeavingIntermission: break; } } override void OnTick() { Ticker(); if (CurState == StatusScreen.LeavingIntermission) jobstate = finished; } //==================================================================== // // // //==================================================================== protected virtual void Drawer() { switch (CurState) { case StatCount: // draw animated background bg.drawBackground(CurState, false, false); drawStats(); break; case ShowNextLoc: case LeavingIntermission: // this must still draw the screen once more for the wipe code to pick up. drawShowNextLoc(); break; default: drawNoState(); break; } } override void Draw(double smoothratio) { Drawer(); } //==================================================================== // // // //==================================================================== virtual void Start (wbstartstruct wbstartstruct) { wbs = wbstartstruct; acceleratestage = 0; cnt = bcnt = 0; me = wbs.pnum; otherkills = wbs.totalkills; for (int i = 0; i < MAXPLAYERS; i++) { Plrs[i] = wbs.plyr[i]; otherkills -= Plrs[i].skills; } if (gameinfo.mHideParTimes) { // par time and suck time are not displayed if zero. wbs.partime = 0; wbs.sucktime = 0; } entering.Init(gameinfo.mStatscreenEnteringFont); finishedp.Init(gameinfo.mStatscreenFinishedFont); mapname.Init(gameinfo.mStatscreenMapNameFont); content.Init(gameinfo.mStatscreenContentFont); author.Init(gameinfo.mStatscreenAuthorFont); Kills = TexMan.CheckForTexture("WIOSTK", TexMan.Type_MiscPatch); // "kills" Secret = TexMan.CheckForTexture("WIOSTS", TexMan.Type_MiscPatch); // "scrt", not used P_secret = TexMan.CheckForTexture("WISCRT2", TexMan.Type_MiscPatch); // "secret" Items = TexMan.CheckForTexture("WIOSTI", TexMan.Type_MiscPatch); // "items" Timepic = TexMan.CheckForTexture("WITIME", TexMan.Type_MiscPatch); // "time" Sucks = TexMan.CheckForTexture("WISUCKS", TexMan.Type_MiscPatch); // "sucks" Par = TexMan.CheckForTexture("WIPAR", TexMan.Type_MiscPatch); // "par" enteringPatch = TexMan.CheckForTexture("WIENTER", TexMan.Type_MiscPatch); // "entering" finishedPatch = TexMan.CheckForTexture("WIF", TexMan.Type_MiscPatch); // "finished" lnametexts[0] = StringTable.Localize(wbstartstruct.thisname); lnametexts[1] = StringTable.Localize(wbstartstruct.nextname); authortexts[0] = StringTable.Localize(wbstartstruct.thisauthor); authortexts[1] = StringTable.Localize(wbstartstruct.nextauthor); bg = InterBackground.Create(wbs); noautostartmap = bg.LoadBackground(false); initStats(); wrapwidth = cwidth = screen.GetWidth(); cheight = screen.GetHeight(); scalemode = -1; scaleFactorX = CleanXfac; scaleFactorY = CleanYfac; } protected virtual void initStats() {} protected virtual void updateStats() {} protected virtual void drawStats() {} native static int, int, int GetPlayerWidths(); native static Color GetRowColor(PlayerInfo player, bool highlight); native static void GetSortedPlayers(in out Array sorted, bool teamplay); } class CoopStatusScreen : StatusScreen { int textcolor; double FontScale; int RowHeight; Font displayFont; //==================================================================== // // // //==================================================================== override void initStats () { textcolor = Font.CR_GRAY; CurState = StatCount; acceleratestage = 0; ng_state = 1; displayFont = NewSmallFont; FontScale = max(screen.GetHeight() / 400, 1); RowHeight = int(max((displayFont.GetHeight() + 1) * FontScale, 1)); cnt_pause = GameTicRate; for (int i = 0; i < MAXPLAYERS; i++) { playerready[i] = false; cnt_kills[i] = cnt_items[i] = cnt_secret[i] = cnt_frags[i] = 0; if (!playeringame[i]) continue; dofrags += fragSum (i); } cnt_otherkills = 0; dofrags = !!dofrags; } //==================================================================== // // // //==================================================================== override void updateStats () { int i; int fsum; bool stillticking; bool autoskip = autoSkip(); if ((acceleratestage || autoskip) && ng_state != 12) { acceleratestage = 0; for (i=0 ; i Plrs[i].skills) cnt_kills[i] = Plrs[i].skills; else stillticking = true; } cnt_otherkills += 2; if (cnt_otherkills > otherkills) cnt_otherkills = otherkills; else stillticking = true; if (!stillticking) { PlaySound("intermission/nextstage"); ng_state++; } } else if (ng_state == 4) { if (!(bcnt&3)) PlaySound("intermission/tick"); stillticking = false; for (i=0 ; i Plrs[i].sitems) cnt_items[i] = Plrs[i].sitems; else stillticking = true; } if (!stillticking) { PlaySound("intermission/nextstage"); ng_state++; } } else if (ng_state == 6) { if (!(bcnt&3)) PlaySound("intermission/tick"); stillticking = false; for (i=0 ; i Plrs[i].ssecret) cnt_secret[i] = Plrs[i].ssecret; else stillticking = true; } if (!stillticking) { PlaySound("intermission/nextstage"); ng_state ++; } } else if (ng_state == 8) { if (!(bcnt&3)) PlaySound("intermission/tick"); stillticking = false; cnt_time += 3; cnt_total_time += 3; int sec = Thinker.Tics2Seconds(Plrs[me].stime); if (cnt_time > sec) { cnt_time = sec; cnt_total_time = Thinker.Tics2Seconds(wbs.totaltime); } else stillticking = true; if (!stillticking) { PlaySound("intermission/nextstage"); ng_state += 1 + 2*!dofrags; } } else if (ng_state == 10) { if (!(bcnt&3)) PlaySound("intermission/tick"); stillticking = false; for (i=0 ; i= (fsum = fragSum(i))) cnt_frags[i] = fsum; else stillticking = true; } if (!stillticking) { PlaySound("intermission/cooptotal"); ng_state++; } } else if (ng_state == 12) { // All players are ready; proceed. if ((acceleratestage) || autoskip) { PlaySound("intermission/pastcoopstats"); initShowNextLoc(); } } else if (ng_state & 1) { if (!--cnt_pause) { ng_state++; cnt_pause = GameTicRate; } } } //==================================================================== // // // //==================================================================== override void drawStats () { int i, x, y, ypadding, height, lineheight; int maxnamewidth, maxscorewidth, maxiconheight; int pwidth = IntermissionFont.GetCharWidth("%"); int icon_x, name_x, kills_x, bonus_x, secret_x; int bonus_len, secret_len; int missed_kills, missed_items, missed_secrets; float h, s, v, r, g, b; int color; String text_bonus, text_secret, text_kills; TextureID readyico = TexMan.CheckForTexture("READYICO", TexMan.Type_MiscPatch); y = drawLF(); [maxnamewidth, maxscorewidth, maxiconheight] = GetPlayerWidths(); // Use the readyico height if it's bigger. Vector2 readysize = TexMan.GetScaledSize(readyico); Vector2 readyoffset = TexMan.GetScaledOffset(readyico); height = int(readysize.Y - readyoffset.Y); maxiconheight = MAX(height, maxiconheight); height = int(displayFont.GetHeight() * FontScale); lineheight = MAX(height, maxiconheight * CleanYfac); ypadding = (lineheight - height + 1) / 2; y += CleanYfac; text_bonus = Stringtable.Localize((gameinfo.gametype & GAME_Raven) ? "$SCORE_BONUS" : "$SCORE_ITEMS"); text_secret = Stringtable.Localize("$SCORE_SECRET"); text_kills = Stringtable.Localize("$SCORE_KILLS"); icon_x = int(8 * FontScale); name_x = int(icon_x + maxscorewidth * FontScale); kills_x = int(name_x + (maxnamewidth + 1 + MAX(displayFont.StringWidth("XXXXXXXXXX"), displayFont.StringWidth(text_kills)) + 16) * FontScale); bonus_x = int(kills_x + ((bonus_len = displayFont.StringWidth(text_bonus)) + 16) * FontScale); secret_x = int(bonus_x + ((secret_len = displayFont.StringWidth(text_secret)) + 16) * FontScale); x = (screen.GetWidth() - secret_x) >> 1; icon_x += x; name_x += x; kills_x += x; bonus_x += x; secret_x += x; drawTextScaled(displayFont, name_x, y, Stringtable.Localize("$SCORE_NAME"), FontScale, textcolor); drawTextScaled(displayFont, kills_x - displayFont.StringWidth(text_kills) * FontScale, y, text_kills, FontScale, textcolor); drawTextScaled(displayFont, bonus_x - bonus_len * FontScale, y, text_bonus, FontScale, textcolor); drawTextScaled(displayFont, secret_x - secret_len * FontScale, y, text_secret, FontScale, textcolor); y += int(height + 6 * FontScale); missed_kills = wbs.maxkills; missed_items = wbs.maxitems; missed_secrets = wbs.maxsecret; // Draw lines for each player for (i = 0; i < MAXPLAYERS; ++i) { if (!playeringame[i]) continue; PlayerInfo player = players[i]; screen.Dim(player.GetDisplayColor(), 0.8f, x, y - ypadding, (secret_x - x) + (8 * CleanXfac), lineheight); //if (playerready[i] || player.Bot != NULL) // Bots are automatically assumed ready, to prevent confusion screen.DrawTexture(readyico, true, x - (readysize.Y * CleanXfac), y, DTA_CleanNoMove, true); Color thiscolor = GetRowColor(player, i == consoleplayer); if (player.mo.ScoreIcon.isValid()) { screen.DrawTexture(player.mo.ScoreIcon, true, icon_x, y, DTA_CleanNoMove, true); } drawTextScaled(displayFont, name_x, y + ypadding, player.GetUserName(), FontScale, thiscolor); drawPercentScaled(displayFont, kills_x, y + ypadding, cnt_kills[i], wbs.maxkills, FontScale, thiscolor); missed_kills -= cnt_kills[i]; if (ng_state >= 4) { drawPercentScaled(displayFont, bonus_x, y + ypadding, cnt_items[i], wbs.maxitems, FontScale, thiscolor); missed_items -= cnt_items[i]; if (ng_state >= 6) { drawPercentScaled(displayFont, secret_x, y + ypadding, cnt_secret[i], wbs.maxsecret, FontScale, thiscolor); missed_secrets -= cnt_secret[i]; } } y += lineheight + CleanYfac; } // Draw "OTHER" line y += 3 * CleanYfac; drawTextScaled(displayFont, name_x, y, Stringtable.Localize("$SCORE_OTHER"), FontScale, Font.CR_DARKGRAY); drawPercentScaled(displayFont, kills_x, y, cnt_otherkills, wbs.maxkills, FontScale, Font.CR_DARKGRAY); missed_kills -= cnt_otherkills; // Draw "MISSED" line y += height + 3 * CleanYfac; drawTextScaled(displayFont, name_x, y, Stringtable.Localize("$SCORE_MISSED"), FontScale, Font.CR_DARKGRAY); drawPercentScaled(displayFont, kills_x, y, missed_kills, wbs.maxkills, FontScale, Font.CR_DARKGRAY); if (ng_state >= 4) { drawPercentScaled(displayFont, bonus_x, y, missed_items, wbs.maxitems, FontScale, Font.CR_DARKGRAY); if (ng_state >= 6) { drawPercentScaled(displayFont, secret_x, y, missed_secrets, wbs.maxsecret, FontScale, Font.CR_DARKGRAY); } } // Draw "TOTAL" line y += height + 3 * CleanYfac; drawTextScaled(displayFont, name_x, y, Stringtable.Localize("$SCORE_TOTAL"), FontScale, textcolor); drawNumScaled(displayFont, kills_x, y, FontScale, wbs.maxkills, 0, textcolor); if (ng_state >= 4) { drawNumScaled(displayFont, bonus_x, y, FontScale, wbs.maxitems, 0, textcolor); if (ng_state >= 6) { drawNumScaled(displayFont, secret_x, y, FontScale, wbs.maxsecret, 0, textcolor); } } // Draw "TIME" line y += height + 3 * CleanYfac; drawTextScaled(displayFont, name_x, y, Stringtable.Localize("$TXT_IMTIME"), FontScale, textcolor); if (ng_state >= 8) { drawTimeScaled(displayFont, kills_x, y, cnt_time, FontScale, textcolor); drawTimeScaled(displayFont, secret_x, y, cnt_total_time, FontScale, textcolor); } } } class DeathmatchStatusScreen : StatusScreen { int textcolor; double FontScale; int RowHeight; Font displayFont; //==================================================================== // // // //==================================================================== override void initStats (void) { int i, j; textcolor = Font.CR_GRAY; CurState = StatCount; acceleratestage = 0; displayFont = NewSmallFont; FontScale = max(screen.GetHeight() / 400, 1); RowHeight = int(max((displayFont.GetHeight() + 1) * FontScale, 1)); for(i = 0; i < MAXPLAYERS; i++) { playerready[i] = false; cnt_frags[i] = cnt_deaths[i] = player_deaths[i] = 0; } total_frags = 0; total_deaths = 0; ng_state = 1; cnt_pause = GameTicRate; for (i=0 ; i Plrs[i].fragcount) cnt_frags[i] = Plrs[i].fragcount; else stillticking = true; } if (!stillticking) { PlaySound("intermission/nextstage"); ng_state++; } } else if (ng_state == 4) { if (!(bcnt & 3)) PlaySound("intermission/tick"); stillticking = false; for (i = 0; i player_deaths[i]) cnt_deaths[i] = player_deaths[i]; else stillticking = true; } if (!stillticking) { PlaySound("intermission/nextstage"); ng_state++; } } else if (ng_state == 6) { // All players are ready; proceed. if ((acceleratestage) || doautoskip) { PlaySound("intermission/pastdmstats"); initShowNextLoc(); } } else if (ng_state & 1) { if (!--cnt_pause) { ng_state++; cnt_pause = GameTicRate; } } } override void drawStats () { int i, pnum, x, y, ypadding, height, lineheight; int maxnamewidth, maxscorewidth, maxiconheight; int pwidth = IntermissionFont.GetCharWidth("%"); int icon_x, name_x, frags_x, deaths_x; int deaths_len; String text_deaths, text_frags; TextureID readyico = TexMan.CheckForTexture("READYICO", TexMan.Type_MiscPatch); y = drawLF(); [maxnamewidth, maxscorewidth, maxiconheight] = GetPlayerWidths(); // Use the readyico height if it's bigger. Vector2 readysize = TexMan.GetScaledSize(readyico); Vector2 readyoffset = TexMan.GetScaledOffset(readyico); height = int(readysize.Y - readyoffset.Y); maxiconheight = MAX(height, maxiconheight); height = int(displayFont.GetHeight() * FontScale); lineheight = MAX(height, maxiconheight * CleanYfac); ypadding = (lineheight - height + 1) / 2; y += CleanYfac; text_deaths = Stringtable.Localize("$SCORE_DEATHS"); //text_color = Stringtable.Localize("$SCORE_COLOR"); text_frags = Stringtable.Localize("$SCORE_FRAGS"); icon_x = int(8 * FontScale); name_x = int(icon_x + maxscorewidth * FontScale); frags_x = name_x + int((maxnamewidth + 1 + MAX(displayFont.StringWidth("XXXXXXXXXX"), displayFont.StringWidth(text_frags)) + 16) * FontScale); deaths_x = frags_x + int(((deaths_len = displayFont.StringWidth(text_deaths)) + 16) * FontScale); x = (Screen.GetWidth() - deaths_x) >> 1; icon_x += x; name_x += x; frags_x += x; deaths_x += x; drawTextScaled(displayFont, name_x, y, Stringtable.Localize("$SCORE_NAME"), FontScale, textcolor); drawTextScaled(displayFont, frags_x - displayFont.StringWidth(text_frags) * FontScale, y, text_frags, FontScale, textcolor); drawTextScaled(displayFont, deaths_x - deaths_len * FontScale, y, text_deaths, FontScale, textcolor); y += height + int(6 * FontScale); // Sort all players Array sortedplayers; GetSortedPlayers(sortedplayers, teamplay); // Draw lines for each player for (i = 0; i < sortedplayers.Size(); i++) { pnum = sortedplayers[i]; PlayerInfo player = players[pnum]; if (!playeringame[pnum]) continue; screen.Dim(player.GetDisplayColor(), 0.8, x, y - ypadding, (deaths_x - x) + (8 * CleanXfac), lineheight); //if (playerready[pnum] || player.Bot != NULL) // Bots are automatically assumed ready, to prevent confusion screen.DrawTexture(readyico, true, x - (readysize.X * CleanXfac), y, DTA_CleanNoMove, true); let thiscolor = GetRowColor(player, pnum == consoleplayer); if (player.mo.ScoreIcon.isValid()) { screen.DrawTexture(player.mo.ScoreIcon, true, icon_x, y, DTA_CleanNoMove, true); } drawTextScaled(displayFont, name_x, y + ypadding, player.GetUserName(), FontScale, thiscolor); drawNumScaled(displayFont, frags_x, y + ypadding, FontScale, cnt_frags[pnum], 0, textcolor); if (ng_state >= 2) { drawNumScaled(displayFont, deaths_x, y + ypadding, FontScale, cnt_deaths[pnum], 0, textcolor); } y += lineheight + CleanYfac; } // Draw "TOTAL" line y += height + 3 * CleanYfac; drawTextScaled(displayFont, name_x, y, Stringtable.Localize("$SCORE_TOTAL"), FontScale, textcolor); drawNumScaled(displayFont, frags_x, y, FontScale, total_frags, 0, textcolor); if (ng_state >= 4) { drawNumScaled(displayFont, deaths_x, y, FontScale, total_deaths, 0, textcolor); } // Draw game time y += height + CleanYfac; int seconds = Thinker.Tics2Seconds(Plrs[me].stime); int hours = seconds / 3600; int minutes = (seconds % 3600) / 60; seconds = seconds % 60; String leveltime = Stringtable.Localize("$SCORE_LVLTIME") .. ": " .. String.Format("%02i:%02i:%02i", hours, minutes, seconds); drawTextScaled(displayFont, x, y, leveltime, FontScale, textcolor); } } class DoomStatusScreen : StatusScreen { int intermissioncounter; override void initStats () { intermissioncounter = gameinfo.intermissioncounter; CurState = StatCount; acceleratestage = 0; sp_state = 1; cnt_kills[0] = cnt_items[0] = cnt_secret[0] = -1; cnt_time = cnt_par = -1; cnt_pause = GameTicRate; cnt_total_time = -1; } override void updateStats () { if (acceleratestage && sp_state != 10) { acceleratestage = 0; sp_state = 10; PlaySound("intermission/nextstage"); cnt_kills[0] = Plrs[me].skills; cnt_items[0] = Plrs[me].sitems; cnt_secret[0] = Plrs[me].ssecret; cnt_time = Thinker.Tics2Seconds(Plrs[me].stime); cnt_par = wbs.partime / GameTicRate; cnt_total_time = Thinker.Tics2Seconds(wbs.totaltime); } if (sp_state == 2) { if (intermissioncounter) { cnt_kills[0] += 2; if (!(bcnt&3)) PlaySound("intermission/tick"); } if (!intermissioncounter || cnt_kills[0] >= Plrs[me].skills) { cnt_kills[0] = Plrs[me].skills; PlaySound("intermission/nextstage"); sp_state++; } } else if (sp_state == 4) { if (intermissioncounter) { cnt_items[0] += 2; if (!(bcnt&3)) PlaySound("intermission/tick"); } if (!intermissioncounter || cnt_items[0] >= Plrs[me].sitems) { cnt_items[0] = Plrs[me].sitems; PlaySound("intermission/nextstage"); sp_state++; } } else if (sp_state == 6) { if (intermissioncounter) { cnt_secret[0] += 2; if (!(bcnt&3)) PlaySound("intermission/tick"); } if (!intermissioncounter || cnt_secret[0] >= Plrs[me].ssecret) { cnt_secret[0] = Plrs[me].ssecret; PlaySound("intermission/nextstage"); sp_state++; } } else if (sp_state == 8) { if (intermissioncounter) { if (!(bcnt&3)) PlaySound("intermission/tick"); cnt_time += 3; cnt_par += 3; cnt_total_time += 3; } int sec = Thinker.Tics2Seconds(Plrs[me].stime); if (!intermissioncounter || cnt_time >= sec) cnt_time = sec; int tsec = Thinker.Tics2Seconds(wbs.totaltime); if (!intermissioncounter || cnt_total_time >= tsec) cnt_total_time = tsec; int psec = wbs.partime / GameTicRate; if (!intermissioncounter || cnt_par >= psec) { cnt_par = psec; if (cnt_time >= sec) { cnt_total_time = tsec; PlaySound("intermission/nextstage"); sp_state++; } } } else if (sp_state == 10) { if (acceleratestage) { PlaySound("intermission/paststats"); initShowNextLoc(); } } else if (sp_state & 1) { if (!--cnt_pause) { sp_state++; cnt_pause = GameTicRate; } } } override void drawStats (void) { // line height int lh = IntermissionFont.GetHeight() * 3 / 2; drawLF(); // For visual consistency, only use the patches here if all are present. bool useGfx = TexMan.OkForLocalization(Kills, "$TXT_IMKILLS") && TexMan.OkForLocalization(Items, "$TXT_IMITEMS") && TexMan.OkForLocalization(P_secret, "$TXT_IMSECRETS") && TexMan.OkForLocalization(Timepic, "$TXT_IMTIME") && (!wbs.partime || TexMan.OkForLocalization(Par, "$TXT_IMPAR")); // The font color may only be used when the entire screen is printed as text. // Otherwise the text based parts should not be translated to match the other graphics patches. let tcolor = useGfx? Font.CR_UNTRANSLATED : content.mColor; Font printFont; Font textFont = generic_ui? NewSmallFont : content.mFont; int statsx = SP_STATSX; int timey = SP_TIMEY; if (wi_showtotaltime) timey = min(SP_TIMEY, 200 - 2 * lh); if (useGfx) { printFont = IntermissionFont; DrawTexture (Kills, statsx, SP_STATSY); DrawTexture (Items, statsx, SP_STATSY+lh); DrawTexture (P_secret, statsx, SP_STATSY+2*lh); DrawTexture (Timepic, SP_TIMEX, timey); if (wbs.partime) DrawTexture (Par, 160 + SP_TIMEX, timey); } else { // Check if everything fits on the screen. String percentage = wi_percents? " 0000%" : " 0000/0000"; int perc_width = textFont.StringWidth(percentage); int k_width = textFont.StringWidth("$TXT_IMKILLS"); int i_width = textFont.StringWidth("$TXT_IMITEMS"); int s_width = textFont.StringWidth("$TXT_IMSECRETS"); int allwidth = max(k_width, i_width, s_width) + perc_width; if ((SP_STATSX*2 + allwidth) > 320) // The content does not fit so adjust the position a bit. { statsx = max(0, (320 - allwidth) / 2); } printFont = generic_ui? IntermissionFont : content.mFont; DrawText (textFont, tcolor, statsx, SP_STATSY, "$TXT_IMKILLS"); DrawText (textFont, tcolor, statsx, SP_STATSY+lh, "$TXT_IMITEMS"); DrawText (textFont, tcolor, statsx, SP_STATSY+2*lh, "$TXT_IMSECRETS"); DrawText (textFont, tcolor, SP_TIMEX, timey, "$TXT_IMTIME"); if (wbs.partime) DrawText (textFont, tcolor, 160 + SP_TIMEX, timey, "$TXT_IMPAR"); } drawPercent (printFont, 320 - statsx, SP_STATSY, cnt_kills[0], wbs.maxkills, true, tcolor); drawPercent (printFont, 320 - statsx, SP_STATSY+lh, cnt_items[0], wbs.maxitems, true, tcolor); drawPercent (printFont, 320 - statsx, SP_STATSY+2*lh, cnt_secret[0], wbs.maxsecret, true, tcolor); drawTimeFont (printFont, 160 - SP_TIMEX, timey, cnt_time, tcolor); // This really sucks - not just by its message - and should have been removed long ago! // To avoid problems here, the "sucks" text only gets printed if the lump is present, this even applies to the text replacement. if (cnt_time >= wbs.sucktime * 60 * 60 && wbs.sucktime > 0 && Sucks.IsValid()) { // "sucks" int x = 160 - SP_TIMEX; int y = timey; if (useGfx && TexMan.OkForLocalization(Sucks, "$TXT_IMSUCKS")) { let size = TexMan.GetScaledSize(Sucks); DrawTexture (Sucks, x - size.X, y - size.Y - 2); } else { DrawText (textFont, tColor, x - printFont.StringWidth("$TXT_IMSUCKS"), y - printFont.GetHeight() - 2, "$TXT_IMSUCKS"); } } if (wi_showtotaltime) { drawTimeFont (printFont, 160 - SP_TIMEX, timey + lh, cnt_total_time, tcolor); } if (wbs.partime) { drawTimeFont (printFont, 320 - SP_TIMEX, timey, cnt_par, tcolor); } } } class RavenStatusScreen : DoomStatusScreen { override void drawStats (void) { // line height int lh = IntermissionFont.GetHeight() * 3 / 2; drawLF(); Font textFont = generic_ui? NewSmallFont : content.mFont; let tcolor = content.mColor; DrawText (textFont, tcolor, 50, 65, "$TXT_IMKILLS", shadow:true); DrawText (textFont, tcolor, 50, 90, "$TXT_IMITEMS", shadow:true); DrawText (textFont, tcolor, 50, 115, "$TXT_IMSECRETS", shadow:true); int countpos = gameinfo.gametype==GAME_Strife? 285:270; if (sp_state >= 2) { drawPercent (textFont, countpos, 65, cnt_kills[0], wbs.maxkills, true, tcolor); } if (sp_state >= 4) { drawPercent (textFont, countpos, 90, cnt_items[0], wbs.maxitems, true, tcolor); } if (sp_state >= 6) { drawPercent (textFont, countpos, 115, cnt_secret[0], wbs.maxsecret, true, tcolor); } if (sp_state >= 8) { DrawText (textFont, tcolor, 85, 160, "$TXT_IMTIME", shadow:true); drawTimeFont (textFont, 249, 160, cnt_time, tcolor); if (wi_showtotaltime) { drawTimeFont (textFont, 249, 180, cnt_total_time, tcolor); } } } } struct MugShot { enum StateFlags { STANDARD = 0x0, XDEATHFACE = 0x1, ANIMATEDGODMODE = 0x2, DISABLEGRIN = 0x4, DISABLEOUCH = 0x8, DISABLEPAIN = 0x10, DISABLERAMPAGE = 0x20, CUSTOM = 0x40, } } class InventoryBarState ui { TextureID box; TextureID selector; Vector2 boxsize; Vector2 boxofs; Vector2 selectofs; Vector2 innersize; TextureID left; TextureID right; Vector2 arrowoffset; double itemalpha; HUDFont amountfont; int cr; int flags; private static void Init(InventoryBarState me, HUDFont indexfont, int cr, double itemalpha, Vector2 innersize, String leftgfx, String rightgfx, Vector2 arrowoffs, int flags) { me.itemalpha = itemalpha; if (innersize == (0, 0)) { me.boxofs = (2, 2); me.innersize = me.boxsize - (4, 4); // Default is based on Heretic's and Hexens icons. } else { me.innersize = innersize; me.boxofs = (me.boxsize - me.innersize) / 2; } if (me.selector.IsValid()) { Vector2 sel = TexMan.GetScaledSize(me.selector); me.selectofs = (me.boxsize - sel) / 2; } me.left = TexMan.CheckForTexture(leftgfx, TexMan.TYPE_MiscPatch); me.right = TexMan.CheckForTexture(rightgfx, TexMan.TYPE_MiscPatch); me.arrowoffset = arrowoffs; me.arrowoffset.Y += me.boxsize.Y/2; // default is centered to the side of the box. if (indexfont == null) { me.amountfont = HUDFont.Create("INDEXFONT"); if (cr == Font.CR_UNTRANSLATED) cr = Font.CR_GOLD; } else me.amountfont = indexfont; me.cr = cr; me.flags = flags; } // The default settings here are what SBARINFO is using. static InventoryBarState Create(HUDFont indexfont = null, int cr = Font.CR_UNTRANSLATED, double itemalpha = 1., String boxgfx = "ARTIBOX", String selgfx = "SELECTBO", Vector2 innersize = (0, 0), String leftgfx = "INVGEML1", String rightgfx = "INVGEMR1", Vector2 arrowoffs = (0, 0), int flags = 0) { let me = new ("InventoryBarState"); me.box = TexMan.CheckForTexture(boxgfx, TexMan.TYPE_MiscPatch); me.selector = TexMan.CheckForTexture(selgfx, TexMan.TYPE_MiscPatch); if (me.box.IsValid() || me.selector.IsValid()) me.boxsize = TexMan.GetScaledSize(me.box.IsValid()? me.box : me.selector); else me.boxsize = (32., 32.); Init(me, indexfont, cr, itemalpha, innersize, leftgfx, rightgfx, arrowoffs, flags); return me; } // The default settings here are what SBARINFO is using. static InventoryBarState CreateNoBox(HUDFont indexfont = null, int cr = Font.CR_UNTRANSLATED, double itemalpha = 1., Vector2 boxsize = (32, 32), String selgfx = "SELECTBO", Vector2 innersize = (0, 0), String leftgfx = "INVGEML1", String rightgfx = "INVGEMR1", Vector2 arrowoffs = (0, 0), int flags = 0) { let me = new ("InventoryBarState"); me.box.SetInvalid(); me.selector = TexMan.CheckForTexture(selgfx, TexMan.TYPE_MiscPatch); me.boxsize = boxsize; Init(me, indexfont, cr, itemalpha, innersize, leftgfx, rightgfx, arrowoffs, flags); return me; } } class HUDMessageBase native ui { virtual native bool Tick(); virtual native void ScreenSizeChanged(); virtual native void Draw(int bottom, int visibility); } class BaseStatusBar : StatusBarCore native { enum EPop { POP_NoChange = -1, POP_None, POP_Log, POP_Keys, POP_Status } // Status face stuff enum EMug { ST_NUMPAINFACES = 5, ST_NUMSTRAIGHTFACES = 3, ST_NUMTURNFACES = 2, ST_NUMSPECIALFACES = 3, ST_NUMEXTRAFACES = 2, ST_FACESTRIDE = ST_NUMSTRAIGHTFACES+ST_NUMTURNFACES+ST_NUMSPECIALFACES, ST_NUMFACES = ST_FACESTRIDE*ST_NUMPAINFACES+ST_NUMEXTRAFACES, ST_TURNOFFSET = ST_NUMSTRAIGHTFACES, ST_OUCHOFFSET = ST_TURNOFFSET + ST_NUMTURNFACES, ST_EVILGRINOFFSET = ST_OUCHOFFSET + 1, ST_RAMPAGEOFFSET = ST_EVILGRINOFFSET + 1, ST_GODFACE = ST_NUMPAINFACES*ST_FACESTRIDE, ST_DEADFACE = ST_GODFACE + 1 } enum EHudState { HUD_StatusBar, HUD_Fullscreen, HUD_None, HUD_AltHud // Used for passing through popups to the alt hud } enum EHUDMSGLayer { HUDMSGLayer_OverHUD, HUDMSGLayer_UnderHUD, HUDMSGLayer_OverMap, NUM_HUDMSGLAYERS, HUDMSGLayer_Default = HUDMSGLayer_OverHUD, }; enum IconType { ITYPE_PLAYERICON = 1000, ITYPE_AMMO1, ITYPE_AMMO2, ITYPE_ARMOR, ITYPE_WEAPON, ITYPE_SIGIL, ITYPE_WEAPONSLOT, ITYPE_SELECTEDINVENTORY, } enum HexArmorType { HEXENARMOR_ARMOR, HEXENARMOR_SHIELD, HEXENARMOR_HELM, HEXENARMOR_AMULET, }; enum AmmoModes { AMMO_PRIMARY, AMMO_SECONDARY, AMMO_ANY, AMMO_BOTH }; enum EHudDraw { HUD_Normal, HUD_HorizCenter } enum EShade { SHADER_HORZ = 0, SHADER_VERT = 2, SHADER_REVERSE = 1 } const XHAIRSHRINKSIZE =(1./18); const XHAIRPICKUPSIZE = (2+XHAIRSHRINKSIZE); const POWERUPICONSIZE = 32; native bool Centering; native bool FixedOrigin; native double CrosshairSize; native double Displacement; native PlayerInfo CPlayer; native bool ShowLog; clearscope native int artiflashTick; clearscope native double itemflashFade; native void AttachMessage(HUDMessageBase msg, uint msgid = 0, int layer = HUDMSGLayer_Default); native HUDMessageBase DetachMessage(HUDMessageBase msg); native HUDMessageBase DetachMessageID(uint msgid); native void DetachAllMessages(); native void UpdateScreenGeometry(); virtual void Init() { } native virtual void Tick (); native virtual void Draw (int state, double TicFrac); native virtual void ScreenSizeChanged (); native virtual clearscope void ReceivedWeapon (Weapon weapn); native virtual clearscope void SetMugShotState (String state_name, bool wait_till_done=false, bool reset=false); clearscope virtual void FlashItem (class itemtype) { artiflashTick = 4; itemflashFade = 0.75; } virtual void AttachToPlayer (PlayerInfo player) { CPlayer = player; UpdateScreenGeometry(); } virtual void FlashCrosshair () { CrosshairSize = XHAIRPICKUPSIZE; } virtual void NewGame () { if (CPlayer != null) AttachToPlayer(CPlayer); } virtual void ShowPop (int popnum) { ShowLog = (popnum == POP_Log && !ShowLog); } virtual bool MustDrawLog(int state) { return true; } // [MK] let the HUD handle notifications and centered print messages virtual bool ProcessNotify(EPrintLevel printlevel, String outline) { return false; } virtual void FlushNotify() {} virtual bool ProcessMidPrint(Font fnt, String msg, bool bold) { return false; } // [MK] let the HUD handle drawing the chat prompt virtual bool DrawChat(String txt) { return false; } // [MK] let the HUD handle drawing the pause graphics virtual bool DrawPaused(int player) { return false; } native TextureID GetMugshot(int accuracy, int stateflags=MugShot.STANDARD, String default_face = "STF"); native int GetTopOfStatusBar(); // These functions are kept native solely for performance reasons. They get called repeatedly and can drag down performance easily if they get too slow. native static TextureID, bool GetInventoryIcon(Inventory item, int flags); //--------------------------------------------------------------------------- // // ValidateInvFirst // // Returns an inventory item that, when drawn as the first item, is sure to // include the selected item in the inventory bar. // //--------------------------------------------------------------------------- Inventory ValidateInvFirst (int numVisible) const { Inventory item; int i; let pmo = CPlayer.mo; if (pmo.InvFirst == NULL) { pmo.InvFirst = pmo.FirstInv(); if (pmo.InvFirst == NULL) { // Nothing to show return NULL; } } // If there are fewer than numVisible items shown, see if we can shift the // view left to show more. for (i = 0, item = pmo.InvFirst; item != NULL && i < numVisible; ++i, item = item.NextInv()) { } while (i < numVisible) { item = pmo.InvFirst.PrevInv (); if (item == NULL) { break; } else { pmo.InvFirst = item; ++i; } } if (pmo.InvSel == NULL) { // Nothing selected, so don't move the view. return pmo.InvFirst == NULL ? pmo.Inv : pmo.InvFirst; } else { // Check if InvSel is already visible for (item = pmo.InvFirst, i = numVisible; item != NULL && i != 0; item = item.NextInv(), --i) { if (item == pmo.InvSel) { return pmo.InvFirst; } } // Check if InvSel is to the right of the visible range for (i = 1; item != NULL; item = item.NextInv(), ++i) { if (item == pmo.InvSel) { // Found it. Now advance InvFirst for (item = pmo.InvFirst; i != 0; --i) { item = item.NextInv(); } return item; } } // Check if InvSel is to the left of the visible range for (item = pmo.Inv; item != pmo.InvSel; item = item.NextInv()) { } if (item != NULL) { // Found it, so let it become the first item shown return item; } // Didn't find the selected item, so don't move the view. // This should never happen. return pmo.InvFirst; } } //============================================================================ // // DBaseStatusBar :: GetCurrentAmmo // // Returns the types and amounts of ammo used by the current weapon. If the // weapon only uses one type of ammo, it is always returned as ammo1. // //============================================================================ Ammo, Ammo, int, int GetCurrentAmmo () const { Ammo ammo1, ammo2; if (CPlayer.ReadyWeapon != NULL) { ammo1 = CPlayer.ReadyWeapon.Ammo1; ammo2 = CPlayer.ReadyWeapon.Ammo2; if (ammo1 == NULL) { ammo1 = ammo2; ammo2 = NULL; } } else { ammo1 = ammo2 = NULL; } let ammocount1 = ammo1 != NULL ? ammo1.Amount : 0; let ammocount2 = ammo2 != NULL ? ammo2.Amount : 0; return ammo1, ammo2, ammocount1, ammocount2; } //============================================================================ // // Get an icon // //============================================================================ TextureID, Vector2 GetIcon(Inventory item, int flags, bool showdepleted = true) { TextureID icon; Vector2 scale = (1,1); icon.SetInvalid(); if (item != null) { bool applyscale; [icon, applyscale] = GetInventoryIcon(item, flags); if (item.Amount == 0 && !showdepleted) return icon, scale; if (applyscale) scale = item.Scale; } return icon, scale; } //============================================================================ // // Convenience functions to retrieve item tags // //============================================================================ String GetAmmoTag(bool secondary = false) { let w = CPlayer.ReadyWeapon; if (w == null) return ""; let ammo = secondary? w.ammo2 : w.ammo1; return ammo.GetTag(); } String GetWeaponTag() { let w = CPlayer.ReadyWeapon; if (w == null) return ""; return w.GetTag(); } String GetSelectedInventoryTag() { let w = CPlayer.mo.InvSel; if (w == null) return ""; return w.GetTag(); } // These cannot be done in ZScript. native static String GetGlobalACSString(int index); native static String GetGlobalACSArrayString(int arrayno, int index); native static int GetGlobalACSValue(int index); native static int GetGlobalACSArrayValue(int arrayno, int index); //============================================================================ // // Convenience functions to retrieve some numbers // //============================================================================ int GetArmorAmount() { let armor = CPlayer.mo.FindInventory("BasicArmor"); return armor? armor.Amount : 0; } int, int GetAmount(class item) { let it = CPlayer.mo.FindInventory(item); int ret1 = it? it.Amount : 0; int ret2 = it? it.MaxAmount : GetDefaultByType(item).MaxAmount; return ret1, ret2; } int GetMaxAmount(class item) { let it = CPlayer.mo.FindInventory(item); return it? it.MaxAmount : GetDefaultByType(item).MaxAmount; } int GetArmorSavePercent() { double add = 0; let harmor = HexenArmor(CPlayer.mo.FindInventory("HexenArmor")); if(harmor != NULL) { add = harmor.Slots[0] + harmor.Slots[1] + harmor.Slots[2] + harmor.Slots[3] + harmor.Slots[4]; } //Hexen counts basic armor also so we should too. let armor = BasicArmor(CPlayer.mo.FindInventory("BasicArmor")); if(armor != NULL && armor.Amount > 0) { add += armor.SavePercent * 100; } return int(add); } // Note that this retrieves the value in tics, not seconds like the equivalent SBARINFO function. // The idea is to let the caller decide what to do with it instead of destroying accuracy here. int GetAirTime() { if(CPlayer.mo.waterlevel < 3) return Level.airsupply; else return max(CPlayer.air_finished - Level.maptime, 0); } int GetSelectedInventoryAmount() { if(CPlayer.mo.InvSel != NULL) return CPlayer.mo.InvSel.Amount; return 0; } int GetKeyCount() { int num = 0; for(Inventory item = CPlayer.mo.Inv;item != NULL;item = item.Inv) { if(item is "Key") num++; } return num; } //============================================================================ // // various checker functions, based on SBARINFOs condition nodes. // //============================================================================ //============================================================================ // // checks ammo use of current weapon // //============================================================================ bool WeaponUsesAmmo(int ValidModes) { if (CPlayer == null) return false; let w = CPlayer.ReadyWeapon; if (w == null) return false; bool usesammo1 = w.AmmoType1 != NULL; bool usesammo2 = w.AmmoType2 != NULL; if (ValidModes == AMMO_PRIMARY) return usesammo1; if (ValidModes == AMMO_SECONDARY) return usesammo2; if (ValidModes == AMMO_ANY) return (usesammo1 || usesammo2); if (ValidModes == AMMO_BOTH) return (usesammo1 && usesammo2); return false; } //============================================================================ // // checks if inventory bar is visible // //============================================================================ bool isInventoryBarVisible() { if (CPlayer == null) return false; return (CPlayer.inventorytics > 0 && !Level.NoInventoryBar); } //============================================================================ // // checks if aspect ratio is in a given range // //============================================================================ bool CheckAspectRatio(double min, double max) { if (CPlayer == null) return false; double aspect = screen.GetAspectRatio(); return (aspect >= min && aspect < max); } //============================================================================ // // checks if weapon is selected. // //============================================================================ bool CheckWeaponSelected(class weap, bool checksister = true) { if (CPlayer == null) return false; let w = CPlayer.ReadyWeapon; if (w == null) return false; if (w.GetClass() == weap) return true; if (checksister && w.SisterWeapon != null && w.SisterWeapon.GetClass() == weap) return true; return false; } //============================================================================ // // checks if player has the given display name // //============================================================================ bool CheckDisplayName(String displayname) { if (CPlayer == null) return false; return displayname == PlayerPawn.GetPrintableDisplayName(CPlayer.mo.GetClass()); } //============================================================================ // // checks if player has the given weapon piece // //============================================================================ int CheckWeaponPiece(class weap, int piecenum) { if (CPlayer == null) return false; for(let inv = CPlayer.mo.Inv; inv != NULL; inv = inv.Inv) { let wh = WeaponHolder(inv); if (wh != null && wh.PieceWeapon == weap) { return (!!(wh.PieceMask & (1 << (PieceNum-1)))); } } return false; } //============================================================================ // // checks if player has the given weapon piece // //============================================================================ int GetWeaponPieceMask(class weap) { if (CPlayer == null) return false; for(let inv = CPlayer.mo.Inv; inv != NULL; inv = inv.Inv) { let wh = WeaponHolder(inv); if (wh != null && wh.PieceWeapon == weap) { return wh.PieceMask; } } return 0; } //============================================================================ // // checks if player has the given weapon piece // //============================================================================ bool WeaponUsesAmmoType(class ammotype) { if (CPlayer == null) return false; let w = CPlayer.ReadyWeapon; if (w == NULL) return false; return w.AmmoType1 == ammotype || w.AmmoType2 == ammotype; } //============================================================================ // // checks if player has the required health // //============================================================================ bool CheckHealth(int Amount, bool percentage = false) { if (CPlayer == null) return false; int phealth = percentage ? CPlayer.mo.health * 100 / CPlayer.mo.GetMaxHealth() : CPlayer.mo.health; return (phealth >= Amount); } //============================================================================ // // checks if player is invulnerable // //============================================================================ bool isInvulnerable() { if (CPlayer == null) return false; return ((CPlayer.mo.bInvulnerable) || (CPlayer.cheats & (CF_GODMODE | CF_GODMODE2))); } //============================================================================ // // checks if player owns enough of the item // //============================================================================ bool CheckInventory(class item, int amount = 1) { if (CPlayer == null) return false; let it = CPlayer.mo.FindInventory(item); return it != null && it.Amount >= amount; } //============================================================================ // // mypos cheat // //============================================================================ virtual void DrawMyPos() { int height = SmallFont.GetHeight(); int i; int vwidth; int vheight; int xpos; int y; let scalevec = GetHUDScale(); int scale = int(scalevec.X); vwidth = screen.GetWidth() / scale; vheight = screen.GetHeight() / scale; xpos = vwidth - SmallFont.StringWidth("X: -00000")-6; y = GetTopOfStatusBar() / (3*scale) - height; Vector3 pos = CPlayer.mo.Pos; for (i = 0; i < 3; y += height, ++i) { double v = i == 0? pos.X : i == 1? pos.Y : pos.Z; String line = String.Format("%c: %d", int("X") + i, v); screen.DrawText (SmallFont, Font.CR_GREEN, xpos, y, line, DTA_KeepRatio, true, DTA_VirtualWidth, vwidth, DTA_VirtualHeight, vheight); } } //============================================================================ // // automap HUD common drawer // This is not called directly to give a status bar the opportunity to // change the text colors. If you want to do something different, // override DrawAutomapHUD directly. // //============================================================================ protected native void DoDrawAutomapHUD(int crdefault, int highlight); virtual void DrawAutomapHUD(double ticFrac) { // game needs to be checked here, so that SBARINFO also gets the correct colors. DoDrawAutomapHUD(Font.CR_GREY, gameinfo.gametype & GAME_DoomChex? Font.CR_UNTRANSLATED : Font.CR_YELLOW); } //--------------------------------------------------------------------------- // // DrawPowerups // //--------------------------------------------------------------------------- virtual void DrawPowerups () { // The AltHUD specific adjustments have been removed here, because the AltHUD uses its own variant of this function // that can obey AltHUD rules - which this cannot. Vector2 pos = (-20, POWERUPICONSIZE * 5 / 4); double maxpos = screen.GetWidth() / 2; for (let iitem = CPlayer.mo.Inv; iitem != NULL; iitem = iitem.Inv) { let item = Powerup(iitem); if (item != null) { let icon = item.GetPowerupIcon(); if (icon.IsValid() && !item.IsBlinking()) { // Each icon gets a 32x32 block. DrawTexture(icon, pos, DI_SCREEN_RIGHT_TOP, 1.0, (POWERUPICONSIZE, POWERUPICONSIZE)); pos.x -= POWERUPICONSIZE; if (pos.x < -maxpos) { pos.x = -20; pos.y += POWERUPICONSIZE * 3 / 2; } } } } } //============================================================================ // // draw stuff // //============================================================================ int GetTranslation() const { if(gameinfo.gametype & GAME_Raven) return Translation.MakeID(TRANSLATION_PlayersExtra, CPlayer.mo.PlayerNumber()); else return Translation.MakeID(TRANSLATION_Players, CPlayer.mo.PlayerNumber()); } //============================================================================ // // // //============================================================================ void DrawHexenArmor(int armortype, String image, Vector2 pos, int flags = 0, double alpha = 1.0, Vector2 boxsize = (-1, -1), Vector2 scale = (1.,1.)) { let harmor = HexenArmor(statusBar.CPlayer.mo.FindInventory("HexenArmor")); if (harmor != NULL) { let slotval = harmor.Slots[armorType]; let slotincr = harmor.SlotsIncrement[armorType]; if (slotval > 0 && slotincr > 0) { //combine the alpha values alpha *= MIN(1., slotval / slotincr); } else return; } DrawImage(image, pos, flags, alpha, boxsize, scale); } //============================================================================ // // // //============================================================================ void DrawInventoryIcon(Inventory item, Vector2 pos, int flags = 0, double alpha = 1.0, Vector2 boxsize = (-1, -1), Vector2 scale = (1.,1.)) { static const String flashimgs[]= { "USEARTID", "USEARTIC", "USEARTIB", "USEARTIA" }; TextureID texture; Vector2 applyscale; [texture, applyscale] = GetIcon(item, flags, false); if((flags & DI_ARTIFLASH) && artiflashTick > 0) { DrawImage(flashimgs[artiflashTick-1], pos, flags, alpha, boxsize); } else if (texture.IsValid()) { if ((flags & DI_DIMDEPLETED) && item.Amount <= 0) flags |= DI_DIM; applyscale.X *= scale.X; applyscale.Y *= scale.Y; DrawTexture(texture, pos, flags, alpha, boxsize, applyscale); } } //============================================================================ // // // //============================================================================ void DrawShader(int which, Vector2 pos, Vector2 size, int flags = 0, double alpha = 1.) { static const String texnames[] = {"BarShaderHF", "BarShaderHR", "BarShaderVF", "BarShaderVR" }; DrawImage(texnames[which], pos, DI_ITEM_LEFT_TOP|DI_ALPHAMAPPED|DI_FORCEFILL | (flags & ~(DI_ITEM_HMASK|DI_ITEM_VMASK)), alpha, size); } //============================================================================ // // // //============================================================================ Vector2, int AdjustPosition(Vector2 position, int flags, double width, double height) { // This must be done here, before altered coordinates get sent to the draw functions. if (!(flags & DI_SCREEN_MANUAL_ALIGN)) { if (position.x < 0) flags |= DI_SCREEN_RIGHT; else flags |= DI_SCREEN_LEFT; if (position.y < 0) flags |= DI_SCREEN_BOTTOM; else flags |= DI_SCREEN_TOP; } // placement by offset is not supported because the inventory bar is a composite. switch (flags & DI_ITEM_HMASK) { case DI_ITEM_HCENTER: position.x -= width / 2; break; case DI_ITEM_RIGHT: position.x -= width; break; } switch (flags & DI_ITEM_VMASK) { case DI_ITEM_VCENTER: position.y -= height / 2; break; case DI_ITEM_BOTTOM: position.y -= height; break; } // clear all alignment flags so that the following code only passes on the rest flags &= ~(DI_ITEM_VMASK|DI_ITEM_HMASK); return position, flags; } //============================================================================ // // note that this does not implement chain wiggling, this is because // it would severely complicate the parameter list. The calling code is // normally in a better position to do the needed calculations anyway. // //============================================================================ void DrawGem(String chain, String gem, int displayvalue, int maxrange, Vector2 pos, int leftpadding, int rightpadding, int chainmod, int flags = 0) { TextureID chaintex = TexMan.CheckForTexture(chain, TexMan.TYPE_MiscPatch); if (!chaintex.IsValid()) return; Vector2 chainsize = TexMan.GetScaledSize(chaintex); [pos, flags] = AdjustPosition(pos, flags, chainsize.X, chainsize.Y); displayvalue = clamp(displayvalue, 0, maxrange); int offset = int(double(chainsize.X - leftpadding - rightpadding) * displayvalue / maxrange); DrawTexture(chaintex, pos + (offset % chainmod, 0), flags | DI_ITEM_LEFT_TOP); DrawImage(gem, pos + (offset + leftPadding, 0), flags | DI_ITEM_LEFT_TOP); } //============================================================================ // // DrawBar // //============================================================================ void DrawBar(String ongfx, String offgfx, double curval, double maxval, Vector2 position, int border, int vertical, int flags = 0, double alpha = 1.0) { let ontex = TexMan.CheckForTexture(ongfx, TexMan.TYPE_MiscPatch); if (!ontex.IsValid()) return; let offtex = TexMan.CheckForTexture(offgfx, TexMan.TYPE_MiscPatch); Vector2 texsize = TexMan.GetScaledSize(ontex); [position, flags] = AdjustPosition(position, flags, texsize.X, texsize.Y); double value = (maxval != 0) ? clamp(curval / maxval, 0, 1) : 0; if(border != 0) value = 1. - value; //invert since the new drawing method requires drawing the bg on the fg. // {cx, cb, cr, cy} double Clip[4]; Clip[0] = Clip[1] = Clip[2] = Clip[3] = 0; bool horizontal = !(vertical & SHADER_VERT); bool reverse = !!(vertical & SHADER_REVERSE); double sizeOfImage = (horizontal ? texsize.X - border*2 : texsize.Y - border*2); Clip[(!horizontal) | ((!reverse)<<1)] = sizeOfImage - sizeOfImage *value; // preserve the active clipping rectangle int cx, cy, cw, ch; [cx, cy, cw, ch] = screen.GetClipRect(); if(border != 0) { for(int i = 0; i < 4; i++) Clip[i] += border; //Draw the whole foreground DrawTexture(ontex, position, flags | DI_ITEM_LEFT_TOP, alpha); SetClipRect(position.X + Clip[0], position.Y + Clip[1], texsize.X - Clip[0] - Clip[2], texsize.Y - Clip[1] - Clip[3], flags); } if (offtex.IsValid() && TexMan.GetScaledSize(offtex) == texsize) DrawTexture(offtex, position, flags | DI_ITEM_LEFT_TOP, alpha); else Fill(color(int(255*alpha),0,0,0), position.X + Clip[0], position.Y + Clip[1], texsize.X - Clip[0] - Clip[2], texsize.Y - Clip[1] - Clip[3]); if (border == 0) { SetClipRect(position.X + Clip[0], position.Y + Clip[1], texsize.X - Clip[0] - Clip[2], texsize.Y - Clip[1] - Clip[3], flags); DrawTexture(ontex, position, flags | DI_ITEM_LEFT_TOP, alpha); } // restore the previous clipping rectangle screen.SetClipRect(cx, cy, cw, ch); } //============================================================================ // // DrawInventoryBar // // This function needs too many parameters, so most have been offloaded to // a struct to keep code readable and allow initialization somewhere outside // the actual drawing code. // //============================================================================ // Except for the placement information this gets all info from the struct that gets passed in. void DrawInventoryBar(InventoryBarState parms, Vector2 position, int numfields, int flags = 0, double bgalpha = 1.) { double width = parms.boxsize.X * numfields; [position, flags] = AdjustPosition(position, flags, width, parms.boxsize.Y); CPlayer.mo.InvFirst = ValidateInvFirst(numfields); if (CPlayer.mo.InvFirst == null) return; // Player has no listed inventory items. Vector2 boxsize = parms.boxsize; // First draw all the boxes for(int i = 0; i < numfields; i++) { DrawTexture(parms.box, position + (boxsize.X * i, 0), flags | DI_ITEM_LEFT_TOP, bgalpha); } // now the items and the rest Vector2 itempos = position + boxsize / 2; Vector2 textpos = position + boxsize - (1, 1 + parms.amountfont.mFont.GetHeight()); int i = 0; Inventory item; for(item = CPlayer.mo.InvFirst; item != NULL && i < numfields; item = item.NextInv()) { for(int j = 0; j < 2; j++) { if (j ^ !!(flags & DI_DRAWCURSORFIRST)) { if (item == CPlayer.mo.InvSel) { double flashAlpha = bgalpha; if (flags & DI_ARTIFLASH) flashAlpha *= itemflashFade; DrawTexture(parms.selector, position + parms.selectofs + (boxsize.X * i, 0), flags | DI_ITEM_LEFT_TOP, flashAlpha); } } else { DrawInventoryIcon(item, itempos + (boxsize.X * i, 0), flags | DI_ITEM_CENTER | DI_DIMDEPLETED ); } } if (parms.amountfont != null && (item.Amount > 1 || (flags & DI_ALWAYSSHOWCOUNTERS))) { DrawString(parms.amountfont, FormatNumber(item.Amount, 0, 5), textpos + (boxsize.X * i, 0), flags | DI_TEXT_ALIGN_RIGHT, parms.cr, parms.itemalpha); } i++; } // Is there something to the left? if (CPlayer.mo.FirstInv() != CPlayer.mo.InvFirst) { DrawTexture(parms.left, position + (-parms.arrowoffset.X, parms.arrowoffset.Y), flags | DI_ITEM_RIGHT|DI_ITEM_VCENTER); } // Is there something to the right? if (item != NULL) { DrawTexture(parms.right, position + parms.arrowoffset + (width, 0), flags | DI_ITEM_LEFT|DI_ITEM_VCENTER); } } } class HUDFont native ui { native Font mFont; native static HUDFont Create(Font fnt, int spacing = 0, EMonospacing monospacing = Mono_Off, int shadowx = 0, int shadowy = 0); } class StatusBarCore native ui { enum DI_Flags { DI_SKIPICON = 0x1, DI_SKIPALTICON = 0x2, DI_SKIPSPAWN = 0x4, DI_SKIPREADY = 0x8, DI_ALTICONFIRST = 0x10, DI_TRANSLATABLE = 0x20, DI_FORCESCALE = 0x40, DI_DIM = 0x80, DI_DRAWCURSORFIRST = 0x100, // only for DrawInventoryBar. DI_ALWAYSSHOWCOUNT = 0x200, // only for DrawInventoryBar. DI_DIMDEPLETED = 0x400, DI_DONTANIMATE = 0x800, // do not animate the texture DI_MIRROR = 0x1000, // flip the texture horizontally, like a mirror DI_ITEM_RELCENTER = 0x2000, DI_MIRRORY = 0x40000000, DI_SCREEN_AUTO = 0, // decide based on given offsets. DI_SCREEN_MANUAL_ALIGN = 0x4000, // If this is on, the following flags will have an effect DI_SCREEN_TOP = DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_VCENTER = 0x8000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_BOTTOM = 0x10000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_VOFFSET = 0x18000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_VMASK = 0x18000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_LEFT = DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_HCENTER = 0x20000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_RIGHT = 0x40000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_HOFFSET = 0x60000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_HMASK = 0x60000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_LEFT_TOP = DI_SCREEN_TOP | DI_SCREEN_LEFT, DI_SCREEN_RIGHT_TOP = DI_SCREEN_TOP | DI_SCREEN_RIGHT, DI_SCREEN_LEFT_BOTTOM = DI_SCREEN_BOTTOM | DI_SCREEN_LEFT, DI_SCREEN_LEFT_CENTER = DI_SCREEN_VCENTER | DI_SCREEN_LEFT, DI_SCREEN_RIGHT_BOTTOM = DI_SCREEN_BOTTOM | DI_SCREEN_RIGHT, DI_SCREEN_RIGHT_CENTER = DI_SCREEN_VCENTER | DI_SCREEN_RIGHT, DI_SCREEN_CENTER = DI_SCREEN_VCENTER | DI_SCREEN_HCENTER, DI_SCREEN_CENTER_TOP = DI_SCREEN_TOP | DI_SCREEN_HCENTER, DI_SCREEN_CENTER_BOTTOM = DI_SCREEN_BOTTOM | DI_SCREEN_HCENTER, DI_SCREEN_OFFSETS = DI_SCREEN_HOFFSET | DI_SCREEN_VOFFSET, DI_ITEM_AUTO = 0, // equivalent with bottom center, which is the default alignment. DI_ITEM_TOP = 0x80000, DI_ITEM_VCENTER = 0x100000, DI_ITEM_BOTTOM = 0, // this is the default vertical alignment DI_ITEM_VOFFSET = 0x180000, DI_ITEM_VMASK = 0x180000, DI_ITEM_LEFT = 0x200000, DI_ITEM_HCENTER = 0, // this is the default horizontal alignment DI_ITEM_RIGHT = 0x400000, DI_ITEM_HOFFSET = 0x600000, DI_ITEM_HMASK = 0x600000, DI_ITEM_LEFT_TOP = DI_ITEM_TOP|DI_ITEM_LEFT, DI_ITEM_RIGHT_TOP = DI_ITEM_TOP|DI_ITEM_RIGHT, DI_ITEM_LEFT_BOTTOM = DI_ITEM_BOTTOM|DI_ITEM_LEFT, DI_ITEM_RIGHT_BOTTOM = DI_ITEM_BOTTOM|DI_ITEM_RIGHT, DI_ITEM_CENTER = DI_ITEM_VCENTER|DI_ITEM_HCENTER, DI_ITEM_CENTER_BOTTOM = DI_ITEM_BOTTOM|DI_ITEM_HCENTER, DI_ITEM_OFFSETS = DI_ITEM_HOFFSET|DI_ITEM_VOFFSET, DI_TEXT_ALIGN_LEFT = 0, DI_TEXT_ALIGN_RIGHT = 0x800000, DI_TEXT_ALIGN_CENTER = 0x1000000, DI_TEXT_ALIGN = 0x1800000, DI_ALPHAMAPPED = 0x2000000, DI_NOSHADOW = 0x4000000, DI_ALWAYSSHOWCOUNTERS = 0x8000000, DI_ARTIFLASH = 0x10000000, DI_FORCEFILL = 0x20000000, // These 2 flags are only used by SBARINFO so these duplicate other flags not used by SBARINFO DI_DRAWINBOX = DI_TEXT_ALIGN_RIGHT, DI_ALTERNATEONFAIL = DI_TEXT_ALIGN_CENTER, }; enum ENumFlags { FNF_WHENNOTZERO = 0x1, FNF_FILLZEROS = 0x2, } // These are block properties for the drawers. A child class can set them to have a block of items use the same settings. native double Alpha; native Vector2 drawOffset; // can be set by subclasses to offset drawing operations native double drawClip[4]; // defines a clipping rectangle (not used yet) native bool fullscreenOffsets; // current screen is displayed with fullscreen behavior. native int RelTop; native int HorizontalResolution, VerticalResolution; native bool CompleteBorder; native Vector2 defaultScale; // factor for fully scaled fullscreen display. native static String FormatNumber(int number, int minsize = 0, int maxsize = 0, int format = 0, String prefix = ""); native double, double, double, double StatusbarToRealCoords(double x, double y=0, double w=0, double h=0); native void DrawTexture(TextureID texture, Vector2 pos, int flags = 0, double Alpha = 1., Vector2 box = (-1, -1), Vector2 scale = (1, 1), ERenderStyle style = STYLE_Translucent, Color col = 0xffffffff, int translation = 0, double clipwidth = -1); native void DrawImage(String texture, Vector2 pos, int flags = 0, double Alpha = 1., Vector2 box = (-1, -1), Vector2 scale = (1, 1), ERenderStyle style = STYLE_Translucent, Color col = 0xffffffff, int translation = 0, double clipwidth = -1); native void DrawTextureRotated(TextureID texid, Vector2 pos, int flags, double angle, double alpha = 1, Vector2 scale = (1, 1), ERenderStyle style = STYLE_Translucent, Color col = 0xffffffff, int translation = 0); native void DrawImageRotated(String texid, Vector2 pos, int flags, double angle, double alpha = 1, Vector2 scale = (1, 1), ERenderStyle style = STYLE_Translucent, Color col = 0xffffffff, int translation = 0); native void DrawString(HUDFont font, String string, Vector2 pos, int flags = 0, int translation = Font.CR_UNTRANSLATED, double Alpha = 1., int wrapwidth = -1, int linespacing = 4, Vector2 scale = (1, 1), int pt = 0, ERenderStyle style = STYLE_Translucent); native double, double, double, double TransformRect(double x, double y, double w, double h, int flags = 0); native void Fill(Color col, double x, double y, double w, double h, int flags = 0); native void SetClipRect(double x, double y, double w, double h, int flags = 0); native void SetSize(int height, int vwidth, int vheight, int hwidth = -1, int hheight = -1); native Vector2 GetHUDScale(); native void BeginStatusBar(bool forceScaled = false, int resW = -1, int resH = -1, int rel = -1); native void BeginHUD(double Alpha = 1., bool forcescaled = false, int resW = -1, int resH = -1); void ClearClipRect() { screen.ClearClipRect(); } //============================================================================ // // Returns how much the status bar's graphics extend into the view // Used for automap text positioning // The parameter specifies how much of the status bar area will be covered // by the element requesting this information. // //============================================================================ virtual int GetProtrusion(double scaleratio) const { return 0; } } //============================================================================ // // a generic value interpolator for status bar elements that can change // gradually to their new value. // //============================================================================ class LinearValueInterpolator : Object { int mCurrentValue; int mMaxChange; static LinearValueInterpolator Create(int startval, int maxchange) { let v = new("LinearValueInterpolator"); v.mCurrentValue = startval; v.mMaxChange = maxchange; return v; } void Reset(int value) { mCurrentValue = value; } // This must be called periodically in the status bar's Tick function. // Do not call this in the Draw function because that may skip some frames! void Update(int destvalue) { if (mCurrentValue > destvalue) { mCurrentValue = max(destvalue, mCurrentValue - mMaxChange); } else { mCurrentValue = min(destvalue, mCurrentValue + mMaxChange); } } // This must be called in the draw function to retrieve the value for output. int GetValue() { return mCurrentValue; } } class DynamicValueInterpolator : Object { int mCurrentValue; int mMinChange; int mMaxChange; double mChangeFactor; static DynamicValueInterpolator Create(int startval, double changefactor, int minchange, int maxchange) { let v = new("DynamicValueInterpolator"); v.mCurrentValue = startval; v.mMinChange = minchange; v.mMaxChange = maxchange; v.mChangeFactor = changefactor; return v; } void Reset(int value) { mCurrentValue = value; } // This must be called periodically in the status bar's Tick function. // Do not call this in the Draw function because that may skip some frames! void Update(int destvalue) { int diff = int(clamp(abs(destvalue - mCurrentValue) * mChangeFactor, mMinChange, mMaxChange)); if (mCurrentValue > destvalue) { mCurrentValue = max(destvalue, mCurrentValue - diff); } else { mCurrentValue = min(destvalue, mCurrentValue + diff); } } // This must be called in the draw function to retrieve the value for output. int GetValue() { return mCurrentValue; } } class StealthArachnotron : Arachnotron { Default { +STEALTH RenderStyle "Translucent"; Alpha 0; Obituary "$OB_STEALTHBABY"; } } class StealthArchvile : Archvile { Default { +STEALTH RenderStyle "Translucent"; Alpha 0; Obituary "$OB_STEALTHVILE"; } } class StealthBaron : BaronOfHell { Default { +STEALTH RenderStyle "Translucent"; Alpha 0; Obituary "$OB_STEALTHBARON"; HitObituary "$OB_STEALTHBARON"; } } class StealthCacodemon : Cacodemon { Default { +STEALTH RenderStyle "Translucent"; Alpha 0; Obituary "$OB_STEALTHCACO"; HitObituary "$OB_STEALTHCACO"; } } class StealthChaingunGuy : ChaingunGuy { Default { +STEALTH RenderStyle "Translucent"; Alpha 0; Obituary "$OB_STEALTHCHAINGUY"; } } class StealthDemon : Demon { Default { +STEALTH RenderStyle "Translucent"; Alpha 0; Obituary "$OB_STEALTHDEMON"; HitObituary "$OB_STEALTHDEMON"; } } class StealthHellKnight : HellKnight { Default { +STEALTH RenderStyle "Translucent"; Alpha 0; Obituary "$OB_STEALTHKNIGHT"; HitObituary "$OB_STEALTHKNIGHT"; } } class StealthDoomImp : DoomImp { Default { +STEALTH RenderStyle "Translucent"; Alpha 0; Obituary "$OB_STEALTHIMP"; HitObituary "$OB_STEALTHIMP"; } } class StealthFatso : Fatso { Default { +STEALTH RenderStyle "Translucent"; Alpha 0; Obituary "$OB_STEALTHFATSO"; } } class StealthRevenant : Revenant { Default { +STEALTH RenderStyle "Translucent"; Alpha 0; Obituary "$OB_STEALTHUNDEAD"; HitObituary "$OB_STEALTHUNDEAD"; } } class StealthShotgunGuy : ShotgunGuy { Default { +STEALTH RenderStyle "Translucent"; Alpha 0; Obituary "$OB_STEALTHSHOTGUNGUY"; } } class StealthZombieMan : ZombieMan { Default { +STEALTH RenderStyle "Translucent"; Alpha 0; Obituary "$OB_STEALTHZOMBIE"; } } // HE-Grenade Rounds -------------------------------------------------------- class HEGrenadeRounds : Ammo { Default { +FLOORCLIP Inventory.Amount 6; Inventory.MaxAmount 30; Ammo.BackpackAmount 6; Ammo.BackpackMaxAmount 60; Inventory.Icon "I_GRN1"; Tag "$TAG_HEGRENADES"; Inventory.PickupMessage "$TXT_HEGRENADES"; } States { Spawn: GRN1 A -1; Stop; } } // Phosphorus-Grenade Rounds ------------------------------------------------ class PhosphorusGrenadeRounds : Ammo { Default { +FLOORCLIP Inventory.Amount 4; Inventory.MaxAmount 16; Ammo.BackpackAmount 4; Ammo.BackpackMaxAmount 32; Inventory.Icon "I_GRN2"; Tag "$TAG_PHGRENADES"; Inventory.PickupMessage "$TXT_PHGRENADES"; } States { Spawn: GRN2 A -1; Stop; } } // Clip of Bullets ---------------------------------------------------------- class ClipOfBullets : Ammo { Default { +FLOORCLIP Inventory.Amount 10; Inventory.MaxAmount 250; Ammo.BackpackAmount 10; Ammo.BackpackMaxAmount 500; Inventory.Icon "I_BLIT"; Tag "$TAG_CLIPOFBULLETS"; Inventory.PickupMessage "$TXT_CLIPOFBULLETS"; } States { Spawn: BLIT A -1; Stop; } } // Box of Bullets ----------------------------------------------------------- class BoxOfBullets : ClipOfBullets { Default { Inventory.Amount 50; Tag "$TAG_BOXOFBULLETS"; Inventory.PickupMessage "$TXT_BOXOFBULLETS"; } States { Spawn: BBOX A -1; Stop; } } // Mini Missiles ------------------------------------------------------------ class MiniMissiles : Ammo { Default { +FLOORCLIP Inventory.Amount 4; Inventory.MaxAmount 100; Ammo.BackpackAmount 4; Ammo.BackpackMaxAmount 200; Inventory.Icon "I_ROKT"; Tag "$TAG_MINIMISSILES"; Inventory.PickupMessage "$TXT_MINIMISSILES"; } States { Spawn: MSSL A -1; Stop; } } // Crate of Missiles -------------------------------------------------------- class CrateOfMissiles : MiniMissiles { Default { Inventory.Amount 20; Tag "$TAG_CRATEOFMISSILES"; Inventory.PickupMessage "$TXT_CRATEOFMISSILES"; } States { Spawn: ROKT A -1; Stop; } } // Energy Pod --------------------------------------------------------------- class EnergyPod : Ammo { Default { +FLOORCLIP Inventory.Amount 20; Inventory.MaxAmount 400; Ammo.BackpackAmount 20; Ammo.BackpackMaxAmount 800; Ammo.DropAmount 20; Inventory.Icon "I_BRY1"; Tag "$TAG_ENERGYPOD"; Inventory.PickupMessage "$TXT_ENERGYPOD"; } States { Spawn: BRY1 AB 6; Loop; } } // Energy pack --------------------------------------------------------------- class EnergyPack : EnergyPod { Default { Inventory.Amount 100; Tag "$TAG_ENERGYPACK"; Inventory.PickupMessage "$TXT_ENERGYPACK"; } States { Spawn: CPAC AB 6; Loop; } } // Poison Bolt Quiver ------------------------------------------------------- class PoisonBolts : Ammo { Default { +FLOORCLIP Inventory.Amount 10; Inventory.MaxAmount 25; Ammo.BackpackAmount 2; Ammo.BackpackMaxAmount 50; Inventory.Icon "I_PQRL"; Tag "$TAG_POISONBOLTS"; Inventory.PickupMessage "$TXT_POISONBOLTS"; } States { Spawn: PQRL A -1; Stop; } } // Electric Bolt Quiver ------------------------------------------------------- class ElectricBolts : Ammo { Default { +FLOORCLIP Inventory.Amount 20; Inventory.MaxAmount 50; Ammo.BackpackAmount 4; Ammo.BackpackMaxAmount 100; Inventory.Icon "I_XQRL"; Tag "$TAG_ELECTRICBOLTS"; Inventory.PickupMessage "$TXT_ELECTRICBOLTS"; } States { Spawn: XQRL A -1; Stop; } } // Ammo Satchel ------------------------------------------------------------- class AmmoSatchel : BackpackItem { Default { +FLOORCLIP Inventory.Icon "I_BKPK"; Tag "$TAG_AMMOSATCHEL"; Inventory.PickupMessage "$TXT_AMMOSATCHEL"; } States { Spawn: BKPK A -1; Stop; } } class MetalArmor : BasicArmorPickup { Default { Radius 20; Height 16; +FLOORCLIP +INVENTORY.AUTOACTIVATE +INVENTORY.INVBAR Inventory.MaxAmount 3; Inventory.Icon "I_ARM1"; Inventory.PickupMessage "$TXT_METALARMOR"; Armor.SaveAmount 200; Armor.SavePercent 50; Tag "$TAG_METALARMOR"; } States { Spawn: ARM3 A -1; Stop; } } class LeatherArmor : BasicArmorPickup { Default { Radius 20; Height 16; +FLOORCLIP +INVENTORY.AUTOACTIVATE +INVENTORY.INVBAR Inventory.MaxAmount 5; Inventory.Icon "I_ARM2"; Inventory.PickupMessage "$TXT_LEATHERARMOR"; Armor.SaveAmount 100; Armor.SavePercent 33.335; Tag "$TAG_LEATHER"; } States { Spawn: ARM4 A -1; Stop; } } // Bishop ------------------------------------------------------------------- class StrifeBishop : Actor { Default { Health 500; Painchance 128; Speed 8; Radius 40; Height 56; Mass 500; Monster; +NOBLOOD +NOTDMATCH +FLOORCLIP +INCOMBAT +NOICEDEATH +NEVERRESPAWN DamageFactor "Fire", 0.5; MinMissileChance 150; MaxDropoffHeight 32; Tag "$TAG_BISHOP"; SeeSound "bishop/sight"; PainSound "bishop/pain"; DeathSound "bishop/death"; ActiveSound "bishop/active"; DropItem "CrateOfMissiles", 256, 20; Obituary "$OB_STFBISHOP"; } States { Spawn: MLDR A 10 A_Look; Loop; See: MLDR AABBCCDD 3 A_Chase; Loop; Missile: MLDR E 3 A_FaceTarget; MLDR F 2 Bright A_SpawnProjectile("BishopMissile", 64, 0, 0, CMF_AIMOFFSET); Goto See; Pain: MLDR D 1 A_Pain; Goto See; Death: MLDR G 3 Bright; MLDR H 5 Bright A_Scream; MLDR I 4 Bright A_TossGib; MLDR J 4 Bright A_Explode(64, 64, alert:true); MLDR KL 3 Bright; MLDR M 4 Bright A_NoBlocking; MLDR N 4 Bright; MLDR O 4 Bright A_TossGib; MLDR P 4 Bright; MLDR Q 4 Bright A_TossGib; MLDR R 4 Bright; MLDR S 4 Bright A_TossGib; MLDR T 4 Bright; MLDR U 4 Bright A_TossGib; MLDR V 4 Bright A_SpawnItemEx("AlienSpectre2", 0, 0, 0, 0, 0, random[spectrespawn](0,255)*0.0078125, 0, SXF_NOCHECKPOSITION); Stop; } } // The Bishop's missile ----------------------------------------------------- class BishopMissile : Actor { Default { Speed 20; Radius 10; Height 14; Damage 10; Projectile; +SEEKERMISSILE +STRIFEDAMAGE MaxStepHeight 4; SeeSound "bishop/misl"; DeathSound "bishop/mislx"; } States { Spawn: MISS A 4 Bright A_RocketInFlight; MISS B 3 Bright A_Tracer2; Loop; Death: SMIS A 0 Bright A_SetRenderStyle(1, STYLE_Normal); SMIS A 5 Bright A_Explode(64, 64, alert:true); SMIS B 5 Bright; SMIS C 4 Bright; SMIS DEFG 2 Bright; Stop; } } // common Strife action functions that are used by multiple different actors extend class Actor { //============================================================================ void A_FLoopActiveSound() { if (ActiveSound != 0 && !(Level.maptime & 7)) { A_StartSound (ActiveSound, CHAN_VOICE); } } void A_LoopActiveSound() { A_StartSound(ActiveSound, CHAN_VOICE, CHANF_LOOPING); } //============================================================================ // // // //============================================================================ void A_Countdown() { if (--reactiontime <= 0) { ExplodeMissile (); bSkullFly = false; } } //============================================================================ // // A_ClearSoundTarget // //============================================================================ void A_ClearSoundTarget() { CurSector.SoundTarget = null; for (Actor mo = CurSector.thinglist; mo != null; mo = mo.snext) { mo.LastHeard = null; } } //========================================================================== // // A_TossGib // //========================================================================== void A_TossGib() { class gibtype; if (bNoBlood) gibtype = "Junk"; else gibtype = "Meat"; Actor gib = Spawn (gibtype, pos + (0,0,24), ALLOW_REPLACE); if (gib == null) { return; } gib.Angle = random[GibTosser]() * (360 / 256.); gib.VelFromAngle(random[GibTosser](0, 15)); gib.Vel.Z = random[GibTosser](0, 15); } //========================================================================== // // // //========================================================================== void A_ShootGun() { if (!target) return; A_StartSound ("monsters/rifle", CHAN_WEAPON); A_FaceTarget (); double pitch = AimLineAttack (angle, MISSILERANGE); LineAttack (Angle + Random2[ShootGun]() * (11.25 / 256), MISSILERANGE, pitch, 3*random[ShootGun](1, 5), 'Hitscan', "StrifePuff"); } //========================================================================== // // // //========================================================================== void A_SetShadow() { bShadow = true; A_SetRenderStyle(HR_SHADOW, STYLE_Translucent); } void A_ClearShadow() { bShadow = false; A_SetRenderStyle(1, STYLE_Normal); } //========================================================================== // // // //========================================================================== void A_GetHurt() { bInCombat = true; if (random[HurtMe](0, 4) == 0) { A_StartSound (PainSound, CHAN_VOICE); health--; } if (health <= 0) { Die (target, target); } } //========================================================================== // // // //========================================================================== void A_DropFire() { Actor drop = Spawn("FireDroplet", pos + (0,0,24), ALLOW_REPLACE); if (drop != null) { drop.Vel.Z = -1.; } A_Explode(64, 64, XF_NOSPLASH|XF_HURTSOURCE|XF_NOTMISSILE, damagetype: 'Fire'); } //========================================================================== // // // //========================================================================== void A_RemoveForceField() { bSpecial = false; CurSector.RemoveForceField(); } //========================================================================== // // // //========================================================================== void A_AlertMonsters(double maxdist = 0, int flags = 0) { Actor target = null; Actor emitter = self; if (player != null || (Flags & AMF_TARGETEMITTER)) { target = self; } else if (self.target != null && (self.target.player != null || (Flags & AMF_TARGETNONPLAYER))) { target = self.target; } if (Flags & AMF_EMITFROMTARGET) emitter = target; if (target != null && emitter != null) { emitter.SoundAlert(target, false, maxdist); } } //============================================================================ // // A_RocketInFlight // //============================================================================ void A_RocketInFlight() { A_StartSound ("misc/missileinflight", CHAN_VOICE); SpawnPuff ("MiniMissilePuff", Pos, Angle - 180, Angle - 180, 2, PF_HITTHING); Actor trail = Spawn("RocketTrail", Vec3Offset(-Vel.X, -Vel.Y, 0.), ALLOW_REPLACE); if (trail != null) { trail.Vel.Z = 1; } } } // Humanoid Base Class ------------------------------------------------------ class StrifeHumanoid : Actor { Default { MaxStepHeight 16; MaxDropoffHeight 32; CrushPainSound "misc/pcrush"; } States { Burn: BURN A 3 Bright Light("PhFire_FX1") A_StartSound("human/imonfire", CHAN_VOICE); BURN B 3 Bright Light("PhFire_FX2") A_DropFire; BURN C 3 Bright Light("PhFire_FX3") A_Wander; BURN D 3 Bright Light("PhFire_FX4") A_NoBlocking; BURN E 5 Bright Light("PhFire_FX5") A_DropFire; BURN F 5 Bright Light("PhFire_FX6") A_Wander; BURN G 5 Bright Light("PhFire_FX7") A_Wander; BURN H 5 Bright Light("PhFire_FX6") A_Wander; BURN I 5 Bright Light("PhFire_FX5") A_DropFire; BURN J 5 Bright Light("PhFire_FX4") A_Wander; BURN K 5 Bright Light("PhFire_FX3") A_Wander; BURN L 5 Bright Light("PhFire_FX2") A_Wander; BURN M 5 Bright Light("PhFire_FX1") A_DropFire; BURN N 5 Bright Light("PhFire_FX2"); BURN O 5 Bright Light("PhFire_FX3"); BURN P 5 Bright Light("PhFire_FX4"); BURN Q 5 Bright Light("PhFire_FX5"); BURN P 5 Bright Light("PhFire_FX4"); BURN Q 5 Bright Light("PhFire_FX5"); BURN R 7 Bright Light("PhFire_FX8"); BURN S 7 Bright Light("PhFire_FX9"); BURN T 7 Bright Light("PhFire_FX10"); BURN U 7 Bright Light("PhFire_FX11"); BURN V -1; Stop; Disintegrate: DISR A 5 A_StartSound("misc/disruptordeath", CHAN_VOICE); DISR BC 5; DISR D 5 A_NoBlocking; DISR EF 5; DISR GHIJ 4; MEAT D 700; Stop; } } // Fire Droplet ------------------------------------------------------------- class FireDroplet : Actor { Default { +NOBLOCKMAP +NOCLIP } States { Spawn: FFOT ABCD 9 Bright; Stop; } } // Med patch ----------------------------------------------------------------- class MedPatch : HealthPickup { Default { Health 10; +FLOORCLIP +INVENTORY.INVBAR Inventory.MaxAmount 20; Tag "$TAG_MEDPATCH"; Inventory.Icon "I_STMP"; Inventory.PickupMessage "$TXT_MEDPATCH"; HealthPickup.Autouse 3; } States { Spawn: STMP A -1; Stop; } } // Medical Kit --------------------------------------------------------------- class MedicalKit : HealthPickup { Default { Health 25; +FLOORCLIP +INVENTORY.INVBAR Inventory.MaxAmount 15; Tag "$TAG_MEDICALKIT"; Inventory.Icon "I_MDKT"; Inventory.PickupMessage "$TXT_MEDICALKIT"; HealthPickup.Autouse 3; } States { Spawn: MDKT A -1; Stop; } } // Surgery Kit -------------------------------------------------------------- class SurgeryKit : HealthPickup { Default { +FLOORCLIP +INVENTORY.INVBAR Health -100; Inventory.MaxAmount 5; Tag "$TAG_SURGERYKIT"; Inventory.Icon "I_FULL"; Inventory.PickupMessage "$TXT_SURGERYKIT"; } States { Spawn: FULL AB 35; Loop; } } // StrifeMap ---------------------------------------------------------------- class StrifeMap : MapRevealer { Default { +FLOORCLIP Inventory.PickupSound "misc/p_pkup"; Inventory.PickupMessage "$TXT_STRIFEMAP"; } States { Spawn: SMAP AB 6 Bright; Loop; } } // Beldin's Ring ------------------------------------------------------------ class BeldinsRing : Inventory { Default { +NOTDMATCH +FLOORCLIP +INVENTORY.INVBAR Tag "$TAG_BELDINSRING"; Inventory.Icon "I_RING"; Inventory.GiveQuest 1; Inventory.PickupMessage "$TXT_BELDINSRING"; } States { Spawn: RING A -1; Stop; } } // Offering Chalice --------------------------------------------------------- class OfferingChalice : Inventory { Default { +DROPPED +FLOORCLIP +INVENTORY.INVBAR Radius 10; Height 16; Tag "$TAG_OFFERINGCHALICE"; Inventory.Icon "I_RELC"; Inventory.PickupMessage "$TXT_OFFERINGCHALICE"; Inventory.GiveQuest 2; } States { Spawn: RELC A -1; Stop; } } // Ear ---------------------------------------------------------------------- class Ear : Inventory { Default { +FLOORCLIP +INVENTORY.INVBAR Tag "$TAG_EAR"; Inventory.Icon "I_EARS"; Inventory.PickupMessage "$TXT_EAR"; Inventory.GiveQuest 9; } States { Spawn: EARS A -1; Stop; } } // Broken Power Coupling ---------------------------------------------------- class BrokenPowerCoupling : Inventory { Default { Health 40; +DROPPED +FLOORCLIP +INVENTORY.INVBAR Radius 16; Height 16; Tag "$TAG_BROKENCOUPLING"; Inventory.MaxAmount 1; Inventory.Icon "I_COUP"; Inventory.PickupMessage "$TXT_BROKENCOUPLING"; Inventory.GiveQuest 8; } States { Spawn: COUP C -1; Stop; } } // Shadow Armor ------------------------------------------------------------- class ShadowArmor : PowerupGiver { Default { +FLOORCLIP +VISIBILITYPULSE +INVENTORY.INVBAR -INVENTORY.FANCYPICKUPSOUND RenderStyle "Translucent"; Tag "$TAG_SHADOWARMOR"; Inventory.MaxAmount 2; Powerup.Type "PowerShadow"; Inventory.Icon "I_SHD1"; Inventory.PickupSound "misc/i_pkup"; Inventory.PickupMessage "$TXT_SHADOWARMOR"; } States { Spawn: SHD1 A -1 Bright; Stop; } } // Environmental suit ------------------------------------------------------- class EnvironmentalSuit : PowerupGiver { Default { +FLOORCLIP +INVENTORY.INVBAR -INVENTORY.FANCYPICKUPSOUND Inventory.MaxAmount 5; Powerup.Type "PowerMask"; Tag "$TAG_ENVSUIT"; Inventory.Icon "I_MASK"; Inventory.PickupSound "misc/i_pkup"; Inventory.PickupMessage "$TXT_ENVSUIT"; } States { Spawn: MASK A -1; Stop; } } // Guard Uniform ------------------------------------------------------------ class GuardUniform : Inventory { Default { +FLOORCLIP +INVENTORY.INVBAR Tag "$TAG_GUARDUNIFORM"; Inventory.Icon "I_UNIF"; Inventory.PickupMessage "$TXT_GUARDUNIFORM"; Inventory.GiveQuest 15; } States { Spawn: UNIF A -1; Stop; } } // Officer's Uniform -------------------------------------------------------- class OfficersUniform : Inventory { Default { +FLOORCLIP +INVENTORY.INVBAR Tag "$TAG_OFFICERSUNIFORM"; Inventory.Icon "I_OFIC"; Inventory.PickupMessage "$TXT_OFFICERSUNIFORM"; } States { Spawn: OFIC A -1; Stop; } } // Flame Thrower Parts ------------------------------------------------------ class FlameThrowerParts : Inventory { Default { +FLOORCLIP +INVENTORY.INVBAR Inventory.Icon "I_BFLM"; Tag "$TAG_FTHROWERPARTS"; Inventory.PickupMessage "$TXT_FTHROWERPARTS"; } States { Spawn: BFLM A -1; Stop; } } // InterrogatorReport ------------------------------------------------------- // SCRIPT32 in strife0.wad has an Acolyte that drops this, but I couldn't // find that Acolyte in the map. It seems to be totally unused in the // final game. class InterrogatorReport : Inventory { Default { +FLOORCLIP Tag "$TAG_REPORT"; Inventory.PickupMessage "$TXT_REPORT"; } States { Spawn: TOKN A -1; Stop; } } // Info --------------------------------------------------------------------- class Info : Inventory { Default { +FLOORCLIP +INVENTORY.INVBAR Tag "$TAG_INFO"; Inventory.Icon "I_TOKN"; Inventory.PickupMessage "$TXT_INFO"; } States { Spawn: TOKN A -1; Stop; } } // Targeter ----------------------------------------------------------------- class Targeter : PowerupGiver { Default { +FLOORCLIP +INVENTORY.INVBAR -INVENTORY.FANCYPICKUPSOUND Tag "$TAG_TARGETER"; Powerup.Type "PowerTargeter"; Inventory.MaxAmount 5; Inventory.Icon "I_TARG"; Inventory.PickupSound "misc/i_pkup"; Inventory.PickupMessage "$TXT_TARGETER"; } States { Spawn: TARG A -1; Stop; } } // Communicator ----------------------------------------------------------------- class Communicator : Inventory { Default { +NOTDMATCH Tag "$TAG_COMMUNICATOR"; Inventory.Icon "I_COMM"; Inventory.PickupSound "misc/p_pkup"; Inventory.PickupMessage "$TXT_COMMUNICATOR"; } States { Spawn: COMM A -1; Stop; } } // Degnin Ore --------------------------------------------------------------- class DegninOre : Inventory { Default { Health 10; Radius 16; Height 16; Inventory.MaxAmount 10; +SOLID +SHOOTABLE +NOBLOOD +FLOORCLIP +INCOMBAT +INVENTORY.INVBAR Tag "$TAG_DEGNINORE"; DeathSound "ore/explode"; Inventory.Icon "I_XPRK"; Inventory.PickupMessage "$TXT_DEGNINORE"; } States { Spawn: XPRK A -1; Stop; Death: XPRK A 1 A_RemoveForceField; BNG3 A 0 A_SetRenderStyle(1, STYLE_Normal); BNG3 A 0 A_Scream; BNG3 A 3 Bright A_Explode(192, 192, alert:true); BNG3 BCDEFGH 3 Bright; Stop; } override bool Use (bool pickup) { if (pickup) { return false; } else { Inventory drop; // Increase the amount by one so that when DropInventory decrements it, // the actor will have the same number of beacons that he started with. // When we return to UseInventory, it will take care of decrementing // Amount again and disposing of this item if there are no more. Amount++; drop = Owner.DropInventory (self); if (drop == NULL) { Amount--; return false; } return true; } } } // Gun Training ------------------------------------------------------------- class GunTraining : Inventory { Default { +FLOORCLIP +INVENTORY.INVBAR +INVENTORY.UNDROPPABLE Inventory.MaxAmount 100; Tag "$TAG_GUNTRAINING"; Inventory.Icon "I_GUNT"; } States { Spawn: GUNT A -1; Stop; } } // Health Training ---------------------------------------------------------- class HealthTraining : Inventory { Default { +FLOORCLIP +INVENTORY.INVBAR +INVENTORY.UNDROPPABLE Inventory.MaxAmount 100; Tag "$TAG_HEALTHTRAINING"; Inventory.Icon "I_HELT"; } States { Spawn: HELT A -1; Stop; } override bool TryPickup (in out Actor toucher) { if (Super.TryPickup(toucher)) { toucher.GiveInventoryType ("GunTraining"); toucher.A_GiveInventory("Coin", toucher.player.mo.accuracy*5 + 300); return true; } return false; } } // Scanner ------------------------------------------------------------------ class Scanner : PowerupGiver { Default { +FLOORCLIP +INVENTORY.FANCYPICKUPSOUND Inventory.MaxAmount 1; Tag "$TAG_SCANNER"; Inventory.Icon "I_PMUP"; Powerup.Type "PowerScanner"; Inventory.PickupSound "misc/i_pkup"; Inventory.PickupMessage "$TXT_SCANNER"; } States { Spawn: PMUP AB 6; Loop; } override bool Use (bool pickup) { if (!level.AllMap) { if (Owner.CheckLocalView()) { Console.MidPrint(null, "$TXT_NEEDMAP"); } return false; } return Super.Use (pickup); } } // Prison Pass -------------------------------------------------------------- class PrisonPass : Key { Default { Inventory.Icon "I_TOKN"; Tag "$TAG_PRISONPASS"; Inventory.PickupMessage "$TXT_PRISONPASS"; } States { Spawn: TOKN A -1; Stop; } override bool TryPickup (in out Actor toucher) { bool res = Super.TryPickup (toucher); Door_Open(223, 16); toucher.GiveInventoryType ("QuestItem10"); return res; } //============================================================================ // // APrisonPass :: SpecialDropAction // // Trying to make a monster that drops a prison pass turns it into an // OpenDoor223 item instead. That means the only way to get it in Strife // is through dialog, which is why it doesn't have its own sprite. // //============================================================================ override bool SpecialDropAction (Actor dropper) { Door_Open(223, 16); Destroy (); return true; } } //--------------------------------------------------------------------------- // Dummy items. They are just used by Strife to perform --------------------- // actions and cannot be held. ---------------------------------------------- //--------------------------------------------------------------------------- class DummyStrifeItem : Inventory { States { Spawn: TOKN A -1; Stop; } } // Sound the alarm! --------------------------------------------------------- class RaiseAlarm : DummyStrifeItem { Default { Tag "$TAG_ALARM"; } override bool TryPickup (in out Actor toucher) { toucher.SoundAlert (toucher); ThinkerIterator it = ThinkerIterator.Create("AlienSpectre3"); Actor spectre = Actor(it.Next()); if (spectre != NULL && spectre.health > 0 && toucher != spectre) { spectre.CurSector.SoundTarget = spectre.LastHeard = toucher; spectre.target = toucher; spectre.SetState (spectre.SeeState); } GoAwayAndDie (); return true; } override bool SpecialDropAction (Actor dropper) { if (dropper.target != null) { dropper.target.SoundAlert(dropper.target); if (dropper.target.CheckLocalView()) { Console.MidPrint(null, "$TXT_YOUFOOL"); } } Destroy (); return true; } } // Open door tag 222 -------------------------------------------------------- class OpenDoor222 : DummyStrifeItem { override bool TryPickup (in out Actor toucher) { Door_Open(222, 16); GoAwayAndDie (); return true; } } // Close door tag 222 ------------------------------------------------------- class CloseDoor222 : DummyStrifeItem { override bool TryPickup (in out Actor toucher) { Door_Close(222, 16); GoAwayAndDie (); return true; } override bool SpecialDropAction (Actor dropper) { Door_Close(222, 16); if (dropper.target != null) { if (dropper.target.CheckLocalView()) { Console.MidPrint(null, "$TXT_YOUREDEAD"); } dropper.target.SoundAlert(dropper.target); } Destroy (); return true; } } // Open door tag 224 -------------------------------------------------------- class OpenDoor224 : DummyStrifeItem { override bool TryPickup (in out Actor toucher) { Door_Open(224, 16); GoAwayAndDie (); return true; } override bool SpecialDropAction (Actor dropper) { Door_Open(224, 16); Destroy (); return true; } } // Ammo --------------------------------------------------------------------- class AmmoFillup : DummyStrifeItem { Default { Tag "$TAG_AMMOFILLUP"; } override bool TryPickup (in out Actor toucher) { Inventory item = toucher.FindInventory("ClipOfBullets"); if (item == NULL) { item = toucher.GiveInventoryType ("ClipOfBullets"); if (item != NULL) { item.Amount = 50; } } else if (item.Amount < 50) { item.Amount = 50; } else { return false; } GoAwayAndDie (); return true; } } // Health ------------------------------------------------------------------- class HealthFillup : DummyStrifeItem { Default { Tag "$TAG_HEALTHFILLUP"; } override bool TryPickup (in out Actor toucher) { static const int skillhealths[] = { -100, -75, -50, -50, -100 }; int index = clamp(skill, 0,4); if (!toucher.GiveBody (skillhealths[index])) { return false; } GoAwayAndDie (); return true; } } // Upgrade Stamina ---------------------------------------------------------- class UpgradeStamina : DummyStrifeItem { Default { Inventory.Amount 10; Inventory.MaxAmount 100; } override bool TryPickup (in out Actor toucher) { if (toucher.player == NULL) return false; toucher.player.mo.stamina += Amount; if (toucher.player.mo.stamina >= MaxAmount) toucher.player.mo.stamina = MaxAmount; toucher.GiveBody (-100); GoAwayAndDie (); return true; } } // Upgrade Accuracy --------------------------------------------------------- class UpgradeAccuracy : DummyStrifeItem { override bool TryPickup (in out Actor toucher) { if (toucher.player == NULL || toucher.player.mo.accuracy >= 100) return false; toucher.player.mo.accuracy += 10; GoAwayAndDie (); return true; } } // Start a slideshow -------------------------------------------------------- class SlideshowStarter : DummyStrifeItem { override bool TryPickup (in out Actor toucher) { Level.StartSlideshow(); if (level.levelnum == 10) { toucher.GiveInventoryType ("QuestItem17"); } GoAwayAndDie (); return true; } } class StrifeKey : Key { Default { Radius 20; Height 16; +NOTDMATCH +FLOORCLIP } } // Base Key ----------------------------------------------------------------- class BaseKey : StrifeKey { Default { Inventory.Icon "I_FUSL"; Tag "$TAG_BASEKEY"; Inventory.PickupMessage "$TXT_BASEKEY"; } States { Spawn: FUSL A -1; Stop; } } // Govs Key ----------------------------------------------------------------- class GovsKey : StrifeKey { Default { Inventory.Icon "I_REBL"; Tag "$TAG_GOVSKEY"; Inventory.PickupMessage "$TXT_GOVSKEY"; } States { Spawn: REBL A -1; Stop; } } // Passcard ----------------------------------------------------------------- class Passcard : StrifeKey { Default { Inventory.Icon "I_TPAS"; Tag "$TAG_PASSCARD"; Inventory.PickupMessage "$TXT_PASSCARD"; } States { Spawn: TPAS A -1; Stop; } } // ID Badge ----------------------------------------------------------------- class IDBadge : StrifeKey { Default { Inventory.Icon "I_CRD1"; Tag "$TAG_IDBADGE"; Inventory.PickupMessage "$TXT_IDBADGE"; } States { Spawn: CRD1 A -1; Stop; } } // Prison Key --------------------------------------------------------------- class PrisonKey : StrifeKey { Default { Inventory.Icon "I_PRIS"; Tag "$TAG_PRISONKEY"; Inventory.GiveQuest 11; Inventory.PickupMessage "$TXT_PRISONKEY"; } States { Spawn: PRIS A -1; Stop; } } // Severed Hand ------------------------------------------------------------- class SeveredHand : StrifeKey { Default { Inventory.Icon "I_HAND"; Tag "$TAG_SEVEREDHAND"; Inventory.GiveQuest 12; Inventory.PickupMessage "$TXT_SEVEREDHAND"; } States { Spawn: HAND A -1; Stop; } } // Power1 Key --------------------------------------------------------------- class Power1Key : StrifeKey { Default { Inventory.Icon "I_PWR1"; Tag "$TAG_POWER1KEY"; Inventory.PickupMessage "$TXT_POWER1KEY"; } States { Spawn: PWR1 A -1; Stop; } } // Power2 Key --------------------------------------------------------------- class Power2Key : StrifeKey { Default { Inventory.Icon "I_PWR2"; Tag "$TAG_POWER2KEY"; Inventory.PickupMessage "$TXT_POWER2KEY"; } States { Spawn: PWR2 A -1; Stop; } } // Power3 Key --------------------------------------------------------------- class Power3Key : StrifeKey { Default { Inventory.Icon "I_PWR3"; Tag "$TAG_POWER3KEY"; Inventory.PickupMessage "$TXT_POWER3KEY"; } States { Spawn: PWR3 A -1; Stop; } } // Gold Key ----------------------------------------------------------------- class GoldKey : StrifeKey { Default { Inventory.Icon "I_KY1G"; Tag "$TAG_GOLDKEY"; Inventory.PickupMessage "$TXT_GOLDKEY"; } States { Spawn: KY1G A -1; Stop; } } // ID Card ------------------------------------------------------------------ class IDCard : StrifeKey { Default { Inventory.Icon "I_CRD2"; Tag "$TAG_IDCARD"; Inventory.PickupMessage "$TXT_IDCARD"; } States { Spawn: CRD2 A -1; Stop; } } // Silver Key --------------------------------------------------------------- class SilverKey : StrifeKey { Default { Inventory.Icon "I_KY2S"; Tag "$TAG_SILVERKEY"; Inventory.PickupMessage "$TXT_SILVERKEY"; } States { Spawn: KY2S A -1; Stop; } } // Oracle Key --------------------------------------------------------------- class OracleKey : StrifeKey { Default { Inventory.Icon "I_ORAC"; Tag "$TAG_ORACLEKEY"; Inventory.PickupMessage "$TXT_ORACLEKEY"; } States { Spawn: ORAC A -1; Stop; } } // Military ID -------------------------------------------------------------- class MilitaryID : StrifeKey { Default { Inventory.Icon "I_GYID"; Tag "$TAG_MILITARYID"; Inventory.PickupMessage "$TXT_MILITARYID"; } States { Spawn: GYID A -1; Stop; } } // Order Key ---------------------------------------------------------------- class OrderKey : StrifeKey { Default { Inventory.Icon "I_FUBR"; Tag "$TAG_ORDERKEY"; Inventory.PickupMessage "$TXT_ORDERKEY"; } States { Spawn: FUBR A -1; Stop; } } // Warehouse Key ------------------------------------------------------------ class WarehouseKey : StrifeKey { Default { Inventory.Icon "I_WARE"; Tag "$TAG_WAREHOUSEKEY"; Inventory.PickupMessage "$TXT_WAREHOUSEKEY"; } States { Spawn: WARE A -1; Stop; } } // Brass Key ---------------------------------------------------------------- class BrassKey : StrifeKey { Default { Inventory.Icon "I_KY3B"; Tag "$TAG_BRASSKEY"; Inventory.PickupMessage "$TXT_BRASSKEY"; } States { Spawn: KY3B A -1; Stop; } } // Red Crystal Key ---------------------------------------------------------- class RedCrystalKey : StrifeKey { Default { Inventory.Icon "I_RCRY"; Tag "$TAG_REDCRYSTALKEY"; Inventory.PickupMessage "$TXT_REDCRYSTAL"; } States { Spawn: RCRY A -1 Bright; Stop; } } // Blue Crystal Key --------------------------------------------------------- class BlueCrystalKey : StrifeKey { Default { Inventory.Icon "I_BCRY"; Tag "$TAG_BLUECRYSTALKEY"; Inventory.PickupMessage "$TXT_BLUECRYSTAL"; } States { Spawn: BCRY A -1 Bright; Stop; } } // Chapel Key --------------------------------------------------------------- class ChapelKey : StrifeKey { Default { Inventory.Icon "I_CHAP"; Tag "$TAG_CHAPELKEY"; Inventory.PickupMessage "$TXT_CHAPELKEY"; } States { Spawn: CHAP A -1; Stop; } } // Catacomb Key ------------------------------------------------------------- class CatacombKey : StrifeKey { Default { Inventory.Icon "I_TUNL"; Tag "$TAG_CATACOMBKEY"; Inventory.GiveQuest 28; Inventory.PickupMessage "$TXT_CATACOMBKEY"; } States { Spawn: TUNL A -1; Stop; } } // Security Key ------------------------------------------------------------- class SecurityKey : StrifeKey { Default { Inventory.Icon "I_SECK"; Tag "$TAG_SECURITYKEY"; Inventory.PickupMessage "$TXT_SECURITYKEY"; } States { Spawn: SECK A -1; Stop; } } // Core Key ----------------------------------------------------------------- class CoreKey : StrifeKey { Default { Inventory.Icon "I_GOID"; Tag "$TAG_COREKEY"; Inventory.PickupMessage "$TXT_COREKEY"; } States { Spawn: GOID A -1; Stop; } } // Mauler Key --------------------------------------------------------------- class MaulerKey : StrifeKey { Default { Inventory.Icon "I_BLTK"; Tag "$TAG_MAULERKEY"; Inventory.PickupMessage "$TXT_MAULERKEY"; } States { Spawn: BLTK A -1; Stop; } } // Factory Key -------------------------------------------------------------- class FactoryKey : StrifeKey { Default { Inventory.Icon "I_PROC"; Tag "$TAG_FACTORYKEY"; Inventory.PickupMessage "$TXT_FACTORYKEY"; } States { Spawn: PROC A -1; Stop; } } // Mine Key ----------------------------------------------------------------- class MineKey : StrifeKey { Default { Inventory.Icon "I_MINE"; Tag "$TAG_MINEKEY"; Inventory.PickupMessage "$TXT_MINEKEY"; } States { Spawn: MINE A -1; Stop; } } // New Key5 ----------------------------------------------------------------- class NewKey5 : StrifeKey { Default { Inventory.Icon "I_BLTK"; Tag "$TAG_NEWKEY5"; Inventory.PickupMessage "$TXT_NEWKEY5"; } States { Spawn: BLTK A -1; Stop; } } // Oracle Pass -------------------------------------------------------------- class OraclePass : Inventory { Default { +INVENTORY.INVBAR Inventory.Icon "I_OTOK"; Inventory.GiveQuest 18; Inventory.PickupMessage "$TXT_ORACLEPASS"; Tag "$TAG_ORACLEPASS"; } States { Spawn: OTOK A -1; Stop; } } // The player --------------------------------------------------------------- class StrifePlayer : PlayerPawn { Default { Health 100; Radius 18; Height 56; Mass 100; PainChance 255; Speed 1; MaxStepHeight 16; CrushPainSound "misc/pcrush"; Player.DisplayName "Rebel"; Player.StartItem "PunchDagger"; Player.RunHealth 15; Player.WeaponSlot 1, "PunchDagger"; Player.WeaponSlot 2, "StrifeCrossbow2", "StrifeCrossbow"; Player.WeaponSlot 3, "AssaultGun"; Player.WeaponSlot 4, "MiniMissileLauncher"; Player.WeaponSlot 5, "StrifeGrenadeLauncher2", "StrifeGrenadeLauncher"; Player.WeaponSlot 6, "FlameThrower"; Player.WeaponSlot 7, "Mauler2", "Mauler"; Player.WeaponSlot 8, "Sigil"; Player.ColorRange 128, 143; Player.Colorset 0, "$TXT_COLOR_BROWN", 0x80, 0x8F, 0x82; Player.Colorset 1, "$TXT_COLOR_RED", 0x40, 0x4F, 0x42, 0x20, 0x3F, 0x00, 0x1F, 0xF1, 0xF6, 0xE0, 0xE5, 0xF7, 0xFB, 0xF1, 0xF5; Player.Colorset 2, "$TXT_COLOR_RUST", 0xB0, 0xBF, 0xB2, 0x20, 0x3F, 0x00, 0x1F; Player.Colorset 3, "$TXT_COLOR_GRAY", 0x10, 0x1F, 0x12, 0x20, 0x2F, 0xD0, 0xDF, 0x30, 0x3F, 0xD0, 0xDF; Player.Colorset 4, "$TXT_COLOR_DARKGREEN", 0x30, 0x3F, 0x32, 0x20, 0x2F, 0xD0, 0xDF, 0x30, 0x3F, 0xD0, 0xDF; Player.Colorset 5, "$TXT_COLOR_GOLD", 0x50, 0x5F, 0x52, 0x20, 0x3F, 0x00, 0x1F, 0x50, 0x5F, 0x80, 0x8F, 0xC0, 0xCF, 0xA0, 0xAF, 0xD0, 0xDF, 0xB0, 0xBF; Player.Colorset 6, "$TXT_COLOR_BRIGHTGREEN",0x60, 0x6F, 0x62, 0x20, 0x3F, 0x00, 0x1F, 0x50, 0x5F, 0x10, 0x1F, 0xC0, 0xCF, 0x20, 0x2F, 0xD0, 0xDF, 0x30, 0x3F; Player.Colorset 7, "$TXT_COLOR_BLUE", 0x90, 0x9F, 0x92, 0x20, 0x3F, 0x00, 0x1F, 0x50, 0x5F, 0x40, 0x4F, 0xC1, 0xCF, 0x01, 0x0F, 0xC0,0xC0,1,1, 0xD0, 0xDF, 0x10, 0x1F; } States { Spawn: PLAY A -1; stop; See: PLAY ABCD 4; loop; Missile: PLAY E 12; goto Spawn; Melee: PLAY F 6; goto Missile; Pain: PLAY Q 4; PLAY Q 4 A_Pain; Goto Spawn; Death: PLAY H 3; PLAY I 3 A_PlayerScream; PLAY J 3 A_NoBlocking; PLAY KLMNO 4; PLAY P -1; Stop; XDeath: RGIB A 5 A_TossGib; RGIB B 5 A_XScream; RGIB C 5 A_NoBlocking; RGIB DEFG 5 A_TossGib; RGIB H -1 A_TossGib; Burn: BURN A 3 Bright A_ItBurnsItBurns; BURN B 3 Bright A_DropFire; BURN C 3 Bright A_Wander; BURN D 3 Bright A_NoBlocking; BURN E 5 Bright A_DropFire; BURN FGH 5 Bright A_Wander; BURN I 5 Bright A_DropFire; BURN JKL 5 Bright A_Wander; BURN M 5 Bright A_DropFire; BURN N 5 Bright A_CrispyPlayer; BURN OPQPQ 5 Bright; BURN RSTU 7 Bright; BURN V -1; Stop; Disintegrate: DISR A 5 A_StartSound("misc/disruptordeath", CHAN_VOICE); DISR BC 5; DISR D 5 A_NoBlocking; DISR EF 5; DISR GHIJ 4; MEAT D -1; Stop; Firehands: WAVE ABCD 3; Loop; Firehandslower: WAVE ABCD 3 A_HandLower; Loop; } void A_ItBurnsItBurns() { A_StartSound ("human/imonfire", CHAN_VOICE); if (player != null && player.mo == self) { player.SetPsprite(PSP_STRIFEHANDS, FindState("FireHands")); player.ReadyWeapon = null; player.PendingWeapon = WP_NOCHANGE; player.playerstate = PST_LIVE; player.extralight = 3; } } void A_CrispyPlayer() { if (player != null && player.mo == self) { PSprite psp = player.GetPSprite(PSP_STRIFEHANDS); State firehandslower = FindState("FireHandsLower"); State firehands = FindState("FireHands"); if (psp) { if (psp.CurState != null && firehandslower != null && firehands != null) { // Calculate state to go to. int dist = firehands.DistanceTo(psp.curState); if (dist > 0) { player.playerstate = PST_DEAD; psp.SetState(firehandslower + dist); return; } } player.playerstate = PST_DEAD; psp.SetState(null); } } } void A_HandLower() { if (player != null) { PSprite psp = player.GetPSprite(PSP_STRIFEHANDS); if (psp) { if (psp.CurState == null) { psp.SetState(null); return; } psp.y += 9; if (psp.y > WEAPONBOTTOM*2) { psp.SetState(null); } } if (player.extralight > 0) player.extralight--; } return; } } // Notes so I don't forget them: // // When shooting missiles at something, if MF_SHADOW is set, the angle is adjusted with the formula: // angle += pr_spawnmissile.Random2() << 21 // When MF_STRIFEx4000000 is set, the angle is adjusted similarly: // angle += pr_spawnmissile.Random2() << 22 // Note that these numbers are different from those used by all the other Doom engine games. // Tank 1 Huge ------------------------------------------------------------ class Tank1 : Actor { Default { Radius 16; Height 192; +SOLID } States { Spawn: TNK1 A 15; TNK1 B 11; TNK1 C 40; Loop; } } // Tank 2 Huge ------------------------------------------------------------ class Tank2 : Actor { Default { Radius 16; Height 192; +SOLID } States { Spawn: TNK2 A 15; TNK2 B 11; TNK2 C 40; Loop; } } // Tank 3 Huge ------------------------------------------------------------ class Tank3 : Actor { Default { Radius 16; Height 192; +SOLID } States { Spawn: TNK3 A 15; TNK3 B 11; TNK3 C 40; Loop; } } // Tank 4 ------------------------------------------------------------------- class Tank4 : Actor { Default { Radius 16; Height 56; +SOLID } States { Spawn: TNK4 A 15; TNK4 B 11; TNK4 C 40; Loop; } } // Tank 5 ------------------------------------------------------------------- class Tank5 : Actor { Default { Radius 16; Height 56; +SOLID } States { Spawn: TNK5 A 15; TNK5 B 11; TNK5 C 40; Loop; } } // Tank 6 ------------------------------------------------------------------- class Tank6 : Actor { Default { Radius 16; Height 56; +SOLID } States { Spawn: TNK6 A 15; TNK6 B 11; TNK6 C 40; Loop; } } // Water Bottle ------------------------------------------------------------- class WaterBottle : Actor { States { Spawn: WATR A -1; Stop; } } // Mug ---------------------------------------------------------------------- class Mug : Actor { States { Spawn: MUGG A -1; Stop; } } // Wooden Barrel ------------------------------------------------------------ class WoodenBarrel : Actor { Default { Health 10; Radius 10; Height 32; +SOLID +SHOOTABLE +NOBLOOD +INCOMBAT DeathSound "woodenbarrel/death"; } States { Spawn: BARW A -1; Stop; Death: BARW B 2 A_Scream; BARW C 2; BARW D 2 A_NoBlocking; BARW EFG 2; BARW H -1; Stop; } } // Strife's explosive barrel ------------------------------------------------ class ExplosiveBarrel2 : Actor { Default { Health 30; Radius 10; Height 32; +SOLID +SHOOTABLE +NOBLOOD +OLDRADIUSDMG DeathSound "world/barrelx"; +INCOMBAT } States { Spawn: BART A -1; Stop; Death: BART B 2 Bright A_Scream; BART CD 2 Bright; BART E 2 Bright A_NoBlocking; BART F 2 Bright A_Explode(64, 64, alert:true); BART GHIJ 2 Bright; BART K 3 Bright; BART L -1; Stop; } } // Light Silver, Fluorescent ---------------------------------------------- class LightSilverFluorescent : Actor { Default { Radius 2.5; Height 16; +NOBLOCKMAP +FIXMAPTHINGPOS } States { Spawn: LITS A -1 Bright; Stop; } } // Light Brown, Fluorescent ----------------------------------------------- class LightBrownFluorescent : Actor { Default { Radius 2.5; Height 16; +NOBLOCKMAP +FIXMAPTHINGPOS } States { Spawn: LITB A -1 Bright; Stop; } } // Light Gold, Fluorescent ------------------------------------------------ class LightGoldFluorescent : Actor { Default { Radius 2.5; Height 16; +NOBLOCKMAP +FIXMAPTHINGPOS } States { Spawn: LITG A -1 Bright; Stop; } } // Light Globe -------------------------------------------------------------- class LightGlobe : Actor { Default { Radius 16; Height 16; +SOLID } States { Spawn: LITE A -1 Bright; Stop; } } // Techno Pillar ------------------------------------------------------------ class PillarTechno : Actor { Default { Radius 20; Height 128; +SOLID } States { Spawn: MONI A -1; Stop; } } // Aztec Pillar ------------------------------------------------------------- class PillarAztec : Actor { Default { Radius 16; Height 128; +SOLID } States { Spawn: STEL A -1; Stop; } } // Damaged Aztec Pillar ----------------------------------------------------- class PillarAztecDamaged : Actor { Default { Radius 16; Height 80; +SOLID } States { Spawn: STLA A -1; Stop; } } // Ruined Aztec Pillar ------------------------------------------------------ class PillarAztecRuined : Actor { Default { Radius 16; Height 40; +SOLID } States { Spawn: STLE A -1; Stop; } } // Huge Tech Pillar --------------------------------------------------------- class PillarHugeTech : Actor { Default { Radius 24; Height 192; +SOLID } States { Spawn: HUGE ABCD 4; Loop; } } // Alien Power Crystal in a Pillar ------------------------------------------ class PillarAlienPower : Actor { Default { Radius 24; Height 192; +SOLID ActiveSound "ambient/alien2"; } States { Spawn: APOW A 4 A_LoopActiveSound; Loop; } } // SStalactiteBig ----------------------------------------------------------- class SStalactiteBig : Actor { Default { Radius 16; Height 54; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: STLG C -1; Stop; } } // SStalactiteSmall --------------------------------------------------------- class SStalactiteSmall : Actor { Default { Radius 16; Height 40; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: STLG A -1; Stop; } } // SStalagmiteBig ----------------------------------------------------------- class SStalagmiteBig : Actor { Default { Radius 16; Height 40; +SOLID } States { Spawn: STLG B -1; Stop; } } // Cave Pillar Top ---------------------------------------------------------- class CavePillarTop : Actor { Default { Radius 16; Height 128; +SOLID +SPAWNCEILING +NOGRAVITY } States { Spawn: STLG D -1; Stop; } } // Cave Pillar Bottom ------------------------------------------------------- class CavePillarBottom : Actor { Default { Radius 16; Height 128; +SOLID } States { Spawn: STLG E -1; Stop; } } // SStalagmiteSmall --------------------------------------------------------- class SStalagmiteSmall : Actor { Default { Radius 16; Height 25; +SOLID } States { Spawn: STLG F -1; Stop; } } // Candle ------------------------------------------------------------------- class Candle : Actor { States { Spawn: KNDL A -1 Bright; Stop; } } // StrifeCandelabra --------------------------------------------------------- class StrifeCandelabra : Actor { Default { Radius 16; Height 40; +SOLID } States { Spawn: CLBR A -1; Stop; } } // Floor Water Drop --------------------------------------------------------- class WaterDropOnFloor : Actor { Default { +NOBLOCKMAP ActiveSound "world/waterdrip"; } States { Spawn: DRIP A 6 A_FLoopActiveSound; DRIP BC 4; DRIP D 4 A_FLoopActiveSound; DRIP EF 4; DRIP G 4 A_FLoopActiveSound; DRIP H 4; Loop; } } // Waterfall Splash --------------------------------------------------------- class WaterfallSplash : Actor { Default { +NOBLOCKMAP ActiveSound "world/waterfall"; } States { Spawn: SPLH ABCDEFG 4; SPLH H 4 A_LoopActiveSound; Loop; } } // Ceiling Water Drip ------------------------------------------------------- class WaterDrip : Actor { Default { Height 1; +NOBLOCKMAP +SPAWNCEILING +NOGRAVITY } States { Spawn: CDRP A 10; CDRP BCD 8; Loop; } } // WaterFountain ------------------------------------------------------------ class WaterFountain : Actor { Default { +NOBLOCKMAP ActiveSound "world/watersplash"; } States { Spawn: WTFT ABC 4; WTFT D 4 A_LoopActiveSound; Loop; } } // Hearts in Tank ----------------------------------------------------------- class HeartsInTank : Actor { Default { Radius 16; Height 56; +SOLID } States { Spawn: HERT ABC 4 Bright; Loop; } } // Teleport Swirl ----------------------------------------------------------- class TeleportSwirl : Actor { Default { +NOBLOCKMAP +ZDOOMTRANS RenderStyle "Add"; Alpha 0.25; } States { Spawn: TELP ABCD 3 Bright; Loop; } } // Dead Player -------------------------------------------------------------- // Strife's disappeared. This one doesn't. class DeadStrifePlayer : Actor { States { Spawn: PLAY P 700; RGIB H -1; Stop; } } // Dead Peasant ------------------------------------------------------------- // Unlike Strife's, this one does not turn into gibs and disappear. class DeadPeasant : Actor { States { Spawn: PEAS N -1; Stop; } } // Dead Acolyte ------------------------------------------------------------- // Unlike Strife's, this one does not turn into gibs and disappear. class DeadAcolyte : Actor { States { Spawn: AGRD N -1; Stop; } } // Dead Reaver -------------------------------------------------------------- class DeadReaver : Actor { States { Spawn: ROB1 R -1; Stop; } } // Dead Rebel --------------------------------------------------------------- class DeadRebel : Actor { States { Spawn: HMN1 N -1; Stop; } } // Sacrificed Guy ----------------------------------------------------------- class SacrificedGuy : Actor { States { Spawn: SACR A -1; Stop; } } // Pile of Guts ------------------------------------------------------------- class PileOfGuts : Actor { // Strife used a doomednum, which is the same as the Aztec Pillar. Since // the pillar came first in the mobjinfo list, you could not spawn this // in a map. Pity. States { Spawn: DEAD A -1; Stop; } } // Burning Barrel ----------------------------------------------------------- class StrifeBurningBarrel : Actor { Default { Radius 16; Height 48; +SOLID } States { Spawn: BBAR ABCD 4 Bright; Loop; } } // Burning Bowl ----------------------------------------------------------- class BurningBowl : Actor { Default { Radius 16; Height 16; +SOLID ActiveSound "world/smallfire"; } States { Spawn: BOWL ABCD 4 Bright; Loop; } } // Burning Brazier ----------------------------------------------------------- class BurningBrazier : Actor { Default { Radius 10; Height 32; +SOLID ActiveSound "world/smallfire"; } States { Spawn: BRAZ ABCD 4 Bright; Loop; } } // Small Torch Lit -------------------------------------------------------- class SmallTorchLit : Actor { Default { Radius 2.5; Height 16; +NOBLOCKMAP +FIXMAPTHINGPOS // It doesn't have any action functions, so how does it use this sound? ActiveSound "world/smallfire"; } States { Spawn: TRHL ABCD 4 Bright; Loop; } } // Small Torch Unlit -------------------------------------------------------- class SmallTorchUnlit : Actor { Default { Radius 2.5; Height 16; +NOBLOCKMAP +FIXMAPTHINGPOS } States { Spawn: TRHO A -1; Stop; } } // Ceiling Chain ------------------------------------------------------------ class CeilingChain : Actor { Default { Radius 20; Height 93; +NOBLOCKMAP +SPAWNCEILING +NOGRAVITY } States { Spawn: CHAN A -1; Stop; } } // Cage Light --------------------------------------------------------------- class CageLight : Actor { Default { // No, it's not bright even though it's a light. Height 3; +NOBLOCKMAP +SPAWNCEILING +NOGRAVITY } States { Spawn: CAGE A -1; Stop; } } // Statue ------------------------------------------------------------------- class Statue : Actor { Default { Radius 20; Height 64; +SOLID } States { Spawn: STAT A -1; Stop; } } // Ruined Statue ------------------------------------------------------------ class StatueRuined : Actor { Default { Radius 20; Height 56; +SOLID } States { Spawn: DSTA A -1; Stop; } } // Medium Torch ------------------------------------------------------------- class MediumTorch : Actor { Default { Radius 4; Height 72; +SOLID } States { Spawn: LTRH ABCD 4; Loop; } } // Outside Lamp ------------------------------------------------------------- class OutsideLamp : Actor { Default { // No, it's not bright. Radius 3; Height 80; +SOLID } States { Spawn: LAMP A -1; Stop; } } // Pole Lantern ------------------------------------------------------------- class PoleLantern : Actor { Default { // No, it's not bright. Radius 3; Height 80; +SOLID } States { Spawn: LANT A -1; Stop; } } // Rock 1 ------------------------------------------------------------------- class SRock1 : Actor { Default { +NOBLOCKMAP } States { Spawn: ROK1 A -1; Stop; } } // Rock 2 ------------------------------------------------------------------- class SRock2 : Actor { Default { +NOBLOCKMAP } States { Spawn: ROK2 A -1; Stop; } } // Rock 3 ------------------------------------------------------------------- class SRock3 : Actor { Default { +NOBLOCKMAP } States { Spawn: ROK3 A -1; Stop; } } // Rock 4 ------------------------------------------------------------------- class SRock4 : Actor { Default { +NOBLOCKMAP } States { Spawn: ROK4 A -1; Stop; } } // Stick in Water ----------------------------------------------------------- class StickInWater : Actor { Default { +NOBLOCKMAP +FLOORCLIP ActiveSound "world/river"; } States { Spawn: LOGW ABCD 5 A_LoopActiveSound; Loop; } } // Rubble 1 ----------------------------------------------------------------- class Rubble1 : Actor { Default { +NOBLOCKMAP +NOCLIP } States { Spawn: RUB1 A -1; Stop; } } // Rubble 2 ----------------------------------------------------------------- class Rubble2 : Actor { Default { +NOBLOCKMAP +NOCLIP } States { Spawn: RUB2 A -1; Stop; } } // Rubble 3 ----------------------------------------------------------------- class Rubble3 : Actor { Default { +NOBLOCKMAP +NOCLIP } States { Spawn: RUB3 A -1; Stop; } } // Rubble 4 ----------------------------------------------------------------- class Rubble4 : Actor { Default { +NOBLOCKMAP +NOCLIP } States { Spawn: RUB4 A -1; Stop; } } // Rubble 5 ----------------------------------------------------------------- class Rubble5 : Actor { Default { +NOBLOCKMAP +NOCLIP } States { Spawn: RUB5 A -1; Stop; } } // Rubble 6 ----------------------------------------------------------------- class Rubble6 : Actor { Default { +NOBLOCKMAP +NOCLIP } States { Spawn: RUB6 A -1; Stop; } } // Rubble 7 ----------------------------------------------------------------- class Rubble7 : Actor { Default { +NOBLOCKMAP +NOCLIP } States { Spawn: RUB7 A -1; Stop; } } // Rubble 8 ----------------------------------------------------------------- class Rubble8 : Actor { Default { +NOBLOCKMAP +NOCLIP } States { Spawn: RUB8 A -1; Stop; } } // Surgery Crab ------------------------------------------------------------- class SurgeryCrab : Actor { Default { +SOLID +SPAWNCEILING +NOGRAVITY Radius 20; Height 16; } States { Spawn: CRAB A -1; Stop; } } // Large Torch -------------------------------------------------------------- class LargeTorch : Actor { Default { Radius 10; Height 72; +SOLID ActiveSound "world/smallfire"; } States { Spawn: LMPC ABCD 4 Bright; Loop; } } // Huge Torch -------------------------------------------------------------- class HugeTorch : Actor { Default { Radius 10; Height 80; +SOLID ActiveSound "world/smallfire"; } States { Spawn: LOGS ABCD 4; Loop; } } // Palm Tree ---------------------------------------------------------------- class PalmTree : Actor { Default { Radius 15; Height 109; +SOLID } States { Spawn: TREE A -1; Stop; } } // Big Tree ---------------------------------------------------------------- class BigTree2 : Actor { Default { Radius 15; Height 109; +SOLID } States { Spawn: TREE B -1; Stop; } } // Potted Tree ---------------------------------------------------------------- class PottedTree : Actor { Default { Radius 15; Height 64; +SOLID } States { Spawn: TREE C -1; Stop; } } // Tree Stub ---------------------------------------------------------------- class TreeStub : Actor { Default { Radius 15; Height 80; +SOLID } States { Spawn: TRET A -1; Stop; } } // Short Bush --------------------------------------------------------------- class ShortBush : Actor { Default { Radius 15; Height 40; +SOLID } States { Spawn: BUSH A -1; Stop; } } // Tall Bush --------------------------------------------------------------- class TallBush : Actor { Default { Radius 20; Height 64; +SOLID } States { Spawn: SHRB A -1; Stop; } } // Chimney Stack ------------------------------------------------------------ class ChimneyStack : Actor { Default { Radius 20; Height 64; // This height does not fit the sprite +SOLID } States { Spawn: STAK A -1; Stop; } } // Barricade Column --------------------------------------------------------- class BarricadeColumn : Actor { Default { Radius 16; Height 128; +SOLID } States { Spawn: BARC A -1; Stop; } } // Pot ---------------------------------------------------------------------- class Pot : Actor { Default { Radius 12; Height 24; +SOLID } States { Spawn: VAZE A -1; Stop; } } // Pitcher ------------------------------------------------------------------ class Pitcher : Actor { Default { Radius 12; Height 32; +SOLID } States { Spawn: VAZE B -1; Stop; } } // Stool -------------------------------------------------------------------- class Stool : Actor { Default { Radius 6; Height 24; +SOLID } States { Spawn: STOL A -1; Stop; } } // Metal Pot ---------------------------------------------------------------- class MetalPot : Actor { Default { +NOBLOCKMAP } States { Spawn: MPOT A -1; Stop; } } // Tub ---------------------------------------------------------------------- class Tub : Actor { Default { +NOBLOCKMAP } States { Spawn: TUB1 A -1; Stop; } } // Anvil -------------------------------------------------------------------- class Anvil : Actor { Default { Radius 16; Height 32; +SOLID } States { Spawn: ANVL A -1; Stop; } } // Silver Tech Lamp ---------------------------------------------------------- class TechLampSilver : Actor { Default { Radius 11; Height 64; +SOLID } States { Spawn: TECH A -1; Stop; } } // Brass Tech Lamp ---------------------------------------------------------- class TechLampBrass : Actor { Default { Radius 8; Height 64; +SOLID } States { Spawn: TECH B -1; Stop; } } // Tray -------------------------------------------------------------------- class Tray : Actor { Default { Radius 24; Height 40; +SOLID } States { Spawn: TRAY A -1; Stop; } } // AmmoFiller --------------------------------------------------------------- class AmmoFiller : Actor { Default { Radius 12; Height 24; +SOLID } States { Spawn: AFED A -1; Stop; } } // Sigil Banner ------------------------------------------------------------- class SigilBanner : Actor { Default { Radius 24; Height 96; +NOBLOCKMAP // I take it this was once solid, yes? } States { Spawn: SBAN A -1; Stop; } } // RebelBoots --------------------------------------------------------------- class RebelBoots : Actor { Default { +NOBLOCKMAP } States { Spawn: BOTR A -1; Stop; } } // RebelHelmet -------------------------------------------------------------- class RebelHelmet : Actor { Default { +NOBLOCKMAP } States { Spawn: HATR A -1; Stop; } } // RebelShirt --------------------------------------------------------------- class RebelShirt : Actor { Default { +NOBLOCKMAP } States { Spawn: TOPR A -1; Stop; } } // Alien Bubble Column ------------------------------------------------------ class AlienBubbleColumn : Actor { Default { Radius 16; Height 128; +SOLID ActiveSound "ambient/alien5"; } States { Spawn: BUBB A 4 A_LoopActiveSound; Loop; } } // Alien Floor Bubble ------------------------------------------------------- class AlienFloorBubble : Actor { Default { Radius 16; Height 72; +SOLID ActiveSound "ambient/alien6"; } States { Spawn: BUBF A 4 A_LoopActiveSound; Loop; } } // Alien Ceiling Bubble ----------------------------------------------------- class AlienCeilingBubble : Actor { Default { Radius 16; Height 72; +SOLID +SPAWNCEILING +NOGRAVITY ActiveSound "ambient/alien4"; } States { Spawn: BUBC A 4 A_LoopActiveSound; Loop; } } // Alien Asp Climber -------------------------------------------------------- class AlienAspClimber : Actor { Default { Radius 16; Height 128; +SOLID ActiveSound "ambient/alien3"; } States { Spawn: ASPR A 4 A_LoopActiveSound; Loop; } } // Alien Spider Light ------------------------------------------------------- class AlienSpiderLight : Actor { Default { Radius 32; Height 56; +SOLID ActiveSound "ambient/alien1"; } States { Spawn: SPDL ABC 5 A_LoopActiveSound; Loop; } } // Target Practice ----------------------------------------------------------- class TargetPractice : Actor { Default { Health 99999999; PainChance 255; Radius 10; Height 72; Mass 9999999; +SOLID +SHOOTABLE +NOBLOOD +INCOMBAT +NODAMAGE PainSound "misc/metalhit"; } States { Spawn: HOGN A 2 A_CheckTerrain; Loop; Pain: HOGN B 1 A_CheckTerrain; HOGN C 1 A_Pain; Goto Spawn; } } // Force Field Guard -------------------------------------------------------- class ForceFieldGuard : Actor { Default { Health 10; Radius 2; Height 1; Mass 10000; +SHOOTABLE +NOSECTOR +NOBLOOD +INCOMBAT } States { Spawn: TNT1 A -1; Stop; Death: TNT1 A 1 A_RemoveForceField; Stop; } override int TakeSpecialDamage (Actor inflictor, Actor source, int damage, Name damagetype) { if (inflictor == NULL || !(inflictor is "DegninOre")) { return -1; } return health; } } // Kneeling Guy ------------------------------------------------------------- class KneelingGuy : Actor { Default { Health 51; Painchance 255; Radius 6; Height 17; Mass 50000; +SOLID +SHOOTABLE +NOBLOOD +ISMONSTER +INCOMBAT Tag "$TAG_KNEELINGGUY"; PainSound "misc/static"; DeathSound "misc/static"; ActiveSound "misc/chant"; } States { Spawn: See: NEAL A 15 A_LoopActiveSound; NEAL B 40 A_LoopActiveSound; Loop; Pain: NEAL C 5 A_SetShadow; NEAL B 4 A_Pain; NEAL C 5 A_ClearShadow; Goto Spawn; Wound: NEAL B 6; NEAL C 13 A_GetHurt; Loop; Death: NEAL D 5; NEAL E 5 A_Scream; NEAL F 6; NEAL G 5 A_NoBlocking; NEAL H 5; NEAL I 6; NEAL J -1; Stop; } } // Power Coupling ----------------------------------------------------------- class PowerCoupling : Actor { Default { Health 40; Radius 17; Height 64; Mass 999999; +SOLID +SHOOTABLE +DROPPED +NOBLOOD +NOTDMATCH +INCOMBAT } States { Spawn: COUP AB 5; Loop; } override void Die (Actor source, Actor inflictor, int dmgflags, Name MeansOfDeath) { Super.Die (source, inflictor, dmgflags, MeansOfDeath); int i; for (i = 0; i < MAXPLAYERS; ++i) if (playeringame[i] && players[i].health > 0) break; if (i == MAXPLAYERS) return; // [RH] In case the player broke it with the dagger, alert the guards now. if (LastHeard != source) { SoundAlert (source); } Door_Close(225, 16); Floor_LowerToHighestEE(44, 8); players[i].mo.GiveInventoryType ("QuestItem6"); S_StartSound ("svox/voc13", CHAN_VOICE); players[i].SetLogNumber (13); players[i].SetSubtitleNumber (13, "svox/voc13"); A_DropItem ("BrokenPowerCoupling", -1, 256); Destroy (); } } // Gibs for things that bleed ----------------------------------------------- class Meat : Actor { Default { +NOCLIP } States { Spawn: MEAT A 700; Stop; MEAT B 700; Stop; MEAT C 700; Stop; MEAT D 700; Stop; MEAT E 700; Stop; MEAT F 700; Stop; MEAT G 700; Stop; MEAT H 700; Stop; MEAT I 700; Stop; MEAT J 700; Stop; MEAT K 700; Stop; MEAT L 700; Stop; MEAT M 700; Stop; MEAT N 700; Stop; MEAT O 700; Stop; MEAT P 700; Stop; MEAT Q 700; Stop; MEAT R 700; Stop; MEAT S 700; Stop; MEAT T 700; Stop; } override void BeginPlay () { // Strife used mod 19, but there are 20 states. Hmm. SetState (SpawnState + random[GibTosser](0, 19)); } } // Gibs for things that don't bleed ----------------------------------------- class Junk : Meat { States { Spawn: JUNK A 700; Stop; JUNK B 700; Stop; JUNK C 700; Stop; JUNK D 700; Stop; JUNK E 700; Stop; JUNK F 700; Stop; JUNK G 700; Stop; JUNK H 700; Stop; JUNK I 700; Stop; JUNK J 700; Stop; JUNK K 700; Stop; JUNK L 700; Stop; JUNK M 700; Stop; JUNK N 700; Stop; JUNK O 700; Stop; JUNK P 700; Stop; JUNK Q 700; Stop; JUNK R 700; Stop; JUNK S 700; Stop; JUNK T 700; Stop; } } class StrifeWeapon : Weapon { Default { Weapon.Kickback 100; } } // Same as the bullet puff for Doom ----------------------------------------- class StrifePuff : Actor { Default { +NOBLOCKMAP +NOGRAVITY +ALLOWPARTICLES RenderStyle "Translucent"; Alpha 0.25; } States { Spawn: POW3 ABCDEFGH 3; Stop; Crash: PUFY A 4 Bright; PUFY BCD 4; Stop; } } // A spark when you hit something that doesn't bleed ------------------------ // Only used by the dagger. class StrifeSpark : StrifePuff { Default { +ZDOOMTRANS RenderStyle "Add"; } States { Crash: POW2 ABCD 4; Stop; } } class StrifeStatusBar : BaseStatusBar { // Number of tics to move the popscreen up and down. const POP_TIME = (Thinker.TICRATE/8); // Popscreen height when fully extended const POP_HEIGHT = 104; // Number of tics to scroll keys left const KEY_TIME = (Thinker.TICRATE/3); enum eImg { imgINVCURS, imgCURSOR01, imgINVPOP, imgINVPOP2, imgINVPBAK, imgINVPBAK2, imgFONY0, imgFONY1, imgFONY2, imgFONY3, imgFONY4, imgFONY5, imgFONY6, imgFONY7, imgFONY8, imgFONY9, imgFONY_PERCENT, imgNEGATIVE, }; TextureID Images[imgNEGATIVE + 1]; int CursorImage; int CurrentPop, PendingPop, PopHeight, PopHeightChange; int KeyPopPos, KeyPopScroll; HUDFont mYelFont, mGrnFont, mBigFont; override void Init() { static const Name strifeLumpNames[] = { "INVCURS", "CURSOR01", "INVPOP", "INVPOP2", "INVPBAK", "INVPBAK2", "INVFONY0", "INVFONY1", "INVFONY2", "INVFONY3", "INVFONY4", "INVFONY5", "INVFONY6", "INVFONY7", "INVFONY8", "INVFONY9", "INVFONY%", "" }; Super.Init(); SetSize(32, 320, 200); Reset(); for(int i = 0; i <= imgNEGATIVE; i++) { Images[i] = TexMan.CheckForTexture(strifeLumpNames[i], TexMan.TYPE_MiscPatch); } CursorImage = Images[imgINVCURS].IsValid() ? imgINVCURS : imgCURSOR01; mYelFont = HUDFont.Create("Indexfont_Strife_Yellow", 7, Mono_CellLeft, 1, 1); mGrnFont = HUDFont.Create("Indexfont_Strife_Green", 7, Mono_CellLeft, 1, 1); mBigFont = HUDFont.Create("BigFont", 0, Mono_Off, 2, 2); } override void NewGame () { Super.NewGame(); Reset (); } override int GetProtrusion(double scaleratio) const { return 10; } override void Draw (int state, double TicFrac) { Super.Draw (state, TicFrac); if (state == HUD_StatusBar) { BeginStatusBar(); DrawMainBar (TicFrac); } else { if (state == HUD_Fullscreen) { BeginHUD(); DrawFullScreenStuff (); } // Draw pop screen (log, keys, and status) if (CurrentPop != POP_None && PopHeight < 0) { // This uses direct low level draw commands and would otherwise require calling // BeginStatusBar(true); DrawPopScreen (screen.GetHeight(), TicFrac); } } } override void ShowPop (int popnum) { Super.ShowPop(popnum); if (popnum == CurrentPop || (popnum == POP_LOG && MustDrawLog(0))) { if (popnum == POP_Keys) { Inventory item; KeyPopPos += 10; KeyPopScroll = 280; int i = 0; for (item = CPlayer.mo.Inv; item != NULL; item = item.Inv) { if (item is "Key") { if (i == KeyPopPos) { return; } i++; } } } PendingPop = POP_None; // Do not scroll keys horizontally when dropping the popscreen KeyPopScroll = 0; KeyPopPos -= 10; } else { KeyPopPos = 0; PendingPop = popnum; } } override bool MustDrawLog(int state) { // Tell the base class to draw the log if the pop screen won't be displayed. return generic_ui || log_vgafont; } void Reset () { CurrentPop = POP_None; PendingPop = POP_NoChange; PopHeight = 0; KeyPopPos = 0; KeyPopScroll = 0; } override void Tick () { Super.Tick (); PopHeightChange = 0; if (PendingPop != POP_NoChange) { if (PopHeight < 0) { PopHeightChange = POP_HEIGHT / POP_TIME; PopHeight += POP_HEIGHT / POP_TIME; } else { CurrentPop = PendingPop; PendingPop = POP_NoChange; } } else { if (CurrentPop == POP_None) { PopHeight = 0; } else if (PopHeight > -POP_HEIGHT) { PopHeight -= POP_HEIGHT / POP_TIME; if (PopHeight < -POP_HEIGHT) { PopHeight = -POP_HEIGHT; } else { PopHeightChange = -POP_HEIGHT / POP_TIME; } } if (KeyPopScroll > 0) { KeyPopScroll -= 280 / KEY_TIME; if (KeyPopScroll < 0) { KeyPopScroll = 0; } } } } private void FillBar(double x, double y, double start, double stopp, Color color1, Color color2) { Fill(color1, x, y, (stopp-start)*2, 1); Fill(color2, x, y+1, (stopp-start)*2, 1); } protected void DrawHealthBar(int health, int x, int y) { Color green1 = Color(255, 180, 228, 128); // light green Color green2 = Color(255, 128, 180, 80); // dark green Color blue1 = Color(255, 196, 204, 252); // light blue Color blue2 = Color(255, 148, 152, 200); // dark blue Color gold1 = Color(255, 224, 188, 0); // light gold Color gold2 = Color(255, 208, 128, 0); // dark gold Color red1 = Color(255, 216, 44, 44); // light red Color red2 = Color(255, 172, 28, 28); // dark red if (health == 999) { FillBar (x, y, 0, 100, gold1, gold2); } else { if (health <= 100) { if (health <= 10) { FillBar (x, y, 0, health, red1, red2); } else if (health <= 20) { FillBar (x, y, 0, health, gold1, gold2); } else { FillBar (x, y, 0, health, green1, green2); } //FillBar (x, y, health, 100, 0, 0); } else { int stopp = 200 - health; FillBar (x, y, 0, stopp, green1, green2); FillBar (x + stopp * 2, y, stopp, 100, blue1, blue2); } } } protected void DrawMainBar (double TicFrac) { Inventory item; int i; // Pop screen (log, keys, and status) if (CurrentPop != POP_None && PopHeight < 0) { double tmp, h; [tmp, tmp, h] = StatusbarToRealCoords(0, 0, 8); DrawPopScreen (int(GetTopOfStatusBar() - h), TicFrac); } DrawImage("INVBACK", (0, 168), DI_ITEM_OFFSETS); DrawImage("INVTOP", (0, 160), DI_ITEM_OFFSETS); // Health DrawString(mGrnFont, FormatNumber(CPlayer.health, 3, 5), (79, 162), DI_TEXT_ALIGN_RIGHT); int points; if (CPlayer.cheats & CF_GODMODE) { points = 999; } else { points = min(CPlayer.health, 200); } DrawHealthBar (points, 49, 172); DrawHealthBar (points, 49, 175); // Armor item = CPlayer.mo.FindInventory('BasicArmor'); if (item != NULL && item.Amount > 0) { DrawInventoryIcon(item, (2, 177), DI_ITEM_OFFSETS); DrawString(mYelFont, FormatNumber(item.Amount, 3, 5), (27, 191), DI_TEXT_ALIGN_RIGHT); } // Ammo Inventory ammo1 = GetCurrentAmmo (); if (ammo1 != NULL) { DrawString(mGrnFont, FormatNumber(ammo1.Amount, 3, 5), (311, 162), DI_TEXT_ALIGN_RIGHT); DrawInventoryIcon (ammo1, (290, 181), DI_ITEM_OFFSETS); } // Sigil item = CPlayer.mo.FindInventory('Sigil'); if (item != NULL) { DrawInventoryIcon (item, (253, 175), DI_ITEM_OFFSETS); } // Inventory CPlayer.inventorytics = 0; CPlayer.mo.InvFirst = ValidateInvFirst (6); i = 0; for (item = CPlayer.mo.InvFirst; item != NULL && i < 6; item = item.NextInv()) { int flags = item.Amount <= 0? DI_ITEM_OFFSETS|DI_DIM : DI_ITEM_OFFSETS; if (item == CPlayer.mo.InvSel) { DrawTexture (Images[CursorImage], (42 + TICRATE*i, 180), flags, 1. - itemflashFade); } DrawInventoryIcon (item, (48 + TICRATE*i, 182), flags); DrawString(mYelFont, FormatNumber(item.Amount, 3, 5), (75 + TICRATE*i, 191), DI_TEXT_ALIGN_RIGHT); i++; } } protected void DrawFullScreenStuff () { // Draw health (use red color if health is below the run health threashold.) DrawString(mGrnFont, FormatNumber(CPlayer.health, 3), (4, -10), DI_TEXT_ALIGN_LEFT, (CPlayer.health < CPlayer.mo.RunHealth)? Font.CR_BRICK : Font.CR_UNTRANSLATED); DrawImage("I_MDKT", (14, -17)); // Draw armor let armor = CPlayer.mo.FindInventory('BasicArmor'); if (armor != NULL && armor.Amount != 0) { DrawString(mYelFont, FormatNumber(armor.Amount, 3), (35, -10)); DrawInventoryIcon(armor, (45, -17)); } // Draw ammo Inventory ammo1, ammo2; int ammocount1, ammocount2; [ammo1, ammo2, ammocount1, ammocount2] = GetCurrentAmmo (); if (ammo1 != NULL) { // Draw primary ammo in the bottom-right corner DrawString(mGrnFont, FormatNumber(ammo1.Amount, 3), (-23, -10)); DrawInventoryIcon(ammo1, (-14, -17)); if (ammo2 != NULL && ammo1!=ammo2) { // Draw secondary ammo just above the primary ammo DrawString(mGrnFont, FormatNumber(ammo2.Amount, 3), (-23, -48)); DrawInventoryIcon(ammo2, (-14, -55)); } } if (deathmatch) { // Draw frags (in DM) DrawString(mBigFont, FormatNumber(CPlayer.FragCount, 3), (4, 1)); } // Draw inventory if (CPlayer.inventorytics == 0) { if (CPlayer.mo.InvSel != null) { if (itemflashFade > 0) { DrawTexture(Images[CursorImage], (-42, -15)); } DrawString(mYelFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3, 5), (-30, -10), DI_TEXT_ALIGN_RIGHT); DrawInventoryIcon(CPlayer.mo.InvSel, (-42, -17), DI_DIMDEPLETED); } } else { CPlayer.mo.InvFirst = ValidateInvFirst (6); int i = 0; Inventory item; Vector2 box = TexMan.GetScaledSize(Images[CursorImage]) - (4, 4); // Fit oversized icons into the box. if (CPlayer.mo.InvFirst != NULL) { for (item = CPlayer.mo.InvFirst; item != NULL && i < 6; item = item.NextInv()) { if (item == CPlayer.mo.InvSel) { DrawTexture(Images[CursorImage], (-90+i*TICRATE, -3), DI_SCREEN_CENTER_BOTTOM, 0.75); } if (item.Icon.isValid()) { DrawInventoryIcon(item, (-90+i*TICRATE, -5), DI_SCREEN_CENTER_BOTTOM|DI_DIMDEPLETED, 0.75); } DrawString(mYelFont, FormatNumber(item.Amount, 3, 5), (-72 + i*TICRATE, -8), DI_TEXT_ALIGN_RIGHT|DI_SCREEN_CENTER_BOTTOM); ++i; } } } } protected void DrawPopScreen (int bottom, double TicFrac) { String buff; String label; int i; Inventory item; int xscale, yscale, left, top; int bars = (CurrentPop == POP_Status) ? imgINVPOP : imgINVPOP2; int back = (CurrentPop == POP_Status) ? imgINVPBAK : imgINVPBAK2; // Extrapolate the height of the popscreen for smoother movement int height = clamp (PopHeight + int(TicFrac * PopHeightChange), -POP_HEIGHT, 0); xscale = CleanXfac; yscale = CleanYfac; left = screen.GetWidth()/2 - 160*CleanXfac; top = bottom + height * yscale; screen.DrawTexture (Images[back], true, left, top, DTA_CleanNoMove, true, DTA_Alpha, 0.75); screen.DrawTexture (Images[bars], true, left, top, DTA_CleanNoMove, true); switch (CurrentPop) { case POP_Log: { // Draw the latest log message. screen.DrawText(SmallFont2, Font.CR_UNTRANSLATED, left + 210 * xscale, top + 8 * yscale, Level.TimeFormatted(), DTA_CleanNoMove, true); if (CPlayer.LogText.Length() > 0) { let text = Stringtable.Localize(CPlayer.LogText); BrokenLines lines = SmallFont2.BreakLines(text, 272); for (i = 0; i < lines.Count(); ++i) { screen.DrawText(SmallFont2, Font.CR_UNTRANSLATED, left + 24 * xscale, top + (18 + i * 12)*yscale, lines.StringAt(i), DTA_CleanNoMove, true); } } break; } case POP_Keys: // List the keys the player has. int pos, endpos, leftcol; int clipleft, clipright; pos = KeyPopPos; endpos = pos + 10; leftcol = 20; clipleft = left + 17*xscale; clipright = left + (320-17)*xscale; if (KeyPopScroll > 0) { // Extrapolate the scroll position for smoother scrolling int scroll = MAX (0, KeyPopScroll - int(TicFrac * (280./KEY_TIME))); pos -= 10; leftcol = leftcol - 280 + scroll; } i = 0; for (item = CPlayer.mo.Inv; i < endpos && item != NULL; item = item.Inv) { if (!(item is "Key")) continue; if (i < pos) { i++; continue; } label = item.GetTag(); int colnum = ((i-pos) / 5) & (KeyPopScroll > 0 ? 3 : 1); int rownum = (i % 5) * 18; screen.DrawTexture (item.Icon, true, left + (colnum * 140 + leftcol)*xscale, top + (6 + rownum)*yscale, DTA_CleanNoMove, true, DTA_ClipLeft, clipleft, DTA_ClipRight, clipright); screen.DrawText (SmallFont2, Font.CR_UNTRANSLATED, left + (colnum * 140 + leftcol + 17)*xscale, top + (11 + rownum)*yscale, label, DTA_CleanNoMove, true, DTA_ClipLeft, clipleft, DTA_ClipRight, clipright); i++; } break; case POP_Status: // Show miscellaneous status items. // Print stats DrINumber2 (CPlayer.mo.accuracy, left+268*xscale, top+28*yscale, 7*xscale, imgFONY0); DrINumber2 (CPlayer.mo.stamina, left+268*xscale, top+52*yscale, 7*xscale, imgFONY0); // How many keys does the player have? i = 0; for (item = CPlayer.mo.Inv; item != NULL; item = item.Inv) { if (item is "Key") { i++; } } DrINumber2 (i, left+268*xscale, top+76*yscale, 7*xscale, imgFONY0); // Does the player have a communicator? item = CPlayer.mo.FindInventory ("Communicator"); if (item != NULL) { screen.DrawTexture (item.Icon, true, left + 280*xscale, top + 74*yscale, DTA_CleanNoMove, true); } // How much ammo does the player have? static const class AmmoList[] = { "ClipOfBullets", "PoisonBolts", "ElectricBolts", "HEGrenadeRounds", "PhosphorusGrenadeRounds", "MiniMissiles", "EnergyPod"}; static const int AmmoY[] = {19, 35, 43, 59, 67, 75, 83}; for (i = 0; i < 7; ++i) { item = CPlayer.mo.FindInventory (AmmoList[i]); if (item == NULL) { DrINumber2 (0, left+206*xscale, top+AmmoY[i] * yscale, 7*xscale, imgFONY0); DrINumber2 (GetDefaultByType(AmmoList[i]).MaxAmount, left+239*xscale, top+AmmoY[i] * yscale, 7*xscale, imgFONY0); } else { DrINumber2 (item.Amount, left+206*xscale, top+AmmoY[i] * yscale, 7*xscale, imgFONY0); DrINumber2 (item.MaxAmount, left+239*xscale, top+AmmoY[i] * yscale, 7*xscale, imgFONY0); } } // What weapons does the player have? static const class WeaponList[] = { "StrifeCrossbow", "AssaultGun", "FlameThrower", "MiniMissileLauncher", "StrifeGrenadeLauncher", "Mauler" }; static const int WeaponX[] = {23, 21, 57, 20, 55, 52}; static const int WeaponY[] = {19, 41, 50, 64, 20, 75}; for (i = 0; i < 6; ++i) { item = CPlayer.mo.FindInventory (WeaponList[i]); if (item != NULL) { screen.DrawTexture (item.Icon, true, left + WeaponX[i] * xscale, top + WeaponY[i] * yscale, DTA_CleanNoMove, true, DTA_LeftOffset, 0, DTA_TopOffset, 0); } } break; } } void DrINumber2 (int val, int x, int y, int width, int imgBase) const { x -= width; if (val == 0) { screen.DrawTexture (Images[imgBase], true, x, y, DTA_CleanNoMove, true); } else { while (val != 0) { screen.DrawTexture (Images[imgBase+val%10], true, x, y, DTA_CleanNoMove, true); val /= 10; x -= width; } } } } // Dark Servant Artifact ---------------------------------------------------- class ArtiDarkServant : Inventory { Default { +COUNTITEM +FLOATBOB Inventory.RespawnTics 4230; Inventory.DefMaxAmount; Inventory.PickupFlash "PickupFlash"; +INVENTORY.INVBAR +INVENTORY.FANCYPICKUPSOUND Inventory.Icon "ARTISUMN"; Inventory.PickupSound "misc/p_pkup"; Inventory.PickupMessage "$TXT_ARTISUMMON"; Tag "$TAG_ARTISUMMON"; } States { Spawn: SUMN A 350; Loop; } //============================================================================ // // Activate the summoning artifact // //============================================================================ override bool Use (bool pickup) { Actor mo = Owner.SpawnPlayerMissile ("SummoningDoll"); if (mo) { mo.target = Owner; mo.tracer = Owner; mo.Vel.Z = 5; } return true; } } // Summoning Doll ----------------------------------------------------------- class SummoningDoll : Actor { Default { Speed 20; +NOBLOCKMAP +DROPOFF +MISSILE +NOTELEPORT } States { Spawn: SUMN A 4; Loop; Death: SUMN AA 4; SUMN A 4 A_Summon; Stop; } //============================================================================ // // A_Summon // //============================================================================ void A_Summon() { Actor mo = Spawn("MinotaurFriend", pos, ALLOW_REPLACE); if (mo) { if (mo.TestMobjLocation() == false || !tracer) { // Didn't fit - change back to artifact mo.Destroy(); Actor arti = Spawn("ArtiDarkServant", Pos, ALLOW_REPLACE); if (arti) arti.bDropped = true; return; } // Careful! The Minotaur might have been replaced // so only set the time if we got a genuine one. MinotaurFriend m = MinotaurFriend(mo); if (m) m.StartTime = level.maptime; if (tracer.bCorpse) { // Master dead mo.tracer = null; // No master } else { mo.tracer = tracer; // Pointer to master Inventory power = Inventory(Spawn("PowerMinotaur")); power.CallTryPickup(tracer); mo.SetFriendPlayer(tracer.player); } // Make smoke puff Spawn("MinotaurSmoke", Pos, ALLOW_REPLACE); A_StartSound(mo.ActiveSound, CHAN_VOICE); } } } // Minotaur Smoke ----------------------------------------------------------- class MinotaurSmoke : Actor { Default { +NOBLOCKMAP +NOGRAVITY +NOTELEPORT RenderStyle "Translucent"; Alpha 0.6; } States { Spawn: MNSM ABCDEFGHIJKLMNOPQ 3; Stop; } } // This turns the helper things for creating lightmaps in SVE into actual light sources class SVELight : PointLight { override void BeginPlay() { Super.BeginPlay(); if (!bSpawnCeiling) AddZ(height); } } class SVELight7958 : SVELight { Default { +SPAWNCEILING +DYNAMICLIGHT.ATTENUATE Height 6; Args 255,255,224,128; } } class SVELight7959 : SVELight { Default { +DYNAMICLIGHT.ATTENUATE Height 6; Args 255,255,224,128; } } class SVELight7960 : SVELight { Default { +SPAWNCEILING +DYNAMICLIGHT.ATTENUATE Height 6; Args 255,255,64,100; } } class SVELight7961 : SVELight { Default { +DYNAMICLIGHT.ATTENUATE Height 6; Args 255,255,64,100; } } class SVELight7962 : SVELight { Default { +DYNAMICLIGHT.ATTENUATE Height 8; Args 255,64,16,128; } } // 7963 has intentionally been omitted class SVELight7964 : SVELight { Default { +SPAWNCEILING +DYNAMICLIGHT.ATTENUATE Height 64; Args 200,200,170,160; } } class SVELight7965 : SVELight { Default { +DYNAMICLIGHT.ATTENUATE Height 64; Args 200,200,170,160; } } class SVELight7971 : SVELight { Default { +DYNAMICLIGHT.ATTENUATE Height 80; Args 248,248,224,144; } } class SVELight7972 : SVELight { Default { +SPAWNCEILING +DYNAMICLIGHT.ATTENUATE Height 24; Args 168,175,255,128; } } class SVELight7973 : SVELight { Default { +DYNAMICLIGHT.ATTENUATE Height 80; Args 112,112,112,100; } } class SVELight7974 : SVELight { Default { +DYNAMICLIGHT.ATTENUATE Height 80; Args 100,100,90,100; } } // CTC flag spots. They are not functional and only here so that something gets spawned for them. class SVEFlagSpotRed : Inventory { States { Spawn: FLGR A 1 BRIGHT; FLGR A 0 BRIGHT; // A_FlagStandSpawn FLGR A 1 BRIGHT; // A_FlagStandCheck Wait; } } class SVEFlagSpotBlue : Inventory { States { Spawn: FLGB A 1 BRIGHT; FLGB A 0 BRIGHT; // A_FlagStandSpawn FLGB A 1 BRIGHT; // A_FlagStandCheck Wait; } } class SVEBlueChalice : Inventory { Default { +DROPPED +FLOORCLIP +INVENTORY.INVBAR Radius 10; Height 16; Tag "$TAG_OFFERINGCHALICE"; Inventory.Icon "I_RELB"; Inventory.PickupMessage "$TXT_OFFERINGCHALICE"; } States { Spawn: RELB A -1 BRIGHT; Stop; } } class SVETalismanPowerup : Inventory { } class SVETalismanRed : Inventory { Default { +DROPPED +FLOORCLIP +INVENTORY.INVBAR Radius 10; Height 16; Inventory.MaxAmount 1; Inventory.Icon "I_FLGR"; Tag "$TAG_TALISMANRED"; Inventory.PickupMessage "$MSG_TALISMANRED"; } States { Spawn: FLGR A -1 BRIGHT; Stop; } override bool TryPickup (in out Actor toucher) { let useok = Super.TryPickup (toucher); if (useok) { if (toucher.FindInventory("SVETalismanRed") && toucher.FindInventory("SVETalismanGreen") && toucher.FindInventory("SVETalismanBlue")) { toucher.A_Print("$MSG_TALISMANPOWER"); toucher.GiveInventoryType("SVETalismanPowerup"); } } return useok; } } class SVETalismanBlue : SVETalismanRed { Default { +INVENTORY.INVBAR Inventory.Icon "I_FLGB"; Tag "$TAG_TALISMANBLUE"; Inventory.PickupMessage "$MSG_TALISMANBLUE"; } States { Spawn: FLGB A -1 BRIGHT; Stop; } } class SVETalismanGreen : SVETalismanRed { Default { +INVENTORY.INVBAR Inventory.Icon "I_FLGG"; Tag "$TAG_TALISMANGREEN"; Inventory.PickupMessage "$MSG_TALISMANGREEN"; } States { Spawn: FLGG A -1 BRIGHT; Stop; } } class SVEOreSpawner : Actor { Default { +NOSECTOR } States { Spawn: TNT1 A 175 A_OreSpawner; loop; } // // A_OreSpawner // // [SVE] svillarreal // void A_OreSpawner() { if(deathmatch) return; bool inrange = false; for(int i = 0; i < MAXPLAYERS; i++) { if(!playeringame[i]) continue; if(Distance2D(players[i].mo) < 2048) { inrange = true; break; } } if(!inrange) return; let it = ThinkerIterator.Create("DegninOre"); Thinker ac; int numores = 0; while (ac = it.Next()) { if (++numores == 3) return; } Spawn("DegninOre", Pos); } } class SVEOpenDoor225 : DummyStrifeItem { override bool TryPickup (in out Actor toucher) { Door_Open(225, 16); GoAwayAndDie (); return true; } override bool SpecialDropAction (Actor dropper) { Door_Open(225, 16); Destroy (); return true; } } class TeleportFog : Actor { default { +NOBLOCKMAP +NOTELEPORT +NOGRAVITY +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: TFOG ABABCDEFGHIJ 6 Bright; Stop; Raven: TELE ABCDEFGHGFEDC 6 Bright; Stop; Strife: TFOG ABCDEFEDCB 6 Bright; Stop; } override void PostBeginPlay () { Super.PostBeginPlay (); A_StartSound ("misc/teleport", CHAN_BODY); switch (gameinfo.gametype) { case GAME_Hexen: case GAME_Heretic: SetStateLabel("Raven"); break; case GAME_Strife: SetStateLabel("Strife"); break; default: break; } } } class TeleportDest : Actor { default { +NOBLOCKMAP +NOSECTOR +DONTSPLASH +NOTONAUTOMAP } } class TeleportDest2 : TeleportDest { default { +NOGRAVITY } } class TeleportDest3 : TeleportDest2 { default { -NOGRAVITY } } // Teleport Other Artifact -------------------------------------------------- class ArtiTeleportOther : Inventory { Default { +COUNTITEM +FLOATBOB +INVENTORY.INVBAR +INVENTORY.FANCYPICKUPSOUND Inventory.PickupFlash "PickupFlash"; Inventory.DefMaxAmount; Inventory.Icon "ARTITELO"; Inventory.PickupSound "misc/p_pkup"; Inventory.PickupMessage "$TXT_ARTITELEPORTOTHER"; Tag "$TAG_ARTITELEPORTOTHER"; } States { Spawn: TELO ABCD 5; Loop; } //=========================================================================== // // Activate Teleport Other // //=========================================================================== override bool Use (bool pickup) { Owner.SpawnPlayerMissile ("TelOtherFX1"); return true; } } // Teleport Other FX -------------------------------------------------------- class TelOtherFX1 : Actor { const TELEPORT_LIFE = 1; Default { Damage 10001; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS +BLOODLESSIMPACT Radius 16; Height 16; Speed 20; } States { Spawn: TRNG E 5 Bright; TRNG D 4 Bright; TRNG C 3 Bright A_TeloSpawnC; TRNG B 3 Bright A_TeloSpawnB; TRNG A 3 Bright A_TeloSpawnA; TRNG B 3 Bright A_TeloSpawnB; TRNG C 3 Bright A_TeloSpawnC; TRNG D 3 Bright A_TeloSpawnD; Goto Spawn+2; Death: TRNG E 3 Bright; Stop; } private void TeloSpawn (class type) { Actor fx = Spawn (type, pos, ALLOW_REPLACE); if (fx) { fx.special1 = TELEPORT_LIFE; // Lifetime countdown fx.angle = angle; fx.target = target; fx.Vel = Vel / 2; } } void A_TeloSpawnA() { TeloSpawn ("TelOtherFX2"); } void A_TeloSpawnB() { TeloSpawn ("TelOtherFX3"); } void A_TeloSpawnC() { TeloSpawn ("TelOtherFX4"); } void A_TeloSpawnD() { TeloSpawn ("TelOtherFX5"); } void A_CheckTeleRing () { if (self.special1-- <= 0) { self.SetStateLabel("Death"); } } //=========================================================================== // // Perform Teleport Other // //=========================================================================== override int DoSpecialDamage (Actor target, int damage, Name damagetype) { if ((target.bIsMonster || target.player != NULL) && !target.bBoss && !target.bNoTeleOther) { if (target.player) { if (deathmatch) P_TeleportToDeathmatchStarts (target); else P_TeleportToPlayerStarts (target); } else { // If death action, run it upon teleport if (target.bIsMonster && target.special) { target.RemoveFromHash (); Actor caller = level.ActOwnSpecial? target : self.target; caller.A_CallSpecial(target.special, target.args[0], target.args[1], target.args[2], target.args[3], target.args[4]); target.special = 0; } // Send all monsters to deathmatch spots P_TeleportToDeathmatchStarts (target); } } return -1; } //=========================================================================== // // P_TeleportToPlayerStarts // //=========================================================================== private void P_TeleportToPlayerStarts (Actor victim) { Vector3 dest; double destAngle; [dest, destAngle] = level.PickPlayerStart(0, PPS_FORCERANDOM | PPS_NOBLOCKINGCHECK); if (!level.useplayerstartz) dest.Z = ONFLOORZ; victim.Teleport (dest, destangle, TELF_SOURCEFOG | TELF_DESTFOG); } //=========================================================================== // // P_TeleportToDeathmatchStarts // //=========================================================================== private void P_TeleportToDeathmatchStarts (Actor victim) { Vector3 dest; double destAngle; [dest, destAngle] = level.PickDeathmatchStart(); if (destAngle < 65536) victim.Teleport((dest.xy, ONFLOORZ), destangle, TELF_SOURCEFOG | TELF_DESTFOG); else P_TeleportToPlayerStarts(victim); } } class TelOtherFX2 : TelOtherFX1 { Default { Speed 16; } States { Spawn: TRNG BCDCB 4 Bright; TRNG A 4 Bright A_CheckTeleRing; Loop; } } class TelOtherFX3 : TelOtherFX1 { Default { Speed 16; } States { Spawn: TRNG CDCBA 4 Bright; TRNG B 4 Bright A_CheckTeleRing; Loop; } } class TelOtherFX4 : TelOtherFX1 { Default { Speed 16; } States { Spawn: TRNG DCBAB 4 Bright; TRNG C 4 Bright A_CheckTeleRing; Loop; } } class TelOtherFX5 : TelOtherFX1 { Default { Speed 16; } States { Spawn: TRNG CBABC 4 Bright; TRNG D 4 Bright A_CheckTeleRing; Loop; } } class Templar : Actor { Default { Health 300; Painchance 100; Speed 8; Radius 20; Height 60; Mass 500; Monster; +NOBLOOD +SEESDAGGERS +NOSPLASHALERT MaxdropoffHeight 32; MinMissileChance 200; SeeSound "templar/sight"; PainSound "templar/pain"; DeathSound "templar/death"; ActiveSound "templar/active"; CrushPainSound "misc/pcrush"; Tag "$TAG_TEMPLAR"; HitObituary "$OB_TEMPLARHIT"; Obituary "$OB_TEMPLAR"; DropItem "EnergyPod"; } States { Spawn: PGRD A 5 A_Look2; Loop; PGRD B 10; Loop; PGRD C 10; Loop; PGRD B 10 A_Wander; Loop; See: PGRD AABBCCDD 3 A_Chase; Loop; Melee: PGRD E 8 A_FaceTarget; PGRD F 8 A_CustomMeleeAttack(random[ReaverMelee](1,8)*3, "reaver/blade"); Goto See; Missile: PGRD G 8 BRIGHT A_FaceTarget; PGRD H 8 BRIGHT A_TemplarAttack; Goto See; Pain: PGRD A 2; PGRD A 2 A_Pain; Goto See; Death: PGRD I 4 A_TossGib; PGRD J 4 A_Scream; PGRD K 4 A_TossGib; PGRD L 4 A_NoBlocking; PGRD MN 4; PGRD O 4 A_TossGib; PGRD PQRSTUVWXYZ[ 4; PGRD \ -1; Stop; } void A_TemplarAttack() { if (target != null) { A_StartSound ("templar/shoot", CHAN_WEAPON); A_FaceTarget (); double pitch = AimLineAttack (angle, MISSILERANGE); for (int i = 0; i < 10; ++i) { int damage = random[Templar](1, 4) * 2; double ang = angle + random2[Templar]() * (11.25 / 256); LineAttack (ang, MISSILERANGE+64., pitch + random2[Templar]() * (7.097 / 256), damage, 'Hitscan', "MaulerPuff"); } } } } /* ** menuinput.cpp ** The string input code ** **--------------------------------------------------------------------------- ** Copyright 2001-2010 Randy Heit ** Copyright 2010-2017 Christoph Oelckers ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ class TextEnterMenu : Menu { const INPUTGRID_WIDTH = 13; const INPUTGRID_HEIGHT = 5; const Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-=.,!?@'\":;[]()<>^#$%&*/_ \b"; String mEnterString; int mEnterSize; int mEnterPos; bool mInputGridOkay; int InputGridX; int InputGridY; int CursorSize; bool AllowColors; Font displayFont; //============================================================================= // // // //============================================================================= // [TP] Added allowcolors private void Init(Menu parent, Font dpf, String textbuffer, int maxlen, bool showgrid, bool allowcolors) { Super.init(parent); mEnterString = textbuffer; mEnterSize = maxlen; mInputGridOkay = (showgrid && (m_showinputgrid == 0)) || (m_showinputgrid >= 1); if (mEnterString.Length() > 0) { InputGridX = INPUTGRID_WIDTH - 1; InputGridY = INPUTGRID_HEIGHT - 1; } else { // If we are naming a new save, don't start the cursor on "end". InputGridX = 0; InputGridY = 0; } AllowColors = allowcolors; // [TP] displayFont = dpf; CursorSize = displayFont.StringWidth(displayFont.GetCursor()); } // This had to be deprecated because the unit for maxlen is 8 pixels. deprecated("3.8") static TextEnterMenu Open(Menu parent, String textbuffer, int maxlen, int sizemode, bool showgrid = false, bool allowcolors = false) { let me = new("TextEnterMenu"); me.Init(parent, Menu.OptionFont(), textbuffer, maxlen*8, showgrid, allowcolors); return me; } static TextEnterMenu OpenTextEnter(Menu parent, Font displayfnt, String textbuffer, int maxlen, bool showgrid = false, bool allowcolors = false) { let me = new("TextEnterMenu"); me.Init(parent, displayfnt, textbuffer, maxlen, showgrid, allowcolors); return me; } //============================================================================= // // // //============================================================================= String GetText() { return mEnterString; } override bool TranslateKeyboardEvents() { return mInputGridOkay; } //============================================================================= // // // //============================================================================= override bool OnUIEvent(UIEvent ev) { // Save game and player name string input if (ev.Type == UIEvent.Type_Char) { mInputGridOkay = false; AppendChar(ev.KeyChar); return true; } int ch = ev.KeyChar; if ((ev.Type == UIEvent.Type_KeyDown || ev.Type == UIEvent.Type_KeyRepeat) && ch == 8) { if (mEnterString.Length() > 0) { mEnterString.DeleteLastCharacter(); } } else if (ev.Type == UIEvent.Type_KeyDown) { if (ch == UIEvent.Key_ESCAPE) { Menu parent = mParentMenu; Close(); parent.MenuEvent(MKEY_Abort, false); return true; } else if (ch == 13) { if (mEnterString.Length() > 0) { // [TP] If we allow color codes, colorize the string now. if (AllowColors) mEnterString = mEnterString.Filter(); Menu parent = mParentMenu; parent.MenuEvent(MKEY_Input, false); Close(); return true; } } } if (ev.Type == UIEvent.Type_KeyDown || ev.Type == UIEvent.Type_KeyRepeat) { return true; } return Super.OnUIEvent(ev); } //============================================================================= // // // //============================================================================= override bool MouseEvent(int type, int x, int y) { int cell_width = 18 * CleanXfac_1; int cell_height = 16 * CleanYfac_1; int screen_y = screen.GetHeight() - INPUTGRID_HEIGHT * cell_height; int screen_x = (screen.GetWidth() - INPUTGRID_WIDTH * cell_width) / 2; if (x >= screen_x && x < screen_x + INPUTGRID_WIDTH * cell_width && y >= screen_y) { InputGridX = (x - screen_x) / cell_width; InputGridY = (y - screen_y) / cell_height; if (type == MOUSE_Release) { if (MenuEvent(MKEY_Enter, true)) { MenuSound("menu/choose"); if (m_use_mouse == 2) InputGridX = InputGridY = -1; } } return true; } else { InputGridX = InputGridY = -1; } return Super.MouseEvent(type, x, y); } //============================================================================= // // // //============================================================================= private void AppendChar(int ch) { String newstring = String.Format("%s%c%s", mEnterString, ch, displayFont.GetCursor()); if (mEnterSize < 0 || displayFont.StringWidth(newstring) < mEnterSize) { mEnterString.AppendCharacter(ch); } } //============================================================================= // // // //============================================================================= override bool MenuEvent (int key, bool fromcontroller) { String InputGridChars = Chars; if (key == MKEY_Back) { mParentMenu.MenuEvent(MKEY_Abort, false); return Super.MenuEvent(key, fromcontroller); } if (fromcontroller) { mInputGridOkay = true; } if (mInputGridOkay) { int ch; if (InputGridX == -1 || InputGridY == -1) { InputGridX = InputGridY = 0; } switch (key) { case MKEY_Down: InputGridY = (InputGridY + 1) % INPUTGRID_HEIGHT; return true; case MKEY_Up: InputGridY = (InputGridY + INPUTGRID_HEIGHT - 1) % INPUTGRID_HEIGHT; return true; case MKEY_Right: InputGridX = (InputGridX + 1) % INPUTGRID_WIDTH; return true; case MKEY_Left: InputGridX = (InputGridX + INPUTGRID_WIDTH - 1) % INPUTGRID_WIDTH; return true; case MKEY_Clear: if (mEnterString.Length() > 0) { mEnterString.DeleteLastCharacter(); } return true; case MKEY_Enter: if (mInputGridOkay) { int ch = InputGridChars.ByteAt(InputGridX + InputGridY * INPUTGRID_WIDTH); if (ch == 0) // end { if (mEnterString.Length() > 0) { Menu parent = mParentMenu; parent.MenuEvent(MKEY_Input, false); Close(); return true; } } else if (ch == 8) // bs { if (mEnterString.Length() > 0) { mEnterString.DeleteLastCharacter(); } } else { AppendChar(ch); } } return true; default: break; } } return false; } //============================================================================= // // // //============================================================================= override void Drawer () { mParentMenu.Drawer(); if (mInputGridOkay) { String InputGridChars = Chars; int cell_width = 18 * CleanXfac_1; int cell_height = 16 * CleanYfac_1; int top_padding = cell_height / 2 - displayFont.GetHeight() * CleanYfac_1 / 2; // Darken the background behind the character grid. screen.Dim(0, 0.8, 0, screen.GetHeight() - INPUTGRID_HEIGHT * cell_height, screen.GetWidth(), INPUTGRID_HEIGHT * cell_height); if (InputGridX >= 0 && InputGridY >= 0) { // Highlight the background behind the selected character. screen.Dim(Color(255,248,220), 0.6, InputGridX * cell_width - INPUTGRID_WIDTH * cell_width / 2 + screen.GetWidth() / 2, InputGridY * cell_height - INPUTGRID_HEIGHT * cell_height + screen.GetHeight(), cell_width, cell_height); } for (int y = 0; y < INPUTGRID_HEIGHT; ++y) { int yy = y * cell_height - INPUTGRID_HEIGHT * cell_height + screen.GetHeight(); for (int x = 0; x < INPUTGRID_WIDTH; ++x) { int xx = x * cell_width - INPUTGRID_WIDTH * cell_width / 2 + screen.GetWidth() / 2; int ch = InputGridChars.ByteAt(y * INPUTGRID_WIDTH + x); int width = displayFont.GetCharWidth(ch); // The highlighted character is yellow; the rest are dark gray. int colr = (x == InputGridX && y == InputGridY) ? Font.CR_YELLOW : Font.CR_DARKGRAY; Color palcolor = (x == InputGridX && y == InputGridY) ? Color(160, 120, 0) : Color(120, 120, 120); if (ch > 32) { // Draw a normal character. screen.DrawChar(displayFont, colr, xx + cell_width/2 - width*CleanXfac_1/2, yy + top_padding, ch, DTA_CleanNoMove_1, true); } else if (ch == 32) { // Draw the space as a box outline. We also draw it 50% wider than it really is. int x1 = xx + cell_width/2 - width * CleanXfac_1 * 3 / 4; int x2 = x1 + width * 3 * CleanXfac_1 / 2; int y1 = yy + top_padding; int y2 = y1 + displayFont.GetHeight() * CleanYfac_1; screen.Clear(x1, y1, x2, y1+CleanYfac_1, palcolor); // top screen.Clear(x1, y2, x2, y2+CleanYfac_1, palcolor); // bottom screen.Clear(x1, y1+CleanYfac_1, x1+CleanXfac_1, y2, palcolor); // left screen.Clear(x2-CleanXfac_1, y1+CleanYfac_1, x2, y2, palcolor); // right } else if (ch == 8 || ch == 0) { // Draw the backspace and end "characters". String str = ch == 8 ? "←" : "↲"; screen.DrawText(displayFont, colr, xx + cell_width/2 - displayFont.StringWidth(str)*CleanXfac_1/2, yy + top_padding, str, DTA_CleanNoMove_1, true); } } } } Super.Drawer(); } } extend class Actor { void A_Bang4Cloud() { double xo = random[Bang4Cloud](0, 3) * (10. / 64); double yo = random[Bang4Cloud](0, 3) * (10. / 64); Spawn("Bang4Cloud", Vec3Offset(xo, yo, 0.), ALLOW_REPLACE); } void A_GiveQuestItem(int questitem) { // Give one of these quest items to every player in the game if (questitem >= 0) { String itemname = "QuestItem" .. questitem; class item = itemname; if (item != null) { for (int i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i]) { players[i].mo.GiveInventoryType(item); } } } } String msgid = "$TXT_QUEST_" .. questitem; String msg = StringTable.Localize(msgid); if (msg != msgid) // if both are identical there was no message of this name in the stringtable. { Console.MidPrint (null, msg); } } } // A Cloud used for various explosions -------------------------------------- // This actor has no direct equivalent in strife. To create this, Strife // spawned a spark and then changed its state to that of this explosion // cloud. Weird. class Bang4Cloud : Actor { Default { +NOBLOCKMAP +NOGRAVITY +ZDOOMTRANS RenderStyle "Add"; VSpeed 1; } States { Spawn: BNG4 BCDEFGHIJKLMN 3 Bright; Stop; } } // Piston ------------------------------------------------------------------- class Piston : Actor { Default { Health 100; Speed 16; Radius 20; Height 76; Mass 10000000; +SOLID +SHOOTABLE +NOBLOOD +FLOORCLIP +INCOMBAT DeathSound "misc/explosion"; } States { Spawn: PSTN AB 8; Loop; Death: PSTN A 4 Bright A_Scream; PSTN B 4 Bright A_NoBlocking; PSTN C 4 Bright A_GiveQuestItem(16); PSTN D 4 Bright A_Bang4Cloud; PSTN E 4 Bright A_TossGib; PSTN F 4 Bright; PSTN G 4 Bright A_Bang4Cloud; PSTN H 4; PSTN I -1; Stop; } } // Computer ----------------------------------------------------------------- class Computer : Actor { Default { Health 80; Speed 27; Radius 26; Height 128; Mass 10000000; +SOLID +SHOOTABLE +NOBLOOD +FLOORCLIP +INCOMBAT DeathSound "misc/explosion"; } States { Spawn: SECR ABCD 4 Bright; Loop; Death: SECR E 5 Bright A_Bang4Cloud; SECR F 5 Bright A_NoBlocking; SECR G 5 Bright A_GiveQuestItem(27); SECR H 5 Bright A_TossGib; SECR I 5 Bright A_Bang4Cloud; SECR J 5; SECR K 5 A_Bang4Cloud; SECR L 5; SECR M 5 A_Bang4Cloud; SECR N 5; SECR O 5 A_Bang4Cloud; SECR P -1; Stop; } } // Power Crystal ------------------------------------------------------------ class PowerCrystal : Actor { Default { Health 50; Speed 14; Radius 20; Height 16; Mass 99999999; +SOLID +SHOOTABLE +NOGRAVITY +NOBLOOD +FLOORCLIP DeathSound "misc/explosion"; ActiveSound "misc/reactor"; } States { Spawn: CRYS A 16 A_LoopActiveSound; CRYS B 5 A_LoopActiveSound; CRYS CDEF 4 A_LoopActiveSound; Loop; Death: BOOM A 0 Bright A_Scream; BOOM A 1 Bright A_Explode512; BOOM B 3 Bright A_GiveQuestItem(14); BOOM C 2 Bright A_LightGoesOut; BOOM D 3 Bright A_Bang4Cloud; BOOM EF 3 Bright; BOOM G 3 Bright A_Bang4Cloud; BOOM H 1 Bright A_Explode512; BOOM I 3 Bright; BOOM JKL 3 Bright A_Bang4Cloud; BOOM MN 3 Bright; BOOM O 3 Bright A_Bang4Cloud; BOOM PQRST 3 Bright; BOOM U 3 Bright A_ExtraLightOff; BOOM VWXY 3 Bright; Stop; } // PowerCrystal ------------------------------------------------------------------- void A_ExtraLightOff() { if (target != NULL && target.player != NULL) { target.player.extralight = 0; } } void A_Explode512() { A_Explode(512, 512); if (target != NULL && target.player != NULL) { target.player.extralight = 5; } A_SetRenderStyle(1, STYLE_Add); } void A_LightGoesOut() { sector sec = CurSector; sec.Flags |= Sector.SECF_SILENTMOVE; sec.lightlevel = 0; // Do this right with proper checks instead of just hacking the floor height. level.CreateFloor(sec, Floor.floorLowerToLowest, null, 65536.); for (int i = 0; i < 8; ++i) { Actor foo = Spawn("Rubble1", Pos, ALLOW_REPLACE); if (foo != NULL) { int t = random[LightOut](0, 7); foo.Vel.X = t - random[LightOut](0, 15); t = random[LightOut](0, 7); foo.Vel.Y = t - random[LightOut](0, 15); foo.Vel.Z = random[LightOut](7, 10); } } } } // // INTERMISSION // Structure passed e.g. to WI_Start(wb) // struct WBPlayerStruct native version("2.4") { // Player stats, kills, collected items etc. native int skills; native int sitems; native int ssecret; native int stime; native int frags[MAXPLAYERS]; native int fragcount; // [RH] Cumulative frags for this player } struct WBStartStruct native version("2.4") { native int finished_ep; native int next_ep; native @WBPlayerStruct plyr[MAXPLAYERS]; native String current; // [RH] Name of map just finished native String next; // next level, [RH] actual map name native String nextname; // next level, printable name native String thisname; // this level, printable name native String nextauthor; // next level, printable name native String thisauthor; // this level, printable name native TextureID LName0; native TextureID LName1; native int totalkills; native int maxkills; native int maxitems; native int maxsecret; native int maxfrags; // the par time and sucktime native int partime; // in tics native int sucktime; // in minutes // total time for the entire current game native int totaltime; // index of this player in game native int pnum; } class WaterZone : Actor { default { +NOSECTOR +NOBLOCKMAP +NOGRAVITY +DONTSPLASH } override void PostBeginPlay () { Super.PostBeginPlay (); CurSector.MoreFlags |= Sector.SECMF_UNDERWATER; Destroy (); } } // Assault Gun -------------------------------------------------------------- class AssaultGun : StrifeWeapon { Default { +FLOORCLIP Weapon.SelectionOrder 600; Weapon.AmmoUse1 1; Weapon.AmmoGive1 20; Weapon.AmmoType1 "ClipOfBullets"; Inventory.Icon "RIFLA0"; Tag "$TAG_ASSAULTGUN"; Inventory.PickupMessage "$TXT_ASSAULTGUN"; Obituary "$OB_MPASSAULTGUN"; } States { Spawn: RIFL A -1; Stop; Ready: RIFG A 1 A_WeaponReady; Loop; Deselect: RIFG B 1 A_Lower; Loop; Select: RIFG A 1 A_Raise; Loop; Fire: RIFF AB 3 A_FireAssaultGun; RIFG D 3 A_FireAssaultGun; RIFG C 0 A_ReFire; RIFG B 2 A_Light0; Goto Ready; } } extend class StateProvider { //============================================================================ // // A_FireAssaultGun // //============================================================================ action void A_FireAssaultGun() { if (player == null) { return; } A_StartSound ("weapons/assaultgun", CHAN_WEAPON); Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } player.mo.PlayAttacking2 (); int damage = 4 * random[StrifeGun](1, 3); double ang = angle; if (player.refire) { ang += Random2[StrifeGun]() * (22.5 / 256) * AccuracyFactor(); } LineAttack (ang, PLAYERMISSILERANGE, BulletSlope (), damage, 'Hitscan', "StrifePuff"); } } // Standing variant of the assault gun -------------------------------------- class AssaultGunStanding : WeaponGiver { Default { DropItem "AssaultGun"; Inventory.PickupMessage "$TXT_ASSAULTGUN"; } States { Spawn: RIFL B -1; Stop; } } // -------------------------------------------------------------------------- // // BFG 9000 // // -------------------------------------------------------------------------- class BFG9000 : DoomWeapon { Default { Height 20; Weapon.SelectionOrder 2800; Weapon.AmmoUse 40; Weapon.AmmoGive 40; Weapon.AmmoType "Cell"; +WEAPON.NOAUTOFIRE; Inventory.PickupMessage "$GOTBFG9000"; Tag "$TAG_BFG9000"; } States { Ready: BFGG A 1 A_WeaponReady; Loop; Deselect: BFGG A 1 A_Lower; Loop; Select: BFGG A 1 A_Raise; Loop; Fire: BFGG A 20 A_BFGsound; BFGG B 10 A_GunFlash; BFGG B 10 A_FireBFG; BFGG B 20 A_ReFire; Goto Ready; Flash: BFGF A 11 Bright A_Light1; BFGF B 6 Bright A_Light2; Goto LightDone; Spawn: BFUG A -1; Stop; OldFire: BFGG A 10 A_BFGsound; BFGG BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 1 A_FireOldBFG; BFGG B 0 A_Light0; BFGG B 20 A_ReFire; Goto Ready; } } //=========================================================================== // // Weapon code (must be attached to StateProvider) // //=========================================================================== extend class StateProvider { action void A_BFGsound() { A_StartSound("weapons/bfgf", CHAN_WEAPON); } // // A_FireBFG // action void A_FireBFG() { if (player == null) { return; } Weapon weap = player.ReadyWeapon; if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { if (!weap.DepleteAmmo (weap.bAltFire, true, deh.BFGCells)) return; } SpawnPlayerMissile("BFGBall", angle, nofreeaim:sv_nobfgaim); } // // A_FireOldBFG // // This function emulates Doom's Pre-Beta BFG // By Lee Killough 6/6/98, 7/11/98, 7/19/98, 8/20/98 // // This code may not be used in other mods without appropriate credit given. // Code leeches will be telefragged. action void A_FireOldBFG() { bool doesautoaim = false; if (player == null) { return; } Weapon weap = player.ReadyWeapon; if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) weap = null; if (weap != null) { if (!weap.DepleteAmmo (weap.bAltFire, true, 1)) return; doesautoaim = weap.bNoAutoaim; weap.bNoAutoaim = true; } player.extralight = 2; // Save values temporarily double SavedPlayerAngle = angle; double SavedPlayerPitch = pitch; for (int i = 0; i < 2; i++) // Spawn two plasma balls in sequence { angle += random[OldBFG](-64, 63) * (90./768); pitch += random[OldBFG](-64, 63) * (90./640); SpawnPlayerMissile (i == 0? (class)("PlasmaBall1") : (class)("PlasmaBall2")); // Restore saved values angle = SavedPlayerAngle; pitch = SavedPlayerPitch; } // Restore autoaim setting if (weap != null) weap.bNoAutoaim = doesautoaim; } } class BFGBall : Actor { Default { Radius 13; Height 8; Speed 25; Damage 100; Projectile; +RANDOMIZE +ZDOOMTRANS RenderStyle "Add"; Alpha 0.75; DeathSound "weapons/bfgx"; Obituary "$OB_MPBFG_BOOM"; } States { Spawn: BFS1 AB 4 Bright; Loop; Death: BFE1 AB 8 Bright; BFE1 C 8 Bright A_BFGSpray; BFE1 DEF 8 Bright; Stop; } } class BFGExtra : Actor { Default { +NOBLOCKMAP +NOGRAVITY +ZDOOMTRANS RenderStyle "Add"; Alpha 0.75; DamageType "BFGSplash"; } States { Spawn: BFE2 ABCD 8 Bright; Stop; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== extend class Actor { // // A_BFGSpray // Spawn a BFG explosion on every monster in view // void A_BFGSpray(class spraytype = "BFGExtra", int numrays = 40, int damagecnt = 15, double ang = 90, double distance = 16*64, double vrange = 32, int defdamage = 0, int flags = 0) { int damage; FTranslatedLineTarget t; // validate parameters if (spraytype == null) spraytype = "BFGExtra"; if (numrays <= 0) numrays = 40; if (damagecnt <= 0) damagecnt = 15; if (ang == 0) ang = 90.; if (distance <= 0) distance = 16 * 64; if (vrange == 0) vrange = 32.; // [RH] Don't crash if no target if (!target) return; // [XA] Set the originator of the rays to the projectile (self) if // the new flag is set, else set it to the player (target) Actor originator = (flags & BFGF_MISSILEORIGIN) ? self : target; // offset angles from its attack ang for (int i = 0; i < numrays; i++) { double an = angle - ang / 2 + ang / numrays*i; originator.AimLineAttack(an, distance, t, vrange); if (t.linetarget != null) { Actor spray = Spawn(spraytype, t.linetarget.pos + (0, 0, t.linetarget.Height / 4), ALLOW_REPLACE); int dmgFlags = 0; Name dmgType = 'BFGSplash'; if (spray != null) { if ((spray.bMThruSpecies && target.GetSpecies() == t.linetarget.GetSpecies()) || (!(flags & BFGF_HURTSOURCE) && target == t.linetarget)) // [XA] Don't hit oneself unless we say so. { spray.Destroy(); // [MC] Remove it because technically, the spray isn't trying to "hit" them. continue; } if (spray.bPuffGetsOwner) spray.target = target; if (spray.bFoilInvul) dmgFlags |= DMG_FOILINVUL; if (spray.bFoilBuddha) dmgFlags |= DMG_FOILBUDDHA; dmgType = spray.DamageType; } if (defdamage == 0) { damage = 0; for (int j = 0; j < damagecnt; ++j) damage += Random[BFGSpray](1, 8); } else { // if this is used, damagecnt will be ignored damage = defdamage; } int newdam = t.linetarget.DamageMobj(originator, target, damage, dmgType, dmgFlags|DMG_USEANGLE, t.angleFromSource); t.TraceBleed(newdam > 0 ? newdam : damage, self); } } } } // Blaster ------------------------------------------------------------------ class Blaster : HereticWeapon { Default { +BLOODSPLATTER Weapon.SelectionOrder 500; Weapon.AmmoUse 1; Weapon.AmmoGive 30; Weapon.YAdjust 15; Weapon.AmmoType "BlasterAmmo"; Weapon.SisterWeapon "BlasterPowered"; Inventory.PickupMessage "$TXT_WPNBLASTER"; Tag "$TAG_BLASTER"; Obituary "$OB_MPBLASTER"; } States { Spawn: WBLS A -1; Stop; Ready: BLSR A 1 A_WeaponReady; Loop; Deselect: BLSR A 1 A_Lower; Loop; Select: BLSR A 1 A_Raise; Loop; Fire: BLSR BC 3; Hold: BLSR D 2 A_FireBlasterPL1; BLSR CB 2; BLSR A 0 A_ReFire; Goto Ready; } //---------------------------------------------------------------------------- // // PROC A_FireBlasterPL1 // //---------------------------------------------------------------------------- action void A_FireBlasterPL1() { if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } double pitch = BulletSlope(); int damage = random[FireBlaster](1, 8) * 4; double ang = angle; if (player.refire) { ang += Random2[FireBlaster]() * (5.625 / 256); if (GetCVar ("vertspread") && !sv_novertspread) { pitch += Random2[FireBlaster]() * (3.549 / 256); } } LineAttack (ang, PLAYERMISSILERANGE, pitch, damage, 'Hitscan', "BlasterPuff"); A_StartSound ("weapons/blastershoot", CHAN_WEAPON); } } class BlasterPowered : Blaster { Default { +WEAPON.POWERED_UP Weapon.AmmoUse 5; Weapon.AmmoGive 0; Weapon.SisterWeapon "Blaster"; Tag "$TAG_BLASTERP"; } States { Fire: BLSR BC 0; Hold: BLSR D 3 A_FireProjectile("BlasterFX1"); BLSR CB 4; BLSR A 0 A_ReFire; Goto Ready; } } // Blaster FX 1 ------------------------------------------------------------- class BlasterFX1 : FastProjectile { Default { Radius 12; Height 8; Speed 184; Damage 2; SeeSound "weapons/blastershoot"; DeathSound "weapons/blasterhit"; +SPAWNSOUNDSOURCE Obituary "$OB_MPPBLASTER"; } States { Spawn: ACLO E 200; Loop; Death: FX18 A 3 BRIGHT A_SpawnRippers; FX18 B 3 BRIGHT; FX18 CDEFG 4 BRIGHT; Stop; } //---------------------------------------------------------------------------- // // // //---------------------------------------------------------------------------- override int DoSpecialDamage (Actor target, int damage, Name damagetype) { if (target is "Ironlich") { // Less damage to Ironlich bosses damage = random[BlasterFX](0, 1); if (!damage) { return -1; } } return damage; } override void Effect () { if (random[BlasterFX]() < 64) { Spawn("BlasterSmoke", (pos.xy, max(pos.z - 8, floorz)), ALLOW_REPLACE); } } //---------------------------------------------------------------------------- // // PROC A_SpawnRippers // //---------------------------------------------------------------------------- void A_SpawnRippers() { for(int i = 0; i < 8; i++) { Actor ripper = Spawn("Ripper", pos, ALLOW_REPLACE); if (ripper != null) { ripper.target = target; ripper.angle = i*45; ripper.VelFromAngle(); ripper.CheckMissileSpawn (radius); } } } } // Blaster smoke ------------------------------------------------------------ class BlasterSmoke : Actor { Default { +NOBLOCKMAP +NOGRAVITY +NOTELEPORT +CANNOTPUSH RenderStyle "Translucent"; Alpha 0.4; } States { Spawn: FX18 HIJKL 4; Stop; } } // Ripper ------------------------------------------------------------------- class Ripper : Actor { Default { Radius 8; Height 6; Speed 14; Damage 1; Projectile; +RIPPER DeathSound "weapons/blasterpowhit"; Obituary "$OB_MPPBLASTER"; } States { Spawn: FX18 M 4; FX18 N 5; Loop; Death: FX18 OPQRS 4 BRIGHT; Stop; } override int DoSpecialDamage (Actor target, int damage, Name damagetype) { if (target is "Ironlich") { // Less damage to Ironlich bosses damage = random[Ripper](0, 1); if (!damage) { return -1; } } return damage; } } // Blaster Puff ------------------------------------------------------------- class BlasterPuff : Actor { Default { +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS +ZDOOMTRANS RenderStyle "Add"; SeeSound "weapons/blasterhit"; } States { Crash: FX17 ABCDE 4 BRIGHT; Stop; Spawn: FX17 FG 3 BRIGHT; FX17 HIJKL 4 BRIGHT; Stop; } } // -------------------------------------------------------------------------- // // Chaingun // // -------------------------------------------------------------------------- class Chaingun : DoomWeapon { Default { Weapon.SelectionOrder 700; Weapon.AmmoUse 1; Weapon.AmmoGive 20; Weapon.AmmoType "Clip"; Inventory.PickupMessage "$GOTCHAINGUN"; Obituary "$OB_MPCHAINGUN"; Tag "$TAG_CHAINGUN"; } States { Ready: CHGG A 1 A_WeaponReady; Loop; Deselect: CHGG A 1 A_Lower; Loop; Select: CHGG A 1 A_Raise; Loop; Fire: CHGG AB 4 A_FireCGun; CHGG B 0 A_ReFire; Goto Ready; Flash: CHGF A 5 Bright A_Light1; Goto LightDone; CHGF B 5 Bright A_Light2; Goto LightDone; Spawn: MGUN A -1; Stop; } } //=========================================================================== // // Code (must be attached to StateProvider) // //=========================================================================== extend class StateProvider { action void A_FireCGun() { if (player == null) { return; } Weapon weap = player.ReadyWeapon; if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { if (!weap.DepleteAmmo (weap.bAltFire, true, 1)) return; A_StartSound ("weapons/chngun", CHAN_WEAPON); State flash = weap.FindState('Flash'); if (flash != null) { // Removed most of the mess that was here in the C++ code because SetSafeFlash already does some thorough validation. State atk = weap.FindState('Fire'); let psp = player.GetPSprite(PSP_WEAPON); if (psp) { State cur = psp.CurState; int theflash = atk == cur? 0:1; player.SetSafeFlash(weap, flash, theflash); } } } player.mo.PlayAttacking2 (); GunShot (!player.refire, "BulletPuff", BulletSlope ()); } } // -------------------------------------------------------------------------- // // Chainsaw // // -------------------------------------------------------------------------- class Chainsaw : Weapon { Default { Weapon.Kickback 0; Weapon.SelectionOrder 2200; Weapon.UpSound "weapons/sawup"; Weapon.ReadySound "weapons/sawidle"; Inventory.PickupMessage "$GOTCHAINSAW"; Obituary "$OB_MPCHAINSAW"; Tag "$TAG_CHAINSAW"; +WEAPON.MELEEWEAPON +WEAPON.NOAUTOSWITCHTO } States { Ready: SAWG CD 4 A_WeaponReady; Loop; Deselect: SAWG C 1 A_Lower; Loop; Select: SAWG C 1 A_Raise; Loop; Fire: SAWG AB 4 A_Saw; SAWG B 0 A_ReFire; Goto Ready; Spawn: CSAW A -1; Stop; } } extend class StateProvider { action void A_Saw(sound fullsound = "weapons/sawfull", sound hitsound = "weapons/sawhit", int damage = 2, class pufftype = "BulletPuff", int flags = 0, double range = 0, double spread_xy = 2.8125, double spread_z = 0, double lifesteal = 0, int lifestealmax = 0, class armorbonustype = "ArmorBonus") { FTranslatedLineTarget t; if (player == null) { return; } if (pufftype == null) { pufftype = 'BulletPuff'; } if (damage == 0) { damage = 2; } if (!(flags & SF_NORANDOM)) { damage *= random[Saw](1, 10); } if (range == 0) { range = MeleeRange + MELEEDELTA + (1. / 65536.); // MBF21 SAWRANGE; } double ang = angle + spread_xy * (Random2[Saw]() / 255.); double slope = AimLineAttack (ang, range, t) + spread_z * (Random2[Saw]() / 255.); Weapon weap = player.ReadyWeapon; if (weap != null && !(flags & SF_NOUSEAMMO) && !(!t.linetarget && (flags & SF_NOUSEAMMOMISS)) && !weap.bDehAmmo && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { if (!weap.DepleteAmmo (weap.bAltFire)) return; } int puffFlags = (flags & SF_NORANDOMPUFFZ) ? LAF_NORANDOMPUFFZ : 0; Actor puff; int actualdamage; [puff, actualdamage] = LineAttack (ang, range, slope, damage, 'Melee', pufftype, puffFlags, t); if (!t.linetarget) { if ((flags & SF_RANDOMLIGHTMISS) && (Random[Saw]() > 64)) { player.extralight = !player.extralight; } A_StartSound (fullsound, CHAN_WEAPON); return; } if (flags & SF_RANDOMLIGHTHIT) { int randVal = Random[Saw](); if (randVal < 64) { player.extralight = 0; } else if (randVal < 160) { player.extralight = 1; } else { player.extralight = 2; } } if (lifesteal && !t.linetarget.bDontDrain) { if (flags & SF_STEALARMOR) { if (armorbonustype == null) { armorbonustype = "ArmorBonus"; } if (armorbonustype != null) { BasicArmorBonus armorbonus = BasicArmorBonus(Spawn(armorbonustype)); armorbonus.SaveAmount = int(armorbonus.SaveAmount * actualdamage * lifesteal); armorbonus.MaxSaveAmount = lifestealmax <= 0 ? armorbonus.MaxSaveAmount : lifestealmax; armorbonus.bDropped = true; armorbonus.ClearCounters(); if (!armorbonus.CallTryPickup (self)) { armorbonus.Destroy (); } } } else { GiveBody (int(actualdamage * lifesteal), lifestealmax); } } A_StartSound (hitsound, CHAN_WEAPON); // turn to face target if (!(flags & SF_NOTURN)) { double anglediff = deltaangle(angle, t.angleFromSource); if (anglediff < 0.0) { if (anglediff < -4.5) angle = t.angleFromSource + 90.0 / 21; else angle -= 4.5; } else { if (anglediff > 4.5) angle = t.angleFromSource - 90.0 / 21; else angle += 4.5; } } if (!(flags & SF_NOPULLIN)) bJustAttacked = true; } } // Strife's Crossbow -------------------------------------------------------- class StrifeCrossbow : StrifeWeapon { Default { +FLOORCLIP Weapon.SelectionOrder 1200; +WEAPON.NOALERT Weapon.AmmoUse1 1; Weapon.AmmoGive1 8; Weapon.AmmoType1 "ElectricBolts"; Weapon.SisterWeapon "StrifeCrossbow2"; Inventory.PickupMessage "$TXT_STRIFECROSSBOW"; Tag "$TAG_STRIFECROSSBOW1"; Inventory.Icon "CBOWA0"; } States { Spawn: CBOW A -1; Stop; Ready: XBOW A 0 A_ShowElectricFlash; XBOW A 1 A_WeaponReady; Wait; Deselect: XBOW A 1 A_Lower; Loop; Select: XBOW A 1 A_Raise; Loop; Fire: XBOW A 3 A_ClearFlash; XBOW B 6 A_FireArrow("ElectricBolt"); XBOW C 4; XBOW D 6; XBOW E 3; XBOW F 5; XBOW G 0 A_ShowElectricFlash; XBOW G 5 A_CheckReload; Goto Ready+1; Flash: XBOW KLM 5; Loop; } //============================================================================ // // A_ClearFlash // //============================================================================ action void A_ClearFlash () { if (player == null) return; player.SetPsprite (PSP_FLASH, null); } //============================================================================ // // A_ShowElectricFlash // //============================================================================ action void A_ShowElectricFlash () { if (player != null) { player.SetPsprite (PSP_FLASH, player.ReadyWeapon.FindState('Flash')); } } //============================================================================ // // A_FireElectric // //============================================================================ action void A_FireArrow (class proj) { if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } if (proj) { double savedangle = angle; angle += Random2[Electric]() * (5.625/256) * AccuracyFactor(); player.mo.PlayAttacking2 (); SpawnPlayerMissile (proj); angle = savedangle; A_StartSound ("weapons/xbowshoot", CHAN_WEAPON); } } } class StrifeCrossbow2 : StrifeCrossbow { Default { Weapon.SelectionOrder 2700; Weapon.AmmoUse1 1; Weapon.AmmoGive1 0; Weapon.AmmoType1 "PoisonBolts"; Weapon.SisterWeapon "StrifeCrossbow"; Tag "$TAG_STRIFECROSSBOW2"; } States { Ready: XBOW H 1 A_WeaponReady; Loop; Deselect: XBOW H 1 A_Lower; Loop; Select: XBOW H 1 A_Raise; Loop; Fire: XBOW H 3; XBOW B 6 A_FireArrow("PoisonBolt"); XBOW C 4; XBOW D 6; XBOW E 3; XBOW I 5; XBOW J 5 A_CheckReload; Goto Ready; Flash: Stop; } } // Electric Bolt ------------------------------------------------------------ class ElectricBolt : Actor { Default { Speed 30; Radius 10; Height 10; Damage 10; Projectile; +STRIFEDAMAGE +NOBLOCKMAP +NOGRAVITY +DROPOFF MaxStepHeight 4; SeeSound "misc/swish"; ActiveSound "misc/swish"; DeathSound "weapons/xbowhit"; Obituary "$OB_MPELECTRICBOLT"; } States { Spawn: AROW A 10 A_LoopActiveSound; Loop; Death: ZAP1 A 3 A_AlertMonsters; ZAP1 BCDEFE 3; ZAP1 DCB 2; ZAP1 A 1; Stop; } } // Poison Bolt -------------------------------------------------------------- class PoisonBolt : Actor { Default { Speed 30; Radius 10; Height 10; Damage 500; Projectile; +STRIFEDAMAGE MaxStepHeight 4; SeeSound "misc/swish"; ActiveSound "misc/swish"; Obituary "$OB_MPPOISONBOLT"; } States { Spawn: ARWP A 10 A_LoopActiveSound; Loop; Death: AROW A 1; Stop; } override int DoSpecialDamage (Actor target, int damage, Name damagetype) { if (target.bNoBlood) { return -1; } if (target.health < 1000000) { if (!target.bBoss) return target.health + 10; else return 50; } return 1; } } // Punch Dagger ------------------------------------------------------------- class PunchDagger : StrifeWeapon { Default { Weapon.SelectionOrder 3900; +WEAPON.NOALERT Obituary "$OB_MPPUNCHDAGGER"; Tag "$TAG_PUNCHDAGGER"; } States { Ready: PNCH A 1 A_WeaponReady; Loop; Deselect: PNCH A 1 A_Lower; Loop; Select: PNCH A 1 A_Raise; Loop; Fire: PNCH B 4; PNCH C 4 A_JabDagger; PNCH D 5; PNCH C 4; PNCH B 5 A_ReFire; Goto Ready; } //============================================================================ // // A_JabDagger // //============================================================================ action void A_JabDagger () { FTranslatedLineTarget t; int damage; if (FindInventory("SVETalismanPowerup")) { damage = 1000; } else { int power = MIN(10, stamina / 10); damage = random[JabDagger](0, power + 7) * (power + 2); if (FindInventory("PowerStrength")) { damage *= 10; } } double angle = angle + random2[JabDagger]() * (5.625 / 256); double pitch = AimLineAttack (angle, 80.); LineAttack (angle, 80., pitch, damage, 'Melee', "StrifeSpark", true, t); // turn to face target if (t.linetarget) { A_StartSound (t.linetarget.bNoBlood ? sound("misc/metalhit") : sound("misc/meathit"), CHAN_WEAPON); angle = t.angleFromSource; bJustAttacked = true; t.linetarget.DaggerAlert (self); } else { A_StartSound ("misc/swish", CHAN_WEAPON); } } } // -------------------------------------------------------------------------- // // Fist // // -------------------------------------------------------------------------- class Fist : Weapon { Default { Weapon.SelectionOrder 3700; Weapon.Kickback 100; Obituary "$OB_MPFIST"; Tag "$TAG_FIST"; +WEAPON.WIMPY_WEAPON +WEAPON.MELEEWEAPON +WEAPON.NOAUTOSWITCHTO } States { Ready: PUNG A 1 A_WeaponReady; Loop; Deselect: PUNG A 1 A_Lower; Loop; Select: PUNG A 1 A_Raise; Loop; Fire: PUNG B 4; PUNG C 4 A_Punch; PUNG D 5; PUNG C 4; PUNG B 5 A_ReFire; Goto Ready; } } //=========================================================================== // // Code (must be attached to Actor) // //=========================================================================== extend class Actor { action void A_Punch() { FTranslatedLineTarget t; if (player != null) { Weapon weap = player.ReadyWeapon; if (weap != null && !weap.bDehAmmo && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { if (!weap.DepleteAmmo (weap.bAltFire)) return; } } int damage = random[Punch](1, 10) << 1; if (FindInventory("PowerStrength")) damage *= 10; double ang = angle + Random2[Punch]() * (5.625 / 256); double range = MeleeRange + MELEEDELTA; double pitch = AimLineAttack (ang, range, null, 0., ALF_CHECK3D); LineAttack (ang, range, pitch, damage, 'Melee', "BulletPuff", LAF_ISMELEEATTACK, t); // turn to face target if (t.linetarget) { A_StartSound ("*fist", CHAN_WEAPON); angle = t.angleFromSource; } } } // Flame Thrower ------------------------------------------------------------ class FlameThrower : StrifeWeapon { Default { +FLOORCLIP Weapon.SelectionOrder 2100; Weapon.Kickback 0; Weapon.AmmoUse1 1; Weapon.AmmoGive1 100; Weapon.UpSound "weapons/flameidle"; Weapon.ReadySound "weapons/flameidle"; Weapon.AmmoType1 "EnergyPod"; Inventory.Icon "FLAMA0"; Tag "$TAG_FLAMER"; Inventory.PickupMessage "$TXT_FLAMER"; } States { Spawn: FLAM A -1; Stop; Ready: FLMT AB 3 A_WeaponReady; Loop; Deselect: FLMT A 1 A_Lower; Loop; Select: FLMT A 1 A_Raise; Loop; Fire: FLMF A 2 A_FireFlamer; FLMF B 3 A_ReFire; Goto Ready; } //============================================================================ // // A_FireFlamer // //============================================================================ action void A_FireFlamer () { if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } player.mo.PlayAttacking2 (); Angle += Random2[Flamethrower]() * (5.625/256.); Actor mo = SpawnPlayerMissile ("FlameMissile"); if (mo != NULL) { mo.Vel.Z += 5; } } } // Flame Thrower Projectile ------------------------------------------------- class FlameMissile : Actor { Default { Speed 15; Height 11; Radius 8; Mass 10; Damage 4; DamageType "Fire"; ReactionTime 8; Projectile; -NOGRAVITY +STRIFEDAMAGE +ZDOOMTRANS MaxStepHeight 4; RenderStyle "Add"; SeeSound "weapons/flamethrower"; Obituary "$OB_MPFLAMETHROWER"; } States { Spawn: FRBL AB 3 Bright; FRBL C 3 Bright A_Countdown; Loop; Death: FRBL D 5 Bright A_FlameDie; FRBL EFGHI 5 Bright; Stop; } //============================================================================ // // A_FlameDie // //============================================================================ void A_FlameDie () { bNoGravity = true; Vel.Z = random[FlameDie](0, 3); } } // Gauntlets ---------------------------------------------------------------- class Gauntlets : Weapon { Default { +BLOODSPLATTER Weapon.SelectionOrder 2300; +WEAPON.WIMPY_WEAPON +WEAPON.MELEEWEAPON Weapon.Kickback 0; Weapon.YAdjust 15; Weapon.UpSound "weapons/gauntletsactivate"; Weapon.SisterWeapon "GauntletsPowered"; Inventory.PickupMessage "$TXT_WPNGAUNTLETS"; Tag "$TAG_GAUNTLETS"; Obituary "$OB_MPGAUNTLETS"; } States { Spawn: WGNT A -1; Stop; Ready: GAUN A 1 A_WeaponReady; Loop; Deselect: GAUN A 1 A_Lower; Loop; Select: GAUN A 1 A_Raise; Loop; Fire: GAUN B 4 A_StartSound("weapons/gauntletsuse", CHAN_WEAPON); GAUN C 4; Hold: GAUN DEF 4 BRIGHT A_GauntletAttack(0); GAUN C 4 A_ReFire; GAUN B 4 A_Light0; Goto Ready; } //--------------------------------------------------------------------------- // // PROC A_GauntletAttack // //--------------------------------------------------------------------------- action void A_GauntletAttack (int power) { int damage; double dist; Class pufftype; FTranslatedLineTarget t; int actualdamage = 0; Actor puff; if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; let psp = player.GetPSprite(PSP_WEAPON); if (psp) { psp.x = ((random[GauntletAtk](0, 3)) - 2); psp.y = WEAPONTOP + (random[GauntletAtk](0, 3)); } } double ang = angle; if (power) { damage = random[GauntletAtk](1, 8) * 2; dist = 4*DEFMELEERANGE; ang += random2[GauntletAtk]() * (2.8125 / 256); pufftype = "GauntletPuff2"; } else { damage = random[GauntletAtk](1, 8) * 2; dist = SAWRANGE; ang += random2[GauntletAtk]() * (5.625 / 256); pufftype = "GauntletPuff1"; } double slope = AimLineAttack (ang, dist); [puff, actualdamage] = LineAttack (ang, dist, slope, damage, 'Melee', pufftype, false, t); if (!t.linetarget) { if (random[GauntletAtk]() > 64) { player.extralight = !player.extralight; } A_StartSound ("weapons/gauntletson", CHAN_AUTO); return; } int randVal = random[GauntletAtk](); if (randVal < 64) { player.extralight = 0; } else if (randVal < 160) { player.extralight = 1; } else { player.extralight = 2; } if (power) { if (!t.linetarget.bDontDrain) GiveBody (actualdamage >> 1); A_StartSound ("weapons/gauntletspowhit", CHAN_AUTO); } else { A_StartSound ("weapons/gauntletshit", CHAN_AUTO); } // turn to face target ang = t.angleFromSource; double anglediff = deltaangle(angle, ang); if (anglediff < 0.0) { if (anglediff < -4.5) angle = ang + 90.0 / 21; else angle -= 4.5; } else { if (anglediff > 4.5) angle = ang - 90.0 / 21; else angle += 4.5; } bJustAttacked = true; } } class GauntletsPowered : Gauntlets { Default { +WEAPON.POWERED_UP Tag "$TAG_GAUNTLETSP"; Obituary "$OB_MPPGAUNTLETS"; Weapon.SisterWeapon "Gauntlets"; } States { Ready: GAUN GHI 4 A_WeaponReady; Loop; Deselect: GAUN G 1 A_Lower; Loop; Select: GAUN G 1 A_Raise; Loop; Fire: GAUN J 4 A_StartSound("weapons/gauntletsuse", CHAN_WEAPON); GAUN K 4; Hold: GAUN LMN 4 BRIGHT A_GauntletAttack(1); GAUN K 4 A_ReFire; GAUN J 4 A_Light0; Goto Ready; } } // Gauntlet puff 1 ---------------------------------------------------------- class GauntletPuff1 : Actor { Default { +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS RenderStyle "Translucent"; Alpha 0.4; VSpeed 0.8; } States { Spawn: PUF1 ABCD 4 BRIGHT; Stop; } } // Gauntlet puff 2 --------------------------------------------------------- class GauntletPuff2 : GauntletPuff1 { States { Spawn: PUF1 EFGH 4 BRIGHT; Stop; } } // High-Explosive Grenade Launcher ------------------------------------------ class StrifeGrenadeLauncher : StrifeWeapon { Default { +FLOORCLIP Weapon.SelectionOrder 2400; Weapon.AmmoUse1 1; Weapon.AmmoGive1 12; Weapon.AmmoType1 "HEGrenadeRounds"; Weapon.SisterWeapon "StrifeGrenadeLauncher2"; Inventory.Icon "GRNDA0"; Tag "$TAG_GLAUNCHER1"; Inventory.PickupMessage "$TXT_GLAUNCHER"; } States { Spawn: GRND A -1; Stop; Ready: GREN A 1 A_WeaponReady; Loop; Deselect: GREN A 1 A_Lower; Loop; Select: GREN A 1 A_Raise; Loop; Fire: GREN A 5 A_FireGrenade("HEGrenade", -90, "Flash"); GREN B 10; GREN A 5 A_FireGrenade("HEGrenade", 90, "Flash2"); GREN C 10; GREN A 0 A_ReFire; Goto Ready; Flash: GREF A 5 Bright A_Light1; Goto LightDone; Flash2: GREF B 5 Bright A_Light2; Goto LightDone; } //============================================================================ // // A_FireGrenade // //============================================================================ action void A_FireGrenade (class grenadetype, double angleofs, statelabel flash) { if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; player.SetPsprite (PSP_FLASH, weapon.FindState(flash), true); } if (grenadetype != null) { AddZ(32); Actor grenade = SpawnSubMissile (grenadetype, self); AddZ(-32); if (grenade == null) return; if (grenade.SeeSound != 0) { grenade.A_StartSound (grenade.SeeSound, CHAN_VOICE); } grenade.Vel.Z = (-clamp(tan(Pitch), -5, 5)) * grenade.Speed + 8; Vector2 offset = AngleToVector(angle, radius + grenade.radius); double an = Angle + angleofs; offset += AngleToVector(an, 15); grenade.SetOrigin(grenade.Vec3Offset(offset.X, offset.Y, 0.), false); } } } // White Phosphorous Grenade Launcher --------------------------------------- class StrifeGrenadeLauncher2 : StrifeGrenadeLauncher { Default { Weapon.SelectionOrder 3200; Weapon.AmmoUse1 1; Weapon.AmmoGive1 0; Weapon.AmmoType1 "PhosphorusGrenadeRounds"; Weapon.SisterWeapon "StrifeGrenadeLauncher"; Tag "$TAG_GLAUNCHER2"; } States { Ready: GREN D 1 A_WeaponReady; Loop; Deselect: GREN D 1 A_Lower; Loop; Select: GREN D 1 A_Raise; Loop; Fire: GREN D 5 A_FireGrenade("PhosphorousGrenade", -90, "Flash"); GREN E 10; GREN D 5 A_FireGrenade("PhosphorousGrenade", 90, "Flash2"); GREN F 10; GREN A 0 A_ReFire; Goto Ready; Flash: GREF C 5 Bright A_Light1; Goto LightDone; Flash2: GREF D 5 Bright A_Light2; Goto LightDone; } } // High-Explosive Grenade --------------------------------------------------- class HEGrenade : Actor { Default { Speed 15; Radius 13; Height 13; Mass 20; Damage 1; Reactiontime 30; Projectile; -NOGRAVITY +STRIFEDAMAGE +BOUNCEONACTORS +EXPLODEONWATER MaxStepHeight 4; BounceType "Doom"; BounceFactor 0.5; BounceCount 2; SeeSound "weapons/hegrenadeshoot"; DeathSound "weapons/hegrenadebang"; Obituary "$OB_MPSTRIFEGRENADE"; } States { Spawn: GRAP AB 3 A_Countdown; Loop; Death: BNG4 A 0 Bright A_NoGravity; BNG4 A 0 Bright A_SetRenderStyle(1, STYLE_Normal); BNG4 A 2 Bright A_Explode(192, 192, alert:true); BNG4 BCDEFGHIJKLMN 3 Bright; Stop; } } // White Phosphorous Grenade ------------------------------------------------ class PhosphorousGrenade : Actor { Default { Speed 15; Radius 13; Height 13; Mass 20; Damage 1; Reactiontime 40; Projectile; -NOGRAVITY +STRIFEDAMAGE +BOUNCEONACTORS +EXPLODEONWATER BounceType "Doom"; MaxStepHeight 4; BounceFactor 0.5; BounceCount 2; SeeSound "weapons/phgrenadeshoot"; DeathSound "weapons/phgrenadebang"; Obituary "$OB_MPPHOSPHOROUSGRENADE"; } States { Spawn: GRIN AB 3 A_Countdown; Loop; Death: BNG3 A 2 A_SpawnItemEx("PhosphorousFire"); Stop; } } // Fire from the Phosphorous Grenade ---------------------------------------- class PhosphorousFire : Actor { Default { Reactiontime 120; DamageType "Fire"; +NOBLOCKMAP +FLOORCLIP +NOTELEPORT +NODAMAGETHRUST +DONTSPLASH +ZDOOMTRANS RenderStyle "Add"; Obituary "$OB_MPPHOSPHOROUSGRENADE"; } States { Spawn: BNG3 B 2 Bright A_Burnarea; BNG3 C 2 Bright A_Countdown; FLBE A 2 Bright A_Burnination; FLBE B 2 Bright A_Countdown; FLBE C 2 Bright A_Burnarea; FLBE D 3 Bright A_Countdown; FLBE E 3 Bright A_Burnarea; FLBE F 3 Bright A_Countdown; FLBE G 3 Bright A_Burnination; Goto Spawn+5; Death: FLBE H 2 Bright; FLBE I 2 Bright A_Burnination; FLBE JK 2 Bright; Stop; } override int DoSpecialDamage (Actor target, int damage, Name damagetype) { // This may look a bit weird but is the same as in SVE: // For the bosses, only their regular 0.5 damage factor for fire applies. let firedamage = target.ApplyDamageFactor('Fire', damage); if (firedamage != damage) return damage; // if the target has a factor, do nothing here. The factor will be applied elsewhere. // For everything else damage is halved, for robots quartered. damage >>= 1; if (target.bNoBlood) { damage >>= 1; } return damage; } // This function is mostly redundant and only kept in case some mod references it. void A_Burnarea () { A_Explode(128, 128); } void A_Burnination () { Vel.Z -= 8; Vel.X += (random2[PHBurn] (3)); Vel.Y += (random2[PHBurn] (3)); A_StartSound ("world/largefire", CHAN_VOICE); // Only the main fire spawns more. if (!bDropped) { // Original x and y offsets seemed to be like this: // x + (((pr_phburn() + 12) & 31) << F.RACBITS); // // But that creates a lop-sided burn because it won't use negative offsets. int xofs, xrand = random[PHBurn](); int yofs, yrand = random[PHBurn](); // Adding 12 is pointless if you're going to mask it afterward. xofs = xrand & 31; if (xrand & 128) { xofs = -xofs; } yofs = yrand & 31; if (yrand & 128) { yofs = -yofs; } Vector2 newpos = Vec2Offset(xofs, yofs); Sector sec = Level.PointInSector(newpos); // Consider portals and 3D floors instead of just using the current sector's z. double floorh = sec.NextLowestFloorAt(newpos.x, newpos.y, pos.z+4, 0, MaxStepHeight); // The sector's floor is too high so spawn the flame elsewhere. if (floorh + MaxStepHeight) { newpos = Pos.xy; } Actor drop = Spawn("PhosphorousFire", (newpos, pos.z + 4.), ALLOW_REPLACE); if (drop != NULL) { drop.Vel.X = Vel.X + random2[PHBurn] (7); drop.Vel.Y = Vel.Y + random2[PHBurn] (7); drop.Vel.Z = Vel.Z - 1; drop.reactiontime = random[PHBurn](2, 5); drop.bDropped = true; } } } } // The mace itself ---------------------------------------------------------- class Mace : HereticWeapon { Default { Weapon.SelectionOrder 1400; Weapon.AmmoUse 1; Weapon.AmmoGive1 50; Weapon.YAdjust 15; Weapon.AmmoType "MaceAmmo"; Weapon.SisterWeapon "MacePowered"; Inventory.PickupMessage "$TXT_WPNMACE"; Tag "$TAG_MACE"; } States { Spawn: WMCE A -1; Stop; Ready: MACE A 1 A_WeaponReady; Loop; Deselect: MACE A 1 A_Lower; Loop; Select: MACE A 1 A_Raise; Loop; Fire: MACE B 4; Hold: MACE CDEF 3 A_FireMacePL1; MACE C 4 A_ReFire; MACE DEFB 4; Goto Ready; } //---------------------------------------------------------------------------- // // PROC A_FireMacePL1 // //---------------------------------------------------------------------------- action void A_FireMacePL1() { if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } if (random[MaceAtk]() < 28) { Actor ball = Spawn("MaceFX2", Pos + (0, 0, 28 - Floorclip), ALLOW_REPLACE); if (ball != null) { ball.Vel.Z = 2 - clamp(tan(pitch), -5, 5); ball.target = self; ball.angle = self.angle; ball.AddZ(ball.Vel.Z); ball.VelFromAngle(); ball.Vel += Vel.xy / 2; ball.A_StartSound ("weapons/maceshoot", CHAN_BODY); ball.CheckMissileSpawn (radius); } } else { let psp = player.GetPSprite(PSP_WEAPON); if (psp) { psp.x = random[MaceAtk](-2, 1); psp.y = WEAPONTOP + random[MaceAtk](0, 3); } Actor ball = SpawnPlayerMissile("MaceFX1", angle + (random[MaceAtk](-4, 3) * (360. / 256))); if (ball) { ball.special1 = 16; // tics till dropoff } } } } class MacePowered : Mace { Default { +WEAPON.POWERED_UP Weapon.AmmoUse 5; Weapon.AmmoGive 0; Weapon.SisterWeapon "Mace"; Tag "$TAG_MACEP"; } States { Fire: Hold: MACE B 4; MACE D 4 A_FireMacePL2; MACE B 4; MACE A 8 A_ReFire; Goto Ready; } //---------------------------------------------------------------------------- // // PROC A_FireMacePL2 // //---------------------------------------------------------------------------- action void A_FireMacePL2() { FTranslatedLineTarget t; if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } Actor mo = SpawnPlayerMissile ("MaceFX4", angle, pLineTarget:t); if (mo) { mo.Vel.xy += Vel.xy; mo.Vel.Z = 2 - clamp(tan(pitch), -5, 5); if (t.linetarget && !t.unlinked) { mo.tracer = t.linetarget; } } A_StartSound ("weapons/maceshoot", CHAN_WEAPON); } } // Mace FX1 ----------------------------------------------------------------- class MaceFX1 : Actor { const MAGIC_JUNK = 1234; Default { Radius 8; Height 6; Speed 20; Damage 2; Projectile; +THRUGHOST BounceType "HereticCompat"; SeeSound "weapons/maceshoot"; Obituary "$OB_MPMACE"; } States { Spawn: FX02 AB 4 A_MacePL1Check; Loop; Death: FX02 F 4 BRIGHT A_MaceBallImpact; FX02 GHIJ 4 BRIGHT; Stop; } //---------------------------------------------------------------------------- // // PROC A_MacePL1Check // //---------------------------------------------------------------------------- void A_MacePL1Check() { if (special1 == 0) return; special1 -= 4; if (special1 > 0) return; special1 = 0; bNoGravity = false; Gravity = 1. / 8; // [RH] Avoid some precision loss by scaling the velocity directly double velscale = 7 / Vel.XY.Length(); Vel.XY *= velscale; Vel.Z *= 0.5; } //---------------------------------------------------------------------------- // // PROC A_MaceBallImpact // //---------------------------------------------------------------------------- void A_MaceBallImpact() { if ((health != MAGIC_JUNK) && bInFloat) { // Bounce health = MAGIC_JUNK; Vel.Z *= 0.75; bBounceOnFloors = bBounceOnCeilings = false; SetState (SpawnState); A_StartSound ("weapons/macebounce", CHAN_BODY); } else { // Explode Vel = (0,0,0); bNoGravity = true; Gravity = 1; A_StartSound ("weapons/macehit", CHAN_BODY); } } } // Mace FX2 ----------------------------------------------------------------- class MaceFX2 : MaceFX1 { Default { Speed 10; Damage 6; Gravity 0.125; -NOGRAVITY SeeSound ""; } States { Spawn: FX02 CD 4; Loop; Death: FX02 F 4 A_MaceBallImpact2; goto Super::Death+1; } //---------------------------------------------------------------------------- // // PROC A_MaceBallImpact2 // //---------------------------------------------------------------------------- void A_MaceBallImpact2() { if ((pos.Z <= floorz) && HitFloor ()) { // Landed in some sort of liquid Destroy (); return; } if (bInFloat) { if (Vel.Z >= 2) { // Bounce Vel.Z *= 0.75; SetState (SpawnState); Actor tiny = Spawn("MaceFX3", Pos, ALLOW_REPLACE); if (tiny != null) { tiny.target = target; tiny.angle = angle + 90.; tiny.VelFromAngle(Vel.Z - 1.); tiny.Vel += (Vel.XY * .5, Vel.Z); tiny.CheckMissileSpawn (radius); } tiny = Spawn("MaceFX3", Pos, ALLOW_REPLACE); if (tiny != null) { tiny.target = target; tiny.angle = angle - 90.; tiny.VelFromAngle(Vel.Z - 1.); tiny.Vel += (Vel.XY * .5, Vel.Z); tiny.CheckMissileSpawn (radius); } return; } } Vel = (0,0,0); bNoGravity = true; bBounceOnFloors = bBounceOnCeilings = false; Gravity = 1; } } // Mace FX3 ----------------------------------------------------------------- class MaceFX3 : MaceFX1 { Default { Speed 7; Damage 4; -NOGRAVITY; Gravity 0.125; } States { Spawn: FX02 AB 4; Loop; } } // Mace FX4 ----------------------------------------------------------------- class MaceFX4 : Actor { Default { Radius 8; Height 6; Speed 7; Damage 18; Gravity 0.125; Projectile; -NOGRAVITY +TELESTOMP +THRUGHOST -NOTELEPORT BounceType "HereticCompat"; SeeSound ""; Obituary "$OB_MPPMACE"; } States { Spawn: FX02 E 99; Loop; Death: FX02 C 4 A_DeathBallImpact; FX02 GHIJ 4 BRIGHT; Stop; } //--------------------------------------------------------------------------- // // FUNC P_AutoUseChaosDevice // //--------------------------------------------------------------------------- private bool AutoUseChaosDevice (PlayerInfo player) { Inventory arti = player.mo.FindInventory("ArtiTeleport"); if (arti != null) { player.mo.UseInventory (arti); player.health = player.mo.health = (player.health+1)/2; return true; } return false; } //---------------------------------------------------------------------------- // // PROC DoSpecialDamage // //---------------------------------------------------------------------------- override int DoSpecialDamage (Actor target, int damage, Name damagetype) { if (target.bBoss || target.bDontSquash || target.IsTeammate (self.target)) { // Don't allow cheap boss kills and don't instagib teammates return damage; } else if (target.player) { // Player specific checks if (target.player.mo.bInvulnerable) { // Can't hurt invulnerable players return -1; } if (AutoUseChaosDevice (target.player)) { // Player was saved using chaos device return -1; } } return TELEFRAG_DAMAGE; // Something's gonna die } //---------------------------------------------------------------------------- // // PROC A_DeathBallImpact // //---------------------------------------------------------------------------- void A_DeathBallImpact() { FTranslatedLineTarget t; if ((pos.Z <= floorz) && HitFloor ()) { // Landed in some sort of liquid Destroy (); return; } if (bInFloat) { if (Vel.Z >= 2) { // Bounce bool newAngle = false; double ang = 0; if (tracer) { if (!tracer.bShootable) { // Target died tracer = null; } else { // Seek ang = AngleTo(tracer); newAngle = true; } } else { // Find new target ang = 0.; for (int i = 0; i < 16; i++) { AimLineAttack (ang, 640., t, 0., ALF_NOFRIENDS|ALF_PORTALRESTRICT, null, target); if (t.linetarget && target != t.linetarget) { tracer = t.linetarget; ang = t.angleFromSource; newAngle = true; break; } ang += 22.5; } } if (newAngle) { angle = ang; VelFromAngle(); } SetState (SpawnState); A_StartSound ("weapons/macestop", CHAN_BODY); return; } } Vel = (0,0,0); bNoGravity = true; Gravity = 1; A_StartSound ("weapons/maceexplode", CHAN_BODY); } } // Mace spawn spot ---------------------------------------------------------- class MaceSpawner : SpecialSpot { Default { +NOSECTOR +NOBLOCKMAP } States { Spawn: TNT1 A 1; TNT1 A -1 A_SpawnSingleItem("Mace", 64, 64, 0); Stop; } } // Mauler ------------------------------------------------------------------- // The scatter version class Mauler : StrifeWeapon { Default { +FLOORCLIP Weapon.SelectionOrder 300; Weapon.AmmoUse1 20; Weapon.AmmoGive1 40; Weapon.AmmoType1 "EnergyPod"; Weapon.SisterWeapon "Mauler2"; Inventory.Icon "TRPDA0"; Tag "$TAG_MAULER1"; Inventory.PickupMessage "$TXT_MAULER"; Obituary "$OB_MPMAULER1"; } States { Ready: MAUL FGHA 6 A_WeaponReady; Loop; Deselect: MAUL A 1 A_Lower; Loop; Select: MAUL A 1 A_Raise; Loop; Fire: BLSF A 5 Bright A_FireMauler1; MAUL B 3 Bright A_Light1; MAUL C 2 A_Light2; MAUL DE 2; MAUL A 7 A_Light0; MAUL H 7; MAUL G 7 A_CheckReload; Goto Ready; Spawn: TRPD A -1; Stop; } //============================================================================ // // A_FireMauler1 // // Hey! This is exactly the same as a super shotgun except for the sound // and the bullet puffs and the disintegration death. // //============================================================================ action void A_FireMauler1() { if (player == null) { return; } A_StartSound ("weapons/mauler1", CHAN_WEAPON); Weapon weap = player.ReadyWeapon; if (weap != null) { if (!weap.DepleteAmmo (weap.bAltFire, true, 2)) return; } player.mo.PlayAttacking2 (); double pitch = BulletSlope (); for (int i = 0 ; i < 20 ; i++) { int damage = 5 * random[Mauler1](1, 3); double ang = angle + Random2[Mauler1]() * (11.25 / 256); // Strife used a range of 2112 units for the mauler to signal that // it should use a different puff. ZDoom's default range is longer // than this, so let's not handicap it by being too faithful to the // original. LineAttack (ang, PLAYERMISSILERANGE, pitch + Random2[Mauler1]() * (7.097 / 256), damage, 'Hitscan', "MaulerPuff"); } } } // Mauler Torpedo version --------------------------------------------------- class Mauler2 : Mauler { Default { Weapon.SelectionOrder 3300; Weapon.AmmoUse1 30; Weapon.AmmoGive1 0; Weapon.AmmoType1 "EnergyPod"; Weapon.SisterWeapon "Mauler"; Tag "$TAG_MAULER2"; } States { Ready: MAUL IJKL 7 A_WeaponReady; Loop; Deselect: MAUL I 1 A_Lower; Loop; Select: MAUL I 1 A_Raise; Loop; Fire: MAUL I 20 A_FireMauler2Pre; MAUL J 10 A_Light1; BLSF A 10 Bright A_FireMauler2; MAUL B 10 Bright A_Light2; MAUL C 2; MAUL D 2 A_Light0; MAUL E 2 A_ReFire; Goto Ready; } //============================================================================ // // A_FireMauler2Pre // // Makes some noise and moves the psprite. // //============================================================================ action void A_FireMauler2Pre () { A_StartSound ("weapons/mauler2charge", CHAN_WEAPON); if (player != null) { PSprite psp = player.GetPSprite(PSP_WEAPON); if (psp) { psp.x += Random2[Mauler2]() / 64.; psp.y += Random2[Mauler2]() / 64.; } } } //============================================================================ // // A_FireMauler2Pre // // Fires the torpedo. // //============================================================================ action void A_FireMauler2 () { if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } player.mo.PlayAttacking2 (); SpawnPlayerMissile ("MaulerTorpedo"); DamageMobj (self, null, 20, 'Disintegrate'); Thrust(7.8125, Angle+180.); } } // Mauler "Bullet" Puff ----------------------------------------------------- class MaulerPuff : Actor { Default { +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS +ZDOOMTRANS RenderStyle "Add"; DamageType "Disintegrate"; } States { Spawn: MPUF AB 5; POW1 ABCDE 4; Stop; } } // The Mauler's Torpedo ----------------------------------------------------- class MaulerTorpedo : Actor { Default { Speed 20; Height 8; Radius 13; Damage 1; DamageType "Disintegrate"; Projectile; +STRIFEDAMAGE +ZDOOMTRANS MaxStepHeight 4; RenderStyle "Add"; SeeSound "weapons/mauler2fire"; DeathSound "weapons/mauler2hit"; Obituary "$OB_MPMAULER"; } States { Spawn: TORP ABCD 4 Bright; Loop; Death: THIT AB 8 Bright; THIT C 8 Bright A_MaulerTorpedoWave; THIT DE 8 Bright; Stop; } //============================================================================ // // A_MaulerTorpedoWave // // Launches lots of balls when the torpedo hits something. // //============================================================================ action void A_MaulerTorpedoWave() { if (target == null) return; readonly wavedef = GetDefaultByType("MaulerTorpedoWave"); double savedz = pos.z; angle += 180.; // If the torpedo hit the ceiling, it should still spawn the wave if (wavedef && ceilingz < pos.z + wavedef.Height) { SetZ(ceilingz - wavedef.Height); } for (int i = 0; i < 80; ++i) { Angle += 4.5; SpawnSubMissile ("MaulerTorpedoWave", target); } SetZ(savedz); } } // The mini torpedoes shot by the big torpedo -------------------------------- class MaulerTorpedoWave : Actor { Default { Speed 35; Radius 13; Height 13; Damage 10; DamageType "Disintegrate"; Projectile; +STRIFEDAMAGE +ZDOOMTRANS MaxStepHeight 4; RenderStyle "Add"; Obituary "$OB_MPMAULER"; } States { Spawn: TWAV AB 9 Bright; Death: TWAV C 9 Bright; Stop; } } // Mini-Missile Launcher ---------------------------------------------------- class MiniMissileLauncher : StrifeWeapon { Default { +FLOORCLIP Weapon.SelectionOrder 1800; Weapon.AmmoUse1 1; Weapon.AmmoGive1 8; Weapon.AmmoType1 "MiniMissiles"; Inventory.Icon "MMSLA0"; Tag "$TAG_MMLAUNCHER"; Inventory.PickupMessage "$TXT_MMLAUNCHER"; } States { Spawn: MMSL A -1; Stop; Ready: MMIS A 1 A_WeaponReady; Loop; Deselect: MMIS A 1 A_Lower; Loop; Select: MMIS A 1 A_Raise; Loop; Fire: MMIS A 4 A_FireMiniMissile; MMIS B 4 A_Light1; MMIS C 5 Bright; MMIS D 2 Bright A_Light2; MMIS E 2 Bright; MMIS F 2 Bright A_Light0; MMIS F 0 A_ReFire; Goto Ready; } //============================================================================ // // A_FireMiniMissile // //============================================================================ action void A_FireMiniMissile () { if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } double savedangle = angle; angle += Random2[MiniMissile]() * (11.25 / 256) * AccuracyFactor(); player.mo.PlayAttacking2 (); SpawnPlayerMissile ("MiniMissile"); angle = savedangle; } } // Rocket Trail ------------------------------------------------------------- class RocketTrail : Actor { Default { +NOBLOCKMAP +NOGRAVITY RenderStyle "Translucent"; Alpha 0.25; SeeSound "misc/missileinflight"; } States { Spawn: PUFY BCBCD 4; Stop; } } // Rocket Puff -------------------------------------------------------------- class MiniMissilePuff : StrifePuff { Default { -ALLOWPARTICLES } States { Spawn: Goto Crash; } } // Mini Missile ------------------------------------------------------------- class MiniMissile : Actor { Default { Speed 20; Radius 10; Height 14; Damage 10; Projectile; +STRIFEDAMAGE MaxStepHeight 4; SeeSound "weapons/minimissile"; DeathSound "weapons/minimissilehit"; Obituary "$OB_MPMINIMISSILELAUNCHER"; } States { Spawn: MICR A 6 Bright A_RocketInFlight; Loop; Death: SMIS A 0 Bright A_SetRenderStyle(1, STYLE_Normal); SMIS A 5 Bright A_Explode(64, 64, alert:true); SMIS B 5 Bright; SMIS C 4 Bright; SMIS DEFG 2 Bright; Stop; } } // Phoenix Rod -------------------------------------------------------------- class PhoenixRod : Weapon { Default { +WEAPON.NOAUTOFIRE Weapon.SelectionOrder 2600; Weapon.Kickback 150; Weapon.YAdjust 15; Weapon.AmmoUse 1; Weapon.AmmoGive 2; Weapon.AmmoType "PhoenixRodAmmo"; Weapon.Sisterweapon "PhoenixRodPowered"; Inventory.PickupMessage "$TXT_WPNPHOENIXROD"; Tag "$TAG_PHOENIXROD"; } States { Spawn: WPHX A -1; Stop; Ready: PHNX A 1 A_WeaponReady; Loop; Deselect: PHNX A 1 A_Lower; Loop; Select: PHNX A 1 A_Raise; Loop; Fire: PHNX B 5; PHNX C 7 A_FirePhoenixPL1; PHNX DB 4; PHNX B 0 A_ReFire; Goto Ready; } //---------------------------------------------------------------------------- // // PROC A_FirePhoenixPL1 // //---------------------------------------------------------------------------- action void A_FirePhoenixPL1() { if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } SpawnPlayerMissile ("PhoenixFX1"); Thrust(4, angle + 180); } } class PhoenixRodPowered : PhoenixRod { const FLAME_THROWER_TICS = (10*TICRATE); private int FlameCount; // for flamethrower duration Default { +WEAPON.POWERED_UP Weapon.SisterWeapon "PhoenixRod"; Weapon.AmmoGive 0; Tag "$TAG_PHOENIXRODP"; } States { Fire: PHNX B 3 A_InitPhoenixPL2; Hold: PHNX C 1 A_FirePhoenixPL2; PHNX B 4 A_ReFire; Powerdown: PHNX B 4 A_ShutdownPhoenixPL2; Goto Ready; } override void EndPowerup () { if (FlameCount > 0) DepleteAmmo (bAltFire); Owner.player.refire = 0; Owner.A_StopSound (CHAN_WEAPON); Owner.player.ReadyWeapon = SisterWeapon; Owner.player.SetPsprite(PSP_WEAPON, SisterWeapon.GetReadyState()); } //---------------------------------------------------------------------------- // // PROC A_InitPhoenixPL2 // //---------------------------------------------------------------------------- action void A_InitPhoenixPL2() { if (player != null) { PhoenixRodPowered flamethrower = PhoenixRodPowered(player.ReadyWeapon); if (flamethrower != null) { flamethrower.FlameCount = FLAME_THROWER_TICS; } } } //---------------------------------------------------------------------------- // // PROC A_FirePhoenixPL2 // // Flame thrower effect. // //---------------------------------------------------------------------------- action void A_FirePhoenixPL2() { if (player == null) { return; } PhoenixRodPowered flamethrower = PhoenixRodPowered(player.ReadyWeapon); if (flamethrower == null || --flamethrower.FlameCount == 0) { // Out of flame player.SetPsprite(PSP_WEAPON, flamethrower.FindState("Powerdown")); player.refire = 0; A_StopSound (CHAN_WEAPON); return; } double slope = -clamp(tan(pitch), -5, 5); double xo = Random2[FirePhoenixPL2]() / 128.; double yo = Random2[FirePhoenixPL2]() / 128.; Vector3 spawnpos = Vec3Offset(xo, yo, 26 + slope - Floorclip); slope += 0.1; Actor mo = Spawn("PhoenixFX2", spawnpos, ALLOW_REPLACE); if (mo != null) { mo.target = self; mo.Angle = Angle; mo.VelFromAngle(); mo.Vel.XY += Vel.XY; mo.Vel.Z = mo.Speed * slope; mo.CheckMissileSpawn (radius); } if (!player.refire) { A_StartSound("weapons/phoenixpowshoot", CHAN_WEAPON, CHANF_LOOPING); } } //---------------------------------------------------------------------------- // // PROC A_ShutdownPhoenixPL2 // //---------------------------------------------------------------------------- action void A_ShutdownPhoenixPL2() { if (player == null) { return; } A_StopSound (CHAN_WEAPON); PhoenixRodPowered weapon = PhoenixRodPowered(player.ReadyWeapon); if (weapon != null) { weapon.FlameCount = 0; weapon.DepleteAmmo (weapon.bAltFire); } } } // Phoenix FX 1 ------------------------------------------------------------- class PhoenixFX1 : Actor { Default { Radius 11; Height 8; Speed 20; Damage 20; DamageType "Fire"; Projectile; +THRUGHOST +SPECIALFIREDAMAGE SeeSound "weapons/phoenixshoot"; DeathSound "weapons/phoenixhit"; Obituary "$OB_MPPHOENIXROD"; } States { Spawn: FX04 A 4 BRIGHT A_PhoenixPuff; Loop; Death: FX08 A 6 BRIGHT A_Explode; FX08 BC 5 BRIGHT; FX08 DEFGH 4 BRIGHT; Stop; } override int DoSpecialDamage (Actor target, int damage, Name damagetype) { Sorcerer2 s2 = Sorcerer2(target); if (s2 != null && random[HornRodFX2]() < 96) { // D'Sparil teleports away s2.DSparilTeleport (); return -1; } return damage; } //---------------------------------------------------------------------------- // // PROC A_PhoenixPuff // //---------------------------------------------------------------------------- void A_PhoenixPuff() { //[RH] Heretic never sets the target for seeking //P_SeekerMissile (self, 5, 10); Actor puff = Spawn("PhoenixPuff", Pos, ALLOW_REPLACE); if (puff != null) { puff.Vel.XY = AngleToVector(Angle + 90, 1.3); } puff = Spawn("PhoenixPuff", Pos, ALLOW_REPLACE); if (puff != null) { puff.Vel.XY = AngleToVector(Angle - 90, 1.3); } } } // Phoenix puff ------------------------------------------------------------- class PhoenixPuff : Actor { Default { +NOBLOCKMAP +NOGRAVITY +NOTELEPORT +CANNOTPUSH RenderStyle "Translucent"; Alpha 0.4; } States { Spawn: FX04 BCDEF 4; Stop; } } // Phoenix FX 2 ------------------------------------------------------------- class PhoenixFX2 : Actor { Default { Radius 6; Height 8; Speed 10; Damage 2; DamageType "Fire"; Projectile; RenderStyle "Add"; +ZDOOMTRANS Obituary "$OB_MPPPHOENIXROD"; } States { Spawn: FX09 ABABA 2 BRIGHT; FX09 B 2 BRIGHT A_FlameEnd; FX09 CDEF 2 BRIGHT; Stop; Death: FX09 G 3 BRIGHT; FX09 H 3 BRIGHT A_FloatPuff; FX09 I 4 BRIGHT; FX09 JK 5 BRIGHT; Stop; } override int DoSpecialDamage (Actor target, int damage, Name damagetype) { if (target.player && Random[PhoenixFX2]() < 128) { // Freeze player for a bit target.reactiontime += 4; } return damage; } //---------------------------------------------------------------------------- // // PROC A_FlameEnd // //---------------------------------------------------------------------------- void A_FlameEnd() { Vel.Z += 1.5; } //---------------------------------------------------------------------------- // // PROC A_FloatPuff // //---------------------------------------------------------------------------- void A_FloatPuff() { Vel.Z += 1.8; } } /* ** a_weaponpieces.cpp ** Implements generic weapon pieces ** **--------------------------------------------------------------------------- ** Copyright 2006-2016 Christoph Oelckers ** Copyright 2006-2016 Randy Heit ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** 3. The name of the author may not be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** */ class WeaponHolder : Inventory { int PieceMask; Class PieceWeapon; Default { +NOBLOCKMAP +NOSECTOR +INVENTORY.UNDROPPABLE } } class WeaponPiece : Inventory { Default { +WEAPONSPAWN; } int PieceValue; Class WeaponClass; Weapon FullWeapon; property number: PieceValue; property weapon: WeaponClass; //========================================================================== // // TryPickupWeaponPiece // //========================================================================== override bool TryPickupRestricted (in out Actor toucher) { // Wrong class, but try to pick up for ammo if (ShouldStay()) { // Can't pick up weapons for other classes in coop netplay return false; } let Defaults = GetDefaultByType(WeaponClass); bool gaveSome = !!(toucher.GiveAmmo (Defaults.AmmoType1, Defaults.AmmoGive1) + toucher.GiveAmmo (Defaults.AmmoType2, Defaults.AmmoGive2)); if (gaveSome) { GoAwayAndDie (); } return gaveSome; } //========================================================================== // // TryPickupWeaponPiece // //========================================================================== override bool TryPickup (in out Actor toucher) { Inventory item; WeaponHolder hold = NULL; bool shouldStay = ShouldStay (); int gaveAmmo; let Defaults = GetDefaultByType(WeaponClass); FullWeapon = NULL; for(item=toucher.Inv; item; item=item.Inv) { hold = WeaponHolder(item); if (hold != null) { if (hold.PieceWeapon == WeaponClass) { break; } hold = NULL; } } if (!hold) { hold = WeaponHolder(Spawn("WeaponHolder")); hold.BecomeItem(); hold.AttachToOwner(toucher); hold.PieceMask = 0; hold.PieceWeapon = WeaponClass; } int pieceval = 1 << (PieceValue - 1); if (shouldStay) { // Cooperative net-game if (hold.PieceMask & pieceval) { // Already has the piece return false; } toucher.GiveAmmo (Defaults.AmmoType1, Defaults.AmmoGive1); toucher.GiveAmmo (Defaults.AmmoType2, Defaults.AmmoGive2); } else { // Deathmatch or singleplayer game gaveAmmo = toucher.GiveAmmo (Defaults.AmmoType1, Defaults.AmmoGive1) + toucher.GiveAmmo (Defaults.AmmoType2, Defaults.AmmoGive2); if (hold.PieceMask & pieceval) { // Already has the piece, check if mana needed if (!gaveAmmo) return false; GoAwayAndDie(); return true; } } hold.PieceMask |= pieceval; // Check if weapon assembled if (hold.PieceMask == (1 << Defaults.health) - 1) { if (!toucher.FindInventory (WeaponClass)) { FullWeapon= Weapon(Spawn(WeaponClass)); // The weapon itself should not give more ammo to the player. FullWeapon.AmmoGive1 = 0; FullWeapon.AmmoGive2 = 0; FullWeapon.AttachToOwner(toucher); FullWeapon.AmmoGive1 = Defaults.AmmoGive1; FullWeapon.AmmoGive2 = Defaults.AmmoGive2; } } GoAwayAndDie(); return true; } //=========================================================================== // // // //=========================================================================== override bool ShouldStay () { // We want a weapon piece to behave like a weapon, so follow the exact // same logic as weapons when deciding whether or not to stay. return (((multiplayer && (!deathmatch && !alwaysapplydmflags)) || sv_weaponstay) && !bDropped); } //=========================================================================== // // PickupMessage // // Returns the message to print when this actor is picked up. // //=========================================================================== override String PickupMessage () { if (FullWeapon) { return FullWeapon.PickupMessage(); } else { return Super.PickupMessage(); } } //=========================================================================== // // DoPlayPickupSound // // Plays a sound when this actor is picked up. // //=========================================================================== override void PlayPickupSound (Actor toucher) { if (FullWeapon) { FullWeapon.PlayPickupSound(toucher); } else { Super.PlayPickupSound(toucher); } } } // -------------------------------------------------------------------------- // // Pistol // // -------------------------------------------------------------------------- class Pistol : DoomWeapon { Default { Weapon.SelectionOrder 1900; Weapon.AmmoUse 1; Weapon.AmmoGive 20; Weapon.AmmoType "Clip"; Obituary "$OB_MPPISTOL"; +WEAPON.WIMPY_WEAPON Inventory.Pickupmessage "$PICKUP_PISTOL_DROPPED"; Tag "$TAG_PISTOL"; } States { Ready: PISG A 1 A_WeaponReady; Loop; Deselect: PISG A 1 A_Lower; Loop; Select: PISG A 1 A_Raise; Loop; Fire: PISG A 4; PISG B 6 A_FirePistol; PISG C 4; PISG B 5 A_ReFire; Goto Ready; Flash: PISF A 7 Bright A_Light1; Goto LightDone; PISF A 7 Bright A_Light1; Goto LightDone; Spawn: PIST A -1; Stop; } } //=========================================================================== // // Code (must be attached to StateProvider) // //=========================================================================== extend class StateProvider { //=========================================================================== // This is also used by the shotgun and chaingun //=========================================================================== protected action void GunShot(bool accurate, Class pufftype, double pitch) { int damage = 5 * random[GunShot](1, 3); double ang = angle; if (!accurate) { ang += Random2[GunShot]() * (5.625 / 256); if (GetCVar ("vertspread") && !sv_novertspread) { pitch += Random2[GunShot]() * (3.549 / 256); } } LineAttack(ang, PLAYERMISSILERANGE, pitch, damage, 'Hitscan', pufftype); } //=========================================================================== action void A_FirePistol() { bool accurate; if (player != null) { Weapon weap = player.ReadyWeapon; if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { if (!weap.DepleteAmmo (weap.bAltFire, true, 1)) return; player.SetPsprite(PSP_FLASH, weap.FindState('Flash'), true); } player.mo.PlayAttacking2 (); accurate = !player.refire; } else { accurate = true; } A_StartSound ("weapons/pistol", CHAN_WEAPON); GunShot (accurate, "BulletPuff", BulletSlope ()); } } // -------------------------------------------------------------------------- // // Plasma rifle // // -------------------------------------------------------------------------- class PlasmaRifle : DoomWeapon { Default { Weapon.SelectionOrder 100; Weapon.AmmoUse 1; Weapon.AmmoGive 40; Weapon.AmmoType "Cell"; Inventory.PickupMessage "$GOTPLASMA"; Tag "$TAG_PLASMARIFLE"; } States { Ready: PLSG A 1 A_WeaponReady; Loop; Deselect: PLSG A 1 A_Lower; Loop; Select: PLSG A 1 A_Raise; Loop; Fire: PLSG A 3 A_FirePlasma; PLSG B 20 A_ReFire; Goto Ready; Flash: PLSF A 4 Bright A_Light1; Goto LightDone; PLSF B 4 Bright A_Light1; Goto LightDone; Spawn: PLAS A -1; Stop; } } class PlasmaBall : Actor { Default { Radius 13; Height 8; Speed 25; Damage 5; Projectile; +RANDOMIZE +ZDOOMTRANS RenderStyle "Add"; Alpha 0.75; SeeSound "weapons/plasmaf"; DeathSound "weapons/plasmax"; Obituary "$OB_MPPLASMARIFLE"; } States { Spawn: PLSS AB 6 Bright; Loop; Death: PLSE ABCDE 4 Bright; Stop; } } // -------------------------------------------------------------------------- // // BFG 2704 // // -------------------------------------------------------------------------- class PlasmaBall1 : PlasmaBall { Default { Damage 4; BounceType "Classic"; BounceFactor 1.0; Obituary "$OB_MPBFG_MBF"; } States { Spawn: PLS1 AB 6 Bright; Loop; Death: PLS1 CDEFG 4 Bright; Stop; } } class PlasmaBall2 : PlasmaBall1 { States { Spawn: PLS2 AB 6 Bright; Loop; Death: PLS2 CDE 4 Bright; Stop; } } //=========================================================================== // // Code (must be attached to StateProvider) // //=========================================================================== extend class StateProvider { //=========================================================================== // // A_FirePlasma // //=========================================================================== action void A_FirePlasma() { if (player == null) { return; } Weapon weap = player.ReadyWeapon; if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { if (!weap.DepleteAmmo (weap.bAltFire, true, 1)) return; State flash = weap.FindState('Flash'); if (flash != null) { player.SetSafeFlash(weap, flash, random[FirePlasma](0, 1)); } } SpawnPlayerMissile ("PlasmaBall"); } } // -------------------------------------------------------------------------- // // Rocket launcher // // -------------------------------------------------------------------------- class RocketLauncher : DoomWeapon { Default { Weapon.SelectionOrder 2500; Weapon.AmmoUse 1; Weapon.AmmoGive 2; Weapon.AmmoType "RocketAmmo"; +WEAPON.NOAUTOFIRE Inventory.PickupMessage "$GOTLAUNCHER"; Tag "$TAG_ROCKETLAUNCHER"; } States { Ready: MISG A 1 A_WeaponReady; Loop; Deselect: MISG A 1 A_Lower; Loop; Select: MISG A 1 A_Raise; Loop; Fire: MISG B 8 A_GunFlash; MISG B 12 A_FireMissile; MISG B 0 A_ReFire; Goto Ready; Flash: MISF A 3 Bright A_Light1; MISF B 4 Bright; MISF CD 4 Bright A_Light2; Goto LightDone; Spawn: LAUN A -1; Stop; } } class Rocket : Actor { Default { Radius 11; Height 8; Speed 20; Damage 20; Projectile; +RANDOMIZE +DEHEXPLOSION +ROCKETTRAIL +ZDOOMTRANS SeeSound "weapons/rocklf"; DeathSound "weapons/rocklx"; Obituary "$OB_MPROCKET"; } States { Spawn: MISL A 1 Bright; Loop; Death: MISL B 8 Bright A_Explode; MISL C 6 Bright; MISL D 4 Bright; Stop; BrainExplode: MISL BC 10 Bright; MISL D 10 A_BrainExplode; Stop; } } // -------------------------------------------------------------------------- // // Grenade -- Taken and adapted from Skulltag, with MBF stuff added to it // // -------------------------------------------------------------------------- class Grenade : Actor { Default { Radius 8; Height 8; Speed 25; Damage 20; Projectile; -NOGRAVITY +RANDOMIZE +DEHEXPLOSION +GRENADETRAIL BounceType "Doom"; Gravity 0.25; SeeSound "weapons/grenlf"; DeathSound "weapons/grenlx"; BounceSound "weapons/grbnce"; Obituary "$OB_GRENADE"; DamageType "Grenade"; } States { Spawn: SGRN A 1 Bright; Loop; Death: MISL B 8 Bright A_Explode; MISL C 6 Bright; MISL D 4 Bright; Stop; Grenade: MISL A 1000 A_Die; Wait; Detonate: MISL B 4 A_Scream; MISL C 6 A_Detonate; MISL D 10; Stop; Mushroom: MISL B 8 A_Mushroom; Goto Death+1; } } //=========================================================================== // // Code (must be attached to StateProvider) // //=========================================================================== extend class StateProvider { //=========================================================================== // // A_FireMissile // //=========================================================================== action void A_FireMissile() { if (player == null) { return; } Weapon weap = player.ReadyWeapon; if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { if (!weap.DepleteAmmo (weap.bAltFire, true, 1)) return; } SpawnPlayerMissile ("Rocket"); } //=========================================================================== // // A_FireSTGrenade: not exactly backported from ST, but should work the same // //=========================================================================== action void A_FireSTGrenade(class grenadetype = "Grenade") { if (grenadetype == null) return; if (player == null) { return; } Weapon weap = player.ReadyWeapon; if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { if (!weap.DepleteAmmo (weap.bAltFire, true, 1)) return; } // Temporarily raise the pitch to send the grenadetype slightly upwards double savedpitch = pitch; pitch -= 6.328125; SpawnPlayerMissile(grenadetype); pitch = SavedPitch; } } class Weapon : StateProvider { enum EFireMode { PrimaryFire, AltFire, EitherFire }; const ZOOM_INSTANT = 1; const ZOOM_NOSCALETURNING = 2; deprecated("3.7") uint WeaponFlags; // not to be used directly. class AmmoType1, AmmoType2; // Types of ammo used by self weapon int AmmoGive1, AmmoGive2; // Amount of each ammo to get when picking up weapon deprecated("3.7") int MinAmmo1, MinAmmo2; // not used anywhere and thus deprecated. int AmmoUse1, AmmoUse2; // How much ammo to use with each shot int Kickback; double YAdjust; // For viewing the weapon fullscreen sound UpSound, ReadySound; // Sounds when coming up and idle class SisterWeaponType; // Another weapon to pick up with self one int SelectionOrder; // Lower-numbered weapons get picked first int MinSelAmmo1, MinSelAmmo2; // Ignore in BestWeapon() if inadequate ammo int ReloadCounter; // For A_CheckForReload int BobStyle; // [XA] Bobbing style. Defines type of bobbing (e.g. Normal, Alpha) (visual only so no need to be a double) float BobSpeed; // [XA] Bobbing speed. Defines how quickly a weapon bobs. float BobRangeX, BobRangeY; // [XA] Bobbing range. Defines how far a weapon bobs in either direction. double WeaponScaleX, WeaponScaleY; // [XA] Weapon scale. Defines the scale for the held weapon sprites (PSprite). Defaults to (1.0, 1.2) since that's what Doom does. Ammo Ammo1, Ammo2; // In-inventory instance variables Weapon SisterWeapon; double FOVScale; double LookScale; // Multiplier for look sensitivity (like FOV scaling but without the zooming) int Crosshair; // 0 to use player's crosshair bool GivenAsMorphWeapon; bool bAltFire; // Set when this weapon's alternate fire is used. readonly bool bDehAmmo; // Uses Doom's original amount of ammo for the respective attack functions so that old DEHACKED patches work as intended. // AmmoUse1 will be set to the first attack's ammo use so that checking for empty weapons still works meta int SlotNumber; meta double SlotPriority; Vector3 BobPivot3D; // Pivot used for BobWeapon3D virtual ui Vector2 ModifyBobLayer(Vector2 Bob, int layer, double ticfrac) { return Bob; } virtual ui Vector3, Vector3 ModifyBobLayer3D(Vector3 Translation, Vector3 Rotation, int layer, double ticfrac) { return Translation, Rotation; } virtual ui Vector3 ModifyBobPivotLayer3D(int layer, double ticfrac) { return BobPivot3D; } property AmmoGive: AmmoGive1; property AmmoGive1: AmmoGive1; property AmmoGive2: AmmoGive2; property AmmoUse: AmmoUse1; property AmmoUse1: AmmoUse1; property AmmoUse2: AmmoUse2; property AmmoType: AmmoType1; property AmmoType1: AmmoType1; property AmmoType2: AmmoType2; property Kickback: Kickback; property ReadySound: ReadySound; property SelectionOrder: SelectionOrder; property MinSelectionAmmo1: MinSelAmmo1; property MinSelectionAmmo2: MinSelAmmo2; property SisterWeapon: SisterWeaponType; property UpSound: UpSound; property YAdjust: YAdjust; property BobSpeed: BobSpeed; property BobRangeX: BobRangeX; property BobRangeY: BobRangeY; property WeaponScaleX: WeaponScaleX; property WeaponScaleY: WeaponScaleY; property SlotNumber: SlotNumber; property SlotPriority: SlotPriority; property LookScale: LookScale; property BobPivot3D : BobPivot3D; flagdef NoAutoFire: WeaponFlags, 0; // weapon does not autofire flagdef ReadySndHalf: WeaponFlags, 1; // ready sound is played ~1/2 the time flagdef DontBob: WeaponFlags, 2; // don't bob the weapon flagdef AxeBlood: WeaponFlags, 3; // weapon makes axe blood on impact flagdef NoAlert: WeaponFlags, 4; // weapon does not alert monsters flagdef Ammo_Optional: WeaponFlags, 5; // weapon can use ammo but does not require it flagdef Alt_Ammo_Optional: WeaponFlags, 6; // alternate fire can use ammo but does not require it flagdef Primary_Uses_Both: WeaponFlags, 7; // primary fire uses both ammo flagdef Alt_Uses_Both: WeaponFlags, 8; // alternate fire uses both ammo flagdef Wimpy_Weapon:WeaponFlags, 9; // change away when ammo for another weapon is replenished flagdef Powered_Up: WeaponFlags, 10; // this is a tome-of-power'ed version of its sister flagdef Ammo_CheckBoth: WeaponFlags, 11; // check for both primary and secondary fire before switching it off flagdef No_Auto_Switch: WeaponFlags, 12; // never switch to this weapon when it's picked up flagdef Staff2_Kickback: WeaponFlags, 13; // the powered-up Heretic staff has special kickback flagdef NoAutoaim: WeaponFlags, 14; // this weapon never uses autoaim (useful for ballistic projectiles) flagdef MeleeWeapon: WeaponFlags, 15; // melee weapon. Used by monster AI with AVOIDMELEE. flagdef NoDeathDeselect: WeaponFlags, 16; // Don't jump to the Deselect state when the player dies flagdef NoDeathInput: WeaponFlags, 17; // The weapon cannot be fired/reloaded/whatever when the player is dead flagdef CheatNotWeapon: WeaponFlags, 18; // Give cheat considers this not a weapon (used by Sigil) flagdef NoAutoSwitchTo : WeaponFlags, 19; // do not auto switch to this weapon ever! // no-op flags flagdef NoLMS: none, 0; flagdef Allow_With_Respawn_Invul: none, 0; flagdef BFG: none, 0; flagdef Explosive: none, 0; Default { Inventory.PickupSound "misc/w_pkup"; Weapon.DefaultKickback; Weapon.BobSpeed 1.0; Weapon.BobRangeX 1.0; Weapon.BobRangeY 1.0; Weapon.WeaponScaleX 1.0; Weapon.WeaponScaleY 1.2; Weapon.SlotNumber -1; Weapon.SlotPriority 32767; Weapon.BobPivot3D (0.0, 0.0, 0.0); +WEAPONSPAWN DefaultStateUsage SUF_ACTOR|SUF_OVERLAY|SUF_WEAPON; } States { LightDone: SHTG E 0 A_Light0; Stop; } //=========================================================================== // // Weapon :: MarkPrecacheSounds // //=========================================================================== override void MarkPrecacheSounds() { Super.MarkPrecacheSounds(); MarkSound(UpSound); MarkSound(ReadySound); } virtual int, int CheckAddToSlots() { if (GetReplacement(GetClass()) == GetClass() && !bPowered_Up) { return SlotNumber, int(SlotPriority*65536); } return -1, 0; } virtual State GetReadyState () { return FindState('Ready'); } virtual State GetUpState () { return FindState('Select'); } virtual State GetDownState () { return FindState('Deselect'); } virtual State GetAtkState (bool hold) { State s = null; if (hold) s = FindState('Hold'); if (s == null) s = FindState('Fire'); return s; } virtual State GetAltAtkState (bool hold) { State s = null; if (hold) s = FindState('AltHold'); if (s == null) s = FindState('AltFire'); return s; } virtual void PlayUpSound(Actor origin) { if (UpSound) { origin.A_StartSound(UpSound, CHAN_WEAPON); } } override String GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack) { // Weapons may never return HitObituary by default. Override this if it is needed. return Obituary; } action void A_GunFlash(statelabel flashlabel = null, int flags = 0) { let player = player; if (null == player || player.ReadyWeapon == null) { return; } if (!(flags & GFF_NOEXTCHANGE)) { player.mo.PlayAttacking2 (); } Weapon weapon = player.ReadyWeapon; state flashstate = null; if (flashlabel == null) { if (weapon.bAltFire) { flashstate = weapon.FindState('AltFlash'); } if (flashstate == null) { flashstate = weapon.FindState('Flash'); } } else { flashstate = weapon.FindState(flashlabel); } player.SetPsprite(PSP_FLASH, flashstate); } //--------------------------------------------------------------------------- // // PROC A_Lower // //--------------------------------------------------------------------------- action void ResetPSprite(PSprite psp) { if (!psp) return; psp.rotation = 0; psp.baseScale.x = invoker.WeaponScaleX; psp.baseScale.y = invoker.WeaponScaleY; psp.scale.x = 1; psp.scale.y = 1; psp.pivot.x = 0; psp.pivot.y = 0; psp.valign = 0; psp.halign = 0; psp.Coord0 = (0,0); psp.Coord1 = (0,0); psp.Coord2 = (0,0); psp.Coord3 = (0,0); } action void A_Lower(int lowerspeed = 6) { let player = player; if (null == player) { return; } if (null == player.ReadyWeapon) { player.mo.BringUpWeapon(); return; } let psp = player.GetPSprite(PSP_WEAPON); if (!psp) return; if (player.morphTics || player.cheats & CF_INSTANTWEAPSWITCH) { psp.y = WEAPONBOTTOM; } else { psp.y += lowerspeed; } if (psp.y < WEAPONBOTTOM) { // Not lowered all the way yet return; } ResetPSprite(psp); if (player.playerstate == PST_DEAD) { // Player is dead, so don't bring up a pending weapon // Player is dead, so keep the weapon off screen player.SetPsprite(PSP_FLASH, null); psp.SetState(player.ReadyWeapon.FindState('DeadLowered')); return; } // [RH] Clear the flash state. Only needed for Strife. player.SetPsprite(PSP_FLASH, null); player.mo.BringUpWeapon (); return; } //--------------------------------------------------------------------------- // // PROC A_Raise // //--------------------------------------------------------------------------- action void A_Raise(int raisespeed = 6) { let player = player; if (null == player) { return; } if (player.PendingWeapon != WP_NOCHANGE) { player.mo.DropWeapon(); return; } if (player.ReadyWeapon == null) { return; } let psp = player.GetPSprite(PSP_WEAPON); if (!psp) return; if (psp.y <= WEAPONBOTTOM) { ResetPSprite(psp); } psp.y -= raisespeed; if (psp.y > WEAPONTOP) { // Not raised all the way yet return; } psp.y = WEAPONTOP; psp.SetState(player.ReadyWeapon.GetReadyState()); return; } //============================================================================ // // PROC A_WeaponReady // // Readies a weapon for firing or bobbing with its three ancillary functions, // DoReadyWeaponToSwitch(), DoReadyWeaponToFire() and DoReadyWeaponToBob(). // [XA] Added DoReadyWeaponToReload() and DoReadyWeaponToZoom() // //============================================================================ static void DoReadyWeaponToSwitch (PlayerInfo player, bool switchable) { // Prepare for switching action. if (switchable) { player.WeaponState |= WF_WEAPONSWITCHOK | WF_REFIRESWITCHOK; } else { // WF_WEAPONSWITCHOK is automatically cleared every tic by P_SetPsprite(). player.WeaponState &= ~WF_REFIRESWITCHOK; } } static void DoReadyWeaponDisableSwitch (PlayerInfo player, int disable) { // Discard all switch attempts? if (disable) { player.WeaponState |= WF_DISABLESWITCH; player.WeaponState &= ~WF_REFIRESWITCHOK; } else { player.WeaponState &= ~WF_DISABLESWITCH; } } static void DoReadyWeaponToFire (PlayerPawn pawn, bool prim, bool alt) { let player = pawn.player; let weapon = player.ReadyWeapon; if (!weapon) { return; } // Change player from attack state if (pawn.InStateSequence(pawn.curstate, pawn.MissileState) || pawn.InStateSequence(pawn.curstate, pawn.MeleeState)) { pawn.PlayIdle (); } // Play ready sound, if any. let psp = player.GetPSprite(PSP_WEAPON); if (weapon.ReadySound && psp && psp.curState == weapon.FindState('Ready')) { if (!weapon.bReadySndHalf || random[WpnReadySnd]() < 128) { pawn.A_StartSound(weapon.ReadySound, CHAN_WEAPON); } } // Prepare for firing action. player.WeaponState |= ((prim ? WF_WEAPONREADY : 0) | (alt ? WF_WEAPONREADYALT : 0)); return; } static void DoReadyWeaponToBob (PlayerInfo player) { if (player.ReadyWeapon) { // Prepare for bobbing action. player.WeaponState |= WF_WEAPONBOBBING; let pspr = player.GetPSprite(PSP_WEAPON); if (pspr) { pspr.x = 0; pspr.y = WEAPONTOP; } } } static int GetButtonStateFlags(int flags) { // Rewritten for efficiency and clarity int outflags = 0; if (flags & WRF_AllowZoom) outflags |= WF_WEAPONZOOMOK; if (flags & WRF_AllowReload) outflags |= WF_WEAPONRELOADOK; if (flags & WRF_AllowUser1) outflags |= WF_USER1OK; if (flags & WRF_AllowUser2) outflags |= WF_USER2OK; if (flags & WRF_AllowUser3) outflags |= WF_USER3OK; if (flags & WRF_AllowUser4) outflags |= WF_USER4OK; return outflags; } action void A_WeaponReady(int flags = 0) { if (!player) return; DoReadyWeaponToSwitch(player, !(flags & WRF_NoSwitch)); if ((flags & WRF_NoFire) != WRF_NoFire) DoReadyWeaponToFire(player.mo, !(flags & WRF_NoPrimary), !(flags & WRF_NoSecondary)); if (!(flags & WRF_NoBob)) DoReadyWeaponToBob(player); player.WeaponState |= GetButtonStateFlags(flags); DoReadyWeaponDisableSwitch(player, flags & WRF_DisableSwitch); } //--------------------------------------------------------------------------- // // PROC A_CheckReload // // Present in Doom, but unused. Also present in Strife, and actually used. // //--------------------------------------------------------------------------- action void A_CheckReload() { let player = self.player; if (player != NULL) { player.ReadyWeapon.CheckAmmo (player.ReadyWeapon.bAltFire ? Weapon.AltFire : Weapon.PrimaryFire, true); } } //=========================================================================== // // A_ZoomFactor // //=========================================================================== action void A_ZoomFactor(double zoom = 1, int flags = 0) { let player = self.player; if (player != NULL && player.ReadyWeapon != NULL) { zoom = 1 / clamp(zoom, 0.1, 50.0); if (flags & 1) { // Make the zoom instant. player.FOV = player.DesiredFOV * zoom; player.cheats |= CF_NOFOVINTERP; } if (flags & 2) { // Disable pitch/yaw scaling. zoom = -zoom; } player.ReadyWeapon.FOVScale = zoom; } } //=========================================================================== // // A_SetCrosshair // //=========================================================================== action void A_SetCrosshair(int xhair) { let player = self.player; if (player != NULL && player.ReadyWeapon != NULL) { player.ReadyWeapon.Crosshair = xhair; } } //=========================================================================== // // Weapon :: TryPickup // // If you can't see the weapon when it's active, then you can't pick it up. // //=========================================================================== override bool TryPickupRestricted (in out Actor toucher) { // Wrong class, but try to pick up for ammo if (ShouldStay()) { // Can't pick up weapons for other classes in coop netplay return false; } bool gaveSome = (NULL != AddAmmo (toucher, AmmoType1, AmmoGive1)); gaveSome |= (NULL != AddAmmo (toucher, AmmoType2, AmmoGive2)); if (gaveSome) { GoAwayAndDie (); } return gaveSome; } //=========================================================================== // // Weapon :: TryPickup // //=========================================================================== override bool TryPickup (in out Actor toucher) { State ReadyState = FindState('Ready'); if (ReadyState != NULL && ReadyState.ValidateSpriteFrame()) { return Super.TryPickup (toucher); } return false; } //=========================================================================== // // Weapon :: Use // // Make the player switch to self weapon. // //=========================================================================== override bool Use (bool pickup) { Weapon useweap = self; // Powered up weapons cannot be used directly. if (bPowered_Up) return false; // If the player is powered-up, use the alternate version of the // weapon, if one exists. if (SisterWeapon != NULL && SisterWeapon.bPowered_Up && Owner.FindInventory ("PowerWeaponLevel2", true)) { useweap = SisterWeapon; } if (Owner.player != NULL && Owner.player.ReadyWeapon != useweap) { Owner.player.PendingWeapon = useweap; } // Return false so that the weapon is not removed from the inventory. return false; } //=========================================================================== // // Weapon :: Destroy // //=========================================================================== override void OnDestroy() { let sister = SisterWeapon; if (sister != NULL) { // avoid recursion sister.SisterWeapon = NULL; if (sister != self) { // In case we are our own sister, don't crash. sister.Destroy(); } } Super.OnDestroy(); } //=========================================================================== // // Weapon :: HandlePickup // // Try to leach ammo from the weapon if you have it already. // //=========================================================================== override bool HandlePickup (Inventory item) { if (item.GetClass() == GetClass()) { if (Weapon(item).PickupForAmmo (self)) { item.bPickupGood = true; } if (MaxAmount > 1) //[SP] If amount 0) gotstuff = AddExistingAmmo (ownedWeapon.Ammo1, AmmoGive1); if (AmmoGive2 > 0) gotstuff |= AddExistingAmmo (ownedWeapon.Ammo2, AmmoGive2); let Owner = ownedWeapon.Owner; if (gotstuff && Owner != NULL && Owner.player != NULL) { if (ownedWeapon.Ammo1 != NULL && oldamount1 == 0) { PlayerPawn(Owner).CheckWeaponSwitch(ownedWeapon.Ammo1.GetClass()); } else if (ownedWeapon.Ammo2 != NULL && oldamount2 == 0) { PlayerPawn(Owner).CheckWeaponSwitch(ownedWeapon.Ammo2.GetClass()); } } } return gotstuff; } //=========================================================================== // // Weapon :: CreateCopy // //=========================================================================== override Inventory CreateCopy (Actor other) { let copy = Weapon(Super.CreateCopy (other)); if (copy != self && copy != null) { copy.AmmoGive1 = AmmoGive1; copy.AmmoGive2 = AmmoGive2; } return copy; } //=========================================================================== // // Weapon :: CreateTossable // // A weapon that's tossed out should contain no ammo, so you can't cheat // by dropping it and then picking it back up. // //=========================================================================== override Inventory CreateTossable (int amt) { // Only drop the weapon that is meant to be placed in a level. That is, // only drop the weapon that normally gives you ammo. if (SisterWeapon != NULL && Default.AmmoGive1 == 0 && Default.AmmoGive2 == 0 && (SisterWeapon.Default.AmmoGive1 > 0 || SisterWeapon.Default.AmmoGive2 > 0)) { return SisterWeapon.CreateTossable (amt); } let copy = Weapon(Super.CreateTossable (-1)); if (copy != NULL) { // If self weapon has a sister, remove it from the inventory too. if (SisterWeapon != NULL) { SisterWeapon.SisterWeapon = NULL; SisterWeapon.Destroy (); } // To avoid exploits, the tossed weapon must not have any ammo. copy.AmmoGive1 = 0; copy.AmmoGive2 = 0; } return copy; } //=========================================================================== // // Weapon :: AttachToOwner // //=========================================================================== override void AttachToOwner (Actor other) { Super.AttachToOwner (other); Ammo1 = AddAmmo (Owner, AmmoType1, AmmoGive1); Ammo2 = AddAmmo (Owner, AmmoType2, AmmoGive2); SisterWeapon = AddWeapon (SisterWeaponType); if (Owner.player != NULL) { if (!Owner.player.GetNeverSwitch() && !bNo_Auto_Switch) { Owner.player.PendingWeapon = self; } if (Owner.player.mo == players[consoleplayer].camera) { StatusBar.ReceivedWeapon (self); } } GivenAsMorphWeapon = false; // will be set explicitly by morphing code } //=========================================================================== // // Weapon :: AddAmmo // // Give some ammo to the owner, even if it's just 0. // //=========================================================================== protected Ammo AddAmmo (Actor other, Class ammotype, int amount) { Ammo ammoitem; if (ammotype == NULL) { return NULL; } // [BC] This behavior is from the original Doom. Give 5/2 times as much ammoitem when // we pick up a weapon in deathmatch. if (( deathmatch && !sv_noextraammo ) && ( gameinfo.gametype & GAME_DoomChex )) amount = amount * 5 / 2; // extra ammoitem in baby mode and nightmare mode if (!bIgnoreSkill) { amount = int(amount * (G_SkillPropertyFloat(SKILLP_AmmoFactor) * sv_ammofactor)); } ammoitem = Ammo(other.FindInventory (ammotype)); if (ammoitem == NULL) { ammoitem = Ammo(Spawn (ammotype)); ammoitem.Amount = MIN (amount, ammoitem.MaxAmount); ammoitem.AttachToOwner (other); } else if (ammoitem.Amount < ammoitem.MaxAmount || sv_unlimited_pickup) { ammoitem.Amount += amount; if (ammoitem.Amount > ammoitem.MaxAmount && !sv_unlimited_pickup) { ammoitem.Amount = ammoitem.MaxAmount; } } return ammoitem; } //=========================================================================== // // Weapon :: AddExistingAmmo // // Give the owner some more ammo he already has. // //=========================================================================== protected bool AddExistingAmmo (Inventory ammo, int amount) { if (ammo != NULL && (ammo.Amount < ammo.MaxAmount || sv_unlimited_pickup)) { // extra ammo in baby mode and nightmare mode if (!bIgnoreSkill) { amount = int(amount * (G_SkillPropertyFloat(SKILLP_AmmoFactor) * sv_ammofactor)); } ammo.Amount += amount; if (ammo.Amount > ammo.MaxAmount && !sv_unlimited_pickup) { ammo.Amount = ammo.MaxAmount; } return true; } return false; } //=========================================================================== // // Weapon :: AddWeapon // // Give the owner a weapon if they don't have it already. // //=========================================================================== protected Weapon AddWeapon (Class weapontype) { Weapon weap; if (weapontype == NULL) { return NULL; } weap = Weapon(Owner.FindInventory (weapontype)); if (weap == NULL) { weap = Weapon(Spawn (weapontype)); weap.AttachToOwner (Owner); } return weap; } //=========================================================================== // // Weapon :: ShouldStay // //=========================================================================== override bool ShouldStay () { if (((multiplayer && (!deathmatch && !alwaysapplydmflags)) || sv_weaponstay) && !bDropped) { return true; } return false; } //=========================================================================== // // Weapon :: EndPowerUp // // The Tome of Power just expired. // //=========================================================================== virtual void EndPowerup () { let player = Owner.player; if (SisterWeapon != NULL && bPowered_Up) { let ready = GetReadyState(); if (ready != SisterWeapon.GetReadyState()) { if (player.PendingWeapon == NULL || player.PendingWeapon == WP_NOCHANGE) { player.refire = 0; player.ReadyWeapon = SisterWeapon; player.SetPsprite(PSP_WEAPON, SisterWeapon.GetReadyState()); } } else { let psp = player.FindPSprite(PSP_WEAPON); if (psp != null && psp.Caller == player.ReadyWeapon && psp.CurState.InStateSequence(ready)) { // If the weapon changes but the state does not, we have to manually change the PSprite's caller here. psp.Caller = SisterWeapon; player.ReadyWeapon = SisterWeapon; } else { if (player.PendingWeapon == NULL || player.PendingWeapon == WP_NOCHANGE) { // Something went wrong. Initiate a regular weapon change. player.refire = 0; player.ReadyWeapon = SisterWeapon; player.SetPsprite(PSP_WEAPON, SisterWeapon.GetReadyState()); } } } } } //=========================================================================== // // Weapon :: PostMorphWeapon // // Bring this weapon up after a player unmorphs. // //=========================================================================== void PostMorphWeapon () { if (Owner == null) { return; } let p = owner.player; p.PendingWeapon = WP_NOCHANGE; p.ReadyWeapon = self; p.refire = 0; let pspr = p.GetPSprite(PSP_WEAPON); if (pspr) { pspr.y = WEAPONBOTTOM; pspr.ResetInterpolation(); pspr.SetState(GetUpState()); } } //=========================================================================== // // Weapon :: CheckAmmo // // Returns true if there is enough ammo to shoot. If not, selects the // next weapon to use. // //=========================================================================== virtual bool CheckAmmo(int fireMode, bool autoSwitch, bool requireAmmo = false, int ammocount = -1) { int count1, count2; int enough, enoughmask; int lAmmoUse1; int lAmmoUse2 = AmmoUse2; if (sv_infiniteammo || (Owner.FindInventory ('PowerInfiniteAmmo', true) != null)) { return true; } if (fireMode == EitherFire) { bool gotSome = CheckAmmo (PrimaryFire, false) || CheckAmmo (AltFire, false); if (!gotSome && autoSwitch) { PlayerPawn(Owner).PickNewWeapon (null); } return gotSome; } let altFire = (fireMode == AltFire); let optional = (altFire? bAlt_Ammo_Optional : bAmmo_Optional); let useboth = (altFire? bAlt_Uses_Both : bPrimary_Uses_Both); if (!requireAmmo && optional) { return true; } count1 = (Ammo1 != null) ? Ammo1.Amount : 0; count2 = (Ammo2 != null) ? Ammo2.Amount : 0; if (ammocount >= 0) { lAmmoUse1 = ammocount; lAmmoUse2 = ammocount; } else if (bDehAmmo && Ammo1 == null) { lAmmoUse1 = 0; } else { lAmmoUse1 = AmmoUse1; } enough = (count1 >= lAmmoUse1) | ((count2 >= lAmmoUse2) << 1); if (useboth) { enoughmask = 3; } else { enoughmask = 1 << altFire; } if (altFire && FindState('AltFire') == null) { // If this weapon has no alternate fire, then there is never enough ammo for it enough &= 1; } if (((enough & enoughmask) == enoughmask) || (enough && bAmmo_CheckBoth)) { return true; } // out of ammo, pick a weapon to change to if (autoSwitch) { PlayerPawn(Owner).PickNewWeapon (null); } return false; } //=========================================================================== // // Weapon :: DepleteAmmo // // Use up some of the weapon's ammo. Returns true if the ammo was successfully // depleted. If checkEnough is false, then the ammo will always be depleted, // even if it drops below zero. // //=========================================================================== virtual bool DepleteAmmo(bool altFire, bool checkEnough = true, int ammouse = -1, bool forceammouse = false) { if (!(sv_infiniteammo || (Owner.FindInventory ('PowerInfiniteAmmo', true) != null))) { if (checkEnough && !CheckAmmo (altFire ? AltFire : PrimaryFire, false, false, ammouse)) { return false; } if (!altFire) { if (Ammo1 != null) { if (ammouse >= 0 && (bDehAmmo || forceammouse)) { Ammo1.Amount -= ammouse; } else { Ammo1.Amount -= AmmoUse1; } } if (bPRIMARY_USES_BOTH && Ammo2 != null) { Ammo2.Amount -= AmmoUse2; } } else { if (Ammo2 != null) { Ammo2.Amount -= AmmoUse2; } if (bALT_USES_BOTH && Ammo1 != null) { Ammo1.Amount -= AmmoUse1; } } if (Ammo1 != null && Ammo1.Amount < 0) Ammo1.Amount = 0; if (Ammo2 != null && Ammo2.Amount < 0) Ammo2.Amount = 0; } return true; } //--------------------------------------------------------------------------- // // Modifies the drop amount of this item according to the current skill's // settings (also called by ADehackedPickup::TryPickup) // //--------------------------------------------------------------------------- override void ModifyDropAmount(int dropamount) { bool ignoreskill = true; double dropammofactor = G_SkillPropertyFloat(SKILLP_DropAmmoFactor); // Default drop amount is half of regular amount * regular ammo multiplication if (dropammofactor == -1) { dropammofactor = 0.5; ignoreskill = false; } if (dropamount > 0) { self.Amount = dropamount; } // Adjust the ammo given by this weapon AmmoGive1 = int(AmmoGive1 * dropammofactor); AmmoGive2 = int(AmmoGive2 * dropammofactor); bIgnoreSkill = ignoreskill; } } class WeaponGiver : Weapon { double AmmoFactor; Default { Weapon.AmmoGive1 -1; Weapon.AmmoGive2 -1; } override bool TryPickup(in out Actor toucher) { DropItem di = GetDropItems(); Weapon weap; if (di != NULL) { Class ti = di.Name; if (ti != NULL) { if (master == NULL) { // save the spawned weapon in 'master' to avoid constant respawning if it cannot be picked up. master = weap = Weapon(Spawn(di.Name)); if (weap != NULL) { weap.bAlwaysPickup = false; // use the flag of self item only. weap.bDropped = bDropped; // If our ammo gives are non-negative, transfer them to the real weapon. if (AmmoGive1 >= 0) weap.AmmoGive1 = AmmoGive1; if (AmmoGive2 >= 0) weap.AmmoGive2 = AmmoGive2; // If AmmoFactor is non-negative, modify the given ammo amounts. if (AmmoFactor > 0) { weap.AmmoGive1 = int(weap.AmmoGive1 * AmmoFactor); weap.AmmoGive2 = int(weap.AmmoGive2 * AmmoFactor); } weap.BecomeItem(); } else return false; } weap = Weapon(master); bool res = false; if (weap != null) { res = weap.CallTryPickup(toucher); if (res) { GoAwayAndDie(); master = NULL; } } return res; } } return false; } //--------------------------------------------------------------------------- // // Modifies the drop amount of this item according to the current skill's // settings (also called by ADehackedPickup::TryPickup) // //--------------------------------------------------------------------------- override void ModifyDropAmount(int dropamount) { bool ignoreskill = true; double dropammofactor = G_SkillPropertyFloat(SKILLP_DropAmmoFactor); // Default drop amount is half of regular amount * regular ammo multiplication if (dropammofactor == -1) { dropammofactor = 0.5; ignoreskill = false; } AmmoFactor = dropammofactor; bIgnoreSkill = ignoreskill; } } struct WeaponSlots native { native bool, int, int LocateWeapon(class weap) const; native static void SetupWeaponSlots(PlayerPawn pp); native class GetWeapon(int slot, int index) const; native int SlotSize(int slot) const; } // -------------------------------------------------------------------------- // // Shotgun // // -------------------------------------------------------------------------- class Shotgun : DoomWeapon { Default { Weapon.SelectionOrder 1300; Weapon.AmmoUse 1; Weapon.AmmoGive 8; Weapon.AmmoType "Shell"; Inventory.PickupMessage "$GOTSHOTGUN"; Obituary "$OB_MPSHOTGUN"; Tag "$TAG_SHOTGUN"; } States { Ready: SHTG A 1 A_WeaponReady; Loop; Deselect: SHTG A 1 A_Lower; Loop; Select: SHTG A 1 A_Raise; Loop; Fire: SHTG A 3; SHTG A 7 A_FireShotgun; SHTG BC 5; SHTG D 4; SHTG CB 5; SHTG A 3; SHTG A 7 A_ReFire; Goto Ready; Flash: SHTF A 4 Bright A_Light1; SHTF B 3 Bright A_Light2; Goto LightDone; Spawn: SHOT A -1; Stop; } } //=========================================================================== // // Code (must be attached to StateProvider) // //=========================================================================== extend class StateProvider { action void A_FireShotgun() { if (player == null) { return; } A_StartSound ("weapons/shotgf", CHAN_WEAPON); Weapon weap = player.ReadyWeapon; if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { if (!weap.DepleteAmmo (weap.bAltFire, true, 1)) return; player.SetPsprite(PSP_FLASH, weap.FindState('Flash'), true); } player.mo.PlayAttacking2 (); double pitch = BulletSlope (); for (int i = 0; i < 7; i++) { GunShot (false, "BulletPuff", pitch); } } } // Skull (Horn) Rod --------------------------------------------------------- class SkullRod : HereticWeapon { Default { Weapon.SelectionOrder 200; Weapon.AmmoUse1 1; Weapon.AmmoGive1 50; Weapon.YAdjust 15; Weapon.AmmoType1 "SkullRodAmmo"; Weapon.SisterWeapon "SkullRodPowered"; Inventory.PickupMessage "$TXT_WPNSKULLROD"; Tag "$TAG_SKULLROD"; } States { Spawn: WSKL A -1; Stop; Ready: HROD A 1 A_WeaponReady; Loop; Deselect: HROD A 1 A_Lower; Loop; Select: HROD A 1 A_Raise; Loop; Fire: HROD AB 4 A_FireSkullRodPL1; HROD B 0 A_ReFire; Goto Ready; } //---------------------------------------------------------------------------- // // PROC A_FireSkullRodPL1 // //---------------------------------------------------------------------------- action void A_FireSkullRodPL1() { if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } Actor mo = SpawnPlayerMissile ("HornRodFX1"); // Randomize the first frame if (mo && random[FireSkullRod]() > 128) { mo.SetState (mo.CurState.NextState); } } } class SkullRodPowered : SkullRod { Default { +WEAPON.POWERED_UP Weapon.AmmoUse1 5; Weapon.AmmoGive1 0; Weapon.SisterWeapon "SkullRod"; Tag "$TAG_SKULLRODP"; } States { Fire: HROD C 2; HROD D 3; HROD E 2; HROD F 3; HROD G 4 A_FireSkullRodPL2; HROD F 2; HROD E 3; HROD D 2; HROD C 2 A_ReFire; Goto Ready; } //---------------------------------------------------------------------------- // // PROC A_FireSkullRodPL2 // // The special2 field holds the player number that shot the rain missile. // The special1 field holds the id of the rain sound. // //---------------------------------------------------------------------------- action void A_FireSkullRodPL2() { FTranslatedLineTarget t; if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } // Use MissileActor instead of the first return value from P_SpawnPlayerMissile // because we need to give info to it, even if it exploded immediately. Actor mo, MissileActor; [mo, MissileActor] = SpawnPlayerMissile ("HornRodFX2", angle, pLineTarget: t); if (MissileActor != null) { if (t.linetarget && !t.unlinked) { MissileActor.tracer = t.linetarget; } MissileActor.A_StartSound ("weapons/hornrodpowshoot", CHAN_WEAPON); } } } // Horn Rod FX 1 ------------------------------------------------------------ class HornRodFX1 : Actor { Default { Radius 12; Height 8; Speed 22; Damage 3; Projectile; +WINDTHRUST +ZDOOMTRANS -NOBLOCKMAP RenderStyle "Add"; SeeSound "weapons/hornrodshoot"; DeathSound "weapons/hornrodhit"; Obituary "$OB_MPSKULLROD"; } States { Spawn: FX00 AB 6 BRIGHT; Loop; Death: FX00 HI 5 BRIGHT; FX00 JK 4 BRIGHT; FX00 LM 3 BRIGHT; Stop; } } // Horn Rod FX 2 ------------------------------------------------------------ class HornRodFX2 : Actor { Default { Radius 12; Height 8; Speed 22; Damage 10; Health 140; Projectile; RenderStyle "Add"; +ZDOOMTRANS SeeSound "weapons/hornrodpowshoot"; DeathSound "weapons/hornrodpowhit"; Obituary "$OB_MPPSKULLROD"; } States { Spawn: FX00 C 3 BRIGHT; FX00 D 3 BRIGHT A_SeekerMissile(10, 30); FX00 E 3 BRIGHT; FX00 F 3 BRIGHT A_SeekerMissile(10, 30); Loop; Death: FX00 H 5 BRIGHT A_AddPlayerRain; FX00 I 5 BRIGHT; FX00 J 4 BRIGHT; FX00 KLM 3 BRIGHT; FX00 G 1 A_HideInCeiling; FX00 G 1 A_SkullRodStorm; Wait; } override int DoSpecialDamage (Actor target, int damage, Name damagetype) { Sorcerer2 s2 = Sorcerer2(target); if (s2 != null && random[HornRodFX2]() < 96) { // D'Sparil teleports away s2.DSparilTeleport (); return -1; } return damage; } //---------------------------------------------------------------------------- // // PROC A_AddPlayerRain // //---------------------------------------------------------------------------- void A_AddPlayerRain() { RainTracker tracker; if (target == null || target.health <= 0) { // Shooter is dead or nonexistent return; } tracker = RainTracker(target.FindInventory("RainTracker")); // They player is only allowed two rainstorms at a time. Shooting more // than that will cause the oldest one to terminate. if (tracker != null) { if (tracker.Rain1 && tracker.Rain2) { // Terminate an active rain if (tracker.Rain1.health < tracker.Rain2.health) { if (tracker.Rain1.health > 16) { tracker.Rain1.health = 16; } tracker.Rain1 = null; } else { if (tracker.Rain2.health > 16) { tracker.Rain2.health = 16; } tracker.Rain2 = null; } } } else { tracker = RainTracker(target.GiveInventoryType("RainTracker")); } // Add rain mobj to list if (tracker.Rain1) { tracker.Rain2 = self; } else { tracker.Rain1 = self; } ActiveSound = "misc/rain"; } //---------------------------------------------------------------------------- // // PROC A_HideInCeiling // //---------------------------------------------------------------------------- void A_HideInCeiling() { // This no longer hides in the ceiling. It just makes the actor invisible and keeps it in place. // We need its actual position to determine the correct ceiling height in A_SkullRodStorm. bInvisible = true; bSolid = false; bMissile = false; Vel = (0,0,0); } //---------------------------------------------------------------------------- // // PROC A_SkullRodStorm // //---------------------------------------------------------------------------- void A_SkullRodStorm() { static const Name translations[] = { "RainPillar1", "RainPillar2", "RainPillar3", "RainPillar4", "RainPillar5", "RainPillar6", "RainPillar7", "RainPillar8" }; if (health-- == 0) { A_StopSound (CHAN_BODY); if (target == null) { // Player left the game Destroy (); return; } RainTracker tracker = RainTracker(target.FindInventory("RainTracker")); if (tracker != null) { if (tracker.Rain1 == self) { tracker.Rain1 = null; } else if (tracker.Rain2 == self) { tracker.Rain2 = null; } } Destroy (); return; } if (Random[SkullRodStorm]() < 25) { // Fudge rain frequency return; } double xo = Random[SkullRodStorm](-64, 63); double yo = Random[SkullRodStorm](-64, 63); Vector3 spawnpos = Vec2OffsetZ(xo, yo, pos.z); Actor mo = Spawn("RainPillar", spawnpos, ALLOW_REPLACE); if (!mo) return; // Find the ceiling above the spawn location. This may come from 3D floors but will not reach through portals. // (should probably be fixed for portals, too.) double newz = mo.CurSector.NextHighestCeilingAt(mo.pos.x, mo.pos.y, mo.pos.z, mo.pos.z, FFCF_NOPORTALS) - mo.height; mo.SetZ(newz); if (multiplayer && target.player) { mo.A_SetTranslation(translations[target.PlayerNumber()]); } mo.target = target; mo.Vel.X = MinVel; // Force collision detection mo.Vel.Z = -mo.Speed; mo.CheckMissileSpawn (radius); if (ActiveSound > 0) A_StartSound(ActiveSound, CHAN_BODY, CHANF_LOOPING); } } // Rain pillar 1 ------------------------------------------------------------ class RainPillar : Actor { Default { Radius 5; Height 12; Speed 12; Damage 5; Mass 5; Projectile; -ACTIVATEPCROSS -ACTIVATEIMPACT +ZDOOMTRANS RenderStyle "Add"; Obituary "$OB_MPPSKULLROD"; } States { Spawn: FX22 A -1 BRIGHT; Stop; Death: FX22 B 4 BRIGHT A_RainImpact; FX22 CDEF 4 BRIGHT; Stop; NotFloor: FX22 GHI 4 BRIGHT; Stop; } //---------------------------------------------------------------------------- // // PROC A_RainImpact // //---------------------------------------------------------------------------- void A_RainImpact() { if (pos.z > floorz) { SetStateLabel("NotFloor"); } else if (random[RainImpact]() < 40) { HitFloor (); } } // Rain pillar 1 ------------------------------------------------------------ override int DoSpecialDamage (Actor target, int damage, Name damagetype) { if (target.bBoss) { // Decrease damage for bosses damage = random[RainDamage](1, 8); } return damage; } } // Rain tracker "inventory" item -------------------------------------------- class RainTracker : Inventory { Actor Rain1, Rain2; Default { +INVENTORY.UNDROPPABLE } } // -------------------------------------------------------------------------- // // Super Shotgun // // -------------------------------------------------------------------------- class SuperShotgun : DoomWeapon { Default { Weapon.SelectionOrder 400; Weapon.AmmoUse 2; Weapon.AmmoGive 8; Weapon.AmmoType "Shell"; Inventory.PickupMessage "$GOTSHOTGUN2"; Obituary "$OB_MPSSHOTGUN"; Tag "$TAG_SUPERSHOTGUN"; } States { Ready: SHT2 A 1 A_WeaponReady; Loop; Deselect: SHT2 A 1 A_Lower; Loop; Select: SHT2 A 1 A_Raise; Loop; Fire: SHT2 A 3; SHT2 A 7 A_FireShotgun2; SHT2 B 7; SHT2 C 7 A_CheckReload; SHT2 D 7 A_OpenShotgun2; SHT2 E 7; SHT2 F 7 A_LoadShotgun2; SHT2 G 6; SHT2 H 6 A_CloseShotgun2; SHT2 A 5 A_ReFire; Goto Ready; // unused states SHT2 B 7; SHT2 A 3; Goto Deselect; Flash: SHT2 I 4 Bright A_Light1; SHT2 J 3 Bright A_Light2; Goto LightDone; Spawn: SGN2 A -1; Stop; } } //=========================================================================== // // Code (must be attached to StateProvider) // //=========================================================================== extend class StateProvider { action void A_FireShotgun2() { if (player == null) { return; } A_StartSound ("weapons/sshotf", CHAN_WEAPON); Weapon weap = player.ReadyWeapon; if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { if (!weap.DepleteAmmo (weap.bAltFire, true, 2)) return; player.SetPsprite(PSP_FLASH, weap.FindState('Flash'), true); } player.mo.PlayAttacking2 (); double pitch = BulletSlope (); for (int i = 0 ; i < 20 ; i++) { int damage = 5 * random[FireSG2](1, 3); double ang = angle + Random2[FireSG2]() * (11.25 / 256); // Doom adjusts the bullet slope by shifting a random number [-255,255] // left 5 places. At 2048 units away, this means the vertical position // of the shot can deviate as much as 255 units from nominal. So using // some simple trigonometry, that means the vertical angle of the shot // can deviate by as many as ~7.097 degrees. LineAttack (ang, PLAYERMISSILERANGE, pitch + Random2[FireSG2]() * (7.097 / 256), damage, 'Hitscan', "BulletPuff"); } } action void A_OpenShotgun2() { A_StartSound("weapons/sshoto", CHAN_WEAPON); } action void A_LoadShotgun2() { A_StartSound("weapons/sshotl", CHAN_WEAPON); } action void A_CloseShotgun2() { A_StartSound("weapons/sshotc", CHAN_WEAPON); A_Refire(); } } // Staff -------------------------------------------------------------------- class Staff : HereticWeapon { Default { Weapon.SelectionOrder 3800; +THRUGHOST +WEAPON.WIMPY_WEAPON +WEAPON.MELEEWEAPON Weapon.sisterweapon "StaffPowered"; Obituary "$OB_MPSTAFF"; Tag "$TAG_STAFF"; } States { Ready: STFF A 1 A_WeaponReady; Loop; Deselect: STFF A 1 A_Lower; Loop; Select: STFF A 1 A_Raise; Loop; Fire: STFF B 6; STFF C 8 A_StaffAttack(random[StaffAttack](5, 20), "StaffPuff"); STFF B 8 A_ReFire; Goto Ready; } //---------------------------------------------------------------------------- // // PROC A_StaffAttackPL1 // //---------------------------------------------------------------------------- action void A_StaffAttack (int damage, class puff) { FTranslatedLineTarget t; if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } double ang = angle + Random2[StaffAtk]() * (5.625 / 256); double slope = AimLineAttack (ang, DEFMELEERANGE); LineAttack (ang, DEFMELEERANGE, slope, damage, 'Melee', puff, true, t); if (t.linetarget) { //S_StartSound(player.mo, sfx_stfhit); // turn to face target angle = t.angleFromSource; } } } class StaffPowered : Staff { Default { Weapon.sisterweapon "Staff"; Weapon.ReadySound "weapons/staffcrackle"; +WEAPON.POWERED_UP +WEAPON.READYSNDHALF +WEAPON.STAFF2_KICKBACK Obituary "$OB_MPPSTAFF"; Tag "$TAG_STAFFP"; } States { Ready: STFF DEF 4 A_WeaponReady; Loop; Deselect: STFF D 1 A_Lower; Loop; Select: STFF D 1 A_Raise; Loop; Fire: STFF G 6; STFF H 8 A_StaffAttack(random[StaffAttack](18, 81), "StaffPuff2"); STFF G 8 A_ReFire; Goto Ready; } } // Staff puff --------------------------------------------------------------- class StaffPuff : Actor { Default { RenderStyle "Translucent"; Alpha 0.4; VSpeed 1; +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS AttackSound "weapons/staffhit"; } States { Spawn: PUF3 A 4 BRIGHT; PUF3 BCD 4; Stop; } } // Staff puff 2 ------------------------------------------------------------- class StaffPuff2 : Actor { Default { RenderStyle "Add"; +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS +ZDOOMTRANS AttackSound "weapons/staffpowerhit"; } States { Spawn: PUF4 ABCDEF 4 BRIGHT; Stop; } } // Gold wand ---------------------------------------------------------------- class GoldWand : HereticWeapon { Default { +BLOODSPLATTER Weapon.SelectionOrder 2000; Weapon.AmmoGive 25; Weapon.AmmoUse 1; Weapon.AmmoType "GoldWandAmmo"; Weapon.SisterWeapon "GoldWandPowered"; Weapon.YAdjust 5; Inventory.PickupMessage "$TXT_WPNGOLDWAND"; Obituary "$OB_MPGOLDWAND"; Tag "$TAG_GOLDWAND"; } States { Spawn: GWAN A -1; Stop; Ready: GWND A 1 A_WeaponReady; Loop; Deselect: GWND A 1 A_Lower; Loop; Select: GWND A 1 A_Raise; Loop; Fire: GWND B 3; GWND C 5 A_FireGoldWandPL1; GWND D 3; GWND D 0 A_ReFire; Goto Ready; } //---------------------------------------------------------------------------- // // PROC A_FireGoldWandPL1 // //---------------------------------------------------------------------------- action void A_FireGoldWandPL1 () { if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } double pitch = BulletSlope(); int damage = random[FireGoldWand](7, 14); double ang = angle; if (player.refire) { ang += Random2[FireGoldWand]() * (5.625 / 256); if (GetCVar ("vertspread") && !sv_novertspread) { pitch += Random2[FireGoldWand]() * (3.549 / 256); } } LineAttack(ang, PLAYERMISSILERANGE, pitch, damage, 'Hitscan', "GoldWandPuff1"); A_StartSound("weapons/wandhit", CHAN_WEAPON); } } class GoldWandPowered : GoldWand { Default { +WEAPON.POWERED_UP Weapon.AmmoGive 0; Weapon.SisterWeapon "GoldWand"; Obituary "$OB_MPPGOLDWAND"; Tag "$TAG_GOLDWANDP"; } States { Fire: GWND B 3; GWND C 4 A_FireGoldWandPL2; GWND D 3; GWND D 0 A_ReFire; Goto Ready; } //---------------------------------------------------------------------------- // // PROC A_FireGoldWandPL2 // //---------------------------------------------------------------------------- action void A_FireGoldWandPL2 () { if (player == null) { return; } Weapon weapon = player.ReadyWeapon; if (weapon != null) { if (!weapon.DepleteAmmo (weapon.bAltFire)) return; } double pitch = BulletSlope(); double vz = -GetDefaultByType("GoldWandFX2").Speed * clamp(tan(pitch), -5, 5); SpawnMissileAngle("GoldWandFX2", angle - (45. / 8), vz); SpawnMissileAngle("GoldWandFX2", angle + (45. / 8), vz); double ang = angle - (45. / 8); for(int i = 0; i < 5; i++) { int damage = random[FireGoldWand](1, 8); LineAttack (ang, PLAYERMISSILERANGE, pitch, damage, 'Hitscan', "GoldWandPuff2"); ang += ((45. / 8) * 2) / 4; } A_StartSound("weapons/wandhit", CHAN_WEAPON); } } // Gold wand FX1 ------------------------------------------------------------ class GoldWandFX1 : Actor { Default { Radius 10; Height 6; Speed 22; Damage 2; Projectile; RenderStyle "Add"; +ZDOOMTRANS DeathSound "weapons/wandhit"; Obituary "$OB_MPPGOLDWAND"; } States { Spawn: FX01 AB 6 BRIGHT; Loop; Death: FX01 EFGH 3 BRIGHT; Stop; } } // Gold wand FX2 ------------------------------------------------------------ class GoldWandFX2 : GoldWandFX1 { Default { Speed 18; Damage 1; DeathSound ""; } States { Spawn: FX01 CD 6 BRIGHT; Loop; } } // Gold wand puff 1 --------------------------------------------------------- class GoldWandPuff1 : Actor { Default { +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: PUF2 ABCDE 3 BRIGHT; Stop; } } // Gold wand puff 2 --------------------------------------------------------- class GoldWandPuff2 : GoldWandFX1 { Default { Skip_Super; +NOBLOCKMAP +NOGRAVITY +PUFFONACTORS } States { Spawn: Goto Super::Death; } } // Wizard -------------------------------------------------------- class Wizard : Actor { Default { Health 180; Radius 16; Height 68; Mass 100; Speed 12; Painchance 64; Monster; +FLOAT +NOGRAVITY +DONTOVERLAP SeeSound "wizard/sight"; AttackSound "wizard/attack"; PainSound "wizard/pain"; DeathSound "wizard/death"; ActiveSound "wizard/active"; Obituary "$OB_WIZARD"; HitObituary "$OB_WIZARDHIT"; Tag "$FN_WIZARD"; DropItem "BlasterAmmo", 84, 10; DropItem "ArtiTomeOfPower", 4, 0; } States { Spawn: WZRD AB 10 A_Look; Loop; See: WZRD A 3 A_Chase; WZRD A 4 A_Chase; WZRD A 3 A_Chase; WZRD A 4 A_Chase; WZRD B 3 A_Chase; WZRD B 4 A_Chase; WZRD B 3 A_Chase; WZRD B 4 A_Chase; Loop; Missile: WZRD C 4 A_WizAtk1; WZRD C 4 A_WizAtk2; WZRD C 4 A_WizAtk1; WZRD C 4 A_WizAtk2; WZRD C 4 A_WizAtk1; WZRD C 4 A_WizAtk2; WZRD C 4 A_WizAtk1; WZRD C 4 A_WizAtk2; WZRD D 12 A_WizAtk3; Goto See; Pain: WZRD E 3 A_GhostOff; WZRD E 3 A_Pain; Goto See; Death: WZRD F 6 A_GhostOff; WZRD G 6 A_Scream; WZRD HI 6; WZRD J 6 A_NoBlocking; WZRD KL 6; WZRD M -1 A_SetFloorClip; Stop; } //---------------------------------------------------------------------------- // // PROC A_GhostOff // //---------------------------------------------------------------------------- void A_GhostOff () { A_SetRenderStyle(1.0, STYLE_Normal); bGhost = false; } //---------------------------------------------------------------------------- // // PROC A_WizAtk1 // //---------------------------------------------------------------------------- void A_WizAtk1 () { A_FaceTarget (); A_GhostOff(); } //---------------------------------------------------------------------------- // // PROC A_WizAtk2 // //---------------------------------------------------------------------------- void A_WizAtk2 () { A_FaceTarget (); A_SetRenderStyle(HR_SHADOW, STYLE_Translucent); bGhost = true; } //---------------------------------------------------------------------------- // // PROC A_WizAtk3 // //---------------------------------------------------------------------------- void A_WizAtk3 () { A_GhostOff(); let targ = target; if (!targ) return; A_StartSound (AttackSound, CHAN_WEAPON); if (CheckMeleeRange()) { int damage = random[WizAtk3](1, 8) * 4; int newdam = targ.DamageMobj (self, self, damage, 'Melee'); targ.TraceBleed (newdam > 0 ? newdam : damage, self); return; } Actor mo = SpawnMissile (targ, "WizardFX1"); if (mo != null) { SpawnMissileAngle("WizardFX1", mo.Angle - 45. / 8, mo.Vel.Z); SpawnMissileAngle("WizardFX1", mo.Angle + 45. / 8, mo.Vel.Z); } } } // Projectile -------------------------------------------------------- class WizardFX1 : Actor { Default { Radius 10; Height 6; Speed 18; FastSpeed 24; Damage 3; Projectile; -ACTIVATEIMPACT -ACTIVATEPCROSS +ZDOOMTRANS RenderStyle "Add"; } States { Spawn: FX11 AB 6 BRIGHT; Loop; Death: FX11 CDEFG 5 BRIGHT; Stop; } } // Wraith ------------------------------------------------------------------- class Wraith : Actor { Default { Health 150; PainChance 25; Speed 11; Height 55; Mass 75; Damage 10; Monster; +NOGRAVITY +DROPOFF +FLOAT +FLOORCLIP +TELESTOMP SeeSound "WraithSight"; AttackSound "WraithAttack"; PainSound "WraithPain"; DeathSound "WraithDeath"; ActiveSound "WraithActive"; HitObituary "$OB_WRAITHHIT"; Obituary "$OB_WRAITH"; Tag "$FN_WRAITH"; } States { Spawn: WRTH A 10; WRTH B 5 A_WraithInit; Goto Look; Look: WRTH AB 15 A_Look; Loop; See: WRTH ABCD 4 A_WraithChase; Loop; Pain: WRTH A 2; WRTH H 6 A_Pain; Goto See; Melee: WRTH E 6 A_FaceTarget; WRTH F 6 A_WraithFX3; WRTH G 6 A_WraithMelee; Goto See; Missile: WRTH E 6 A_FaceTarget; WRTH F 6; WRTH G 6 A_SpawnProjectile("WraithFX1"); Goto See; Death: WRTH I 4; WRTH J 4 A_Scream; WRTH KL 4; WRTH M 4 A_NoBlocking; WRTH N 4 A_QueueCorpse; WRTH O 4; WRTH PQ 5; WRTH R -1; Stop; XDeath: WRT2 A 5; WRT2 B 5 A_Scream; WRT2 CD 5; WRT2 E 5 A_NoBlocking; WRT2 F 5 A_QueueCorpse; WRT2 G 5; WRT2 H -1; Stop; Ice: WRT2 I 5 A_FreezeDeath; WRT2 I 1 A_FreezeDeathChunks; Wait; } //============================================================================ // // A_WraithInit // //============================================================================ void A_WraithInit() { AddZ(48); // [RH] Make sure the wraith didn't go into the ceiling if (pos.z + height > ceilingz) { SetZ(ceilingz - Height); } WeaveIndexZ = 0; // index into floatbob } //============================================================================ // // A_WraithChase // //============================================================================ void A_WraithChase() { int weaveindex = WeaveIndexZ; AddZ(BobSin(weaveindex)); WeaveIndexZ = (weaveindex + 2) & 63; A_Chase (); A_WraithFX4 (); } //============================================================================ // // A_WraithFX3 // // Spawn an FX3 around the wraith during attacks // //============================================================================ void A_WraithFX3() { int numdropped = random[WraithFX3](0,14); while (numdropped-- > 0) { double xo = (random[WraithFX3]() - 128) / 32.; double yo = (random[WraithFX3]() - 128) / 32.; double zo = random[WraithFX3]() / 64.; Actor mo = Spawn("WraithFX3", Vec3Offset(xo, yo, zo), ALLOW_REPLACE); if (mo) { mo.floorz = floorz; mo.ceilingz = ceilingz; mo.target = self; } } } //============================================================================ // // A_WraithFX4 // // Spawn an FX4 during movement // //============================================================================ void A_WraithFX4 () { int chance = random[WraithFX4](); bool spawn4, spawn5; if (chance < 10) { spawn4 = true; spawn5 = false; } else if (chance < 20) { spawn4 = false; spawn5 = true; } else if (chance < 25) { spawn4 = true; spawn5 = true; } else { spawn4 = false; spawn5 = false; } if (spawn4) { double xo = (random[WraithFX4]() - 128) / 16.; double yo = (random[WraithFX4]() - 128) / 16.; double zo = (random[WraithFX4]() / 64.); Actor mo = Spawn ("WraithFX4", Vec3Offset(xo, yo, zo), ALLOW_REPLACE); if (mo) { mo.floorz = floorz; mo.ceilingz = ceilingz; mo.target = self; } } if (spawn5) { double xo = (random[WraithFX4]() - 128) / 32.; double yo = (random[WraithFX4]() - 128) / 32.; double zo = (random[WraithFX4]() / 64.); Actor mo = Spawn ("WraithFX5", Vec3Offset(xo, yo, zo), ALLOW_REPLACE); if (mo) { mo.floorz = floorz; mo.ceilingz = ceilingz; mo.target = self; } } } //============================================================================ // // A_WraithMelee // //============================================================================ void A_WraithMelee() { // Steal health from target and give to self if (CheckMeleeRange() && (random[StealHealth]()<220)) { int amount = random[StealHealth](1, 8) * 2; target.DamageMobj (self, self, amount, 'Melee'); health += amount; } } } // Buried wraith ------------------------------------------------------------ class WraithBuried : Wraith { Default { Height 68; -SHOOTABLE -SOLID +DONTMORPH +DONTBLAST +SPECIALFLOORCLIP +STAYMORPHED +INVISIBLE PainChance 0; } States { Spawn: Goto Super::Look; See: WRTH A 2 A_WraithRaiseInit; WRTH A 2 A_WraithRaise; WRTH A 2 A_FaceTarget; WRTH BB 2 A_WraithRaise; Goto See + 1; Chase: Goto Super::See; } //============================================================================ // // A_WraithRaiseInit // //============================================================================ void A_WraithRaiseInit() { bInvisible = false; bNonShootable = false; bDontBlast = false; bShootable = true; bSolid = true; Floorclip = Height; } //============================================================================ // // A_WraithRaise // //============================================================================ void A_WraithRaise() { if (RaiseMobj (2)) { // Reached it's target height // [RH] Once a buried wraith is fully raised, it should be // morphable, right? bDontMorph = false; bSpecialFloorClip = false; SetStateLabel ("Chase"); // [RH] Reset PainChance to a normal wraith's. PainChance = GetDefaultByType("Wraith").PainChance; } SpawnDirt (radius); } } // Wraith FX 1 -------------------------------------------------------------- class WraithFX1 : Actor { Default { Speed 14; Radius 10; Height 6; Mass 5; Damage 5; DamageType "Fire"; Projectile; +FLOORCLIP SeeSound "WraithMissileFire"; DeathSound "WraithMissileExplode"; } States { Spawn: WRBL A 3 Bright; WRBL B 3 Bright A_WraithFX2; WRBL C 3 Bright; Loop; Death: WRBL D 4 Bright; WRBL E 4 Bright A_WraithFX2; WRBL F 4 Bright; WRBL GH 3 Bright A_WraithFX2; WRBL I 3 Bright; Stop; } //============================================================================ // // A_WraithFX2 - spawns sparkle tail of missile // //============================================================================ void A_WraithFX2() { for (int i = 2; i; --i) { Actor mo = Spawn ("WraithFX2", Pos, ALLOW_REPLACE); if(mo) { double newangle = random[WraithFX2]() * (360 / 1024.f); if (random[WraithFX2]() >= 128) { newangle = -newangle; } newangle += angle; mo.Vel.X = ((random[WraithFX2]() / 512.) + 1) * cos(newangle); mo.Vel.Y = ((random[WraithFX2]() / 512.) + 1) * sin(newangle); mo.Vel.Z = 0; mo.target = self; mo.Floorclip = 10; } } } } // Wraith FX 2 -------------------------------------------------------------- class WraithFX2 : Actor { Default { Radius 2; Height 5; Mass 5; +NOBLOCKMAP +DROPOFF +FLOORCLIP +NOTELEPORT } States { Spawn: WRBL JKLMNOP 4 Bright; Stop; } } // Wraith FX 3 -------------------------------------------------------------- class WraithFX3 : Actor { Default { Radius 2; Height 5; Mass 5; +NOBLOCKMAP +DROPOFF +MISSILE +FLOORCLIP +NOTELEPORT DeathSound "Drip"; } States { Spawn: WRBL QRS 4 Bright; Loop; Death: WRBL S 4 Bright; Stop; } } // Wraith FX 4 -------------------------------------------------------------- class WraithFX4 : Actor { Default { Radius 2; Height 5; Mass 5; +NOBLOCKMAP +DROPOFF +MISSILE +NOTELEPORT DeathSound "Drip"; } States { Spawn: WRBL TUVW 4; Loop; Death: WRBL W 10; Stop; } } // Wraith FX 5 -------------------------------------------------------------- class WraithFX5 : WraithFX4 { States { Spawn: WRBL XYZ 7; Loop; Death: WRBL Z 35; Stop; } } // Zombie ------------------------------------------------------------------- class Zombie : StrifeHumanoid { Default { Health 31; Radius 20; Height 56; PainChance 0; +SOLID +SHOOTABLE +FLOORCLIP +CANPASS +CANPUSHWALLS +ACTIVATEMCROSS MinMissileChance 150; MaxStepHeight 16; MaxDropOffHeight 32; Translation 0; Tag "$TAG_STRIFEZOMBIE"; DeathSound "zombie/death"; CrushPainSound "misc/pcrush"; } States { Spawn: PEAS A 5 A_CheckTerrain; Loop; Pain: AGRD A 5 A_CheckTerrain; Loop; Death: GIBS M 5 A_TossGib; GIBS N 5 A_XScream; GIBS O 5 A_NoBlocking; GIBS PQRST 4 A_TossGib; GIBS U 5; GIBS V -1; Stop; } } // Zombie Spawner ----------------------------------------------------------- class ZombieSpawner : Actor { Default { Health 20; +SHOOTABLE +NOSECTOR RenderStyle "None"; ActiveSound "zombie/spawner"; // Does Strife use this somewhere else? } States { Spawn: TNT1 A 175 A_SpawnItemEx("Zombie"); Loop; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapAchievementDef : SnapDefinition { SnapAchievementCondition Condition; SnapAchievementReward Reward; CVar StatusVar; enum AchievementStatusVar { // Setting STATUS_UNFINISHED = 0, STATUS_NEWLY_UNLOCKED = 1, STATUS_UNLOCKED = 2, STATUS_MASK = STATUS_UNFINISHED|STATUS_NEWLY_UNLOCKED|STATUS_UNLOCKED, // Flags STATUS_FLAG_SKIPPED = 16, STATUS_FLAG_MASK = STATUS_FLAG_SKIPPED, } bool ConditionAchieved() { // Check for explicit completion. if (Condition == null) { return false; } return Condition.Achieved(); } bool RewardUnlocked() { // Check status memory for explicit completion, // or if it was skipped. if (StatusVar == null) { return false; } int Status = StatusVar.GetInt(); if (Status & STATUS_FLAG_SKIPPED) { return true; } return ((Status & STATUS_MASK) == STATUS_UNLOCKED); } bool ConditionDisablesFreeSpace() { if (Condition != null) { return Condition.DisableFreeSpace(); } return false; } bool AlreadyGot() { if (StatusVar == null) { return true; } int Status = StatusVar.GetInt(); if (Status & SnapAchievementDef.STATUS_FLAG_SKIPPED) { return true; } return ((Status & STATUS_MASK) != STATUS_UNFINISHED); } bool CanUseFreeSpace() { if (ConditionDisablesFreeSpace() == true) { // Free spaces aren't allowed for this type. return false; } // Only use them on unfinished tiles. return (AlreadyGot() == false); } String GetHint() { if (Condition == null) { return "Invalid challenge?"; } let str = Condition.Hint(); let punct = str.Mid(str.Length() - 1); if (punct != "?" && punct != "!" && punct != ".") { // If there isn't already punctuation // (most frequently happens due to the // ???-ification of unvisited level // titles), then append a "!" to the // end to make it exciting. str.AppendCharacter(0x21); } return str; } String GetRewardString() { if (Reward == null) { return ""; } return Reward.RewardString(); } override void InternalDeserialize(JsonObject Obj) { StatusVar = ParseForCVar(Obj, "achievedvar"); JsonElement ConditionElem = Obj.Get("condition"); if (ConditionElem != null) { JsonObject ConditionObj = JsonObject(ConditionElem); if (ConditionObj == null) { Console.Printf( "SNAPDEFS parse warning: element \"%s\" is not an object.", "condition" ); } else { String ConditionClassName; ParseForString(ConditionClassName, ConditionObj, "class"); ConditionClassName = String.Format("SnapCondition_%s", ConditionClassName); class ConditionClass = ConditionClassName; if (ConditionClass != null) { Condition = SnapAchievementCondition(new(ConditionClass)); if (Condition != null) { JsonElement ArgsElem = ConditionObj.Get("args"); if (ArgsElem != null) { let ArgsObj = JsonObject(ArgsElem); if (ArgsObj == null) { Console.Printf( "SNAPDEFS parse warning: element \"%s\" is not an object.", "args" ); } else { Condition.DeserializeArgs(ArgsObj); } } Condition.Initialize(); } } } } JsonElement RewardElem = Obj.Get("reward"); if (RewardElem != null) { JsonObject RewardObj = JsonObject(RewardElem); if (RewardObj == null) { Console.Printf( "SNAPDEFS parse warning: element \"%s\" is not an object.", "reward" ); } else { String RewardClassName; ParseForString(RewardClassName, RewardObj, "class"); RewardClassName = String.Format("SnapReward_%s", RewardClassName); class RewardClass = RewardClassName; if (RewardClass != null) { Reward = SnapAchievementReward(new(RewardClass)); if (Reward != null) { JsonElement ArgsElem = RewardObj.Get("args"); if (ArgsElem != null) { let ArgsObj = JsonObject(ArgsElem); if (ArgsObj == null) { Console.Printf( "SNAPDEFS parse warning: element \"%s\" is not an object.", "args" ); } else { Reward.DeserializeArgs(ArgsObj); } } Reward.Initialize(); } } } } } static void Deserialize( in out Map Dest, Name FindID, JsonElement Elem) { if (Elem == null) { Console.Printf("SNAPDEFS parse warning: entry \"%s\" is not an element.", FindID); return; } let Obj = JsonObject(Elem); if (Obj == null) { Console.Printf("SNAPDEFS parse warning: entry \"%s\" is not an object.", FindID); return; } SnapAchievementDef EditDef = null; bool Exists = false; [EditDef, Exists] = Dest.CheckValue(FindID); if (Exists == false) { EditDef = new("SnapAchievementDef"); EditDef.ID = FindID; EditDef.Sort = Dest.CountUsed(); Dest.Insert(FindID, EditDef); } EditDef.InternalDeserialize(Obj); } static SnapAchievementDef Get(Name ID) { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return null; } SnapDefinitions defs = ev.SnapDefs; if (defs == null) { return null; } if (defs.AchievementMap.CheckKey(ID) == false) { return null; } return defs.AchievementMap.Get(ID); } } extend class SnapDefinitions { Map AchievementMap; } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- mixin class SnapGeneralFunctions { const BASETOUCHDELAY = 16; uint TouchDelay; uint TouchDamage; property TouchDamage: TouchDamage; uint DeferredTouchDamage; Actor DeferredTouchInflictor; Actor DeferredTouchSource; uint SnapActorFlags; flagdef MissileSpriteFix: SnapActorFlags, 0; flagdef CanDropAmmo: SnapActorFlags, 1; flagdef NoFootsteps: SnapActorFlags, 2; uint WaterPushed; uint DamageFlash; String DamageFlashTranslation; bool DropAmmo; bool LastFlash; Actor DominoSource; uint SnapScore; property Score: SnapScore; enum ECheckSolidFootingFlags { CSF_SOLIDFLOOR = 1<<0, CSF_ACTORFLOOR = 1<<1, CSF_SOLIDCEILING = 1<<2, CSF_ACTORCEILING = 1<<3, CSF_FLOORMASK = CSF_SOLIDFLOOR|CSF_ACTORFLOOR, CSF_CEILINGMASK = CSF_SOLIDCEILING|CSF_ACTORCEILING } // // == FUNCTIONS == // // - KickMomentumReduce - // Reduces momentum, meant to be called when damaged in a kick state. void KickMomentumReduce() { // Shot & kicked enemies can be kept in the air! Vel *= 0.7; } // - CheckSolidFooting - // Checks if this actor has hit the ground. int CheckSolidFooting() { int FootingFlags = 0; //FindFloorCeiling(); // Solid floors. if (Pos.Z <= FloorZ && Vel.Z <= 0.0) { FootingFlags |= CSF_SOLIDFLOOR; } // Solid ceilings. if (Pos.Z + Height >= CeilingZ && Vel.Z >= 0.0) { FootingFlags |= CSF_SOLIDCEILING; } // Check if we're standing on an object. bool ok = false; Actor below = null; [ok, below] = TestMobjZ(true); if (below != null) { if (below.bMissile == false) // Just assume missiles aren't blocking :V { FootingFlags |= CSF_ACTORFLOOR; } } return FootingFlags; } Vector2 GetWallBounceDir(double TryVelX = 0.0, double TryVelY = 0.0) { Vector2 TryVel = (TryVelX, TryVelY); Vector2 bounce = (0, 0); if (TryVel ~== (0, 0)) { TryVel = Vel.XY; } if (SnapUtils.ValidVec2Unit(TryVel) == false) { return bounce; } FCheckPosition moveData; Vector2 VelDir = SnapUtils.SafeVec2Unit(TryVel); bool result = CheckMove(Pos.XY + TryVel, 0, moveData); if (result == false) { bounce = VelDir * -1; let tracer = new("BounceTrace"); if (tracer == null) { return bounce; } tracer.master = self; tracer.Trace( Pos + (0, 0, height * 0.5), CurSector, (VelDir.X, VelDir.Y, 0) * 2.0, (TryVel.Length() * 2.0) + (radius * 1.5), 0 ); if (SnapUtils.ValidVec2Unit(tracer.BounceNormal) == true) { bounce = SnapUtils.SafeVec2Unit(SnapUtils.ReflectVector2(TryVel, tracer.BounceNormal)); } if (tracer.results.HitType == TRACE_HitWall && tracer.results.HitLine != null) { if (self is "PlayerPawn") { tracer.results.HitLine.Activate(self, tracer.results.Side, SPAC_Push); } if (bCanPushWalls == true) { tracer.results.HitLine.Activate(self, tracer.results.Side, SPAC_MPush); } if (bActivateImpact == true) { tracer.results.HitLine.Activate(self, tracer.results.Side, SPAC_Impact); } } } return bounce; } bool CanAttackHurt(Actor victim, Actor shooter) { // Port of GZDoom internal function. if (victim == null || shooter == null) { return false; } if (victim.player == null && shooter.player == null) { if (victim.IsFriend(shooter)) { // Friends never harm each other, unless the shooter has the HARMFRIENDS set. if (shooter.bHarmFriends == true) { return false; } } else { if (victim.TIDtoHate != 0 && victim.TIDtoHate == shooter.TIDtoHate) { // [RH] Don't hurt monsters that hate the same victim as you do return false; } if (victim.GetSpecies() == shooter.GetSpecies() && shooter.bDoHarmSpecies == false) { // Don't hurt same species or any relative - // but only if the target isn't one's hostile. if (victim.IsHostile(shooter) == false) { // Allow hurting monsters the shooter hates. if (victim.tid == 0 || shooter.TIDtoHate != victim.tid) { return false; } } } } } return true; } bool DealTouchDamage(Actor toucher) { if (TouchDamage == 0 || Health <= 0) { return false; } if (toucher.bShootable == false) { return false; } Actor theSource = self; if (bMissile == true) { theSource = target; } else //if (bIsMonster == true) { if (master != null) { theSource = master; } else { theSource = self; } } if (toucher == theSource) { return false; } if (theSource != null) { if (CanAttackHurt(toucher, theSource) == false) { return false; } } let pawn = SnapPlayer(toucher); if (pawn) { if (pawn.TouchDelay > 0) { return true; } pawn.TouchDelay = BASETOUCHDELAY; pawn.DeferredTouchDamage += TouchDamage; pawn.DeferredTouchInflictor = self; pawn.DeferredTouchSource = theSource; return true; } let sa = SnapActor(toucher); if (sa) { if (sa.TouchDelay > 0) { return true; } sa.TouchDelay = BASETOUCHDELAY; sa.DeferredTouchDamage += TouchDamage; sa.DeferredTouchInflictor = self; sa.DeferredTouchSource = theSource; return true; } return true; } void DecrementTouchDelay() { if (TouchDelay > 0) { TouchDelay--; } } void UpdateTouchDamage() { if (DeferredTouchDamage > 0) { Name mod = 'None'; if (DeferredTouchInflictor != null) { mod = DeferredTouchInflictor.DamageType; } DamageMobj(DeferredTouchInflictor, DeferredTouchSource, DeferredTouchDamage, mod); let sa = SnapActor(DeferredTouchInflictor); if (sa != null) { sa.TouchDamageDealt(self, DeferredTouchSource, DeferredTouchDamage, mod); } TouchDelay = BASETOUCHDELAY; DeferredTouchDamage = 0; DeferredTouchInflictor = null; DeferredTouchSource = null; } } virtual void TouchDamageDealt(Actor victim, Actor source, int dmg, Name mod) { return; } void SetDamageFlash(int amount) { if (amount <= 0) { return; } if (GetCVar("gl_weaponlight") ~== 0) { return; } DamageFlash = min(max(DamageFlash, amount + 1), 51); } int DefaultFlashing() { if (DamageFlash > 0 && DamageFlashTranslation.Length() > 0 && (Level.maptime & 1)) { return Translate.GetID(DamageFlashTranslation); } return -1; } void RunDamageFlash() { bool flash = false; int FlashTranslation = GetFlashTranslation(); if (FlashTranslation >= 0) { Translation = FlashTranslation; bBright = true; flash = true; } if (DamageFlash > 0) { DamageFlash--; } if (flash == false && LastFlash == true) { Translation = GetDefaultTranslation(); bBright = Default.bBright; } LastFlash = flash; } // - DoFootstep - // Spawns a footstep particle for the object's terrain type. Actor DoFootstep(double spd = 0.0, bool DoSound = false) { if (Level.IsFrozen() != 0) { // Don't spawn footsteps while the level is frozen. return null; } class StepSplashType = SnapUtils.GetStepSplashType(GetFloorTerrain()); if (StepSplashType == null) { return null; } FindFloorCeiling(FFCF_SAMESECTOR|FFCF_NOCEILING); if (Pos.Z > FloorZ) { return null; } Vector3 StepPos = (Pos.X, Pos.Y, FloorZ); Actor StepSplash = Spawn(StepSplashType, StepPos, ALLOW_REPLACE); if (StepSplash) { double a = angle; Vector3 NewPos = StepPos; double dis = StepSplash.Radius; Vector2 dir = ( cos(angle), sin(angle) ); if (SnapUtils.ValidVec2Unit(Vel.XY) == true) { dir = SnapUtils.SafeVec2Unit(Vel.XY); } NewPos.XY -= dis * dir; StepSplash.SetOrigin(NewPos, false); if (spd != 0.0) { a += frandom[snap_splash](-22.5, 22.5); StepSplash.Vel.XY -= ( spd * cos(a), spd * sin(a) ); double zMul = frandom[snap_splash](0.8, 1.2); StepSplash.Vel.Z *= zMul; } } return StepSplash; } void DoWaterPushEFX() { if (WaterPushed > 0) { WaterPushed--; A_KickedDust("SnapWaterDrops"); } } Vector3 RotateVector3(Vector3 vec, double angle, double pitch) { // Rotate by pitch Vector2 rotXZ = RotateVector((vec.x, vec.z), -pitch); vec.x = rotXZ.x; vec.z = rotXZ.y; // Rotate by angle vec.xy = RotateVector(vec.xy, angle); return vec; } // // == ACTIONS == // void SetPhysicalSize(Vector2 NewScale) { Scale = NewScale; A_SetSize((Default.Radius / Default.Scale.X) * NewScale.X, (Default.Height / Default.Scale.Y) * NewScale.Y); if (bMissileSpriteFix == true) { DoMissileSpriteFix(); } } // - A_SnapScreenShake - // Generalized settings for screen shaking. const SCREEN_SHAKE_Z_EXTRA = sqrt(3.0); action void A_SnapScreenShake(int fullDist, int dist, double quakeIntensity = 5.0, double quakeTime = 1.0) { A_QuakeEx( 0.0, 0.0, int(ceil(quakeIntensity * SCREEN_SHAKE_Z_EXTRA)), //quakeIntensity, quakeIntensity, quakeIntensity, int(ceil(quakeTime * SCREEN_SHAKE_Z_EXTRA * TICRATE)), // int(ceil(quakeTime * TICRATE)) 0, dist, "", QF_SCALEDOWN, 1, 1, 1, fullDist ); } // - A_SnapExplode - // A wrapper for A_Explode and A_SnapScreenShake. action int A_SnapExplode( int damage, double dist, int flags = XF_THRUSTZ|XF_CIRCULAR, class VisualType = "SnapRadiusDamageEFX", double quakeIntensity = 5.0, double quakeTime = 0.5, Name dmgType = 'None') { if (Scale != (1.0, 1.0)) { dist *= max(Scale.X, Scale.Y); } double quakeFullDist = dist * 2; if (dist <= 0) { // A_Quake with fulldist set to 0 means "no falloff" // A_Explode with fulldist set to 0 means "all the falloff" // So this is to correct that :V quakeFullDist = 1; } A_SnapScreenShake(int(quakeFullDist), int(dist * 3.0), quakeIntensity, quakeTime); // Spawn the explosion effect. Actor spawned = Spawn(VisualType, Pos + (0, 0, Height * 0.5), ALLOW_REPLACE); let exp = SnapRadiusDamageEFX(spawned); if (exp != null) { exp.RDSize = dist; exp.RDJitter = 8.0; } return A_Explode(damage, int(dist + GetDefaultByType("SnapPlayer").Radius), flags, false, int(dist), 0, 10, "BulletPuff", dmgType); } // - DoOverheal - // Spawns particle effect for when above max health. Actor DoOverheal(int trans = -1) { if (bInvisible == true) { return null; } int OrigHealth = Default.Health; // SpawnHealth() if (Health <= OrigHealth) { return null; } Vector3 SpawnPos = Pos + (0, 0, Height * 0.25); double Range = min(Radius * 2.0, Height) * 1.5; double Offset = frandom[snap_decor](Range * 0.5, Range); double OAng = frandom[snap_decor](-180, 180); double OPtc = frandom[snap_decor](-180, 180); SpawnPos += Offset * ( cos(OAng) * cos(OPtc), sin(OAng) * cos(OPtc), sin(OPtc) * 0.5 ); let Particle = Spawn("SnapOverheal", SpawnPos, ALLOW_REPLACE); //particle.Scale = Scale; particle.Vel = Vel; if (trans < 0) { if (Level.maptime & 1) { particle.Translation = Translate.GetID("OverhealGreen"); } } else { particle.Translation = trans; } let player = self.player; if (player != null) { if (self == players[consoleplayer].camera && !(player.cheats & CF_CHASECAM)) { particle.bInvisible = true; } } return particle; } // - A_KickedDust - // Spawns a dust trail. action Actor A_KickedDust(class type = "SnapPuff", bool offTick = false) { if (bInvisible == true) { return null; } bool ourTick = (Level.maptime & 1); if (ourTick != offTick) { return null; } Vector3 puffPosOffset = ( 0, 0, frandom[snap_decor](0, height) ); Actor puff = Spawn(type, Pos + puffPosOffset, ALLOW_REPLACE); if (puff) { puff.Vel = ( random[snap_decor](-1, 1), random[snap_decor](-1, 1), random[snap_decor](0, 4) ); } return puff; } action void A_SnapStun() { double a = 0; double spd = 8.0; if (target && target.health > 0) { a = AngleTo(target, true) + 180; a += random[snap_decor](-3,3) * 11.25; } else { a = random[snap_decor](0,7) * 45; } Vector3 dizzyOffset = ( 0, 0, Default.Height * 0.5 ); Actor dizzyStar = Spawn("SnapDizzy", Pos + dizzyOffset, ALLOW_REPLACE); // Scale with size of the monster // Makes this effect easier to see on taller enemies. double spdMul = Height / 48; spdMul = 1.0 + ((spdMul - 1.0) * 0.5); spd = spd * spdMul; if (dizzyStar) { dizzyStar.Vel = ( spd * 0.5 * cos(a), spd * 0.5 * sin(a), spd ); dizzyStar.Vel += Vel; //dizzyStar.A_StartSound("stunned"); } } action void A_SnapJuggle(Actor inflictor) { double a = 0; double spd = 12.0; if (inflictor) { a = AngleTo(inflictor, true) + 90; a += random[snap_decor](0,1) * 180; } else { a = random[snap_decor](0,7) * 45; } Vector3 dizzyOffset = ( 0, 0, Default.Height * 0.5 ); Actor dizzyStar = Spawn("SnapJuggle", Pos + dizzyOffset, ALLOW_REPLACE); // Scale with size of the monster // Makes this effect easier to see on the bigger enemies. double spdMul = Radius / 24; spdMul = 1.0 + ((spdMul - 1.0) * 0.5); spd = spd * spdMul; if (dizzyStar) { dizzyStar.Vel = ( spd * cos(a), spd * sin(a), spd ); dizzyStar.Vel += Vel; dizzyStar.A_StartSound("stunned"); } } // - PlayDamageSound - // Play a sound for damage dealt, depending on the amount of damage. static void PlayDamageSound(uint dmg, Actor victim = null, Actor inflictor = null, Actor source = null) { static const String damageSounds[] = { "damage/wimpy", "damage/small", "damage/medium", "damage/big", "damage/extreme", "damage/crit" }; if (inflictor != null && inflictor.bRipper == true && inflictor.IsZeroDamage() == false) { // Ripper damage is compounding, so adjust the brackets to make that noticeable. // In particular, this gives the large end of the flame thrower a different sound. dmg += (dmg * dmg) / 5; } uint numSounds = 6; uint soundID = 0; if (dmg > 99) { soundID = 5; } else if (dmg > 45) { soundID = 4; } else if (dmg > 20) { soundID = 3; } else if (dmg > 13) { soundID = 2; } else if (dmg > 7) { soundID = 1; } // else keep ID 0 double attenuation = ATTN_NORM; // Play the sound globally if it involves you. if (victim != null) { let DamagePlayer = victim.player; if (DamagePlayer != null && DamagePlayer == players[consoleplayer]) { attenuation = ATTN_NONE; } else if (source != null) { let SourcePlayer = source.player; if (SourcePlayer != null && SourcePlayer == players[consoleplayer]) { attenuation = ATTN_NONE; } } } if (victim == null) { S_StartSound(damageSounds[soundID], CHAN_DAMAGE, CHANF_DEFAULT, 1.0, attenuation); } else { victim.A_StartSound(damageSounds[soundID], CHAN_DAMAGE, CHANF_DEFAULT, 1.0, attenuation); bool hasShield = false; let mon = SnapMonster(victim); if (mon != null) { hasShield = mon.bHalfShield; } if (victim.CountInv("SnapShieldPower") > 0) { hasShield = true; } if (hasShield == true) { victim.A_StartSound("damage/reduced", CHAN_DAMAGE_REDUCED, CHANF_DEFAULT, 1.0, attenuation); } } } action void A_DamageSound(uint dmg, Actor inflictor = null, Actor source = null) { PlayDamageSound(dmg, self, inflictor, source); } // - A_HitConfirm - // Spawn a hit confirm particle. action Actor A_HitConfirm(Actor confirmSpawnFrom, PlayerPawn pawn, bool meleeHack = false) { if (!confirmSpawnFrom || !pawn) { return null; } Vector3 confirmPos = confirmSpawnFrom.pos; if (meleeHack == true) { confirmPos.z += 32.0; } int range = 13; confirmPos.x += random[snap_decor](-range, range); confirmPos.y += random[snap_decor](-range, range); confirmPos.z += random[snap_decor](-range, range); Actor confirm = Spawn("SnapHitConfirm", confirmPos, ALLOW_REPLACE); let sp = SnapPlayer(pawn); if (sp) { confirm.Translation = sp.GetDefaultTranslation(); } if (meleeHack == true) { confirm.angle = pawn.angle; } else { Vector2 v = Vec2To(confirm); confirm.angle = VectorAngle(v.x, v.y); } confirm.bXFlip = random[snap_decor](0, 1); confirm.bYFlip = random[snap_decor](0, 1); double dis = confirmSpawnFrom.Distance3D(pawn); if (dis > 0.0) { double sc = 1.0 + (dis / 2048.0); confirm.Scale = (sc, sc); } return confirm; } // - A_DeathmatchGoAway - // Hides an object in Deathmatch to respawn later, destroys it in Coop/SP. action void A_DeathmatchGoAway() { if (!deathmatch) { Destroy(); } Height = Default.Height; bInvisible = true; bSolid = false; } double SnapDropItems( class item, uint numDrops = 1, uint totalDrops = 0, double a = -666, int amountPerDrop = -1, uint powerupTimer = 0 ) { if (item == null) { return a; } if (numDrops == 0) { return a; } if (totalDrops == 0) { totalDrops = numDrops; } double spawnZ = Height * 0.5; double aOffset = 360 / totalDrops; if (a == -666) { a = (aOffset * 0.5); } double spreadOut = 0.0; if (totalDrops > 1) { spreadOut = 4.0; } for (uint i = 0; i < numDrops; i++) { Actor mo = Spawn(item, Pos + (0, 0, spawnZ), ALLOW_REPLACE); if (mo) { mo.bDropped = true; mo.bNoGravity = false; mo.Vel = ( spreadOut * cos(angle + a), spreadOut * sin(angle + a), 8.0 ); let inv = Inventory(mo); if (inv) { inv.ModifyDropAmount(amountPerDrop); inv.bTossed = true; if (inv.SpecialDropAction(self)) { inv.Destroy(); } if (powerupTimer > 0) { let power = PowerupGiver(inv); if (power) { power.EffectTics = powerupTimer; } } } } a += aOffset; } return a; } action void A_SnapNoBlocking(bool drop = true) { let ourselves = SnapActor(self); if (ourselves == null) { A_NoBlocking(drop); return; } bSolid = false; if (drop == true && !(self is "PlayerPawn")) { let m = SnapMonster(self); if (m != null) { m.ContainerRelease(); } uint totalDrops = 0; double a = -666; if (ourselves.DropAmmo == true) { totalDrops++; } DropItem di; DropItem drop; drop = di = GetDropItems(); if (drop != null) { while (di != null) { if (di.Name != 'None') { totalDrops++; } di = di.Next; } di = drop; while (di != null) { if (di.Name != 'None') { class cls = di.Name; if (cls != null) { a = ourselves.SnapDropItems(cls, 1, totalDrops, a, di.Amount); } } di = di.Next; } } if (ourselves.DropAmmo == true) { a = ourselves.SnapDropItems("SnapAmmoDrop", 1, totalDrops, a); } } } void DoMissileSpriteFix() { SpriteOffset.Y = Height * -0.5; } // Fix chain reactions from mine snails not counting. Actor GetDominoSource(Actor src) { if (src != null && src.Health > 0) { // The original is fine :) return src; } Array ActorsTried; ActorsTried.Push(src); Actor NewSrc = null; Actor NextSrc = null; let newM = SnapActor(src); if (newM) { NewSrc = newM.DominoSource; ActorsTried.Push(NewSrc); let nextM = SnapActor(NewSrc); if (nextM) { NextSrc = nextM.DominoSource; } } while (NextSrc != null) { if (NewSrc != null && NewSrc.Health > 0) { // Current source is fine. break; } if (ActorsTried.Find(NextSrc) != ActorsTried.Size()) { // Recursion prevention. break; } // Try the next one in line. NewSrc = NextSrc; ActorsTried.Push(NewSrc); // Queue up the next one if possible NextSrc = null; let anotherM = SnapActor(NewSrc); if (anotherM) { NextSrc = anotherM.DominoSource; } } if (NewSrc == null) { // Might as well try to use our original (if it even exists) return src; } return NewSrc; } Actor SetDominoSource(Actor src) { DominoSource = GetDominoSource(src); return DominoSource; } bool CanHomeActor(Actor Lock, Actor Owner) { if (Lock == null) { return false; } if (Lock == Owner) { return false; } if (Lock.bShootable == false || Lock.bNonShootable == true) { // Not able to be shot at. return false; } if (Owner.IsTeammate(Lock) == true) { // Ignore teammates. return false; } if (CanSeek(Lock) == false) { // Can't home in on this one. return false; } if (Lock.bIsMonster == true || Lock is "PlayerPawn") { // Home in if it's a monster or player! return true; } return false; } Actor FindHomingTarget(double SearchDist, double SearchAngle, Actor Owner = null) { BlockThingsIterator it = BlockThingsIterator.Create(self, SearchDist + Radius); Actor CurMo = null; Actor BestMo = null; double BestDist = max(SearchDist + Radius, Radius); if (Owner == null) { Owner = self; } Vector2 SearchDir = ( cos(SearchAngle), sin(SearchAngle) ); while (it.Next()) { CurMo = it.thing; if (CurMo == null || CurMo == self || CurMo == Owner) { continue; } if (CanHomeActor(CurMo, Owner) == false) { continue; } Vector2 DirTo = SnapUtils.SafeVec2Unit(Vec2To(CurMo)); if ((SearchDir dot DirTo) < 0.0) { continue; } double dis = Distance3D(CurMo); if (dis < BestDist && CheckSight(CurMo)) { BestMo = CurMo; BestDist = dis; } } return BestMo; } static void GenericKick( Actor target, Actor source, Actor hitPuff, uint KickDamage, Vector3 KickSpeed, int HitstunFrames, bool FromFriendly) { if (target == null || target.Health <= 0) { // Already dead. return; } if (target.bShootable == false || target.bDormant == true) { // Non-interactable. return; } if (FromFriendly == true) { // From a friendly player. return; } // Sorta emulate the monster kicks if (target.bDontThrust == false) { target.Vel = KickSpeed; } int dr = target.DamageMobj(source, source, KickDamage, 'Melee'); if (dr > 0) { let sp = SnapPlayer(source); let sa = SnapActor(source); if (sp) { sp.AddHitstun(HitstunFrames, false); } else if (sa) { sa.AddHitstun(HitstunFrames, false); } } } void AddToCombo(Actor Source) { SnapPlayer sp = null; if (multiplayer == false && playeringame[consoleplayer] == true) { // Always redirect to the player when playing singleplayer sp = SnapPlayer(players[consoleplayer].mo); } else { sp = SnapPlayer(Source); } if (sp == null) { return; } if (bCountKill == true) { sp.AddScore(SnapScore); sp.Combo.Increase(); } /* else { sp.Combo.TimeReset(); } */ } void IncreaseComboTime(Actor Source, int Amount) { let sp = SnapPlayer(source); if (sp == null) { return; } sp.Combo.TimeIncrease(Amount); } } class SnapActor : Actor abstract { // Actor extension with some useful or repeated functions. mixin SnapHitstunFuncs; mixin SnapGeneralFunctions; property DamageFlash: DamageFlashTranslation; override void BeginPlay() { super.BeginPlay(); HitstunBegin(); Translation = GetDefaultTranslation(); if (bMissileSpriteFix == true) { DoMissileSpriteFix(); } } override void Tick() { UpdateTouchDamage(); bool objPause = TickPaused(); bool inHitstun = RunHitstun(); if (objPause == true || inHitstun == true) { return; } super.Tick(); RunDamageFlash(); DecrementTouchDelay(); DoWaterPushEFX(); DoOverheal(); } override int TakeSpecialDamage(Actor inflictor, Actor source, int damage, Name damagetype) { int result = super.TakeSpecialDamage(inflictor, source, damage, damagetype); let srcMonster = SnapMonster(source); if (srcMonster != null) { if (srcMonster.bQuadDamage == true) { result *= 4; } if (srcMonster.VictoryMarch > 0) { result = int(ceil(result * 1.5)); } } if (Hitstun != null && Hitstun.Burst > 0) { // Reduced damage during burst. result = int(ceil(result * SnapHitstun.BURST_DMG_FACTOR)); } return result; } override int DamageMobj(Actor inflictor, Actor source, int damage, Name mod, int flags, double angle) { source = SetDominoSource(source); int trueDamage = super.DamageMobj(inflictor, source, damage, mod, flags, angle); HandleDamageHitstun(trueDamage, inflictor); SetDamageFlash(trueDamage); IncreaseComboTime(source, damage); return trueDamage; } override void Die(Actor source, Actor inflictor, int dmgflags, Name MeansOfDeath) { source = SetDominoSource(source); /* // The killing blow has max hitstun let inf = SnapActor(inflictor); if (inf) { inf.AddHitstun(SnapHitstun.MAX_HITLAG, false); } AddHitstun(SnapHitstun.MAX_HITLAG, true); */ if (bCanDropAmmo == true) { let sp = SnapPlayer(source); if (sp) { // Only do the drop cycling if you have a powerup. if (sp.CountInv("SnapPowerupAmmo") > 0) { sp.AmmoDropCycle++; if (sp.AmmoDropCycle >= sp.RobotsForAmmoDrop()) { DropAmmo = true; sp.AmmoDropCycle = 0; } } } } AddToCombo(source); super.Die(source, inflictor, dmgflags, MeansOfDeath); } override bool CanCollideWith(Actor toucher, bool passive) { if (TouchDamage != 0 && bMissile == false && toucher.bMissile == false) { if ((Pos.Z <= toucher.Pos.Z + toucher.Height) && (Pos.Z + Height >= toucher.Pos.Z)) { DealTouchDamage(toucher); } return false; } return super.CanCollideWith(toucher, passive); } override int SpecialMissileHit(Actor toucher) { if (TouchDamage != 0) { DealTouchDamage(toucher); return 1; } return super.SpecialMissileHit(toucher); } virtual int GetDefaultTranslation() { return Default.Translation; } virtual int GetFlashTranslation() { return DefaultFlashing(); } virtual void WasKicked( Actor source, Actor hitPuff, uint KickDamage, Vector3 KickSpeed, int HitstunFrames, bool FromFriendly) { // Determines what happens when you're kicked by, // when you're struck by, Snap GenericKick(self, source, hitPuff, KickDamage, KickSpeed, HitstunFrames, FromFriendly); } virtual Actor CreateShiftDIGhost(Vector3 SpawnPos) { // Needs implemented per object, due to // multi-part objects and MODELDEF shenanigans. return null; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapAmmoDrop : SnapInventory { Default { Inventory.PickupMessage "$POWERUP_AMMO"; Inventory.Amount 20; SnapInventory.ShadowSize 8; Mass 5; } States { Spawn: AMMO A 10; AMMO A 10 Bright; Loop; } override bool TryPickup (in out Actor other) { let sp = SnapPlayer(other); if (sp) { int amt = sp.CountInv("SnapPowerupAmmo"); if (amt > 0 && amt < 99 && sp.InfiniteWeapon == false) { // Give ammo for your current weapon. sp.GiveAmmo("SnapPowerupAmmo", Amount); } else { // Give just a tiny bit of meter. // These normally won't drop without you having a weapon, // so this is more of an easter egg. sp.AddSnapPOWMeter(250, false); } ItemExtendCombo(sp); GoAwayAndDie(); return true; } return false; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapPlayer { const DEFAULT_AMMO_DROP = 10; virtual uint RobotsForAmmoDrop() { let props = SnapWeaponProps.GetWeaponPropsByID(WeaponPower); if (props != null) { if (props.DropFreq > 0) { return props.DropFreq; } } return DEFAULT_AMMO_DROP; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- // // Snap "Animator" class. // This helps manage multi-part objects that need to animate quickly. // class SnapPartFrameData { const MAXJOINTS = 8; Vector3 Joints[MAXJOINTS]; } class SnapPartBase : SnapDynamicDecor abstract { uint SnapPartBaseFlags; flagdef FootCheck: SnapPartBaseFlags, 0; Array Frames; abstract void InitFrameData(); int ConnectTo; int ConnectJoint; double AngleOffset; double PitchOffset; double RollOffset; uint AnimID; uint AnimPrevID; uint AnimTics; uint AnimFrame; virtual Vector3 ParentAngles() { return (0.0, 0.0, 0.0); // Angle, Pitch, Roll. } virtual double AnimSpeedMul() { return 1.0; } void SetJointData(uint FrameID, uint JointID, Vector3 JointPos) { if (FrameID >= uint(Frames.Size())) { SnapPartFrameData NewFrameData = new("SnapPartFrameData"); Frames.Insert(FrameID, NewFrameData); } Frames[FrameID].Joints[JointID] = JointPos; } override void BeginPlay() { InitFrameData(); super.BeginPlay(); ChangeStatNum(STAT_ANIMATOR); } Default { +MASTERNOSEE } } class SnapAnimationParts { StateLabel St; double Angle; double Pitch; double Roll; } class SnapAnimationFrames { Vector3 Offset; Array PartSettings; } class SnapAnimationData abstract { SnapAnimatorBase Animator; int Tics; bool SetInstantly; Array Frames; void SetAnimationFrameOffset(uint FrameID, Vector3 o) { if (FrameID >= uint(Frames.Size())) { SnapAnimationFrames NewFrameData = new("SnapAnimationFrames"); Frames.Insert(FrameID, NewFrameData); } Frames[FrameID].Offset = o; } void InsertAnimationFramePartInfo( uint FrameID, uint PartID, double a = 0.0, double p = 0.0, double r = 0.0 ) { if (FrameID >= uint(Frames.Size())) { SnapAnimationFrames NewFrameData = new("SnapAnimationFrames"); Frames.Insert(FrameID, NewFrameData); } SnapAnimationParts NewPartData = new("SnapAnimationParts"); NewPartData.Angle = a; NewPartData.Pitch = p; NewPartData.Roll = r; //NewPartData.St = St; Frames[FrameID].PartSettings.Insert(PartID, NewPartData); } static int SpeedUpTics(int initTics, double spd, double step = 6.25) { if (initTics <= 1) { return initTics; } int newTics = initTics - int(spd / step); if (newTics < 1) { newTics = 1; } return newTics; } abstract void InitAnim(); virtual int GetTics() { return Tics; } } class SnapAnimatorBase : SnapStaticDecor abstract { const ANGLECHANGE = 45.0; Array Animations; abstract void InitAnimations(); Array Parts; abstract void InitParts(); abstract void ResolveAnimIDs(in out Array AnimIDs); bool AnimatorInit; Vector3 AnimatorOffset; Default { +NOGRAVITY +NOBLOCKMAP +DONTSPLASH +NOINTERACTION +MASTERNOSEE } void ReserveAnimation(class type, uint ID) { let NewData = SnapAnimationData(new(type)); if (NewData == null) { return; } NewData.Animator = SnapAnimatorBase(self); NewData.InitAnim(); Animations.Insert(ID, NewData); } void ReservePart( class type, uint ID, int ConnectToID, int ConnectJoint ) { let NewPart = SnapPartBase(Spawn(type, Pos, ALLOW_REPLACE)); if (NewPart == null) { return; } NewPart.target = self; NewPart.tracer = self.target; NewPart.master = self.master; NewPart.ConnectTo = ConnectToID; NewPart.ConnectJoint = ConnectJoint; NewPart.bInvisible = true; Parts.Insert(ID, NewPart); } void CopyPropsToPart(Actor Src, SnapPartBase Part) { if (Src == null || Part == null) { return; } Part.bInvisible = Src.bInvisible; Part.bBright = Src.bBright; Part.Scale = Src.Scale; Part.Translation = Src.Translation; } Vector3 RotateCoords(Vector3 Input, double RotAngle, double RotPitch, double RotRoll) { Vector3 Result = Input; Result.Y = (Input.Y * cos(RotRoll)) - (Input.Z * sin(RotRoll)); Result.Z = (Input.Y * sin(RotRoll)) + (Input.Z * cos(RotRoll)); Input = Result; Result.X = (Input.X * cos(RotPitch)) + (Input.Z * sin(RotPitch)); Result.Z = (-Input.X * sin(RotPitch)) + (Input.Z * cos(RotPitch)); Input = Result; Result.X = (Input.X * cos(RotAngle)) - (Input.Y * sin(RotAngle)); Result.Y = (Input.X * sin(RotAngle)) + (Input.Y * cos(RotAngle)); return Result; } Vector3 ScaleCoord(Vector3 input, Vector2 iScale) { return ( input.x * iScale.x, input.y * iScale.x, input.z * iScale.y ); } Vector3 GetJointCoords( SnapPartBase Part, SnapPartBase ConnectToPart, uint ConnectToJoint, uint ThisJointFrame, uint ConnectJointFrame) { SnapPartFrameData ConnectFrameData = ConnectToPart.Frames[ConnectJointFrame]; Vector3 JointInfo = ConnectFrameData.Joints[ConnectToJoint]; JointInfo = ScaleCoord(JointInfo, target.Scale); // JointFixOffset fixes any parts that don't have their connecting joint set as 0,0,0 Vector3 JointFixOffset = Part.Frames[ThisJointFrame].Joints[0]; JointFixOffset = ScaleCoord(JointFixOffset, target.Scale); // Rotate the joint coordinates around to match the object's angle. Vector3 Rotated = RotateCoords(JointInfo, ConnectToPart.Angle, ConnectToPart.Pitch, ConnectToPart.Roll); Vector3 RotFix = RotateCoords(JointFixOffset, Part.Angle, Part.Pitch, Part.Roll); return (Rotated - RotFix); } SnapAnimationFrames GetFrameProperties(SnapAnimationData Anim, uint Frame, uint NumFrames) { if (Anim == null) { return null; } if (NumFrames == 0) { return null; } uint AnimFrame = Frame % NumFrames; return Anim.Frames[AnimFrame]; } double UpdateAngle(double Input, double Dest, double AngSpeed = ANGLECHANGE) { double Result = Input; double Delta = -DeltaAngle(Input, Dest); if (AngSpeed < abs(Delta)) { if (Delta > 0) { Result -= AngSpeed; } else { Result += AngSpeed; } } else { Result = Dest; } return Result; } void UpdateParts(bool NeedsInit = false) { if (target == null) { //Destroy(); return; } int NumParts = Parts.Size(); if (NumParts <= 0) { //Destroy(); return; } bool HideEm = false; if (target.Sprite != GetSpriteIndex('ANIM')) { // In a specialized pose. HideEm = true; } // The animation system works like so: // You can queue up several animations in a single frame. // Anything that is not set in an animation will be left alone that frame. // If multiple animations try to adjust the same things, the one pushed to // the end of the array has priority. Array NewAnimIDs; ResolveAnimIDs(NewAnimIDs); int NumAnimUpdates = NewAnimIDs.Size(); if (NumAnimUpdates <= 0) { return; } // First: Find the highest priority animation for all parts. for (int j = 0; j < NumAnimUpdates; j++) { uint NewAnimID = NewAnimIDs[j]; SnapAnimationData CurAnimData = Animations[NewAnimID]; uint AnimNumFrames = CurAnimData.Frames.Size(); for (int i = 0; i < NumParts; i++) { let Part = Parts[i]; if (Part == null) { continue; } SnapAnimationFrames FrameProps = GetFrameProperties(CurAnimData, Part.AnimFrame, AnimNumFrames); if (FrameProps == null) { continue; } SnapAnimationParts PartProps = null; if (i < FrameProps.PartSettings.Size()) { PartProps = FrameProps.PartSettings[i]; if (PartProps != null) { // Update anim ID. Part.AnimID = NewAnimID; } } } } // Second loop: Update angles. for (int i = 0; i < NumParts; i++) { let Part = Parts[i]; if (Part == null) { continue; } SnapAnimationData CurAnimData = Animations[Part.AnimID]; uint AnimNumFrames = CurAnimData.Frames.Size(); SnapAnimationFrames FrameProps = GetFrameProperties(CurAnimData, Part.AnimFrame, AnimNumFrames); if (FrameProps == null) { continue; } SnapAnimationParts PartProps = null; if (i < FrameProps.PartSettings.Size()) { PartProps = FrameProps.PartSettings[i]; } // Set animation frames Vector3 pAngles = Part.ParentAngles(); double DestAngleOffset = 0.0; double DestPitchOffset = 0.0; double DestRollOffset = 0.0; if (PartProps != null) { DestAngleOffset = PartProps.Angle; DestPitchOffset = PartProps.Pitch; DestRollOffset = PartProps.Roll; } if (CurAnimData.SetInstantly == true || NeedsInit == true) { Part.AngleOffset = DestAngleOffset; Part.PitchOffset = DestPitchOffset; Part.RollOffset = DestRollOffset; } else { Part.AngleOffset = UpdateAngle(Part.AngleOffset, DestAngleOffset); Part.PitchOffset = UpdateAngle(Part.PitchOffset, DestPitchOffset); Part.RollOffset = UpdateAngle(Part.RollOffset, DestRollOffset); } Part.Angle = pAngles.x + Part.AngleOffset; Part.Pitch = pAngles.y + Part.PitchOffset; Part.Roll = pAngles.z + Part.RollOffset; } // Third loop: Now that all of the parts' angles are updated, // we can update the positioning to make them make sense. for (int i = 0; i < NumParts; i++) { let Part = Parts[i]; if (Part == null) { continue; } CopyPropsToPart(target, Part); if (Part.ConnectTo >= NumParts) { //Destroy(); return; } SnapAnimationData CurAnimData = Animations[Part.AnimID]; uint AnimNumFrames = CurAnimData.Frames.Size(); SnapPartBase ConnectToPart = null; int ConnectJointID = -1; if (Part.ConnectTo >= 0 && Part.ConnectTo < Parts.Size()) { ConnectToPart = Parts[Part.ConnectTo]; ConnectJointID = Part.ConnectJoint; } Vector3 Coords = Part.Pos; if (ConnectToPart == null || ConnectJointID == -1) { Vector3 FinalOffset = AnimatorOffset; SnapAnimationFrames FrameProps = GetFrameProperties(CurAnimData, Part.AnimFrame, AnimNumFrames); if (FrameProps != null) { FinalOffset += FrameProps.Offset; } Coords = Target.Pos + RotateCoords(FinalOffset, Part.Angle, Part.Pitch, Part.Roll); } else { Vector3 JointCoords = GetJointCoords(Part, ConnectToPart, ConnectJointID, 0, 0); Coords = ConnectToPart.Pos + JointCoords; } Part.SetOrigin(Coords, true); } // One more loop to calculate foot clipping. double FootZ = target.Pos.Z; for (int i = 0; i < NumParts; i++) { let Part = Parts[i]; if (Part == null) { continue; } if (HideEm == true) { Part.bInvisible = true; } if (Part.bFootCheck == true) { FootZ = min(FootZ, Part.Pos.Z); } } double ZOffset = (target.Pos.Z - FootZ) - target.FloorClip; if (ZOffset != 0.0) { for (int i = 0; i < NumParts; i++) { let Part = Parts[i]; if (Part == null) { continue; } Part.SetOrigin(Part.Pos + (0, 0, ZOffset), true); } } // Finally, update animation properties for (int i = 0; i < NumParts; i++) { let Part = Parts[i]; if (Part == null) { continue; } SnapAnimationData CurAnimData = Animations[Part.AnimID]; int AnimNumFrames = CurAnimData.Frames.Size(); int AnimTicVal = CurAnimData.GetTics(); int AnimSpeed = abs(AnimTicVal); bool AnimReverse = (AnimTicVal < 0); if (Part.AnimPrevID != Part.AnimID) { Part.AnimFrame = 0; Part.AnimTics = min(Part.AnimTics, AnimSpeed); } else if (AnimSpeed > 0) { if (Part.AnimTics > 0) { Part.AnimTics--; } if (Part.AnimTics <= 0) { Part.AnimTics = AnimSpeed; int NewFrame = Part.AnimFrame; if (AnimReverse == true) { NewFrame--; } else { NewFrame++; } if (NewFrame >= AnimNumFrames) { NewFrame = 0; } else if (NewFrame < 0) { NewFrame = AnimNumFrames-1; } Part.AnimFrame = NewFrame; } } Part.AnimPrevID = Part.AnimID; } } override void BeginPlay() { super.BeginPlay(); ChangeStatNum(STAT_ANIMATOR); } override void PostBeginPlay() { InitAnimations(); InitParts(); super.PostBeginPlay(); } override void Tick() { super.Tick(); UpdateParts(!AnimatorInit); AnimatorInit = true; } override void OnDestroy() { for (int i = 0; i < Parts.Size(); i++) { let Part = Parts[i]; if (Part != null) { Part.Destroy(); } } super.OnDestroy(); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapEventHandler { static void PlayAnnouncerLine(Sound sfx) { PlayerInfo player = players[consoleplayer]; let sp = player.mo; if (sp != null) { sp.A_StopSound(CHAN_ANNOUNCER); sp.A_StartSound(sfx, CHAN_ANNOUNCER, CHANF_UI|CHANF_LOCAL, 1.0, ATTN_NONE); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class ArsonTopFlame : SnapDynamicDecor { Default { Radius 20; Height 32; RenderStyle "Add"; +RANDOMIZE +BRIGHT } States { Spawn: DEXP ABCDEFG 2 Light("BlueExplosionLight"); Stop; } } class ArsonTopFlameSpawner : SnapMissile { action void A_CreateFlame() { Vector2 NewScale = self.Scale + (((1.0, 1.0) - self.Scale) * 0.75); let flame = Spawn( "ArsonTopFlame", Pos, ALLOW_REPLACE ); if (flame) { flame.Scale = NewScale; flame.Vel.X = random[snap_decor](-2, 2) * NewScale.X; flame.Vel.Y = random[snap_decor](-2, 2) * NewScale.X; flame.Vel.Z = random[snap_decor](0, 6) * NewScale.Y; flame.target = self.target; flame.tracer = self.tracer; } } Default { Radius 20; Height 32; Speed 1; DamageFunction 1; DamageType "Fire"; SeeSound "revolver/flame"; Obituary "$OB_ARSONTOP"; -NOGRAVITY -NOBLOCKMAP +RIPPER +DONTREFLECT +NODAMAGETHRUST +NOEXPLODEFLOOR +BRIGHT +DONTSPLASH +SnapShadowActor.DISABLESHADOW } States { Spawn: TNT1 A 1; TNT1 AAAAAAAAAAAAAAA 5 A_CreateFlame; Stop; } } class ArsonTopFireball : SnapMissile { action void A_CreateFlameSpawner() { Vector3 spawnPos = Pos + (0, 0, Height * 0.5); let spawner = SnapActor(Spawn("ArsonTopFlameSpawner", spawnPos, ALLOW_REPLACE)); if (spawner) { spawner.SetPhysicalSize(Scale); PlaySpawnSound(spawner); spawner.target = self.target; spawner.tracer = self.tracer; spawner.angle = self.angle; spawner.Vel.XY = AngleToVector(spawner.angle, spawner.Default.Speed); spawner.Vel.Z = self.Vel.Z + 6; } } Default { Radius 24; Height 40; Speed 20; DamageFunction 10; DamageType "Fire"; SeeSound "arson/fire"; Obituary "$OB_ARSONTOP"; RenderStyle "Add"; +RANDOMIZE +RIPPER +BRIGHT +STEPMISSILE } States { Spawn: AFBL ABCDEF 3 Light("ArsonTopShotLight") A_CreateFlameSpawner; Loop; Death: AFBL GHIJK 2 Light("ArsonTopShotLight"); Stop; } } class ArsonTopRudeFireball : ArsonTopFireball { States { Spawn: AFBL ABCDEF 3 A_CreateFlameSpawner; AFBL A 0 { ExplodeMissile(); } Stop; } } class ArsonTop : SnapMonster { const ARSONSPREAD = 5.625; int ArsonFireballSign; uint ArsonSpinCounter; action void A_ArsonFire(uint phase = 1) { if (target == null) { return; } A_FaceTarget(22.5); int FireballSign = 1; double FireballAngle = 0.0; let arson = ArsonTop(self); if (arson) { if (phase == 1) { if (SnapUtils.SafeVec2Unit(target.Vel.XY) dot AngleToVector(angle + 90) < 0.0) { arson.ArsonFireballSign = -1; } else { arson.ArsonFireballSign = 1; } } FireballSign = arson.ArsonFireballSign; } switch (phase) { case 1: FireballAngle = ARSONSPREAD; break; case 2: FireballAngle = -ARSONSPREAD; break; case 3: FireballAngle = -ARSONSPREAD * 0.5; break; default: return; } for (int i = 0; i < 2; i++) { int sign = -1; if (i & 1) { sign = 1; } A_SnapMonsterProjectile( "ArsonTopFireball", (4, 44 * sign, 8), FireballAngle * FireballSign ); switch (phase) { case 1: FireballAngle += ARSONSPREAD; break; case 2: FireballAngle -= ARSONSPREAD; break; case 3: FireballAngle += ARSONSPREAD; break; default: return; } } } action void A_ArsonRudeSpin() { let arson = ArsonTop(self); if (arson) { arson.ArsonSpinCounter++; } Angle += 11.25; } action state A_ArsonRudeFire() { let arson = ArsonTop(self); if (!arson) { A_ArsonReset(); return ResolveState('See'); } if (arson.ArsonSpinCounter >= 16) { double FireballAngle = -ARSONSPREAD * 0.5; for (int i = 0; i < 2; i++) { int sign = -1; if (i & 1) { sign = 1; } A_SnapMonsterProjectile( "ArsonTopRudeFireball", (4, 44 * sign, 8), FireballAngle, 0.0, SMP_DONTAIM ); FireballAngle += ARSONSPREAD; } frame -= 1; } if (arson.ArsonSpinCounter > 48) { A_ArsonReset(); return ResolveState('Missile'); // 'Missile' ? } A_ArsonRudeSpin(); return null; } action void A_ArsonChase() { let arson = ArsonTop(self); if (!arson) { A_SnapChase(); return; } if (arson.bVeryRude == true) { A_SnapChase(null, 'RudeMissile'); return; } A_SnapChase(); } action void A_ArsonReset() { let arson = ArsonTop(self); if (arson) { arson.ArsonSpinCounter = 0; arson.ArsonFireballSign = 1; } ReactionTime = 35; } Default { Health 200; Radius 40; Height 72; Speed 10; Mass 400; SnapActor.DamageFlash "EnemyDamagedBlue"; SnapMonster.Poise 200; SnapActor.Score 1000; SeeSound "arson/see"; ActiveSound "arson/idle"; PainSound "arson/hurt"; Obituary "$OB_ARSONTOP"; Tag "$TAG_ARSONTOP"; Species "Robot"; +SnapMonster.ROBOTTOUGH +SnapMonster.ROBOTEXPLODES } States { Spawn: ARSN A 2 A_SnapMonsterLook(); ARSN BABAB 2; Loop; See: ARSN CDEF 2 A_ArsonChase(); Loop; Missile: ARSN HHHHHHH 2 A_FaceTarget(22.5); ARSN G 2 Light("ArsonTopMuzzleLight") A_ArsonFire(1); ARSN HHHHHHHHHHHHHHH 2 A_FaceTarget(22.5); ARSN G 2 Light("ArsonTopMuzzleLight") A_ArsonFire(2); ARSN HHHHHHHHHHHHHHH 2 A_FaceTarget(22.5); ARSN G 2 Light("ArsonTopMuzzleLight") A_ArsonFire(3); ARSN HHHHHHH 2; ARNS H 0 A_ArsonReset(); Goto See; RudeMissile: ARSN H 1 A_ArsonRudeSpin(); ARSN G 2 Light("ArsonTopMuzzleLight") A_ArsonRudeFire(); Loop; Pain: ARSN I 8 A_ArsonReset(); ARSN I 8 A_SnapMonsterPain(); Goto See; Kicked: ARSN I 8 A_ArsonReset(); ARSN I 8 A_SnapMonsterPain(); KickLoop: ARSN I 3 A_EndKick(); Loop; Death: ARSN I 1; ARSN IIIIIIII 4 DoSnapMonsterExplode(); TNT1 A 35 DoSnapMonsterDie(); Stop; GiantDeath: ARSN I 1; ARSN IIIII 4 DoSnapBossExplode(); ARSN I 4 DoSnapBossBigExplode(); ARSN IIIII 4 DoSnapBossExplode(); ARSN I 4 DoSnapBossBigExplode(); ARSN IIIII 4 DoSnapBossExplode(); ARSN I 4 DoSnapBossBigExplode(); ARSN IIIII 4 DoSnapBossExplode(); ARSN I 4 DoSnapBossBigExplode(); ARSN IIIII 4 DoSnapBossExplode(); TNT1 A 35 DoSnapBossDie(); Stop; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class AugerMissile : SnapMissile { Default { Radius 16; Height 48; Speed 15; DamageFunction 10; RenderStyle "Add"; SeeSound "turret/shoot"; DeathSound "revolver/death"; Obituary "$OB_AUGER"; +RANDOMIZE +BRIGHT } States { Spawn: AGBL ABCD 1 Light("AugerBulletLight"); Loop; Death: AGBL BEFGHIJK 1 Light("AugerBulletLight"); Stop; } override void BeginPlay() { super.BeginPlay(); bXFlip = random[snap_decor](0, 1); } override int SpecialMissileHit(Actor victim) { Actor source = target; if (source != null) { if (victim == source) { // Our shooter. return 1; } Actor owner = source.master; if (owner != null) { if (victim == owner || victim.master == owner) { // Our shooter's owner, or the shooter has the same owner as the victim. return 1; } } } return -1; } override bool CanCollideWith(Actor toucher, bool passive) { if ((toucher is "Auger") || (toucher is "AugerAttachment") || (toucher is "AugerSeg") || (toucher is "AugerDrill")) { return false; } return super.CanCollideWith(toucher, passive); } } class AugerFire : SnapFlameShot { Default { Speed 12; SeeSound "revolver/flame"; } override int DoSpecialDamage(Actor target, int damage, name damagetype) { // Don't deal the flame shot's bonus damage to players. return damage; } override int SpecialMissileHit(Actor victim) { Actor source = target; if (source != null) { if (victim == source) { // Our shooter. return 1; } Actor owner = source.master; if (owner != null) { if (victim == owner || victim.master == owner) { // Our shooter's owner, or the shooter has the same owner as the victim. return 1; } } } return -1; } override bool CanCollideWith(Actor toucher, bool passive) { if ((toucher is "Auger") || (toucher is "AugerAttachment") || (toucher is "AugerSeg") || (toucher is "AugerDrill")) { return false; } return super.CanCollideWith(toucher, passive); } } class AugerShockwaveDust : SnapActor { Default { Radius 16; Height 8; RenderStyle "Translucent"; Alpha 0.5; +NOBLOCKMAP +NOINTERACTION +BRIGHT } States { Spawn: ASHW A 2; ASHW B 1 A_SetRenderStyle(0.7, STYLE_Translucent); ASHW C 1 A_SetRenderStyle(0.5, STYLE_Translucent); ASHW D 1 A_SetRenderStyle(0.7, STYLE_Translucent); ASHW E 1 A_SetRenderStyle(0.5, STYLE_Translucent); ASHW F 1 A_SetRenderStyle(0.7, STYLE_Translucent); Stop; } } class AugerShockwave : SnapMissile { action void A_SpawnShockwaveDust() { let dust = SnapActor(Spawn("AugerShockwaveDust", Pos, ALLOW_REPLACE)); if (dust != null) { dust.SetPhysicalSize(Scale); } } Default { Radius 16; Height 8; Speed 16; Damage 0; SnapActor.TouchDamage 10; Obituary "$OB_AUGER"; Gravity 8.0; -NOGRAVITY +RIPPER +DONTREFLECT +NODAMAGETHRUST +NOEXPLODEFLOOR +BRIGHT +STEPMISSILE -SnapActor.MISSILESPRITEFIX } States { Spawn: TNT1 A 1; TNT1 AAAAAAAAAAAA 1 A_SpawnShockwaveDust(); Stop; Death: TNT1 A 1; Stop; } override int SpecialMissileHit(Actor victim) { if ((victim is "Auger") || (victim is "AugerAttachment") || (victim is "AugerSeg") || (victim is "AugerDrill")) { return 1; } return super.SpecialMissileHit(victim); } override bool CanCollideWith(Actor other, bool passive) { if ((other is "Auger") || (other is "AugerAttachment") || (other is "AugerSeg") || (other is "AugerDrill")) { return false; } return super.CanCollideWith(other, true); } } class AugerPuff : SnapPuff { States { Spawn: TNT1 A 4; Goto Super::Spawn; } } class Auger : SnapBoss { Array AugerAttachments; uint AugerBaseAttachments; Actor OurDrill; const AUGERMAXSEGS = 8; const AUGERMAXSEGSINVASION = 4; uint AugerDestSegs; uint AugerNumSegs; const AUGERBASESPINSPEED = 0.8; const AUGERANGLEACCEL = 0.05; double AugerDestAngleMom; double AugerAngleMom; const AUGERZACCEL = 12.0; double AugerZ; uint AugerPatternPos; uint AugerWeaponPos; uint AugerDrillDropID; Vector3 AugerOrigin; Vector2 FollowVel; uint AugerIdle; const AUGERFIRETIME = 2; int AugerFireSeg; int AugerFireSegDir; uint AugerFireSegDelay; const AUGERSWINGSNDFREQ = 45.0; double AugerSwingAmt; uint SpinFlipDelay; uint AugerFlags; flagdef DrillsExtend: AugerFlags, 0; flagdef DrillsAnimate: AugerFlags, 1; flagdef DrillItemPop: AugerFlags, 2; flagdef DidItemPop: AugerFlags, 3; flagdef AreWeDropped: AugerFlags, 4; flagdef PrevDropped: AugerFlags, 5; flagdef AugerPinch: AugerFlags, 6; flagdef FollowTarget: AugerFlags, 7; flagdef NoMoving: AugerFlags, 8; flagdef FlipFiring: AugerFlags, 9; flagdef FireNow: AugerFlags, 10; flagdef IntroDrop: AugerFlags, 11; flagdef DropHop: AugerFlags, 12; flagdef DrillsWereExtended: AugerFlags, 13; flagdef SpinFlipped: AugerFlags, 14; Default { Health 2000; Radius 36; Height 80; Speed 16; Mass 1000; SnapActor.TouchDamage 10; SnapMonster.Poise 400; DamageFactor "ScreenClear", 0.5; SeeSound "auger/see"; ActiveSound "auger/idle"; PainSound "auger/hurt"; Obituary "$OB_AUGER"; Tag "$TAG_AUGER"; +DONTTHRUST +MISSILEMORE +DONTCORPSE +NOGRAVITY +INVULNERABLE +CANTSEEK -WINDTHRUST +NOTELEPORT +SnapMonster.ROBOTTOUGH } uint GetAugerMaxSegs() { if (bAmbush == false) { return AUGERMAXSEGSINVASION; } return AUGERMAXSEGS; } action state A_PickAugerAttack() { let ourselves = Auger(self); if (!ourselves) { return null; } state attackState = null; uint maxPattern = 0; if (ourselves.bAugerPinch == true) { if (ourselves.bBossHard == true) { attackState = ResolveState("PinchHardDrill"); } else { attackState = ResolveState("PinchDrill"); } } else { if (ourselves.bBossHard == true) { statelabel AttackPattern[52]; maxPattern = 52; AttackPattern[0] = "Reset"; AttackPattern[1] = "Expand"; AttackPattern[2] = "FireSegs"; AttackPattern[3] = "SpinL"; AttackPattern[4] = "ItemDrill"; AttackPattern[5] = "SpinL"; AttackPattern[6] = "FireSegs"; AttackPattern[7] = "SpinL"; AttackPattern[8] = "FastSpinL"; AttackPattern[9] = "FireSegs"; AttackPattern[10] = "SpinL"; AttackPattern[11] = "ItemDrill"; AttackPattern[12] = "SpinR"; AttackPattern[13] = "DrillDrop"; AttackPattern[14] = "SpinR"; AttackPattern[15] = "FastSpinR"; AttackPattern[16] = "DrillRise"; AttackPattern[17] = "FireSegs"; AttackPattern[18] = "ItemDrill"; AttackPattern[19] = "SpinR"; AttackPattern[20] = "StopSpin"; AttackPattern[21] = "Reduce"; AttackPattern[22] = "CrazySpinL"; AttackPattern[23] = "CrazySpinL"; AttackPattern[24] = "StopSpin"; AttackPattern[25] = "Expand"; AttackPattern[26] = "FireSegs"; AttackPattern[27] = "Reduce"; AttackPattern[28] = "ItemDrill"; AttackPattern[29] = "CrazySpinR"; AttackPattern[30] = "CrazySpinR"; AttackPattern[31] = "StopSpin"; AttackPattern[32] = "Expand"; AttackPattern[33] = "FireSegs"; AttackPattern[34] = "FastSpinL"; AttackPattern[35] = "StopSpin"; AttackPattern[36] = "DrillDrop"; AttackPattern[37] = "SpinL"; AttackPattern[38] = "DrillRise"; AttackPattern[39] = "FireSegs"; AttackPattern[40] = "FireSegs"; AttackPattern[41] = "ItemDrill"; AttackPattern[42] = "FastSpinR"; AttackPattern[43] = "StopSpin"; AttackPattern[44] = "DrillDrop"; AttackPattern[45] = "SpinR"; AttackPattern[46] = "DrillRise"; AttackPattern[47] = "FireSegs"; AttackPattern[48] = "FireSegs"; AttackPattern[49] = "ItemDrill"; AttackPattern[50] = "Reduce"; AttackPattern[51] = "StopSpin"; attackState = ResolveState(AttackPattern[ourselves.AugerPatternPos]); } else { statelabel AttackPattern[32]; maxPattern = 32; AttackPattern[0] = "Reset"; AttackPattern[1] = "CrazySpinR"; AttackPattern[2] = "CrazySpinR"; AttackPattern[3] = "DrillDrop"; AttackPattern[4] = "ItemDrill"; AttackPattern[5] = "DrillRise"; AttackPattern[6] = "Expand"; AttackPattern[7] = "CrazySpinL"; AttackPattern[8] = "CrazySpinL"; AttackPattern[9] = "StopSpin"; AttackPattern[10] = "DrillDrop"; AttackPattern[11] = "SpinR"; AttackPattern[12] = "SpinR"; AttackPattern[13] = "FastSpinR"; AttackPattern[14] = "FastSpinR"; AttackPattern[15] = "SpinR"; AttackPattern[16] = "ItemDrill"; AttackPattern[17] = "SpinL"; AttackPattern[18] = "SpinL"; AttackPattern[19] = "FastSpinL"; AttackPattern[20] = "FastSpinL"; AttackPattern[21] = "SpinR"; AttackPattern[22] = "SpinR"; AttackPattern[23] = "FastSpinR"; AttackPattern[24] = "FastSpinR"; AttackPattern[25] = "ItemDrill"; AttackPattern[26] = "DrillRise"; AttackPattern[27] = "FastSpinL"; AttackPattern[28] = "DrillDrop"; AttackPattern[29] = "FastSpinL"; AttackPattern[30] = "FastSpinL"; AttackPattern[31] = "ItemDrill"; attackState = ResolveState(AttackPattern[ourselves.AugerPatternPos]); } } ourselves.AugerPatternPos++; if (ourselves.AugerPatternPos >= maxPattern) { ourselves.AugerPatternPos = 0; } A_PickBossTarget(); return attackState; } action void A_AugerSpin(int dir) { let ourselves = Auger(self); if (!ourselves) { return; } ourselves.AugerDestAngleMom = -AUGERBASESPINSPEED * dir; } action void A_AugerExtend(int segs = -1) { let ourselves = Auger(self); if (!ourselves) { return; } if (segs < 0) { // Default value segs = ourselves.GetAugerMaxSegs(); } if (ourselves.AugerDestSegs != segs) { A_StartSound("auger/extend"); } ourselves.AugerDestSegs = segs; } action void A_AugerDrillExtend(bool veryyes) { let ourselves = Auger(self); if (!ourselves) { return; } ourselves.bDrillsExtend = veryyes; } action void A_AugerDrop(bool veryyes) { let ourselves = Auger(self); if (!ourselves) { return; } ourselves.bAreWeDropped = veryyes; ourselves.bDropHop = false; } action void A_AugerHardOnlyExtend() { let ourselves = Auger(self); if (!ourselves) { return; } bool exVal = ourselves.bBossHard; A_AugerDrillExtend(exVal); A_AugerDrop(!exVal); } action void A_AugerItemDrill(bool itemPop = false) { let ourselves = Auger(self); if (!ourselves) { return; } ourselves.bDrillsAnimate = true; ourselves.bDrillItemPop = itemPop; } action void A_AugerFollow(bool veryyes) { let ourselves = Auger(self); if (!ourselves) { return; } ourselves.bFollowTarget = veryyes; if (ourselves.bFollowTarget == true) { ourselves.bNoMoving = false; } } action void A_AugerStop(bool veryyes) { let ourselves = Auger(self); if (!ourselves) { return; } ourselves.bNoMoving = veryyes; ourselves.FollowVel = (0.0, 0.0); if (veryyes == true && ourselves.bAugerPinch == true) { A_StartSound("auger/charge"); if (ourselves.bBossHard == false) { ourselves.bDropHop = true; } } } action void A_AugerFire() { let ourselves = Auger(self); if (!ourselves) { return; } if (ourselves.bFlipFiring == true) { ourselves.AugerFireSeg = ourselves.GetAugerMaxSegs() - 1; ourselves.AugerFireSegDir = -1; } else { ourselves.AugerFireSeg = 0; ourselves.AugerFireSegDir = 1; } ourselves.AugerFireSegDelay = AUGERFIRETIME; ourselves.bFlipFiring = !ourselves.bFlipFiring; } States { Spawn: AUGR A 3 A_SnapMonsterLook(); Loop; See: AUGR A 16; AUGR A 0 A_PickAugerAttack(); Loop; SpinL: AUGR A 0 A_AugerSpin(1); AUGR A 45; Goto See; SpinR: AUGR A 0 A_AugerSpin(-1); AUGR A 45; Goto See; FastSpinL: AUGR A 0 A_AugerSpin(2); AUGR A 45; Goto See; FastSpinR: AUGR A 0 A_AugerSpin(-2); AUGR A 45; Goto See; CrazySpinL: AUGR A 0 A_AugerSpin(4); AUGR A 45; Goto See; CrazySpinR: AUGR A 0 A_AugerSpin(-4); AUGR A 45; Goto See; StopSpin: AUGR A 0 A_AugerSpin(0); AUGR A 16; Goto See; FireSegs: AUGR A 35 A_AugerFire(); Goto See; Expand: AUGR A 16 A_AugerExtend(); Goto See; Reduce: AUGR A 16 A_AugerExtend(0); Goto See; DrillDrop: AUGR A 16 A_AugerDrillExtend(false); AUGR A 16 A_AugerDrop(true); Goto See; DrillRise: AUGR A 16 A_AugerDrop(false); Goto See; DrillExtend: AUGR A 16 A_AugerDrillExtend(true); Goto See; DrillUnextend: AUGR A 16 A_AugerDrillExtend(false); Goto See; ItemDrill: AUGR A 0 A_AugerStop(true); AUGR A 0 A_AugerSpin(0); AUGR A 16 A_AugerHardOnlyExtend(); AUGR AAAA 8 A_AugerItemDrill(); AUGR AAAA 6 A_AugerItemDrill(); AUGR AAAA 4 A_AugerItemDrill(); AUGR AAAA 2 A_AugerItemDrill(); AUGR AAAA 2 A_AugerItemDrill(); AUGR A 2 A_AugerItemDrill(true); AUGR AA 2 A_AugerItemDrill(); AUGR AA 2 A_AugerItemDrill(); AUGR AA 4 A_AugerItemDrill(); AUGR AA 6 A_AugerItemDrill(); AUGR AA 8 A_AugerItemDrill(); AUGR A 0 A_AugerStop(false); Goto See; PinchStart: AUGR B 16 A_AugerDrop(true); AUGR EFGHI 3; AUGR J 16; AUGR J 0 A_AugerDrillExtend(false); AUGR J 16 A_AugerDrop(false); AUGR J 0 { bInvulnerable = false; bCantSeek = false; } Goto See; PinchDrill: AUGR A 0 A_AugerDrillExtend(false); AUGR A 64 A_AugerFollow(true); AUGR A 0 A_AugerStop(true); AUGR A 16 A_AugerFollow(false); AUGR A 16 A_AugerHardOnlyExtend(); AUGR AAAA 4 A_AugerItemDrill(); AUGR AAAA 3 A_AugerItemDrill(); AUGR AAAA 2 A_AugerItemDrill(); AUGR AAAA 2 A_AugerItemDrill(); AUGR AAAA 2 A_AugerItemDrill(); AUGR A 2 A_AugerItemDrill(true); AUGR AA 2 A_AugerItemDrill(); AUGR AA 2 A_AugerItemDrill(); AUGR AA 2 A_AugerItemDrill(); AUGR AA 3 A_AugerItemDrill(); AUGR AA 4 A_AugerItemDrill(); AUGR A 0 A_AugerDrop(false); AUGR A 0 A_AugerStop(false); AUGR A 0 A_AugerDrillExtend(false); Goto See; PinchHardDrill: AUGR A 0 A_AugerDrillExtend(false); AUGR A 64 A_AugerFollow(true); AUGR A 0 A_AugerStop(true); AUGR A 16 A_AugerFollow(false); AUGR A 16 A_AugerHardOnlyExtend(); AUGR A 0 A_AugerDrillExtend(false); AUGR A 32 A_AugerFollow(true); AUGR A 0 A_AugerStop(true); AUGR A 16 A_AugerFollow(false); AUGR A 16 A_AugerHardOnlyExtend(); AUGR A 0 A_AugerDrillExtend(false); AUGR A 32 A_AugerFollow(true); AUGR A 0 A_AugerStop(true); AUGR A 16 A_AugerFollow(false); AUGR A 16 A_AugerHardOnlyExtend(); AUGR AAAA 4 A_AugerItemDrill(); AUGR AAAA 3 A_AugerItemDrill(); AUGR AAAA 2 A_AugerItemDrill(); AUGR AAAA 2 A_AugerItemDrill(); AUGR AAAA 2 A_AugerItemDrill(); AUGR A 2 A_AugerItemDrill(true); AUGR AA 2 A_AugerItemDrill(); AUGR AA 2 A_AugerItemDrill(); AUGR AA 2 A_AugerItemDrill(); AUGR AA 3 A_AugerItemDrill(); AUGR AA 4 A_AugerItemDrill(); AUGR A 0 A_AugerDrop(false); AUGR A 0 A_AugerStop(false); AUGR A 0 A_AugerDrillExtend(false); Goto See; Pain: AUGR A 16 A_SnapMonsterPain(); Reset: AUGR A 0 A_AugerDrop(false); AUGR A 0 A_AugerStop(false); AUGR A 0 A_AugerDrillExtend(false); AUGR A 0 A_AugerFollow(false); AUGR A 0 A_AugerExtend(0); Goto See; Death: AUGR J 1; AUGR JJJJJ 4 DoSnapBossExplode(); AUGR J 4 DoSnapBossBigExplode(); AUGR JJJJJ 4 DoSnapBossExplode(); AUGR J 4 DoSnapBossBigExplode(); AUGR JJJJJ 4 DoSnapBossExplode(); AUGR J 4 DoSnapBossBigExplode(); AUGR JJJJJ 4 DoSnapBossExplode(); AUGR J 4 DoSnapBossBigExplode(); AUGR JJJJJ 4 DoSnapBossExplode(); AUGR J 0 DoSnapBossDie(); TNT1 A 70; TNT1 A 0 A_BossDeath(); Stop; } void ShockwaveForActor(Actor origin, double Zpos) { origin.A_StartSound("auger/drop"); origin.A_QuakeEx( 1, 1, 9, 20, 0, 1024, "", QF_SCALEDOWN, 1, 1, 1, 128 ); for (int i = 0; i < 8; i++) { double a = i * 45; Actor spawner = origin.Spawn("AugerShockwave", (origin.Pos.X, origin.Pos.Y, Zpos), ALLOW_REPLACE); if (spawner) { if (origin.master != null) { spawner.target = origin.master; } else { spawner.target = origin; } spawner.master = origin; spawner.angle = origin.angle + a; spawner.Vel.XY = AngleToVector(spawner.angle, spawner.Default.Speed); spawner.Vel.Z = origin.Vel.Z + 6; spawner.CheckMissileSpawn(origin.Radius); } } } void SegThink(Actor seg, double segDist, double a, double z) { seg.bDormant = bDormant; seg.bInvisible = bDormant; seg.bThruActors = bDormant; Vector3 segOffset = ( segDist * cos(a), segDist * sin(a), z ); seg.SetOrigin(Pos + segOffset, true); seg.Vel = (0.001, 0.0, 0.0); // HACK: get it to register collision seg.angle = a; } class NextItemPop() { String ItemList[8]; uint ItemListLen = 8; ItemList[0] = "SnapSpreadCan"; ItemList[1] = "SnapRapidCan"; ItemList[2] = "SnapSpreadCan"; ItemList[3] = "SnapHomingCan"; ItemList[4] = "SnapRapidCan"; ItemList[5] = "SnapSpreadCan"; ItemList[6] = "SnapFlameCan"; ItemList[7] = "SnapSpreadCan"; class PopItem = ItemList[AugerWeaponPos]; AugerWeaponPos++; if (AugerWeaponPos >= ItemListLen) { AugerWeaponPos = 0; } return PopItem; } void DrillThink(Actor origin, Actor drill, uint ItemPopID, bool Shockwaves, bool DoDust = true) { let d = AugerDrill(drill); if (!d) { return; } d.bDormant = origin.bDormant; d.bInvisible = origin.bDormant; d.bThruActors = origin.bDormant; if (Shockwaves == true) { d.QueueShockwave = true; } Vector3 drillBase = origin.Pos; drillBase.Z -= drill.Height; double DestDrillOffset = 0.0; double FloorZ = origin.GetZAt(); if (bDrillsExtend == true) { DestDrillOffset = drillBase.Z - FloorZ; } if (abs(d.DrillOffset - DestDrillOffset) <= AUGERZACCEL) { d.DrillOffset = DestDrillOffset; } else { if (d.DrillOffset > DestDrillOffset) { d.DrillOffset -= AUGERZACCEL; } else if (d.DrillOffset < DestDrillOffset) { d.DrillOffset += AUGERZACCEL; } } Vector3 newPos = drillBase - (0, 0, d.DrillOffset); d.SetOrigin(newPos, true); d.Vel = (0.001, 0.0, 0.0); // HACK: get it to register collision if (d.Pos.Z <= FloorZ) { if (d.QueueShockwave == true) { ShockwaveForActor(d, FloorZ); d.QueueShockwave = false; } else if (DoDust == true && AugerAngleMom != 0.0 && (Level.maptime % 3 == 0)) { Actor DrillTrail = Spawn("AugerPuff", d.Pos, ALLOW_REPLACE); DrillTrail.Vel.Z = 1.0; } } if (bDrillsAnimate == true) { d.SetStateLabel('Spin'); } if (d.DrillOffset == DestDrillOffset && bDrillItemPop == true && ItemPopID == AugerDrillDropID) { Actor DroppedItem = d.A_DropItem(NextItemPop()); if (DroppedItem && target) { DroppedItem.Vel.XY = SnapUtils.SafeVec2Unit(d.Vec2To(target)) * 4.0; } bDidItemPop = true; } } override void BeginPlay() { super.BeginPlay(); AugerOrigin = Pos; if (bBossHard == true) { AugerBaseAttachments = 4; } else { AugerBaseAttachments = 2; } Actor NewDrill = Spawn("AugerDrill", Pos, NO_REPLACE); if (NewDrill) { let ND = AugerDrill(NewDrill); if (ND) { ND.master = self; ND.SetHitstunParent(self); OurDrill = NewDrill; } } double aOffset = 360 / AugerBaseAttachments; double a = angle + 90; for (uint i = 0; i < AugerBaseAttachments; i++) { Actor NewAttach = Spawn("AugerAttachment", Pos, NO_REPLACE); if (NewAttach) { let NA = AugerAttachment(NewAttach); if (NA) { NA.AttachOffset = 90 + (i * aOffset); NA.master = self; NA.SetHitstunParent(self); Actor AttachNewDrill = Spawn("AugerDrill", Pos, NO_REPLACE); if (AttachNewDrill) { let AnotherDrill = AugerDrill(AttachNewDrill); if (AnotherDrill) { AnotherDrill.master = NewAttach; AnotherDrill.SetHitstunParent(self); NA.OurDrill = AttachNewDrill; } } AugerAttachments.Push(NewAttach); } } a += aOffset; } } override void Tick() { super.Tick(); if (TickPaused() == true) { return; } AugerIdle++; uint AugerFrame = (AugerIdle / 3) % 4; if (bAugerPinch == true) { AugerFrame += 9; } if (CurState != null && CurState.Sprite == GetSpriteIndex("AUGR") && CurState.Frame == 0) { // This is a dumb hack, but I was already using // state logic for the gameplay, and didn't want // to redo everything... Frame = AugerFrame; } if (Health <= 0) { Vel = (0.0, 0.0, 0.0); return; } double DropOffset = 0.0; bool DoDrillShockwaves = false; bThruActors = bDormant; if (bDormant == true) { DropOffset = -1024.0; bIntroDrop = true; bInvisible = true; bThruActors = true; } else { bInvisible = Default.bInvisible; bThruActors = Default.bThruActors; if (bAreWeDropped == true) { if (bPrevDropped == false) { DoDrillShockwaves = true; } DropOffset = AugerOrigin.Z - GetZAt(); if (OurDrill) { DropOffset -= OurDrill.Height; } } else if (bDropHop == true) { DropOffset = -64.0; } if (bDrillsExtend == true && bDrillsWereExtended == false) { DoDrillShockwaves = true; } if (random[snap_decor](0, 255) == 0) { PlayActiveSound(); } } bPrevDropped = bAreWeDropped; bDrillsWereExtended = bDrillsExtend; double accel = AUGERZACCEL; if (bIntroDrop == true) { // Drop from the ceiling really fast for the intro animation. if (AugerZ >= 0.0) { bIntroDrop = false; } else { accel *= 8.0; } } if (abs(AugerZ - DropOffset) <= accel) { AugerZ = DropOffset; } else { if (AugerZ > DropOffset) { AugerZ -= accel; } else if (AugerZ < DropOffset) { AugerZ += accel; } } if (SpinFlipDelay > 0) { SpinFlipDelay--; } Vector3 AugerPos = ( Pos.X, Pos.Y, AugerOrigin.Z - AugerZ ); Vector2 MoveDir = (0, 0); Vector2 FollowXY = Pos.XY; Vector2 DestXY = Pos.XY; double MoveSpeed = 0.0; double CircleRadius = GetDefaultByType("AugerDrill").Radius * 0.8; if (bNoMoving == false) { if (bFollowTarget == true) { // Pinch phase following MoveSpeed = Default.Speed * 2.0; if (target) { FollowXY = target.Pos.XY; } else { // Wants to follow, but there wasn't anyone. A_PickBossTarget(); } } else if (bAmbush == false) { // Invasion mode -- always allow a bit of movement MoveSpeed = 2.0; if (bAreWeDropped == true) { MoveSpeed *= 0.5; } if (target) { DestXY = target.Pos.XY; Vector2 DestDiff = (DestXY - Pos.XY); if (DestDiff.Length() <= CircleRadius) { double a = Level.MapTime; DestXY += (cos(a), sin(a)) * CircleRadius; } } else { // Wants to follow, but there wasn't anyone. A_PickBossTarget(); } } else if (CurState == ResolveState("See")) { DestXY = AugerOrigin.XY; } } bool DoFollow = false; if (Pos.XY != FollowXY) { DoFollow = true; MoveDir = FollowXY - Pos.XY; } else if (Pos.XY != DestXY) { MoveDir = DestXY - Pos.XY; } if (MoveSpeed > 0.0 && SnapUtils.ValidVec2Unit(MoveDir) == true) { if (DoFollow == true) { Vector2 FollowDiff = (FollowXY - Pos.XY); if (FollowDiff.Length() > CircleRadius) { MoveSpeed /= Default.Speed * 2.0; double mul = 1.0; if (SnapUtils.ValidVec2Unit(FollowVel) == true) { double d = MoveDir.Unit() dot FollowVel.Unit(); mul += abs(d - 1.0) * 3.0; MoveSpeed *= mul; } FollowVel += MoveDir.Unit() * MoveSpeed; } } else { Vector2 move = MoveDir; if (move.Length() > MoveSpeed) { move = move.Unit() * MoveSpeed; } if (bAmbush == false && bAugerPinch == false) { if (SpinFlipDelay > 0) { move = -move; //(0, 0); } else { for (uint i = 0; i < AugerBaseAttachments; i++) { let NA = AugerAttachment(AugerAttachments[i]); if (NA == null || NA.bDestroyed) { continue; } if (NA.Health <= 0) { continue; } if (NA.TestMobjLocation() == true && NA.CheckMove(NA.Pos.XY + (move * 2.0), PCM_NOACTORS) == false) { // Swap direction A_StartSound("auger/extend"); move = (0, 0); bSpinFlipped = !bSpinFlipped; SpinFlipDelay = 10; break; } } } } AugerPos += move; if (bAmbush == false) { // Invasion mode -- move the origin with you. AugerOrigin.XY += move; AugerOrigin.Z = 144.0 + GetZAt(AugerOrigin.X, AugerOrigin.Y, 0, GZF_ABSOLUTEPOS); } } } if (FollowVel != (0, 0)) { Vel.XY = FollowVel; if (bAmbush == false) { // Invasion mode -- move the origin with you. AugerOrigin += Vel.XY; AugerOrigin.Z = 144.0 + GetZAt(AugerOrigin.X, AugerOrigin.Y, 0, GZF_ABSOLUTEPOS); } Vector2 bounce = (0, 0); if (bAugerPinch == false) { double segRad = GetDefaultByType("AugerSeg").Radius * 0.8; double dist = segRad * 2.0 * AugerNumSegs; bounce = GetWallBounceDir(dist); } else { bounce = GetWallBounceDir(); } if (bounce != (0, 0)) { FollowVel = Vel.XY = FollowVel.Length() * bounce; } } else { SetOrigin(AugerPos, true); Vel = (0.001, 0.0, 0.0); // HACK: get it to register collision } uint MaxDropID = 0; if (OurDrill) { DrillThink(self, OurDrill, MaxDropID, DoDrillShockwaves, false); MaxDropID++; if (bDrillsAnimate == true) { A_QuakeEx( 1, 1, 5, 20, 0, 1024, "", QF_SCALEDOWN, 1, 1, 1, 128 ); } } if (bAugerPinch == true) { A_FaceTarget(22.5); } else { if (AugerNumSegs > AugerDestSegs) { AugerNumSegs--; } else if (AugerNumSegs < AugerDestSegs) { AugerNumSegs++; } if (AugerFireSegDir != 0) { if (AugerFireSegDelay > 0) { AugerFireSegDelay--; } else { AugerFireSeg += AugerFireSegDir; AugerFireSegDelay = AUGERFIRETIME; if (AugerFireSeg < 0 || AugerFireSeg >= int(GetAugerMaxSegs())) { AugerFireSegDir = 0; } else { bFireNow = true; } } } uint NumAttach = 0; for (uint i = 0; i < AugerBaseAttachments; i++) { let NA = AugerAttachment(AugerAttachments[i]); if (!NA || NA.bDestroyed) { continue; } NumAttach++; if (NA.Health <= 0) { continue; } double a = angle + NA.AttachOffset; double baseDist = radius + NA.radius; double segRad = GetDefaultByType("AugerSeg").Radius * 0.8; double dist = baseDist + (segRad * 2.0 * AugerNumSegs); SegThink(NA, dist, a, 0.0); if (NA.OurDrill) { DrillThink(NA, NA.OurDrill, MaxDropID, DoDrillShockwaves); MaxDropID++; } Array CleanupList; uint attachSize = NA.AttachSegs.Size(); uint segs = 0; double segDist = radius + segRad; for (uint j = 0; j < attachSize; j++) { let seg = AugerSeg(NA.AttachSegs[j]); if (seg == null || seg.bDestroyed || seg.health <= 0) { CleanupList.Push(seg); continue; } if (segs >= AugerNumSegs) { // Too many segs, destroy them. //seg.Destroy(); CleanupList.Push(seg); continue; } SegThink(seg, segDist, a, Height * 0.3); if (segs == AugerFireSeg && bFireNow == true) { if (bVeryRude == true) { seg.SetStateLabel("RudeMissile"); } else { seg.SetStateLabel("Missile"); } } segs++; segDist += segRad * 2.0; int d = ((AugerNumSegs - segs) + 1) * 3; seg.ExplodeDelay = max(d, 0); } if (segs < AugerNumSegs) { // Not enough segs, add them. let newSeg = AugerSeg(Spawn("AugerSeg", NA.Pos, NO_REPLACE)); if (newSeg) { newSeg.master = NA; newSeg.SetHitstunParent(self); SegThink(newSeg, segDist, a, Height * 0.3); segDist += segRad * 2.0; NA.AttachSegs.Push(newSeg); } segs++; } uint cleanSize = CleanupList.Size(); for (uint j = 0; j < cleanSize; j++) { uint index = NA.AttachSegs.Find(CleanupList[j]); if (index != NA.AttachSegs.Size()) { NA.AttachSegs.Delete(index); } let seg = Actor(CleanupList[j]); if (!seg || seg.bDestroyed || seg.health <= 0) { continue; } seg.Destroy(); } } if (abs(AugerAngleMom - AugerDestAngleMom) <= AUGERANGLEACCEL) { AugerAngleMom = AugerDestAngleMom; } else { if (AugerAngleMom > AugerDestAngleMom) { AugerAngleMom -= AUGERANGLEACCEL; } else if (AugerAngleMom < AugerDestAngleMom) { AugerAngleMom += AUGERANGLEACCEL; } } double mul = 1.0 + ((AugerBaseAttachments - numAttach) / (AugerBaseAttachments-1)); if (bVeryRude == true) { // Increase rotation speed closer to its old value for Rude mode. mul *= 1.5; } if (bSpinFlipped == true) { mul = -mul; } angle += AugerAngleMom * mul; AugerSwingAmt += abs(AugerAngleMom * mul); if (AugerSwingAmt >= AUGERSWINGSNDFREQ) { A_StartSound("auger/swing"); AugerSwingAmt = 0.0; } if (numAttach == 0) { SetStateLabel("PinchStart"); A_StartSound("auger/charge"); bAugerPinch = true; AugerPatternPos = 0; } } if (bDidItemPop == true) { bDidItemPop = false; bDrillItemPop = false; AugerDrillDropID++; } if (AugerDrillDropID >= MaxDropID) { AugerDrillDropID = 0; } bDrillsAnimate = false; bFireNow = false; } override bool CanCollideWith(Actor toucher, bool passive) { if ((toucher is "Auger") || (toucher is "AugerAttachment") || (toucher is "AugerSeg") || (toucher is "AugerDrill")) { return false; } return super.CanCollideWith(toucher, passive); } override void InitBossMeter() { super.InitBossMeter(); for (uint i = 0; i < AugerBaseAttachments; i++) { AddActorToBossMeter(AugerAttachments[i]); } } } class AugerAttachment : SnapBoss { double AttachOffset; Array AttachSegs; Actor OurDrill; Default { Health 2000; Radius 24; Height 60; Speed 16; Mass 1000; Obituary "$OB_AUGER"; SnapActor.TouchDamage 10; DamageFactor "ScreenClear", 0.5; +SOLID +SHOOTABLE +DONTTHRUST +MISSILEMORE +NOPAIN +NOGRAVITY -COUNTKILL -WINDTHRUST +DONTFALL +NOTELEPORT +SnapMonster.ROBOTTOUGH } States { Spawn: AARM AB 1; Loop; Death: AARM A 1; AARM AAAAAAAA 4 DoSnapMonsterExplode(); TNT1 A 35 DoSnapMonsterDie(); Stop; } override bool CanCollideWith(Actor toucher, bool passive) { if ((toucher is "Auger") || (toucher is "AugerAttachment") || (toucher is "AugerSeg") || (toucher is "AugerDrill")) { return false; } return super.CanCollideWith(toucher, passive); } override void InitBossMeter() { return; } } class AugerSeg : SnapShadowActor { uint ExplodeDelay; Default { Health 1; Radius 32; Height 12; Mass 10; Obituary "$OB_AUGER"; SnapShadowActor.ShadowSize 16; SnapActor.TouchDamage 10; +SOLID +DONTTHRUST +NORADIUSDMG +NOTELEFRAG +NOGRAVITY +SHOOTABLE +NONSHOOTABLE +INVULNERABLE +DONTFALL +NOTELEPORT } States { Spawn: ASEG A -1; Loop; Missile: ASEG B 3 Light("AugerMuzzleLight") A_AugerSegShoot("AugerMissile"); ASEG A 10; ASEG B 3 Light("AugerMuzzleLight") A_AugerSegShoot("AugerMissile"); ASEG A 10; ASEG B 3 Light("AugerMuzzleLight") A_AugerSegShoot("AugerMissile"); ASEG A 10; Goto Spawn; RudeMissile: ASEG AAAAAAAAA 3 A_AugerSegShoot("AugerFire"); Goto Spawn; Death: ASEG A 1 A_SetDeathDelay(); TNT1 A 1 A_SpawnItemEx("SnapMonsterExplode", zvel: 4.0); Stop; } action void A_SetDeathDelay() { let us = AugerSeg(self); if (us != null) { tics += us.ExplodeDelay; } } action Actor A_AugerSegShoot(class PType) { Actor NP = Spawn(PType, Pos - (0, 0, GetDefaultByType(PType).Height), ALLOW_REPLACE); if (NP != null) { PlaySpawnSound(NP); NP.target = self; NP.master = self.master; NP.Vel = (0, 0, -NP.Speed); if (NP.CheckMissileSpawn(Radius) == false) { return null; } } return NP; } override void Tick() { super.Tick(); if (Health > 0 && (!master || master.bDestroyed || master.Health <= 0)) { A_Die(); } } override bool CanCollideWith(Actor toucher, bool passive) { if ((toucher is "Auger") || (toucher is "AugerAttachment") || (toucher is "AugerSeg") || (toucher is "AugerDrill")) { return false; } return super.CanCollideWith(toucher, passive); } } class AugerDrillRock : SnapDynamicDecor { Default { -NOGRAVITY } States { Spawn: ARCK A 70; Stop; ARCK B 70; Stop; ARCK C 70; Stop; } override void BeginPlay() { super.BeginPlay(); SetState(SpawnState + random[snap_decor](0, 2)); } } class AugerDrillSeg : SnapStaticDecor { Default { Health 1; Radius 2; Height 2; Mass 10; +NOGRAVITY +NOINTERACTION +NOBLOCKMAP +DONTSPLASH +DONTFALL } States { Spawn: DRLB A -1; Stop; } } class AugerDrill : SnapActor { double DrillOffset; bool QueueShockwave; const NUMDRILLSEGS = 5; Actor DrillSegs[NUMDRILLSEGS]; Default { Health 1; Radius 30; Height 20; Mass 10; Obituary "$OB_AUGER"; Damage 0; SnapActor.TouchDamage 10; +SOLID +DONTTHRUST +NORADIUSDMG +NOTELEFRAG +NOGRAVITY +SHOOTABLE +NONSHOOTABLE +INVULNERABLE +DONTFALL +NOTELEPORT } States { Spawn: ADRL A 0 A_StopSound(CHAN_BODY); ADRL A -1; Loop; Spin: ADRL B 0 A_SpawnDrillRock(); ADRL BCDEFGHA 1; Goto Spawn; Death: ADRL A 1 A_StopSound(CHAN_BODY); TNT1 A 1 A_SpawnItemEx("SnapMonsterExplode", zvel: 4.0); Stop; } action void A_SpawnDrillRock() { A_StartSound("auger/drill", CHAN_BODY, CHANF_NOSTOP); Actor rock = Spawn("AugerDrillRock", Pos, ALLOW_REPLACE); rock.Vel.XY = ( frandom[snap_decor](-4.0, 4.0), frandom[snap_decor](-4.0, 4.0) ); rock.Vel.Z = 12.0 + frandom[snap_decor](0.0, 4.0); } override void Tick() { super.Tick(); if (Health <= 0) { return; } if (master == null || master.bDestroyed || master.Health <= 0) { A_Die(); for (uint i = 0; i < NUMDRILLSEGS; i++) { let DSegExists = DrillSegs[i]; if (DSegExists != null) { DSegExists.Destroy(); } } return; } for (uint i = 0; i < NUMDRILLSEGS; i++) { let DSegExists = DrillSegs[i]; if (DrillOffset <= 0.0) { if (DSegExists != null) { DSegExists.Destroy(); } } else { double OffsetDist = (DrillOffset / NUMDRILLSEGS) * (i + 1); Vector3 NewPos = Pos + (0, 0, Height + OffsetDist); if (DSegExists == null) { DrillSegs[i] = Spawn("AugerDrillSeg", NewPos, ALLOW_REPLACE); DrillSegs[i].Translation = self.Translation; } else { DSegExists.SetOrigin(NewPos, true); DSegExists.Translation = self.Translation; } } } } override bool CanCollideWith(Actor toucher, bool passive) { if ((toucher is "Auger") || (toucher is "AugerAttachment") || (toucher is "AugerSeg") || (toucher is "AugerDrill")) { return false; } return super.CanCollideWith(toucher, passive); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- #include "./base/consts.zs" #include "./base/easings.zs" #include "./base/utils.zs" #include "./base/efx.zs" #include "./base/hitstun.zs" #include "./base/actor.zs" #include "./base/shadow.zs" #include "./base/missile.zs" //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapBasicShot : SnapMissile { Default { Radius 12; Height 12; Speed 30; Mass 10; DamageFunction 25; DamageType "Basic"; Obituary "$OB_REVOLVER"; RenderStyle "Add"; DeathSound "revolver/death"; BounceSound "revolver/bounce"; // For a few of the children inheriting from this +RANDOMIZE +BRIGHT } States { Spawn: BULL A 3 Light("BasicShotLight"); BULL B 2 Light("BasicShotLight"); Loop; Death: BULL CCCDDEF 1 Light("BasicShotLight"); Stop; } } class SnapBasicBigShot : SnapBasicShot { Default { Radius 16; Damage 0; SnapActor.TouchDamage 50; +RIPPER } States { Spawn: LSTB ABACAD 2 Light("BigShotLight"); Loop; } override void Tick() { super.Tick(); if (TickPaused() == true) { return; } SnapActor particle = SnapActor(Spawn("SnapBasicBigShotTrail", Pos, ALLOW_REPLACE)); if (particle) { particle.Target = self; particle.SetHitstunParent(self); particle.Angle = Angle; particle.Pitch = Pitch; particle.Roll = Roll; particle.bRollSprite = bRollSprite; particle.bRollCenter = bRollCenter; particle.Scale = self.Scale; particle.SpriteOffset = self.SpriteOffset; } uint timer = Level.maptime / 2; double ha = angle + 90; double va = (timer % 8) * 45; double dist = radius * 2.0; if (Level.maptime & 1) { va += 180.0; } Vector3 offset = ( dist * cos(ha) * cos(va), dist * sin(ha) * cos(va), (dist * 0.8) * sin(va) ); offset.Z += Height * 0.5; SnapActor particleS = SnapActor(Spawn("SnapBasicBigShotTrail2", Pos + offset, ALLOW_REPLACE)); if (particleS) { particleS.Target = self; particleS.SetHitstunParent(self); particleS.Angle = Angle; particleS.Pitch = Pitch; particleS.Roll = Roll; particleS.bRollSprite = bRollSprite; particleS.bRollCenter = bRollCenter; particleS.Scale = self.Scale; //particleS.SpriteOffset = self.SpriteOffset; } } } class SnapBasicBigShotTrail : SnapActor { Default { RenderStyle "AddStencil"; StencilColor "FF2200"; +NOINTERACTION +NOBLOCKMAP +NOGRAVITY +RANDOMIZE +BRIGHT } States { Spawn: TNT1 A 2; LSTB AB 1 Light("BigShotTrailLight"); LSTB ACAD 1 A_SetRenderStyle(Alpha - 0.2, STYLE_AddStencil); Stop; } } class SnapBasicBigShotTrail2 : SnapBasicBigShotTrail { Default { RenderStyle "Add"; +RANDOMIZE +BRIGHT +NOGRAVITY +NOINTERACTION } States { Spawn: BULL AB 3; BULL BABABABAB 1 A_SetRenderStyle(Alpha - 0.1, STYLE_AddStencil); Stop; } } class SnapStandardAmmo : Ammo { Default { Inventory.MaxAmount 7; +INVENTORY.IGNORESKILL } } class SnapBasicMisfire : SnapMissile { Default { Radius 12; Height 12; Speed 20; Mass 10; Damage 0; +SnapShadowActor.DISABLESHADOW +THRUACTORS +NOINTERACTION +RANDOMIZE } States { Spawn: PUFF CDEFGH 2; Stop; } } class SnapSmoke : SnapPuff { States { Spawn: SMOK ABCDEFGH 2; Stop; } } extend class SnapGun { action void A_SnapgunBasic() { if (player == null || player.mo == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } int av = player.mo.CountInv("SnapStandardAmmo"); if (av > 0) { if (av == 1) { A_SnapgunFlash('BigFlash'); A_SnapgunMomentumProjectile("SnapBasicBigShot"); A_StartSound("revolver/bigfire", CHAN_WEAPON); } else { A_SnapgunFlash('Flash'); A_SnapgunMomentumProjectile("SnapBasicShot"); A_StartSound("revolver/fire", CHAN_WEAPON); } SoundAlert(self); player.mo.TakeInventory("SnapStandardAmmo", 1, false, true); } else { let pmo = SnapPlayer(player.mo); if (pmo) { pmo.PlayFireNoFlash(); } A_SnapgunMomentumProjectile("SnapBasicMisfire"); A_StartSound("revolver/misfire", CHAN_BODY); } } action void A_SnapgunReload() { if (player == null || player.mo == null) { return; } player.mo.GiveInventory("SnapStandardAmmo", 1); } States { FireBasic: SGUN A 1 A_SnapgunBasic; SGUN BCD 1; SGUN E 2; SGUN A 0 A_SnapGunRefire(); Reload: SGUN E 4; SGUN F 5; SREL AAABBB 1 A_OverlayOffset(GUNLAYER, 0, -5.75, WOF_ADD); SREL CDE 2; SGUN A 0 A_SetSnapGunState(RELOADLAYER, 'OpenSesame'); SGUN A 0 A_StartSound("revolver/reload1", CHAN_WEAPON); SREL IFIGIH 1; SREL LK 1; SGUN A 0 A_SetSnapGunState(RELOADLAYER, 'PutInDaBullets'); SREL M 4; SGUN A 0 A_StartSound("revolver/reload2", CHAN_WEAPON); SREL N 1; SREL O 1 A_SnapgunReload(); SREL P 1 A_SnapgunReload(); SREL Q 1; SREL N 1 A_SnapgunReload(); SREL O 1 A_SnapgunReload(); SREL P 1; SREL Q 1 A_SnapgunReload(); SREL N 1 A_SnapgunReload(); SREL O 1; SREL P 1 A_SnapgunReload(); SGUN A 0 A_StartSound("revolver/reload3", CHAN_WEAPON); SREL KJI 1; SREL EDC 1; SREL BA 1 A_OverlayOffset(GUNLAYER, 0, 17.25, WOF_ADD); Goto GunIdle; Flash: TNT1 A 1 Bright A_Light(2); SFL0 A 1 Bright A_Light(1); SFL0 B 1 Bright A_Light(0); SFL0 C 1 Bright; SFL0 D 1 Bright; Goto LightDone; BigFlash: TNT1 A 1 Bright A_Light(2); SFL0 E 1 Bright A_Light(2); SFL0 A 1 Bright A_Light(1); SFL0 B 1 Bright A_Light(0); SFL0 C 1 Bright; SFL0 D 1 Bright; Goto LightDone; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class BeachFlagSegment : SnapStaticDecor abstract { Default { Health 1000; Radius 8; Height 24; +NOBLOCKMAP +NOGRAVITY +NOINTERACTION +WALLSPRITE } } class BeachFlag : SnapStaticDecor abstract { class FlagSegType; int FlagPhase; bool FlagInit; property SegType: FlagSegType; Default { Health 1000; Radius 4; Height 88; Mass 4; // Num segments Speed 4; // waving multiplier +FORCEYBILLBOARD BeachFlag.SegType "BeachFlagSegment"; } States { Spawn: FLAG A -1; Stop; } override void BeginPlay() { super.BeginPlay(); // HACK to make it face perfectly in the right way angle -= 22.5; int numSegs = Default.Mass; Actor appendTo = self; double Zpos = Pos.Z + 40; double realAngle = appendTo.Angle; for (int i = 0; i < numSegs; i++) { double dist = appendTo.radius + GetDefaultByType(FlagSegType).radius; Vector3 newpos = appendTo.Pos; newpos.XY += AngleToVector(realAngle, dist); newpos.Z = Zpos; appendTo.target = Spawn(FlagSegType, newpos, ALLOW_REPLACE); if (!appendTo.target) { break; } realAngle = appendTo.angle; appendTo.target.angle = realAngle + 90; appendTo = appendTo.target; } FlagPhase = random[snap_decor](0, 15); FlagInit = true; } override void Tick() { super.Tick(); if (Level.isFrozen() == true || FlagInit == false) { return; } double waving = (Default.Speed) / 8; double t = Level.maptime + FlagPhase; Actor rotatey = self; double Zpos = Pos.Z + 64; double realAngle = rotatey.Angle; int segStep = 0; while (rotatey) { realAngle += (BobSin(t) * waving); if (segStep == 0) { rotatey.A_SetAngle(realAngle, 0); } else { rotatey.A_SetAngle(realAngle + 90, 0); } segStep++; if (rotatey.target) { double dist = (rotatey.radius + rotatey.target.radius) - 2.0; Vector3 newpos = rotatey.Pos; newpos.XY += AngleToVector(realAngle, dist); newpos.Z = Zpos; rotatey.target.SetOrigin(newpos, false); rotatey = rotatey.target; } else { break; } } } } class BeachFlagSegmentYellow : BeachFlagSegment { States { Spawn: FLAG B -1; Stop; } } class BeachFlagYellow : BeachFlag { Default { BeachFlag.SegType "BeachFlagSegmentYellow"; } } class BeachFlagSegmentPurple : BeachFlagSegment { States { Spawn: FLAG C -1; Stop; } } class BeachFlagPurple : BeachFlag { Default { BeachFlag.SegType "BeachFlagSegmentPurple"; } } class BeachFlagSegmentRed : BeachFlagSegment { States { Spawn: FLAG D -1; Stop; } } class BeachFlagRed : BeachFlag { Default { BeachFlag.SegType "BeachFlagSegmentRed"; } } class BeachFlagSegmentGreen : BeachFlagSegment { States { Spawn: FLAG E -1; Stop; } } class BeachFlagGreen : BeachFlag { Default { BeachFlag.SegType "BeachFlagSegmentGreen"; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapMapBomb : SnapMonster { Default { Health 20; Radius 24; Height 40; DeathSound "explosion/bigEnemy"; Species "MapBomb"; SnapShadowActor.ShadowSize 32; +NOBLOOD +DONTGIB +NOICEDEATH +DONTTHRUST +DOHARMSPECIES -COUNTKILL -CANPUSHWALLS -CANUSEWALLS -ACTIVATEMCROSS -CANPASS -ISMONSTER +NOGRAVITY +DONTFALL +RANDOMIZE +SnapActor.MISSILESPRITEFIX -SnapActor.CANDROPAMMO } States { Spawn: OBOM A 5 Bright; OBOM A 5; Loop; Death: OBOM A 1; OBOM AAAAA 4 DoSnapBossExplode(); OBOM A 1 DoSnapBossDie(); Stop; } override void BeginPlay() { super.BeginPlay(); ChangeStatNum(STAT_MAPBOMB); } } class SnapMapBombData play { int Tag; Array BombList; Array SectorList; } extend class SnapEventHandler { Array SnapMapBombs; void AddBombToList(Actor Bomb) { if (!Bomb || Bomb.health <= 0) { return; } if (Bomb.TID == 0) { return; } int i = 0; for (i = 0; i < SnapMapBombs.Size(); i++) { SnapMapBombData ExistingData = SnapMapBombs[i]; if (ExistingData.Tag == Bomb.TID) { // Add to existing table. ExistingData.BombList.Push(Bomb); return; } } // No existing table, so we need to create it. // First find if there's any 3D floors for these bombs. Array SecList; SectorTagIterator SectorTags = Level.CreateSectorTagIterator(Bomb.TID); int SectorID = -1; while (SectorID = SectorTags.next()) { if (SectorID < 0) { break; } Sector sec = Level.Sectors[SectorID]; if (!sec) { continue; } if (sec.Get3DFloorCount() <= 0) { // No point, doesn't have any 3D floors continue; } SecList.Push(sec); } // If no sectors were found, this bomb is invalid. if (SecList.Size() <= 0) { return; } // Create new bomb data. SnapMapBombData Data = New("SnapMapBombData"); Data.Tag = Bomb.TID; Data.BombList.Push(Bomb); Data.SectorList.Move(SecList); // Insert into the full list. SnapMapBombs.Push(Data); } static void Remove3DFloor(Sector FlModel) { if (FlModel == null) { return; } //fl.flags &= ~F3DFloor.FF_EXISTS; //FF_EXISTS // Move under the floor instantly. FlModel.MoveFloor(666.0, -10000.0, 0, -1, false); FlModel.MoveCeiling(666.0, -10000.0, 0, -1, false); } static void CreateBustUpParticles(Sector FlModel, Sector OrigSec, double Spacing = 80.0) { // Create bustup particles Vector2 minV = (65535, 65535); Vector2 maxV = (-65535, -65535); for (uint i = 0; i < uint(OrigSec.lines.Size()); i++) { // Determine rough bounds of the sector. let ld = OrigSec.lines[i]; minV.x = min(ld.v1.p.x, minV.x); minV.x = min(ld.v2.p.x, minV.x); minV.y = min(ld.v1.p.y, minV.y); minV.y = min(ld.v2.p.y, minV.y); maxV.x = max(ld.v1.p.x, maxV.x); maxV.x = max(ld.v2.p.x, maxV.x); maxV.y = max(ld.v1.p.y, maxV.y); maxV.y = max(ld.v2.p.y, maxV.y); } int particles = int(((maxV.x - minV.x) / Spacing) * ((maxV.y - minV.y) / Spacing)); if (particles <= 0) { return; } for (int i = 0; i < particles; i++) { Vector2 TryPos = ( frandom[snap_decor](minV.x, maxV.x), frandom[snap_decor](minV.y, maxV.y) ); uint GiveUp = 0; while (Level.PointInSector(TryPos) != OrigSec) { if (GiveUp >= 64) { break; } TryPos = ( frandom[snap_decor](minV.x, maxV.x), frandom[snap_decor](minV.y, maxV.y) ); GiveUp++; } if (GiveUp >= 64) { continue; } double f = FlModel.floorplane.ZatPoint(TryPos); double range = FlModel.ceilingplane.ZatPoint(TryPos) - f; Vector3 PPos = ( TryPos.X, TryPos.Y, f + frandom[snap_decor](0, range) ); Actor particle = null; if (random[snap_decor](0, 5) == 0) { particle = Actor.Spawn("SnapMonsterShrapnelSpawner", PPos, ALLOW_REPLACE); } else { particle = Actor.Spawn("SnapMonsterExplode", PPos, ALLOW_REPLACE); } if (particle != null) { particle.Vel.X = frandom[snap_decor](-2.0, 2.0); particle.Vel.Y = frandom[snap_decor](-2.0, 2.0); particle.Vel.Z = 8.0 + frandom[snap_decor](-2.0, 2.0); } } } static void Destroy3DFloor(Sector FlModel, Sector OrigSec) { if (FlModel == null || OrigSec == null) { return; } CreateBustUpParticles(FlModel, OrigSec); Remove3DFloor(FlModel); } static void Destroy3DFloorsInSector(Sector sec) { if (sec == null) { return; } for (int k = 0; k < sec.Get3DFloorCount(); k++) { F3DFloor fl = sec.Get3DFloor(k); if (fl == null) { continue; } Destroy3DFloor(fl.model, sec); } } static void ACS_Destroy3DFloorsInSector(int secTag) { SectorTagIterator SectorTags = Level.CreateSectorTagIterator(secTag); int SectorID = -1; while (SectorID = SectorTags.next()) { if (SectorID < 0) { break; } Sector sec = Level.Sectors[SectorID]; if (sec == null) { continue; } if (sec.Get3DFloorCount() <= 0) { // No point, doesn't have any 3D floors continue; } Destroy3DFloorsInSector(sec); } } void UnloadMapBombs() { SnapMapBombs.Clear(); } void LoadMapBombs() { UnloadMapBombs(); ThinkerIterator BombFinder = ThinkerIterator.Create("SnapMapBomb", STAT_MAPBOMB); Actor Bomb = null; while (Bomb = Actor(BombFinder.Next())) { AddBombToList(Bomb); } } void TickMapBombs() { Array DataRemovalList; int i = 0; int j = 0; int remove = 0; for (i = 0; i < SnapMapBombs.Size(); i++) { SnapMapBombData Data = SnapMapBombs[i]; if (!Data) { DataRemovalList.Push(Data); continue; } bool AllBombsGone = true; Array BombRemovalList; for (j = 0; j < Data.BombList.Size(); j++) { Actor Bomb = Data.BombList[j]; if (!Bomb) { BombRemovalList.Push(Bomb); continue; } AllBombsGone = false; } for (j = 0; j < BombRemovalList.Size(); j++) { remove = Data.BombList.Find(BombRemovalList[j]); Data.BombList.Delete(remove); } if (AllBombsGone == true) { // Destroy all 3D floors in all of the attached sectors. for (j = 0; j < Data.SectorList.Size(); j++) { Sector sec = Data.SectorList[j]; Destroy3DFloorsInSector(sec); } DataRemovalList.Push(Data); continue; } } for (i = 0; i < DataRemovalList.Size(); i++) { remove = SnapMapBombs.Find(DataRemovalList[i]); SnapMapBombs.Delete(remove); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapBoomerangProps : SnapWeaponProps { override void Init() { WeaponName = "Boomerang"; NiceName = "$SNAPMENU_WEAPON_BOOMERANG"; PickupType = "SnapBoomerangPowerup"; WeaponIcon = "WP_BRANG"; FireState = "FireBoomerang"; } } class SnapBoomerangCan : SnapItemCan { Default { DropItem "SnapBoomerangPowerup"; } States { Spawn: WP_B A 10; WP_B A 10 Bright; Loop; } } class SnapBoomerangPowerup : SnapWeaponPowerup { Default { SnapWeaponPowerup.WeaponPower "Boomerang"; Inventory.PickupMessage "$POWERUP_BOOMERANG"; SnapInventory.VoiceSample "voice/boomerang"; } States { Spawn: WP_B B 10; WP_B B 10 Bright; Loop; } } class SnapBoomerangShot : SnapBasicShot { const BOOMERANGSPEED = 2.0; const INTERCEPTTIME = 8; const BOUNCERESTORETIME = 32; const RANGSTUFFTIME = 16; bool BoomerangSpeedUp; uint RangStuffDelay; uint InterceptDelay; uint BounceRestore; int PrevBounces; Default { Radius 24; Height 32; DamageFunction 40; DamageType "Boomerang"; Obituary "$OB_BOOMERANG"; ProjectileKickback 1000; BounceType "Grenade"; BounceCount 5; BounceFactor 1.0; WallBounceFactor 1.0; +BOUNCEONWALLS +BOUNCEONFLOORS +BOUNCEONCEILINGS -ALLOWBOUNCEONACTORS -BOUNCEONACTORS +DONTBOUNCEONSHOOTABLES +SnapMissile.DIEWHENOWNERDIES } void SickFlipsBro() { bXFlip = random[snap_decor](0, 1); bYFlip = random[snap_decor](0, 1); } States { Spawn: RANG AB 1 Light("BoomerangLight1"); RANG CD 1 Light("BoomerangLight2"); Loop; Death: RANG A 1 Light("BoomerangLight1"); RANG E 1 Light("BoomerangLight1") SickFlipsBro(); RANG FG 1 Light("BoomerangLight2"); RANG HI 1 Light("BoomerangLight1"); RANG JK 1 Light("BoomerangLight2"); RANG L 1 Light("BoomerangLight2"); Stop; Caught: RCTC A 1 Light("BoomerangLight1") SickFlipsBro(); RCTC B 1 Light("BoomerangLight1"); RCTC CD 1 Light("BoomerangLight2"); RCTC EF 1 Light("BoomerangLight1"); RCTC GH 1 Light("BoomerangLight2"); RCTC IJ 1 Light("BoomerangLight1"); RCTC KL 1 Light("BoomerangLight2"); Stop; } override void BeginPlay() { super.BeginPlay(); RangStuffDelay = RANGSTUFFTIME; InterceptDelay = INTERCEPTTIME; } override void Tick() { if (bMissile == false || TickPaused() == true) { super.Tick(); return; } A_StartSound("revolver/boomerangFly", CHAN_BODY, CHANF_LOOPING); if (RangStuffDelay > 0) { // Kind of just act like a regular bullet for now, // until this init timer is up. RangStuffDelay--; BounceCount = Default.BounceCount; super.Tick(); return; } if (InterceptDelay > 0) { InterceptDelay--; } if (BounceCount == Default.BounceCount || BounceCount < PrevBounces) { BounceRestore = BOUNCERESTORETIME; } else { if (BounceRestore == 0) { BounceCount = Default.BounceCount; } else { BounceRestore--; } } PrevBounces = BounceCount; double currentSpeed = Vel.Length(); Vector3 curDir = SnapUtils.SafeVec3Unit(Vel); if (curDir.Length() == 0.0) { curDir = ( cos(angle) * cos(pitch), sin(angle) * cos(pitch), sin(pitch) ); } Vector3 newDir = (0.0, 0.0, 0.0); if (target == null) { // Continue in your current direction, speed up if necessary. if (currentSpeed < Speed) { Vel += curDir * BOOMERANGSPEED; currentSpeed = Vel.Length(); if (currentSpeed > Speed) { Vel = SnapUtils.SafeVec3Unit(Vel) * Speed; } } super.Tick(); return; } Vector3 ourPos = Pos; ourPos.Z += (Height * 0.5); Vector3 theirPos = target.Pos; theirPos.Z += (target.Height * 0.5); newDir = SnapUtils.SafeVec3Unit(theirPos - ourPos); double ourDot = curDir dot newDir; bool SpeedUp = false; if (currentSpeed < BOOMERANGSPEED || ourDot > 0.5) { SpeedUp = true; } if (SpeedUp == true) { if (currentSpeed < Speed) { Vel += newDir * BOOMERANGSPEED; currentSpeed = Vel.Length(); if (currentSpeed >= Speed) { Vel = SnapUtils.SafeVec3Unit(Vel) * Speed; } } } else if (InterceptDelay == 0) { if (currentSpeed <= BOOMERANGSPEED) { Vel = (0.0, 0.0, 0.0); } else { Vel -= curDir * BOOMERANGSPEED; } } if (abs(ourPos.Z - theirPos.Z) <= (Height * 0.25)) { // Straighten out when on the player's level. Vel.Z *= 0.5; } super.Tick(); } override int SpecialMissileHit(Actor victim) { if (victim == target && InterceptDelay == 0 && Health > 0) { Vector2 missileDir = SnapUtils.SafeVec2Unit(Vel.XY); Vector2 victimDir = ( cos(victim.angle), sin(victim.angle) ); double dirDot = missileDir dot victimDir; if (dirDot < 0.0) { // Player caught it, we need to remove it. A_StopSound(CHAN_BODY); A_StartSound("revolver/boomerangCatch", CHAN_BODY); ExplodeMissile(null, victim); Vel = (0, 0, 0); bMissile = false; Health = 0; SetStateLabel("Caught"); return 1; } else { // Boomerangs coming from behind pass through. return 1; } } return super.SpecialMissileHit(victim); } } extend class SnapGun { action void A_SnapgunBoomerang() { if (player == null || player.mo == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } A_SnapgunFlash('BoomerangFlash'); A_SnapgunMomentumProjectile("SnapBoomerangShot"); A_StartSound("revolver/boomerang", CHAN_WEAPON); SoundAlert(self); player.mo.TakeInventory("SnapPowerupAmmo", 1, false, true); } States { FireBoomerang: SGUN A 1 A_SnapgunBoomerang; SGUN BCD 1; SGUN E 5; SGUN A 0 A_SnapGunRefire(); SGUN E 1; SGUN F 5; Goto GunIdle; BoomerangFlash: TNT1 A 1 Bright A_Light(2); SFL7 A 1 Bright A_Light(1); SFL7 B 1 Bright A_Light(0); SFL7 C 1 Bright; SFL7 D 1 Bright; Goto LightDone; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapMonster { Actor PrevBossTarget; bool BossMeterWasInit; void AddActorToBossMeter(Actor a) { SnapEventHandler ev = SnapEventHandler(EventHandler.Find("SnapEventHandler")); if (ev != null) { ev.BossMobjs.Push(a); } } virtual void InitBossMeter() { AddActorToBossMeter(self); } action void A_PickBossTarget() { let us = SnapMonster(self); if (us != null && us.SnapTIDTarget(TIDToHate) == true) { // Target Invasion Core above all else! return; } PlayerPawn potentialTargets[MAXPLAYERS]; uint numPlayers = 0; for (int i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] == false) { continue; } if (players[i].cheats & CF_NOTARGET) { continue; } let mo = players[i].mo; if (IsVisible(mo, true) == true) { potentialTargets[numPlayers] = mo; numPlayers++; } } if (numPlayers == 0) { return; } if (numPlayers == 1) { // don't call rng target = potentialTargets[0]; return; } target = potentialTargets[ random[snap_gameplay](0, numPlayers-1) ]; } static double GetBossHPScale() { uint Debug = SnapEventHandler.CoopScalingDebug(); int NumPlayers = (Debug > 0) ? Debug : SnapEventHandler.CoopScalingPlayers(); // Literally juuust enough that more players // does make a boss go faster if everyone contributes, // buuut not by a whole lot. // 1P: x1.0, 2P: x1.95, 4P: x3.85, 8P: x7.65 return 1.0 + ((NumPlayers - 1) * 0.95); } void MultiplyMonsterHP(double HealthMul) { if (HealthMul <= 0.0) { // Wasn't set. return; } if (HealthMul == 1.0) { // Don't need to do anything. return; } // Round to nearest 5% HealthMul = (round(HealthMul * 20)) / 20; Health = int(round(Health * HealthMul)); StartHealth = Health; double PoiseMul = ((HealthMul - 1.0) * 0.5) + 1.0; Poise = PoiseMax = int(round(PoiseMax * PoiseMul)); } } class SnapBoss : SnapMonster abstract { // Just a shortcut for some regular boss flags. Default { SnapActor.Score 1000; +BOSS +BOSSDEATH +NOTELEFRAG -SnapActor.CANDROPAMMO } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapBotPowerShot : SnapRapidShot { void DoBotPowerExplode() { bNoGravity = true; A_StartSound("explosion/bigEnemy"); for (int i = 0; i < 8; i++) { double a = i * 45; double h = 10; double v = 8; Vector2 speed; if (i & 1) { h = 4; v = 12; } h = frandom[snap_decor](h * 0.5, h * 2.0); v = frandom[snap_decor](v * 0.5, v * 2.0); speed = AngleToVector(a, h); A_SpawnItemEx( "SnapMonsterExplode", 0, 0, 0, speed.x, speed.y, v ); } double starta = random[snap_decor](0,7) * 45; for (int i = 0; i < 2; i++) { double a = starta + (i * 180); double h = 6; double v = 16; Vector2 speed; h = frandom[snap_decor](h * 0.5, h * 2.0); v = frandom[snap_decor](v * 0.5, v * 2.0); speed = AngleToVector(a, h); A_SpawnItemEx( "SnapMonsterShrapnelSpawner", 0, 0, 0, speed.x, speed.y, v ); } A_SnapExplode(20, 192, VisualType: "SnapMissileDamageEFX", dmgType: "BotPower"); } Default { DamageType "BotPower"; Obituary "$OB_BOTPOWER"; Speed 120; } States { Death: RBUL A 1 Light("RapidShotLight"); TNT1 A 2 DoBotPowerExplode(); Stop; } } extend class SnapGun { action void A_SnapgunBotPower() { if (player == null || player.mo == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } A_SnapgunFlash('RapidFlash'); A_SnapgunMomentumProjectile("SnapBotPowerShot"); A_StartSound("revolver/missile", CHAN_WEAPON); SoundAlert(self); } States { FireBotPower: SGUN A 1 A_SnapgunBotPower(); SGUN BCDE 1; SGUN A 0 A_SnapGunRefire(); SGUN E 5; SGUN F 5; Goto GunIdle; SpreadFlash: TNT1 A 1 Bright A_Light(2); SFL2 A 1 Bright A_Light(1); SFL2 B 1 Bright A_Light(0); SFL2 C 1 Bright; SFL2 D 1 Bright; Goto LightDone; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class CactusShrapnel : SnapMissile { action void A_CactusParticle() { A_SpawnParticle( "dd ff 00", SPF_RELATIVE, TICRATE/2, random[snap_decor](6, 10), 0, random[snap_decor](-8, 8), random[snap_decor](-8, 8), random[snap_decor](0, 8), random[snap_decor](-2, 2), random[snap_decor](-2, 2), random[snap_decor](0, -4) ); } Default { Radius 12; Height 12; Mass 5; DamageFunction 20; Obituary "$OB_CACTUS"; //+HITOWNER -NOGRAVITY -ACTIVATEIMPACT -ACTIVATEPCROSS } States { Spawn: CACT B 4 A_CactusParticle; Loop; Spawn2: CACT C 3 A_CactusParticle; Loop; Spawn3: CACT D 2 A_CactusParticle; Loop; Death: Stop; } override void BeginPlay() { super.BeginPlay(); StateLabel labels[3]; labels[0] = "Spawn"; labels[1] = "Spawn2"; labels[2] = "Spawn3"; SetStateLabel(labels[random[snap_decor](0, 2)]); } } class Cactus : SnapMonster { action void A_CactusExplode() { A_FaceTarget(); A_Scream(); A_SnapNoBlocking(); A_SpawnItemEx( "SnapMonsterExplode", 0, 0, 8, 0, 0, 8 ); double a = angle; double h = 10; double v = 10; for (int i = 0; i < 16; i++) { if (i == 8) { h = 6; v = 12; a += 22.5; } Actor shrapnel = Spawn("CactusShrapnel", Pos, ALLOW_REPLACE); if (shrapnel) { shrapnel.target = self; shrapnel.tracer = self.target; shrapnel.angle = a; Vector2 speed = AngleToVector(a, h); shrapnel.Vel = (speed.X, speed.Y, v); } a += 45; } } Default { Health 20; Radius 24; Height 72; Obituary "$OB_CACTUS"; DeathSound "explosion/enemy"; Species "Cactus"; SnapShadowActor.ShadowSize 32; +NOBLOOD +DONTGIB +NOICEDEATH +DONTTHRUST +DOHARMSPECIES +CANTSEEK -COUNTKILL -CANPUSHWALLS -CANUSEWALLS -ACTIVATEMCROSS -ISMONSTER -SnapActor.CANDROPAMMO } States { Spawn: CACT A -1; Loop; Death: CACT A 1; TNT1 A 35 A_CactusExplode; TNT1 A 1050 A_DeathmatchGoAway; TNT1 A 5 A_Respawn; Wait; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapCarBase : SnapMonster abstract { int CarTrans; Default { Health 50; Radius 56; Height 56; Speed 32; Species "Car"; Obituary "$OB_CARS"; +NOBLOOD +DONTGIB +NOICEDEATH +DONTTHRUST +DOHARMSPECIES +NOPAIN +DONTRIP +CANTSEEK +NOBLOCKMONST +INVULNERABLE //+SnapActor.NOHITLAG -COUNTKILL -CANUSEWALLS -ISMONSTER -SnapActor.CANDROPAMMO -SnapMonster.ISCONTAINER } void CarDeath() { Vel.X = frandom[snap_decor](-8.0, 8.0); Vel.Y = frandom[snap_decor](-8.0, 8.0); Vel.Z = 16.0; A_SnapNoBlocking(); bNoInteraction = true; } States { Spawn: CARS AB 1; Loop; Death: CARS E 1; CARS E 0 CarDeath(); CARS E 35; Stop; } static const Name CarTranslations[] = { "PlayerRed", "PlayerRed", "PlayerRed", "PlayerRed", "PlayerRed", "PlayerBlack", "PlayerBlack", "PlayerBlack", "PlayerMecha", "PlayerMecha", "PlayerWhite", "PlayerBlue", "PlayerBlue", "PlayerBlue", "PlayerBlue", "PlayerBlue", "PlayerGold", "PlayerGold", "PlayerGold", "PlayerGreen", "PlayerGreen", "PlayerGreen", "PlayerCyan", "PlayerCyan", "PlayerCyan", "PlayerPurple", "PlayerPurple", "PlayerPurple", "PlayerYellow", "PlayerYellow", "PlayerLime", "PlayerLime", "PlayerTurquoise", "PlayerTurquoise", "PlayerCobalt", "PlayerCobalt", "PlayerMagenta", "PlayerMagenta", "PlayerPink", "PlayerPink", "PlayerForest", "PlayerIndigo", "PlayerMauve", "PlayerPastel", "PlayerBrown" }; const NUMCARTRANSLATIONS = 45; override void BeginPlay() { super.BeginPlay(); A_SetTranslation(CarTranslations[random[snap_decor](0, NUMCARTRANSLATIONS-1)]); CarTrans = Translation; } override int GetDefaultTranslation() { return CarTrans; } override void Tick() { super.Tick(); if (TickPaused() == true) { return; } if (Health == 0) { if (Tics <= TICRATE/2) { bInvisible = (Tics & 1); } else { bInvisible = false; } } if (bNoInteraction == true && bNoGravity == false) { Vel.Z -= Gravity; } } override int DamageMobj(Actor inflictor, Actor source, int dmg, Name mod, int flags, double angle) { bool prevInvulnerable = bInvulnerable; if (flags & DMG_EXPLOSION) { // Only takes damage from explosions. bInvulnerable = false; } int ret = super.DamageMobj(inflictor, source, dmg, mod, flags, angle); bInvulnerable = prevInvulnerable; return ret; } } class SnapCarHitbox : SnapShadowActor { Default { Radius 56; Height 56; +SOLID +INVISIBLE +DONTSPLASH +NOGRAVITY +NOTELEPORT } States { Spawn: TNT1 A -1; Stop; } } class SnapCar : SnapCarBase { Actor Hitboxes[2]; void RemoveHitboxes() { for (uint i = 0; i < 2; i++) { let hb = Hitboxes[i]; if (hb != null) { hb.Destroy(); } } } const HITBOXDIS = 52.0; void UpdateHitboxes() { for (uint i = 0; i < 2; i++) { let hb = Hitboxes[i]; if (hb != null) { double a = angle; if (i & 1) { a += 180; } Vector3 Offset = Vec3Offset( cos(a) * HITBOXDIS, sin(a) * HITBOXDIS, 0.0 ); hb.SetOrigin(Offset, false); } } } override void BeginPlay() { super.BeginPlay(); for (uint i = 0; i < 2; i++) { Hitboxes[i] = Spawn("SnapCarHitbox", Pos, ALLOW_REPLACE); } UpdateHitboxes(); } override void Tick() { super.Tick(); if (bSolid == false) { RemoveHitboxes(); return; } UpdateHitboxes(); } override void OnDestroy() { RemoveHitboxes(); super.OnDestroy(); } override bool CanCollideWith(Actor toucher, bool passive) { if (toucher is "SnapCarHitbox") { return false; } return super.CanCollideWith(toucher, passive); } } class SnapTruck : SnapCar { States { Spawn: TRUC AB 1; Loop; Death: TRUC E 1; TRUC E 0 CarDeath(); TRUC E 35; Stop; } } class SnapBuggy : SnapCar { States { Spawn: PBUG AB 1; Loop; Death: PBUG E 1; PBUG E 0 CarDeath(); PBUG E 35; Stop; } } class SnapSportz : SnapCar { States { Spawn: SPRT AB 1; Loop; Death: SPRT E 1; SPRT E 0 CarDeath(); SPRT E 35; Stop; } } class SnapCarMoving : SnapCarBase { Vector3 LastPos; uint SetLastPos; const LASTPOSTIME = 2; const TICSPEEDFACTOR = 0.25; void SetWheelTick() { if (Tics <= 0) { return; } Tics -= int((Speed - Default.Speed) * TICSPEEDFACTOR); if (Tics <= 0) { Tics = 1; } } States { Spawn: CARS CD 2 SetWheelTick(); Loop; } bool CarCanDamage(Actor toucher) { if (toucher.bShootable == false) { return false; } Actor theSource = self; if (master != null) { theSource = master; } else { theSource = self; } if (toucher == theSource) { return false; } if (theSource != null) { if (CanAttackHurt(toucher, theSource) == false) { return false; } } return true; } override bool CanCollideWith(Actor toucher, bool passive) { if (toucher is "SnapCarMoving") { return false; } if (CarCanDamage(toucher) == true) { return false; } return super.CanCollideWith(toucher, passive); } void CarAttack() { if (TouchDelay > 0) { return; } BlockThingsIterator it = BlockThingsIterator.Create(self, Radius); Actor toucher; while (it.Next()) { toucher = it.thing; // Get the Actor it's currently on if (toucher == null) { continue; } if (CarCanDamage(toucher) == false) { continue; } double r = (toucher.Radius + self.Radius); if (abs(toucher.Pos.X - self.Pos.X) > r) { continue; } if (abs(toucher.Pos.Y - self.Pos.Y) > r) { continue; } if (toucher.Pos.Z > self.Pos.Z + self.Height) { continue; } if (self.Pos.Z > toucher.Pos.Z + toucher.Height) { continue; } let pawn = SnapPlayer(toucher); if (pawn) { if (pawn.TouchDelay > 0) { continue; } pawn.TouchDelay = BASETOUCHDELAY; pawn.DamageMobj(self, self, 100, "Roadkill"); continue; } let sa = SnapActor(toucher); if (sa) { if (sa.TouchDelay > 0) { continue; } sa.TouchDelay = BASETOUCHDELAY; sa.DamageMobj(self, self, 100, "Roadkill"); continue; } } } override void Tick() { super.Tick(); if (Health <= 0) { return; } CarAttack(); if (TickPaused() == true) { SetLastPos = 0; return; } if (LastPos == Pos) { SetLastPos++; if (SetLastPos > LASTPOSTIME) { Destroy(); // A_Die? return; } } else { SetLastPos = 0; } LastPos = Pos; if (goal != null && Distance2D(goal) <= Radius) { // Go to the next patrol point. let iterator = Level.CreateActorIterator(goal.args[0], "PatrolPoint"); let specit = Level.CreateActorIterator(goal.TID, "PatrolSpecial"); Actor spec = null; // Execute the specials of any PatrolSpecials with the same TID // as the goal. while (spec = specit.Next()) { A_CallSpecial(spec.special, spec.args[0], spec.args[1], spec.args[2], spec.args[3], spec.args[4]); } goal = iterator.Next(); if (goal != null) { Vector2 NewDir = Vec2To(goal); if (NewDir != (0, 0)) { A_SetAngle(VectorAngle(NewDir.X, NewDir.Y), SPF_INTERPOLATE); } } } Vel.XY = ( cos(Angle), sin(Angle) ) * Speed; } override int DoSpecialDamage(Actor victim, int dmg, Name mod) { int result = super.DoSpecialDamage(victim, dmg, mod); if (result > 0) { Vector2 TheirDir = Vec2To(victim); if (TheirDir != (0, 0)) { TheirDir = TheirDir.Unit(); Vector2 NewDir = ( 0, 0 ); Vector2 SideDir = ( cos(angle + 90), sin(angle + 90) ); if (SideDir dot TheirDir < 0.0) { NewDir = ( cos(angle - 45), sin(angle - 45) ); } else { NewDir = ( cos(angle + 45), sin(angle + 45) ); } Vector3 CarPushVec = (0.0, 0.0, 16.0); if (NewDir != (0, 0)) { CarPushVec.XY = NewDir * 32.0; } let can = SnapItemCan(victim); if (can != null) { // Item Can kicking opens them, // we want to push them around. can.Vel = CarPushVec; can.kickTossed = true; } else { SnapUtils.TryKick( victim, self, self, (victim is "SnapMonster") ? 70 : 0, CarPushVec, SnapHitstun.DamageToHitstun(100), false ); } } } return result; } } class SnapTruckMoving : SnapCarMoving { States { Spawn: TRUC CD 2 SetWheelTick(); Loop; Death: TRUC E 1; TRUC E 0 CarDeath(); TRUC E 35; Stop; } } class SnapBuggyMoving : SnapCarMoving { States { Spawn: PBUG CD 2 SetWheelTick(); Loop; Death: PBUG E 1; PBUG E 0 CarDeath(); PBUG E 35; Stop; } } class SnapSportzMoving : SnapCarMoving { States { Spawn: SPRT CD 2 SetWheelTick(); Loop; Death: SPRT E 1; SPRT E 0 CarDeath(); SPRT E 35; Stop; } } class SnapCarSpawner : SnapDynamicDecor { Default { Radius 56; Height 56; +INVISIBLE -COUNTKILL } void InitDelay() { if (args[3] > 0) { // Set init waypoint for the car. let iterator = Level.CreateActorIterator(args[3], "PatrolPoint"); goal = iterator.Next(); } if (args[1] <= 0) { return; } Tics = args[1]; } void SetSpawnFreq() { if (args[0] <= 0) { return; } Tics = args[0]; } void CreateCar() { Actor car = Spawn("SnapCarMoving", Pos, ALLOW_REPLACE); if (car != null) { if (args[2] != 0) { car.Speed += args[2]; } car.Angle = Angle; car.Vel.XY = ( cos(Angle), sin(Angle) ) * car.Speed; car.Goal = self.Goal; } } States { Spawn: TNT1 A 1 NoDelay InitDelay(); SpawnLoop: TNT1 A 0 CreateCar(); TNT1 A TICRATE SetSpawnFreq(); Loop; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapAchievementItem : SnapMenuItemBase { SnapAchievementDef Achievement; enum AchievementMenuStatus { ITEM_HIDDEN = 0, ITEM_HINT, ITEM_UNLOCKED, ITEM_SKIPPED, ITEM__MAX } uint Status; uint ItemCol; uint ItemRow; String Reward; TextureID mBoxHidden; TextureID mBoxHint; TextureID mBox; TextureID mBoxSelector; const GOLD_SHINE_COLORS = 7; const GOLD_SHINE_FREQ = 5; uint ShineOffset; int ShineTick; const JITTER_DIST = 12.0; const JITTER_DIST_SMALL = JITTER_DIST * 0.25; double ExplodeJitter; SnapAchievementItem Init() { super.Init("", 'None', true); mBoxHidden = TexMan.CheckForTexture("A_HIDDEN", TexMan.Type_MiscPatch); mBoxHint = TexMan.CheckForTexture("PLAYBACK", TexMan.Type_MiscPatch); mBox = TexMan.CheckForTexture("A_DONE", TexMan.Type_MiscPatch); mBoxSelector = TexMan.CheckForTexture("GSELECT", TexMan.Type_MiscPatch); return self; } override void Ticker() { super.Ticker(); ShineTick++; if (ExplodeJitter > 0.0) { ExplodeJitter *= 0.8; if (ExplodeJitter < 0.3) { ExplodeJitter = 0.0; } } } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { let OurMenu = SnapAchievementMenu(Parent); if (OurMenu == null) { return xOffset; } UpdateScaleParameters(); Vector2 Pos = (BASE_VID_WIDTH * 0.5 + xOffset, yOffset); if (Parent != null) { Pos.Y -= (1.0 - Parent.MenuTransition) * VirtualSize.Y; } if (ExplodeJitter > 0.0) { Pos += ( frandom[snap_menu](-ExplodeJitter, ExplodeJitter), frandom[snap_menu](-ExplodeJitter, ExplodeJitter) ); } switch (Status) { case ITEM_HIDDEN: { SnapMenuTexture(mBoxHidden, Pos); break; } case ITEM_HINT: { SnapMenuTexture(mBoxHint, Pos); break; } default: { int ColorIndex; if (Status == ITEM_SKIPPED) { ColorIndex = Translate.GetID("PlayerPurple"); } else { if (OurMenu.NumAchieved >= OurMenu.TotalAchievements) { static const Name GoldColors[] = { "AchievementGoldA", "AchievementGoldB", "AchievementGoldC", "AchievementGoldD", "AchievementGoldC", "AchievementGoldB", "AchievementGoldA" }; uint GoldID = (ShineTick / GOLD_SHINE_FREQ) + ShineOffset; ColorIndex = Translate.GetID(GoldColors[GoldID % GOLD_SHINE_COLORS]); } else { ColorIndex = Translate.GetID("PlayerTurquoise"); } } SnapMenuTextureTranslated(mBox, Pos, ColorIndex); break; } } if (selected == true && OurMenu.ChallengeMenuPaused() == false) { SnapMenuTexture(mBoxSelector, Pos); } return xOffset; } override bool Activate() { if (Achievement != null) { let OurMenu = SnapAchievementMenu(Parent); if (OurMenu != null && OurMenu.FreeSpaces > 0) { if (Achievement.AlreadyGot() == true) { return false; } else if (Achievement.ConditionDisablesFreeSpace() == true) { // Free spaces aren't allowed for this type. Menu.MenuSound("menu/cant"); Menu.StartMessage(StringTable.Localize("$SNAPMENU_CHALLENGE_CANTFREESPACE"), 1); return true; } else { // Create a confirmation box. Menu.MenuSound("menu/prompt"); Menu.StartMessage(StringTable.Localize("$SNAPMENU_CHALLENGE_FREESPACE"), 0); return true; } } else { Menu.MenuSound("menu/cant"); Menu.StartMessage(StringTable.Localize("$SNAPMENU_CHALLENGE_NOFREESPACE"), 1); return true; } } Menu.MenuSound("menu/cant"); return false; } override bool MenuEvent(int mKey, bool gamepad) { let OurMenu = SnapAchievementMenu(Parent); if (OurMenu != null && mKey == Menu.MKEY_MBYes) { // Confirmed free space usage from message box. //OurMenu.UseFreeSpace(ItemCol, ItemRow); // Deferred after the message box goes away. OurMenu.FreeSpaceUsed = true; OurMenu.FreeSpaceX = ItemCol; OurMenu.FreeSpaceY = ItemRow; return true; } return super.MenuEvent(mKey, gamepad); } override void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.Offscreen(); } override int GetLineSpacing() { return SnapAchievementMenu.COLUMN_Y_OFFSET; } } class SnapAchievementColumn ui { const COLUMN_HEIGHT = 4; // 5 uint Index; OptionMenuItem Items[COLUMN_HEIGHT]; int NumItems; virtual void Init(uint SetIndex) { Index = SetIndex; } } class SnapAchievementMenu : SnapMenuBase { const COLUMN_X_OFFSET = 36; const COLUMN_Y_OFFSET = 28; Array Columns; int CurColumn; int CurRow; int ColumnFocus; int RowFocus; const UNLOCK_DELAY_TIME = TICRATE; uint UnlockDelay; TextureID RewardBG; TextureID FreeSpaceTex; uint NumAchieved; uint TotalAchievements; const FREE_SPACE_CONFIRM = TICRATE; uint FreeSpaces; int FreeSpaceConfirm; const EXPLODE_DIST = 100.0; const EXPLODE_DIST_SMALL = EXPLODE_DIST * 0.5; const NUM_EXPLOSION_FRAMES = 7; const NUM_EXPLOSION_FRAMES_SMALL = 4; const EXPLODE_ANIM_SPEED = 2; const EXPLODE_TIME = NUM_EXPLOSION_FRAMES * EXPLODE_ANIM_SPEED; const EXPLODE_ROTATE = 37.5; uint ExplodeTick; bool FreeSpaceUsed; int FreeSpaceX; int FreeSpaceY; Vector2 UseFreeSpacePos; static clearscope bool UnlockedNewStuff() { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return false; } SnapDefinitions defs = ev.SnapDefs; if (defs == null) { return false; } MapIterator it; if (it.Init(defs.AchievementMap) == false) { return false; } while (it.Next() == true) { SnapAchievementDef def = it.GetValue(); if (def == null) { continue; } if (def.StatusVar != null) { int Status = def.StatusVar.GetInt(); int StatusMode = (Status & SnapAchievementDef.STATUS_MASK); if (StatusMode == SnapAchievementDef.STATUS_NEWLY_UNLOCKED) { // New thing was unlocked! return true; } } } // Nothing new to grab our attention with. return false; } void UnlockEffectsAtCoordinate(int x, int y, bool FromSkip = false) { CurColumn = ColumnFocus = x; CurRow = RowFocus = y; UpdateDestScroll(GetSelectedItem()); ExplodeTick = EXPLODE_TIME; bool Reward = false; let item = SnapAchievementItem(Columns[x].Items[y]); if (item != null) { item.ExplodeJitter = item.JITTER_DIST; if (item.Achievement.Reward != null) { Reward = true; } } if (FromSkip == true) { MenuSound("menu/challenge/skip"); } else if (Reward == true) { MenuSound("menu/challenge/reward"); } else { MenuSound("menu/challenge/fill"); } for (int i = 0; i < 4; i++) { int revealX = x; int revealY = y; switch (i) { case 0: { revealX--; break; } case 1: { revealX++; break; } case 2: { revealY--; break; } case 3: { revealY++; break; } default: { break; } } if (revealX < 0 || revealX >= Columns.Size()) { continue; } if (revealY < 0 || revealY >= Columns[revealX].NumItems) { continue; } let revealItem = SnapAchievementItem(Columns[revealX].Items[revealY]); if (revealItem == null) { continue; } revealItem.ExplodeJitter = revealItem.JITTER_DIST_SMALL; } } bool UnlockSomething() { for (int x = 0; x < Columns.Size(); x++) { for (int y = 0; y < Columns[x].NumItems; y++) { let item = SnapAchievementItem(Columns[x].Items[y]); if (item == null) { continue; } if (item.Achievement.StatusVar == null) { continue; } int Status = item.Achievement.StatusVar.GetInt(); int StatusMode = (Status & SnapAchievementDef.STATUS_MASK); if (StatusMode == SnapAchievementDef.STATUS_NEWLY_UNLOCKED) { item.Achievement.StatusVar.SetInt( SnapAchievementDef.STATUS_UNLOCKED | (Status & SnapAchievementDef.STATUS_FLAG_MASK) ); UnlockEffectsAtCoordinate(x, y); return true; } } } // Nothing left to do. return false; } void CreateAchievementItem(SnapAchievementColumn Col, SnapAchievementDef AchievementDef, uint ShineOffset) { let item = SnapAchievementItem( new("SnapAchievementItem") ); item.Init(); mDesc.mItems.Push(item); item.ItemCol = Col.Index; item.ItemRow = Col.NumItems; Col.Items[Col.NumItems] = item; Col.NumItems++; item.OnMenuCreated(); item.Parent = self; item.Achievement = AchievementDef; let Reward = AchievementDef.Reward; if (Reward != null) { item.mBox = TexMan.CheckForTexture(Reward.GetTexture(), TexMan.Type_MiscPatch); } item.Status = SnapAchievementItem.ITEM_HIDDEN; item.mTooltip = "???"; item.ShineOffset = ShineOffset + (Col.NumItems - 1); TotalAchievements++; } void UpdateAchievementTiles() { NumAchieved = 0; FreeSpaces = SnapReward_FreeSpace.CountFreeSpaces(); UseFreeSpacePos = GetFreeSpaceDestPos(); // First pass: show all of the already checked-off items. for (int x = 0; x < Columns.Size(); x++) { for (int y = 0; y < Columns[x].NumItems; y++) { let item = SnapAchievementItem(Columns[x].Items[y]); if (item == null) { continue; } let def = item.Achievement; if (def.StatusVar == null) { continue; } int Status = def.StatusVar.GetInt(); int StatusMode = (Status & SnapAchievementDef.STATUS_MASK); if (StatusMode == SnapAchievementDef.STATUS_UNLOCKED) { item.Status = SnapAchievementItem.ITEM_UNLOCKED; } else if (Status & SnapAchievementDef.STATUS_FLAG_SKIPPED) { item.Status = SnapAchievementItem.ITEM_SKIPPED; } else { continue; } // We've achieved this one. NumAchieved++; // Show the hint. item.mTooltip = def.GetHint(); // Show the reward, if it has one. item.Reward = def.GetRewardString(); // Now, look at the surrounding items. // Make them show their hints too. for (int i = 0; i < 4; i++) { int revealX = x; int revealY = y; switch (i) { case 0: { revealX--; break; } case 1: { revealX++; break; } case 2: { revealY--; break; } case 3: { revealY++; break; } default: { break; } } if (revealX < 0 || revealX >= Columns.Size()) { continue; } if (revealY < 0 || revealY >= Columns[revealX].NumItems) { continue; } let revealItem = SnapAchievementItem(Columns[revealX].Items[revealY]); if (revealItem == null) { continue; } if (revealItem.Status == SnapAchievementItem.ITEM_HIDDEN) { revealItem.Status = SnapAchievementItem.ITEM_HINT; revealItem.mTooltip = revealItem.Achievement.GetHint(); } } } } } const DEFAULT_SEED = 0x7FD09913; void ConstructColumns() { TotalAchievements = 0; Columns.Clear(); let ev = SnapStaticEventHandler.Get(); if (ev == null) { return; } SnapDefinitions defs = ev.SnapDefs; if (defs == null) { return; } uint NumAchievements = defs.AchievementMap.CountUsed(); if (NumAchievements == 0) { ThrowAbortException("No achievements defined for challenge menu"); return; } uint seed = DEFAULT_SEED; CVar SeedVar = CVar.FindCVar("snap_menu_achievement_seed"); if (SeedVar != null) { seed = SeedVar.GetInt(); if (seed == 0) { // Seed has not been set. // Generate one! seed = SystemTime.Now(); if (seed == 0) { // Just in case... seed = DEFAULT_SEED; } else { seed ^= seed << 13; seed ^= seed >> 17; seed ^= seed << 5; } SeedVar.SetInt(int(seed)); } } SetRandomSeed[snap_menu_achievement](seed); SnapAchievementColumn NewColumn = null; uint ColumnShine = 0; Array UnaddedDefs; MapIterator it; if (it.Init(defs.AchievementMap) == true) { while (it.Next() == true) { UnaddedDefs.Push(it.GetValue()); } } while (UnaddedDefs.Size() > 0) { uint i = random[snap_menu_achievement](0, UnaddedDefs.Size() - 1); if (NewColumn == null) { NewColumn = new("SnapAchievementColumn"); NewColumn.Init(Columns.Size()); } CreateAchievementItem(NewColumn, UnaddedDefs[i], ColumnShine); if (NewColumn.NumItems >= SnapAchievementColumn.COLUMN_HEIGHT) { Columns.Push(NewColumn); NewColumn = null; ColumnShine++; } UnaddedDefs.Delete(i); } if (NewColumn != null) { Columns.Push(NewColumn); } CurColumn = ColumnFocus = int((Columns.Size() * 0.5) - 0.5); CurRow = RowFocus = int((Columns[CurColumn].NumItems * 0.5) - 0.5); UpdateDestScroll(GetSelectedItem()); UpdateAchievementTiles(); } bool UseFreeSpace(int x, int y) { let item = SnapAchievementItem(Columns[CurColumn].Items[CurRow]); if (item == null) { return false; } item.Achievement.StatusVar.SetInt( item.Achievement.StatusVar.GetInt() | SnapAchievementDef.STATUS_FLAG_SKIPPED ); UnlockEffectsAtCoordinate(x, y, true); UpdateAchievementTiles(); SnapStaticEventHandler.CheckAchievements(); UnlockDelay = UNLOCK_DELAY_TIME; return true; } bool ChangeColumn(int dir) { if (dir == 0) { return false; } int sign = 1; if (dir < 0) { sign = -1; } int NewColumn = CurColumn + sign; if (NewColumn < 0) { NewColumn = 0; } else if (NewColumn >= Columns.Size()) { NewColumn = Columns.Size() - 1; } if (CurRow >= Columns[NewColumn].NumItems) { return false; } if (CurColumn == NewColumn) { return false; } CurColumn = ColumnFocus = NewColumn; UpdateDestScroll(GetSelectedItem()); return true; } bool ChangeRow(int dir) { if (dir == 0) { return false; } int sign = 1; if (dir < 0) { sign = -1; } int NewRow = CurRow + sign; if (NewRow < 0) { NewRow = 0; } else if (NewRow >= Columns[CurColumn].NumItems) { NewRow = Columns[CurColumn].NumItems - 1; } if (CurRow == NewRow) { return false; } CurRow = RowFocus = NewRow; UpdateDestScroll(GetSelectedItem()); return true; } bool ValidSelectedChallenge() { if (CurColumn >= 0 && CurColumn < Columns.Size()) { if (CurRow >= 0 && CurRow <= Columns[CurColumn].NumItems) { return true; } } return false; } override void Init(Menu parent, OptionMenuDescriptor desc) { super.Init(parent, desc); FreeSpaceUsed = false; FreeSpaceX = FreeSpaceY = -1; RewardBG = TexMan.CheckForTexture(StringTable.Localize("$SNAP_GFX_REWARDBG"), TexMan.Type_MiscPatch); FreeSpaceTex = TexMan.CheckForTexture("CURSORS0", TexMan.Type_MiscPatch); uint NumItems = mDesc.mItems.Size(); for (uint i = 0; i < NumItems; i++) { let item = mDesc.mItems[i]; if (item is "SnapAchievementItem") { item.Destroy(); mDesc.mItems.Delete(i); i--; NumItems--; continue; } } ConstructColumns(); if (UnlockedNewStuff() == true) { UnlockDelay = UNLOCK_DELAY_TIME / 2; } if (StepThru() == true) { TryTransitionIn(null); } } override void GetItemList(in out Array ret) { if (CurColumn >= 0 && CurColumn < Columns.Size()) { let Col = SnapAchievementColumn( Columns[CurColumn] ); for (int i = 0; i < Col.NumItems; i++) { ret.Push(Col.Items[i]); } } } override int GetSelectedItem() { return CurColumn; } override void SetSelectedItem(int value, bool updateScroll) { CurColumn = value; if (CurColumn >= 0 && CurColumn < Columns.Size()) { if (CurRow < 0) { CurRow = 0; } else if (CurRow >= Columns[CurColumn].NumItems) { CurRow = Columns[CurColumn].NumItems - 1; } } else { CurRow = -1; } ColumnFocus = CurColumn; RowFocus = CurRow; if (updateScroll == true) { UpdateDestScroll(GetSelectedItem()); } } override int GetTotalScrollSpace() { return int(VirtualSize.X + 0.5); } override int GetItemPos(int DestItem) { if (DestItem < 0 || DestItem >= Columns.Size()) { return 0; } return int((COLUMN_X_OFFSET * DestItem) + 0.5); } const COLUMN_PAD = 3; const COLUMNS_SHORT = ((COLUMN_PAD + 1) * 2); override void ClampScrollPos() { int NumColumns = Columns.Size(); if (NumColumns <= COLUMNS_SHORT) { // We have a small screen. We just want to be centered. int ItemPos = GetItemPos(0); DestScrollPos.X = ItemPos + (COLUMN_X_OFFSET * NumColumns * 0.5); } else { int first = COLUMN_PAD; int last = NumColumns - COLUMN_PAD - 1; int FirstPos = GetItemPos(first); int LastPos = GetItemPos(last); double min = FirstPos + (COLUMN_X_OFFSET * 0.5); double max = LastPos + (COLUMN_X_OFFSET * 0.5); if (max < min) { DestScrollPos.X = (min + max) * 0.5; } else { DestScrollPos.X = clamp(DestScrollPos.X, min, max); } } } override void UpdateDestScroll(int Selected, bool force) { int NumColumns = Columns.Size(); Selected = clamp(Selected, 0, NumColumns-1); int ItemPos = GetItemPos(Selected); DestScrollPos.X = ItemPos + (COLUMN_X_OFFSET * 0.5); ClampScrollPos(); if (force == true) { ScrollPos = DestScrollPos; } } override String GetTooltip() { if (ValidSelectedChallenge()) { let Col = SnapAchievementColumn( Columns[CurColumn] ); let Item = Col.Items[CurRow]; return GetItemTooltip(Item); } return ""; } bool ChallengeMenuPaused() { return (UnlockDelay > 0 || FreeSpaceUsed == true); } Vector2 GetFreeSpaceDestPos() { bool SelectableFreeSpace = false; if (ChallengeMenuPaused() == false && InMenuTransition() == false && ValidSelectedChallenge() == true) { let CurItem = SnapAchievementItem(Columns[CurColumn].Items[CurRow]); if (CurItem != null && CurItem.Achievement.CanUseFreeSpace() == true) { SelectableFreeSpace = true; } } Vector2 HeaderPos = (BASE_VID_WIDTH * 0.5, 8); HeaderPos.Y -= (1.0 - MenuTransition) * (VirtualSize.Y * 0.5); Vector2 FreeSpaceDestPos = HeaderPos + (12, 14); FreeSpaceDestPos.X -= 20.0 * (FreeSpaces - 1); if (SelectableFreeSpace == true) { FreeSpaceDestPos = (CurColumn * COLUMN_X_OFFSET, mDesc.mPosition) - ScrollPos; FreeSpaceDestPos.X += (COLUMN_X_OFFSET * 0.5) + (BASE_VID_WIDTH * 0.5); FreeSpaceDestPos.Y += COLUMN_Y_OFFSET * (CurRow + 0.5); Vector2 GunSize = SnapMenuTextureSize(FreeSpaceTex); FreeSpaceDestPos -= (GunSize.X, GunSize.Y * 0.5); } return FreeSpaceDestPos; } const FREESPACE_EASE_SPD = 1.0 / 5.0; override void SnapTicker() { super.SnapTicker(); if (FreeSpaces == 0 || ChallengeMenuPaused() == true) { UseFreeSpacePos = GetFreeSpaceDestPos(); } else { UseFreeSpacePos += (GetFreeSpaceDestPos() - UseFreeSpacePos) * 0.5; } if (InMenuTransition() == true) { return; } if (ExplodeTick > 0) { ExplodeTick--; } if (UnlockDelay > 0) { UnlockDelay--; if (UnlockDelay == 0) { if (UnlockSomething() == true) { UpdateAchievementTiles(); SnapStaticEventHandler.CheckAchievements(); UnlockDelay = UNLOCK_DELAY_TIME; } } } if (FreeSpaceUsed == true) { FreeSpaceUsed = false; // Don't process more than once. if (FreeSpaceX < 0 || FreeSpaceX >= Columns.Size()) { FreeSpaceX = FreeSpaceY = -1; // invalid, ignore } else { let Col = SnapAchievementColumn( Columns[FreeSpaceX] ); if (FreeSpaceY < 0 || FreeSpaceY >= Col.NumItems) { FreeSpaceX = FreeSpaceY = -1; // invalid, ignore } else { UseFreeSpace(FreeSpaceX, FreeSpaceY); } } } } override bool MenuEvent(int mKey, bool gamepad) { if (InMenuTransition() == true) { return false; } if (ChallengeMenuPaused() == true) { return false; } bool moved = false; switch (mKey) { case MKEY_Left: moved = ChangeColumn(-1); break; case MKEY_Right: moved = ChangeColumn(1); break; case MKEY_Up: moved = ChangeRow(-1); break; case MKEY_Down: moved = ChangeRow(1); break; case MKEY_Back: let m = GetCurrentMenu(); let p = m.mParentMenu; MenuSound(p != null ? "menu/backup" : "menu/clear"); TryTransitionOut(p); ClosingMenu = true; return true; case MKEY_Enter: if (ValidSelectedChallenge() && Columns[CurColumn].Items[CurRow].Activate()) { return true; } /* FALLTHRU */ default: if (ValidSelectedChallenge() && Columns[CurColumn].Items[CurRow].MenuEvent(mKey, gamepad) == true) { return true; } return false; } if (moved == true) { MenuSound("menu/cursor"); } return true; } override bool MouseEvent(int type, int x, int y) { if (InMenuTransition() == true) { return false; } if (mFocusControl) { mFocusControl.MouseEvent(type, x, y); return true; } else { Vector2 ScreenPos = (VirtualOffset.X + (BASE_VID_WIDTH * 0.5), VirtualOffset.Y + mDesc.mPosition) - ScrollPos; int newColumn = (x - ScreenPos.X) / COLUMN_X_OFFSET; int newRow = (y - ScreenPos.Y) / COLUMN_Y_OFFSET; bool set = false; if (newColumn >= 0 && newColumn < Columns.Size()) { let Col = Columns[newColumn]; if (newRow >= 0 && newRow < Col.NumItems) { CurColumn = newColumn; CurRow = newRow; bool changed = (CurColumn != ColumnFocus || CurRow != RowFocus); if (type == MOUSE_Release) { ColumnFocus = CurColumn; RowFocus = CurRow; } if (m_use_mouse == 2 && changed == true) { return true; } Col.Items[CurRow].MouseEvent(type, x, y); return true; } } } CurColumn = CurRow = -1; ColumnFocus = RowFocus = -1; return true; } override bool OnUIEvent(UIEvent ev) { if (InMenuTransition() == true) { return false; } if (ev.type == UIEvent.Type_WheelUp) { SetSelectedItem(-1, false); DestScrollPos.X -= MOUSE_SCROLL_PIXELS; ClampScrollPos(); return true; } else if (ev.type == UIEvent.Type_WheelDown) { SetSelectedItem(-1, false); DestScrollPos.X += MOUSE_SCROLL_PIXELS; ClampScrollPos(); return true; } return MouseEvents(ev); } void DrawExplodeFrame(Vector2 Pos, int Frame, bool Small = false) { TextureID Expl; if (Small == true) { if (Frame < 0 || Frame >= NUM_EXPLOSION_FRAMES_SMALL) { return; } static const String ExplFramesSmall[] = { "REXPH0", "REXPI0", "REXPJ0", "REXPK0" }; Expl = TexMan.CheckForTexture(ExplFramesSmall[Frame], TexMan.Type_Sprite); } else { if (Frame < 0 || Frame >= NUM_EXPLOSION_FRAMES) { return; } static const String ExplFrames[] = { "REXPA0", "REXPB0", "REXPC0", "REXPD0", "REXPE0", "REXPF0", "REXPG0" }; Expl = TexMan.CheckForTexture(ExplFrames[Frame], TexMan.Type_Sprite); } SnapMenuTexture(Expl, Pos); } void DrawExplodeCircle(Vector2 Pos, uint Tick, uint Particles, double Dist, double Angle, double Rotate, bool Small = false) { uint TimeSpent = EXPLODE_TIME - Tick; int Frame = (TimeSpent / 2); double Offset = 360.0 / Particles; Angle += (Tick * Rotate); for (uint i = 0; i < Particles; i++) { double ExplodeDist = Dist * (double(TimeSpent) / double(EXPLODE_TIME)); Vector2 ExplodePos = Pos + ( (cos(Angle), sin(Angle)) * ExplodeDist ); Angle += Offset; DrawExplodeFrame(ExplodePos, Frame, Small); } } override void ItemsDrawer() { uint NumColumns = Columns.Size(); for (uint i = 0; i < NumColumns; i++) { let Col = SnapAchievementColumn( Columns[i] ); Vector2 Pos = ((COLUMN_X_OFFSET * i), mDesc.mPosition); Array items; for (int i = 0; i < Col.NumItems; i++) { items.Push(Col.Items[i]); } DrawItemList(Pos, items, (i == CurColumn) ? CurRow : -1); } if (ExplodeTick > 0) { Vector2 ExplodeBasePos = (CurColumn * COLUMN_X_OFFSET, mDesc.mPosition) - ScrollPos; ExplodeBasePos.X += (COLUMN_X_OFFSET * 0.5) + (BASE_VID_WIDTH * 0.5); ExplodeBasePos.Y += COLUMN_Y_OFFSET * (CurRow + 0.5); DrawExplodeCircle( ExplodeBasePos, ExplodeTick, 4, EXPLODE_DIST, 0.0, EXPLODE_ROTATE, false ); DrawExplodeCircle( ExplodeBasePos, ExplodeTick, 4, EXPLODE_DIST_SMALL, 45.0, EXPLODE_ROTATE, true ); } bool CanUseFreeSpace = false; if (InMenuTransition() == false && ValidSelectedChallenge() == true) { let CurItem = SnapAchievementItem(Columns[CurColumn].Items[CurRow]); if (CurItem != null) { CanUseFreeSpace = CurItem.Achievement.CanUseFreeSpace(); if (CurItem.Reward.Length() > 0) { Vector2 RewardPos = (BASE_VID_WIDTH * 0.5, 164); SnapMenuTexture(RewardBG, RewardPos - (96, 2)); SnapMenuText( FontThin, Font.CR_UNTRANSLATED, CenterAlignPos(FontThin, CurItem.Reward, RewardPos + (0, 4)), CurItem.Reward ); } } } Vector2 HeaderPos = (BASE_VID_WIDTH * 0.5, 8); HeaderPos.Y -= (1.0 - MenuTransition) * (VirtualSize.Y * 0.5); String LabelText = Stringtable.Localize("$SNAPMENU_CHALLENGE"); DrawMenuHeader( LabelText, CenterAlignPos(FontHeader, LabelText, HeaderPos) ); Vector2 TallyPos = HeaderPos + (64, 22); String Tally = String.Format("%d / %d", NumAchieved, TotalAchievements); DrawSticker(TallyPos + (0, 2), 44, STICKER_TYPE_TEXT); SnapMenuText( FontSmall, (NumAchieved >= TotalAchievements) ? FontHighlightColor : Font.CR_UNTRANSLATED, CenterAlignPos(FontSmall, Tally, TallyPos), Tally ); Vector2 FreeSpacePos = HeaderPos + (12, 14); for (uint i = 0; i < FreeSpaces; i++) { if (i == FreeSpaces-1) { FreeSpacePos = UseFreeSpacePos; } SnapMenuTexture(FreeSpaceTex, FreeSpacePos); FreeSpacePos.X -= 20.0; } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapChargeProps : SnapWeaponProps { override void Init() { WeaponName = "Charge"; NiceName = "$SNAPMENU_WEAPON_CHARGE"; PickupType = "SnapChargePowerup"; WeaponIcon = "WP_CHARG"; FireState = "FireCharge"; DropFreq = 15; } } class SnapChargeCan : SnapItemCan { Default { DropItem "SnapChargePowerup"; } States { Spawn: WP_C A 10; WP_C A 10 Bright; Loop; } } class SnapChargePowerup : SnapWeaponPowerup { Default { SnapWeaponPowerup.WeaponPower "Charge"; Inventory.PickupMessage "$POWERUP_CHARGE"; SnapInventory.VoiceSample "voice/charge"; } States { Spawn: WP_C B 10; WP_C B 10 Bright; Loop; } } class SnapChargeHitConfirm : SnapDynamicDecor { Default { RenderStyle "Add"; +BRIGHT +ROLLSPRITE } States { Spawn: CHCN ABABCDCDEFEFGHGH 1; CHCN I 1; TNT1 A 1; CHCN I 1; Stop; Alt: TNT1 A 1 A_SetRenderStyle(0.5, STYLE_Add); CHCN ABABCDCDEFEFGHGH 1; CHCN I 1; TNT1 A 1; CHCN I 1; Stop; } } class SnapChargeShotTrailGood : SnapActor { Default { RenderStyle "Add"; +NOINTERACTION +NOGRAVITY +NOBLOCKMAP +RANDOMIZE +BRIGHT } States { Spawn: CRGB A 3; CRGB BABAB 1; Stop; } } class SnapChargeShotTrailGreat : SnapChargeShotTrailGood { States { Spawn: CRGB C 3 Light("ChargeShotWimpLight"); CRGB DECDF 1 Light("ChargeShotWimpLight"); CRGB ABAB 1; Stop; } } class SnapChargeShotTrailPerfect : SnapChargeShotTrailGreat { States { Spawn: CRGB G 3 Light("ChargeShotGoodLight"); CRGB HIGHJ 1 Light("ChargeShotGoodLight"); CRGB CDECDF 1 Light("ChargeShotWimpLight"); CRGB ABAB 1; Stop; } } class SnapChargeShot : SnapBasicShot abstract { meta double ChargeSwerve; property ChargeSwerve: ChargeSwerve; meta uint ChargeDamage; property ChargeDamage: ChargeDamage; meta double ChargeRadius; property ChargeRadius: ChargeRadius; meta uint ChargeHitDelay; property ChargeHitDelay: ChargeHitDelay; const SEARCHDIST = 192.0; const PREDICTFLOOR = 32; const FLOORPREVENT = 0.9; Default { DamageType "Charge"; Obituary "$OB_CHARGE"; Damage 0; Radius 8; Height 12; SnapChargeShot.ChargeHitDelay BASETOUCHDELAY; +RIPPER +DONTBOUNCEONSHOOTABLES +SnapActor.RIPPERHITSTUN } override int GetDamageForClink() { return ChargeDamage; } virtual void SpawnChargeHitConfirm(Actor victim, Actor source) { Actor hc = Spawn("SnapChargeHitConfirm", victim.Pos + (0, 0, victim.Height * 0.5), ALLOW_REPLACE); if (hc != null) { hc.Roll = frandom[snap_decor](-180.0, 180.0); hc.bXFlip = random[snap_decor](0, 1); hc.bYFlip = random[snap_decor](0, 1); if (source != null) { double dis = hc.Distance3D(source); if (dis > 0.0) { double sc = 1.0 + (dis / 2048.0); hc.Scale = (sc, sc); } } Actor hctwo = Spawn("SnapChargeHitConfirm", hc.Pos, ALLOW_REPLACE); if (hctwo != null) { hctwo.Roll = hc.Roll; hctwo.bXFlip = hc.bXFlip; hctwo.bYFlip = hc.bYFlip; hctwo.Scale = hc.Scale; hctwo.SetStateLabel("Alt"); } } } void HandleChargeSwerve() { if (Vel == (0, 0, 0)) { return; } if (ChargeSwerve <= 0.0) { return; } Vector3 OrigDir = SnapUtils.SafeVec3Unit(Vel); double sd = SEARCHDIST * Scale.X; Actor SwerveTarget = FindHomingTarget(sd, VectorAngle(Vel.X, Vel.Y), target); if (SwerveTarget != null) { Vector3 DistTo = Vec3To(SwerveTarget); DistTo.Z += SwerveTarget.Height * 0.5; Vector3 DirTo = SnapUtils.SafeVec3Unit(DistTo); double distVal = sd - DistTo.Length(); if (DistTo.Length() > 0 && distVal > 0) { double distMul = distVal / SEARCHDIST; double product = OrigDir dot DirTo; double interp = (product * distMul) * ChargeSwerve; if (interp > 0.0) { Vector3 NewDir = ((1 - interp) * OrigDir) + (interp * DirTo); if (NewDir.Length() > 0) { Vel = Vel.Length() * NewDir; } } } } // People tend to naturally aim slightly down, even if they don't intend to, // so try to even out if it's going to hit the ground at a shallow angle. double ZPredict = Vel.Z * PREDICTFLOOR; if (Pos.Z + ZPredict <= FloorZ) { Vel.Z *= FLOORPREVENT; } } void HandleChargeDamage() { if (TouchDelay > 0) { return; } double cr = ChargeRadius * Scale.X; if (cr <= 0) { return; } BlockThingsIterator it = BlockThingsIterator.Create(self, cr); Actor toucher; while (it.Next()) { toucher = it.thing; // Get the Actor it's currently on if (toucher == null || Distance3D(toucher) - toucher.Radius > cr) { continue; } if (toucher.bShootable == false) { continue; } Actor theSource = target; if (toucher == theSource) { continue; } if (theSource != null) { if (CanAttackHurt(toucher, theSource) == false) { continue; } } int finalDmg = int(ChargeDamage * Scale.X); int dmgFlags = 0; if (finalDmg >= 100) { // destroy E1M8 cars dmgFlags |= DMG_EXPLOSION; } let pawn = SnapPlayer(toucher); if (pawn) { if (pawn.TouchDelay > 0) { continue; } pawn.DamageMobj(self, theSource, finalDmg, DamageType, dmgFlags); pawn.TouchDelay = ChargeHitDelay; SpawnChargeHitConfirm(toucher, theSource); continue; } let sa = SnapActor(toucher); if (sa) { if (sa.TouchDelay > 0) { continue; } sa.DamageMobj(self, theSource, finalDmg, DamageType, dmgFlags); sa.TouchDelay = ChargeHitDelay; SpawnChargeHitConfirm(toucher, theSource); continue; } } } override void Tick() { super.Tick(); ShadowSize = ChargeRadius; HandleChargeDamage(); if (TickPaused() == true) { return; } HandleChargeSwerve(); } action void A_GoodChargeTrail() { if (Level.maptime & 1) { return; } uint timer = Level.maptime / 2; double ha = angle + 90; double va = (timer % 8) * 45; double dist = 16.0; Vector3 offset = ( dist * cos(ha) * cos(va), dist * sin(ha) * cos(va), (dist * 0.8) * sin(va) ); offset.Z += Height * 0.5; SnapActor particle = SnapActor(Spawn("SnapChargeShotTrailGood", Pos + offset, ALLOW_REPLACE)); if (particle) { particle.target = self; particle.SetHitstunParent(self); } } action void A_GoodChargeExplode() { double ha = angle + 90; double spd = 8.0; for (int i = 0; i < 4; i++) { double va = 45 + (i * 90); Vector3 spawnPos = Pos; spawnPos.Z += Height * 0.5; SnapActor particle = SnapActor(Spawn("SnapChargeShotTrailGood", spawnPos, ALLOW_REPLACE)); if (particle) { particle.target = self; particle.SetHitstunParent(self); particle.Vel = ( spd * cos(ha) * cos(va), spd * sin(ha) * cos(va), spd * sin(va) ); } } } action void A_GreatChargeTrail() { if (Level.maptime & 1) { return; } uint timer = Level.maptime / 2; double ha = angle + 90; double va = (timer % 8) * 45; double dist = 32.0; Vector3 offset = ( dist * cos(ha) * cos(va), dist * sin(ha) * cos(va), (dist * 0.8) * sin(va) ); offset.Z += Height * 0.5; SnapActor particle = SnapActor(Spawn("SnapChargeShotTrailGreat", Pos + offset, ALLOW_REPLACE)); if (particle) { particle.target = self; particle.SetHitstunParent(self); } va += 180.0; offset = ( dist * cos(ha) * cos(va), dist * sin(ha) * cos(va), (dist * 0.8) * sin(va) ); offset.Z += Height * 0.5; particle = SnapActor(Spawn("SnapChargeShotTrailGood", Pos + offset, ALLOW_REPLACE)); if (particle) { particle.target = self; particle.SetHitstunParent(self); } } action void A_GreatChargeExplode() { double ha = angle + 90; for (int i = 0; i < 8; i++) { double va = i * 45; double spd = 16.0; SnapActor particle = null; Vector3 spawnPos = Pos; spawnPos.Z += Height * 0.5; if (i & 1) { particle = SnapActor(Spawn("SnapChargeShotTrailGreat", spawnPos, ALLOW_REPLACE)); } else { particle = SnapActor(Spawn("SnapChargeShotTrailGood", spawnPos, ALLOW_REPLACE)); spd *= 0.5; } if (particle) { particle.target = self; particle.SetHitstunParent(self); particle.Vel = ( spd * cos(ha) * cos(va), spd * sin(ha) * cos(va), spd * sin(va) ); } } } action void A_PerfectChargeTrail() { if (Level.maptime & 1) { return; } uint timer = Level.maptime / 2; double ha = angle + 90; double va = (timer % 8) * 45; double dist = 64.0; Vector3 offset = ( dist * cos(ha) * cos(va), dist * sin(ha) * cos(va), (dist * 0.8) * sin(va) ); offset.Z += Height * 0.5; SnapActor particle = SnapActor(Spawn("SnapChargeShotTrailPerfect", Pos + offset, ALLOW_REPLACE)); if (particle) { particle.target = self; particle.SetHitstunParent(self); } va += 120.0; offset = ( dist * cos(ha) * cos(va), dist * sin(ha) * cos(va), (dist * 0.8) * sin(va) ); offset.Z += Height * 0.5; particle = SnapActor(Spawn("SnapChargeShotTrailGreat", Pos + offset, ALLOW_REPLACE)); if (particle) { particle.target = self; particle.SetHitstunParent(self); } va += 120.0; offset = ( dist * cos(ha) * cos(va), dist * sin(ha) * cos(va), (dist * 0.8) * sin(va) ); offset.Z += Height * 0.5; particle = SnapActor(Spawn("SnapChargeShotTrailGood", Pos + offset, ALLOW_REPLACE)); if (particle) { particle.target = self; particle.SetHitstunParent(self); } } action void A_PerfectChargeExplode() { double ha = angle + 90; for (int i = 0; i < 16; i++) { double va = (i * 22.5) + 45; double spd = 24.0; SnapActor particle = null; Vector3 spawnPos = Pos; spawnPos.Z += Height * 0.5; int pID = (i % 4); switch (pID) { case 0: particle = SnapActor(Spawn("SnapChargeShotTrailPerfect", spawnPos, ALLOW_REPLACE)); break; case 2: particle = SnapActor(Spawn("SnapChargeShotTrailGreat", spawnPos, ALLOW_REPLACE)); spd *= 0.6; break; default: particle = SnapActor(Spawn("SnapChargeShotTrailGood", spawnPos, ALLOW_REPLACE)); spd *= 0.3; break; } if (particle) { particle.target = self; particle.SetHitstunParent(self); particle.Vel = ( spd * cos(ha) * cos(va), spd * sin(ha) * cos(va), spd * sin(va) ); } } } } class SnapChargeShotWimp : SnapChargeShot { Default { SnapChargeShot.ChargeDamage 40; SnapChargeShot.ChargeSwerve 0.6; SnapChargeShot.ChargeRadius 15.0; Gravity 0.5; -NOGRAVITY } States { Spawn: CRGB AB 1 Light("ChargeShotWimpLight"); Loop; Death: CRGB A 1 Light("ChargeShotWimpLight"); Stop; } } class SnapChargeShotGood : SnapChargeShot { Default { SnapChargeShot.ChargeDamage 120; SnapChargeShot.ChargeSwerve 0.4; SnapChargeShot.ChargeRadius 30.0; } States { Spawn: CRGB CDECDF 1 Light("ChargeShotGoodLight") A_GoodChargeTrail(); Loop; Death: CRGB C 1 Light("ChargeShotGoodLight"); TNT1 A 1 A_GoodChargeExplode(); Stop; } } class SnapChargeShotGreat : SnapChargeShotGood { Default { SnapChargeShot.ChargeDamage 300; SnapChargeShot.ChargeSwerve 0.2; SnapChargeShot.ChargeRadius 48.0; } States { Spawn: CRGB GHIGHJ 1 Light("ChargeShotGreatLight") A_GreatChargeTrail(); Loop; Death: CRGB G 1 Light("ChargeShotGreatLight"); TNT1 A 1 A_GreatChargeExplode(); Stop; } } class SnapChargeShotPerfect : SnapChargeShotGreat { Default { Speed 15; SnapChargeShot.ChargeDamage 100; SnapChargeShot.ChargeSwerve 0.1; SnapChargeShot.ChargeRadius 96.0; SnapChargeShot.ChargeHitDelay (BASETOUCHDELAY/4); // Multi-hit. } States { Spawn: CRGB KLOMNP 1 Light("ChargeShotPerfectLight") A_PerfectChargeTrail(); Loop; Death: CRGB L 1 Light("ChargeShotPerfectLight"); TNT1 A 1 A_PerfectChargeExplode(); Stop; } } extend class SnapGun { action void A_SnapgunCharge(bool sounds = false, bool useAmmo = false) { if (player == null || player.mo == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } let pmo = SnapPlayer(player.mo); if (pmo == null) { return; } bool forceRelease = false; uint PrevCharge = weap.ChargeLevel; weap.ChargeLevel++; if (weap.ChargeLevel >= weap.PerfectCharge && PrevCharge < weap.PerfectCharge) { A_SetSnapGunState(CHARGEWRAPLAYER_C, 'ChargeWrap'); A_SetSnapGunState(FLASHLAYER, 'ChargeFlashD'); A_SetSnapGunState(CHARGELEVELLAYER, 'ChargeLevelD'); } else if (weap.ChargeLevel >= weap.GreatCharge && PrevCharge < weap.GreatCharge) { A_SetSnapGunState(CHARGEWRAPLAYER_B, 'ChargeWrap'); A_SetSnapGunState(FLASHLAYER, 'ChargeFlashC'); A_SetSnapGunState(CHARGELEVELLAYER, 'ChargeLevelC'); } else if (weap.ChargeLevel >= weap.GoodCharge && PrevCharge < weap.GoodCharge) { A_SetSnapGunState(CHARGEWRAPLAYER_A, 'ChargeWrap'); A_SetSnapGunState(FLASHLAYER, 'ChargeFlashB'); A_SetSnapGunState(CHARGELEVELLAYER, 'ChargeLevelB'); } if (sounds == true) { if (weap.ChargeLevel >= weap.PerfectCharge) { A_StartSound("revolver/charge4", CHAN_WEAPON); } else if (weap.ChargeLevel >= weap.GreatCharge) { A_StartSound("revolver/charge3", CHAN_WEAPON); } else if (weap.ChargeLevel >= weap.GoodCharge) { A_StartSound("revolver/charge2", CHAN_WEAPON); } else { A_StartSound("revolver/charge1", CHAN_WEAPON); } pmo.PlayFireNoFlash(); } if (useAmmo == true) { pmo.TakeInventory("SnapPowerupAmmo", 1, false, true); forceRelease = A_OutOfAmmo(); } if (!(player.cmd.buttons & BT_ATTACK) || forceRelease == true) { A_SetSnapGunState(GUNLAYER, 'FireChargeRelease'); A_SetSnapGunState(FLASHLAYER, 'LightDone'); A_SetSnapGunState(CHARGEWRAPLAYER_A, 'LightDone'); A_SetSnapGunState(CHARGEWRAPLAYER_B, 'LightDone'); A_SetSnapGunState(CHARGEWRAPLAYER_C, 'LightDone'); A_SetSnapGunState(CHARGESTREAKLAYER, 'LightDone'); A_SetSnapGunState(CHARGELEVELLAYER, 'LightDone'); return; } } action void A_SnapgunChargeFire() { if (player == null || player.mo == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } A_SnapgunFlash('ChargeReleaseFlash'); if (weap.ChargeLevel >= weap.PerfectCharge) { A_SnapgunMomentumProjectile("SnapChargeShotPerfect"); A_StartSound("revolver/chargeFire4", CHAN_WEAPON); } else if (weap.ChargeLevel >= weap.GreatCharge) { A_SnapgunMomentumProjectile("SnapChargeShotGreat"); A_StartSound("revolver/chargeFire3", CHAN_WEAPON); } else if (weap.ChargeLevel >= weap.GoodCharge) { A_SnapgunMomentumProjectile("SnapChargeShotGood"); A_StartSound("revolver/chargeFire2", CHAN_WEAPON); } else { A_SnapgunMomentumProjectile("SnapChargeShotWimp"); A_StartSound("revolver/chargeFire1", CHAN_WEAPON); } SoundAlert(self); weap.ChargeLevel = 0; } action void A_SnapgunChargeStreakTics() { if (player == null || player.mo == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } let pmo = SnapPlayer(player.mo); if (pmo == null) { return; } let pspChargeStreak = player.GetPSprite(CHARGESTREAKLAYER); if (pspChargeStreak) { if (pspChargeStreak.tics <= 0) { return; } if (weap.ChargeLevel >= weap.PerfectCharge) { pspChargeStreak.tics -= 3; } else if (weap.ChargeLevel >= weap.GreatCharge) { pspChargeStreak.tics -= 2; } else if (weap.ChargeLevel >= weap.GoodCharge) { pspChargeStreak.tics -= 1; } if (pspChargeStreak.tics < 1) { pspChargeStreak.tics = 1; } } } States { FireCharge: SREL AAABBB 1 A_OverlayOffset(GUNLAYER, 0, -5.75, WOF_ADD); SREL CDE 2; SGUN A 0 A_SetSnapGunState(RELOADLAYER, 'OpenSesame'); SGUN A 0 A_StartSound("revolver/reload1", CHAN_WEAPON); SREL IFIGIH 1; SREL LK 1; SREL M 4; SREL M 0 A_SetSnapGunState(FLASHLAYER, 'ChargeFlashA'); SREL M 0 A_SetSnapGunState(CHARGELEVELLAYER, 'ChargeLevelA'); SREL M 0 A_SetSnapGunState(CHARGESTREAKLAYER, 'ChargeStreak'); FireChargeLoop: SREL N 1 A_SnapgunCharge(true, true); SREL OPQ 1 A_SnapgunCharge(); SREL N 1 A_SnapgunCharge(true, false); SREL OPQ 1 A_SnapgunCharge(); SREL N 1 A_SnapgunCharge(true, false); SREL OPQ 1 A_SnapgunCharge(); Loop; FireChargeRelease: SGUN A 0 A_StartSound("revolver/reload3", CHAN_WEAPON); SREL KJI 1; SREL EDC 1; SREL BA 1 A_OverlayOffset(GUNLAYER, 0, 17.25, WOF_ADD); SGUN A 1 A_SnapgunChargeFire(); SGUN BCD 1; SGUN E 6; SGUN F 5; Goto GunIdle; ChargeWrap: CFL1 ABC 1 Bright; TNT1 A 4; CFL1 DEF 1 Bright; TNT1 A 4; CFL1 GH 1 Bright; Loop; ChargeStreak: CFL2 ABCDEF 4 Bright A_SnapgunChargeStreakTics(); Loop; ChargeLevelA: CFL3 AB 1 Bright; Loop; ChargeLevelB: CFL3 CD 1 Bright; Loop; ChargeLevelC: CFL3 EF 1 Bright; Loop; ChargeLevelD: CFL3 GH 1 Bright; Loop; ChargeFlashA: TNT1 A 1; // maybe temp? Loop; ChargeFlashB: CFL4 A 1 Bright; TNT1 A 1; CFL4 B 1 Bright; TNT1 A 1; Loop; ChargeFlashC: CFL4 C 1 Bright; TNT1 A 1; CFL4 D 1 Bright; TNT1 A 1; CFL4 E 1 Bright; TNT1 A 1; Loop; ChargeFlashD: CFL4 C 1 Bright; CFL4 F 1 Bright; CFL4 D 1 Bright; CFL4 F 1 Bright; CFL4 E 1 Bright; CFL4 F 1 Bright; Loop; ChargeReleaseFlash: TNT1 A 1 Bright A_Light(2); SFL6 A 1 Bright A_Light(1); SFL6 B 1 Bright A_Light(0); SFL6 C 1 Bright; SFL6 D 1 Bright; Goto LightDone; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapMonster { // Reimplementation of A_Chase and // all of its related functions, mostly // to remove RNG. const MISSILERANGEADD = 100.0; double MissileRangeIncrease; double BaseMissileRange; property BaseMissileRange: BaseMissileRange; enum dirtype_t { DI_EAST, DI_NORTHEAST, DI_NORTH, DI_NORTHWEST, DI_WEST, DI_SOUTHWEST, DI_SOUTH, DI_SOUTHEAST, DI_NODIR, NUMDIRS }; virtual bool HandleMonsterMove(Vector2 TryMoveDir, int dropoff, in out FCheckPosition tm) { Vector2 OrigXY = Pos.XY; Vector2 DeltaXY = Speed * TryMoveDir; Vector2 TryXY = OrigXY + DeltaXY; double maxmove = radius-1; int steps = 1; if (maxmove > 0) { Vector2 SpeedXY = ( abs(DeltaXY.X), abs(DeltaXY.Y) ); if (SpeedXY.X > SpeedXY.Y) { if (SpeedXY.X > maxmove) { steps = 1 + int(SpeedXY.X / maxmove); } } else { if (SpeedXY.Y > maxmove) { steps = 1 + int(SpeedXY.Y / maxmove); } } } tm.FromPMove = true; double oldAngle = angle; Vector2 StartXY = OrigXY; Vector2 MoveXY = DeltaXY; bool try_ok = true; for (int i = 1; i <= steps; i++) { Vector2 ptry = OrigXY + DeltaXY * i / steps; // killough 3/15/98: don't jump over dropoffs: try_ok = TryMove(ptry, dropoff, false, tm); if (try_ok == false) { break; } // Handle portal transitions just like P_XYMovement. if (steps > 1 && Pos.XY != ptry) { double AngleDiff = DeltaAngle(oldangle, angle); if (AngleDiff != 0) { MoveXY = RotateVector(MoveXY, AngleDiff); oldAngle = angle; } StartXY = Pos.XY - MoveXY * i / steps; } } ClearInterpolation(); return try_ok; } virtual bool HandleMonsterFloat(int FloatDir) { if (FloatDir == 0) { return false; } double FloatMove = FloatDir * FloatSpeed; AddZ(FloatMove); return TestMobjZ(); } virtual Vector2 GetMonsterMoveDir() { if (movedir >= DI_NODIR) { return ( 0, 0 ); } double SQRTHALF = 0.7071075439453125; double xspeed[8] = {1,SQRTHALF,0,-SQRTHALF,-1,-SQRTHALF,0,SQRTHALF}; double yspeed[8] = {0,SQRTHALF,1,SQRTHALF,0,-SQRTHALF,-1,-SQRTHALF}; return ( xspeed[movedir], yspeed[movedir] ); } const MIN_TARGET_DIFF = 256.0; const MAX_FLOAT_HEIGHT = 1024.0; bool SnapMonsterMove() { // MonsterMove with NO RNG. int dropoff = 0; if (bBlasted == true) { DoFootstep(Speed); return true; } if (movedir >= DI_NODIR) { // make sure it's valid. movedir = DI_NODIR; return false; } // [RH] Walking actors that are not on the ground cannot walk. We don't // want to yank them to the ground here as Doom did, since that makes // it difficult to thrust them vertically in a reasonable manner. // [GZ] Let jumping actors jump. if ((bNoGravity == false && bCanJump == false) && Pos.Z > FloorZ && bOnMobj == false) { return false; } if (bNoFootsteps == false) { DoFootstep(Speed * 0.25); } if (bFloat == true) { // Floating monsters give themselves their own friction. Vel *= 0.95; } // killough 10/98: allow dogs to drop off of taller ledges sometimes. // dropoff==1 means always allow it, dropoff==2 means only up to 128 high, // and only if the target is immediately on the other side of the line. if ((bJumpDown == true) && target && (target.IsFriend(self) == false) && Distance2D(target) < 144) // NO MORE RNG CALL FOR DROPPING OFF { dropoff = 2; } Vector2 TryMoveDir = GetMonsterMoveDir(); bool try_ok = false; FCheckPosition tm; try_ok = HandleMonsterMove(TryMoveDir, dropoff, tm); // [RH] If a walking monster is no longer on the floor, move it down // to the floor if it is within MaxStepHeight, presuming that it is // actually walking down a step. if (try_ok == true && !(bNoGravity || bCanJump) && Pos.Z > FloorZ && !bOnMobj) { if (Pos.Z <= FloorZ + MaxStepHeight) { double savedz = Pos.Z; SetZ(FloorZ); // Make sure that there isn't some other actor between us and // the floor we could get stuck in. The old code did not do this. if (TestMobjZ() == false) { SetZ(savedz); } else { // The monster just hit the floor, so trigger any actions. Vector3 relPos = PosRelative(FloorSector); if (FloorSector.SecActTarget != null && FloorZ == FloorSector.FloorPlane.ZatPoint(relPos.XY)) { FloorSector.TriggerSectorActions(self, SectorAction.SECSPAC_HitFloor); } CheckFor3DFloorHit(Pos.Z, true); } } } if (try_ok == false) { if ((bCanJump || bFloat) && tm.floatok) { double savedz = Pos.Z; int floatDir = 0; if (Pos.Z < tm.floorz) { floatDir = 1; } else { floatDir = -1; } // [RH] Check to make sure there's nothing in the way of the float if (HandleMonsterFloat(floatDir)) { bInFloat = true; return true; } SetZ(savedz); } // open any specials movedir = DI_NODIR; // I REMADE THIS ENTIRE FUNCTION // JUST TO REPLACE THIS ONE LINE // AAAAAAAAAAAAAAAAA return CheckMonsterUseSpecials(); } else { if (bFloat && tm.floatok) { double savedz = Pos.Z; int floatDir = 0; if (bFloatMatchHeight == true) { double TopZ = min(CeilingZ, Target.Pos.Z + Target.Height + Height); double BottomZ = max(FloorZ, Target.Pos.Z - Height); if (Pos.Z + Height >= TopZ) { floatDir = -1; } else if (Pos.Z <= BottomZ) { floatDir = 1; } } else { // Snap: Try to get away from the floor/ceiling (if there's enough room) double CZ = CeilingZ; double diff = CZ - FloorZ; if (diff > MAX_FLOAT_HEIGHT) { CZ = FloorZ + MAX_FLOAT_HEIGHT; diff = MAX_FLOAT_HEIGHT; } double Fspacing = min(max(32.0, diff * 0.4), MIN_TARGET_DIFF); double Cspacing = (Fspacing * 0.25); if (diff > (Height + Fspacing)) { double top = Pos.Z + Height; if (Pos.Z < FloorZ + Fspacing) { floatDir = 1; } else if ((top > CZ - Cspacing) && (Pos.Z - Target.Pos.Z > MIN_TARGET_DIFF) && (diff > Height + Fspacing + MIN_TARGET_DIFF)) { floatDir = -1; } } } // [RH] Check to make sure there's nothing in the way of the float if (HandleMonsterFloat(floatDir)) { bInFloat = true; return true; } SetZ(savedz); } bInFloat = false; } return true; } bool SnapTryWalk() { // TryWalk, except with a static movecount value. if (SnapMonsterMove() == false) { return false; } movecount = 8; return true; } // NewChaseDir, with all of the RNG stripped. void SnapDoNewChaseDir(Vector2 delta) { if (delta.Length() <= 0.0) { movedir = DI_NODIR; return; } int opposite[9] = { DI_WEST, DI_SOUTHWEST, DI_SOUTH, DI_SOUTHEAST, DI_EAST, DI_NORTHEAST, DI_NORTH, DI_NORTHWEST, DI_NODIR }; int diags[4] = { DI_NORTHWEST, DI_NORTHEAST, DI_SOUTHWEST, DI_SOUTHEAST }; bool attempts[NUMDIRS-1]; int olddir = movedir; int turnaround = opposite[olddir]; int d[3]; if (delta.X > 10) { d[1] = DI_EAST; } else if (delta.X < -10) { d[1] = DI_WEST; } else { d[1] = DI_NODIR; } if (delta.Y < -10) { d[2] = DI_SOUTH; } else if (delta.Y > 10) { d[2] = DI_NORTH; } else { d[2] = DI_NODIR; } // Try direct route. if (d[1] != DI_NODIR && d[2] != DI_NODIR) { movedir = diags[((delta.Y < 0) << 1) + (delta.x > 0)]; if (movedir != turnaround) { attempts[movedir] = true; if (SnapTryWalk() == true) { return; } } } // Try other directions. int tdir = 0; if (abs(delta.Y) > abs(delta.X)) { tdir = d[1]; d[1] = d[2]; d[2] = tdir; } if (d[1] == turnaround) { d[1] = DI_NODIR; } if (d[2] == turnaround) { d[2] = DI_NODIR; } if (d[1] != DI_NODIR && attempts[d[1]] == false) { movedir = d[1]; attempts[movedir] = true; if (SnapTryWalk() == true) { // either moved forward or attacked return; } } if (d[2] != DI_NODIR && attempts[d[2]] == false) { movedir = d[2]; attempts[movedir] = true; if (SnapTryWalk() == true) { return; } } // there is no direct path to the player, // so pick another direction. if (olddir != DI_NODIR && attempts[olddir] == false) { movedir = olddir; attempts[movedir] = true; if (SnapTryWalk() == true) { return; } } // search in direction depending on the delta if (delta.Y < 0) { // Starting southeast going counter-clockwise if target is below us for (tdir = DI_SOUTHEAST; tdir != (DI_EAST-1); tdir--) { if (tdir != turnaround && attempts[tdir] == false) { movedir = tdir; attempts[movedir] = true; if (SnapTryWalk() == true) { return; } } } } else { // Starting east going clockwise if target is above us for (tdir = DI_EAST; tdir <= DI_SOUTHEAST; tdir++) { if (tdir != turnaround && attempts[tdir] == false) { movedir = tdir; attempts[movedir] = true; if (SnapTryWalk() == true) { return; } } } } if (turnaround != DI_NODIR && attempts[turnaround] == false) { movedir = turnaround; attempts[movedir] = true; if (SnapTryWalk() == true) { return; } } movedir = DI_NODIR; // can not move } virtual Vector2 GetChaseDelta() { Vector2 delta = (0, 0); if ((bChaseGoal == true || goal == target) && goal != null) { delta = Vec2To(goal); } else if (target != null) { delta = Vec2To(target); if (bNoFear == false) { if ((bFrightened == true) || (target.bFrightening == true) || (target.player != null && target.player.cheats & CF_FRIGHTENING)) { delta = -delta; } } } else { // No target. return (0, 0); } if (bAvoidMelee == true) { // Live enemy target if (target.health > 0 && IsFriend(target) == false && target != goal) { double dist = Distance2D(target); double MRange = 112.0; if (target.player == null) { MRange = target.MeleeRange; } double FullRange = Radius + target.radius + (MRange * 5); if (dist < FullRange) { delta = -delta; } } } return delta; } void SnapNewChaseDir() { Vector2 delta = GetChaseDelta(); SnapDoNewChaseDir(delta); } bool SnapSuggestMissileAttack(double dist, state NewMeleeState = null) { // SuggestMissileAttack, without the RNG!! // new version encapsulates the different behavior in flags instead of virtual functions // The advantage is that this allows inheriting the missile attack attributes from the // various Doom monsters by custom monsters if (MaxTargetRange > 0 && dist > MaxTargetRange) { // The Arch Vile's special behavior turned into a property return false; } if (NewMeleeState != null && dist < MeleeThreshold) { // From the Revenant: close enough for fist attack return false; } if (bMissileMore == true) { dist *= 0.5; } if (bMissileEvenMore == true) { dist *= 0.125; } // Instead of a RNG call, always attack when in a range. // Each time this is called and it fails, the range gets larger. // When it's successful, the range is reset. double AtkDist = (BaseMissileRange + MissileRangeIncrease) * Scale.X; if (dist <= AtkDist) { return true; } else { return false; } } bool SnapCheckMissileRange(state NewMeleeState = null) { // CheckMissileRange, without the RNG!! if (!target) { return false; } /* if (Sector.Flags & SECF_NOATTACK) { return false; } */ if (CheckSight(target, SF_SEEPASTBLOCKEVERYTHING) == false) { return false; } if (bJustHit == true) { bJustHit = false; if (target.health <= 0) { // Don't attack a corpse. return false; } else if (IsFriend(target) == false) { // Not a friend, so time to attack. return true; } return true; } if (ReactionTime > 0) { // do not attack yet return false; } if (IsFriend(target) == true) { // killough 7/18/98: friendly monsters don't attack other friendly // monsters or players (except when attacked, and then only once) return false; } if (bFriendly == true && HitFriend() == true) { return false; } double dist = Distance2D(target) - 64; if (NewMeleeState == null) { // No melee attack, fire more. dist -= 128; } return SnapSuggestMissileAttack(dist, NewMeleeState); } bool SnapTryMissileAttack(state NewMeleeState = null) { bool result = SnapCheckMissileRange(NewMeleeState); if (result == true) { MissileRangeIncrease = 0; } else { MissileRangeIncrease += MISSILERANGEADD; } return result; } bool SnapTIDTarget(int id) { if (id <= 0) { return false; } Actor NewTarget = null; ActorIterator it = Level.CreateActorIterator(id); Actor mo; double ShortestDist = -666.0; while (mo = it.Next()) { if (mo.Health <= 0 || mo.bShootable == false) { continue; } double Dist = Distance2D(mo); if (ShortestDist < 0.0 || Dist < ShortestDist) { if (CheckSight(mo) == true) { NewTarget = mo; ShortestDist = Dist; } } } if (NewTarget != null && NewTarget.Health > 0) { Target = NewTarget; return true; } return false; } virtual void ChaseUpdateAngle() { // turn towards movement direction if not there yet if (movedir < 8) { angle = floor(angle / 45) * 45; double delta = deltaangle(angle, movedir * 45); if (delta < 0) { angle -= 45; } else if (delta > 0) { angle += 45; } } } virtual bool HandleChaseUpdate() { // Handle lots of stuff at the beginning (reaction time, patrol points, target updating, etc) // TODO: Maybe make it even more split up if (reactiontime > 0) { reactiontime--; } // [RH] Don't chase invisible targets if (target != null && target.bInvisible == true && target != goal) { target = null; } if (threshold) { if (target == null || target.health <= 0) { threshold = 0; } else { threshold--; } } ChaseUpdateAngle(); // [RH] If the target is dead or a friend (and not a goal), stop chasing it. if (target && target != goal && (target.health <= 0 || IsFriend(target) == true)) { target = null; } // [RH] Friendly monsters will consider chasing whoever hurts a player if they // don't already have a target. if (bFriendly == true && target == null) { PlayerInfo player; if (FriendPlayer != 0) { player = Players[FriendPlayer - 1]; } else { int newPlayer = 0; if (multiplayer) { for ( newPlayer = random[snap_gameplay](0, MAXPLAYERS-1); !playeringame[newPlayer]; newPlayer = (newPlayer + 1) & (MAXPLAYERS-1) ); } player = Players[newPlayer]; } Actor attacker = player.attacker; if (attacker && attacker.health > 0 && attacker.bShootable == true) { if (attacker.bFriendly == false /* || (deathmatch && FriendPlayer != 0 && attacker.FriendPlayer != 0 && FriendPlayer != attacker.FriendPlayer) */ ) { target = attacker; } } } if (target == null || target.bShootable == false) { if (target != null && target.bNonShootable == true) { // Target is only temporarily unshootable, so remember it. lastenemy = target; // Switch targets faster, since we're only changing because we can't // hurt our old one temporarily. threshold = 0; } // Snap: Prioritize your hatred. if (SnapTIDTarget(TIDToHate) == true) { // got a new target return false; } // look for a new target if (LookForPlayers(true) == true && target != goal) { // got a new target return false; } if (target == null) { SetIdle(); return false; } } return true; } virtual bool HandleChaseAttack(StateLabel MeleeStateLabel = "Melee", StateLabel MissileStateLabel = "Missile") { // do not attack twice in a row if (bJustAttacked == true) { bJustAttacked = false; SnapNewChaseDir(); return false; } bool noAttack = false; // [RH] Don't attack if just moving toward goal if (target == goal || (bChaseGoal == true && goal != null)) { Actor savedtarget = target; target = goal; bool ReachedGoal = CheckMeleeRange(); target = savedtarget; if (ReachedGoal == true) { let iterator = Level.CreateActorIterator(goal.args[0], "PatrolPoint"); let specit = Level.CreateActorIterator(goal.TID, "PatrolSpecial"); Actor spec = null; // Execute the specials of any PatrolSpecials with the same TID // as the goal. while (spec = specit.Next()) { A_CallSpecial(spec.special, spec.args[0], spec.args[1], spec.args[2], spec.args[3], spec.args[4]); } double LastGoalAngle = goal.angle; int delay = 0; Actor NewGoal = iterator.Next(); if (NewGoal != null && goal == target) { delay = NewGoal.args[1]; reactiontime = delay * TICRATE + Level.maptime; } else { delay = 0; reactiontime = Default.ReactionTime; Angle = LastGoalAngle; } if (target == goal) { target = null; } bJustAttacked = true; if (NewGoal != null && delay != 0) { bInCombat = true; SetIdle(); } goal = NewGoal; return false; } if (goal == target) { noAttack = true; } } // Scared monsters don't attack if (bFrightened == true) { // Scared of everything noAttack = true; } else if (target != null) { // Scared of their target if ((target.bFrightening == true) || (target.player != null && (target.player.cheats & CF_FRIGHTENING))) { noAttack = true; } } if (noAttack == false) { // check for melee attack state NewMeleeState = FindState(MeleeStateLabel); if (NewMeleeState != null && CheckMeleeRange() == true) { if (AttackSound) { S_StartSound(AttackSound, CHAN_WEAPON); } SetState(NewMeleeState); return false; } // Boss enemies attempt to focus-fire the core. if (bBoss == true && movecount == 0) { SnapTIDTarget(TIDToHate); } // check for missile attack state NewMissileState = FindState(MissileStateLabel); if (NewMissileState != null && movecount == 0) { // Separated, because MissileRangeIncrease gets janked up // if it's successful when movecount != 0 and you can't actually attack. if (SnapTryMissileAttack(NewMeleeState) == true) { SetState(NewMissileState); bJustAttacked = true; bInCombat = true; return false; } } } return true; } virtual bool HandleChase() { // Possibly choose another target if ((multiplayer || TIDtoHate) && threshold == 0 && CheckSight(target) == false) { Actor oldTarget = target; bool success = LookForPlayers(true); if (success == true && target != oldTarget) { return false; // got a new target } } // chase towards player movecount--; if (movecount < 0 || SnapMonsterMove() == false) { SnapNewChaseDir(); } // make active sound // (This RNG is OK because it's not gameplay impacting!) if (random[snap_decor](0, 255) < 3) { PlayActiveSound(); } return true; } action void A_SnapChase(StateLabel MeleeStateLabel = "Melee", StateLabel MissileStateLabel = "Missile") { let us = SnapMonster(self); if (!us) { return; } if (bInConversation == true) { return; } if (bInChase == true) { return; } bInChase = true; if (us.HandleChaseUpdate() == false) { bInChase = false; return; } if (us.HandleChaseAttack(MeleeStateLabel, MissileStateLabel) == false) { bInChase = false; return; } if (us.HandleChase() == false) { bInChase = false; return; } bInChase = false; } action void A_SnapMonsterLook( int LookFlags = 0, float MinSeeDist = 0.0, float MaxSeeDist = 0.0, float MaxHearDist = 0.0, double SeeFOV = 0.0, StateLabel JumpState = "See") { // This used to be where boss meter was initalized, but I had to move it. // Didn't feel like changing everything back to A_Look though, so we'll keep it here just in case. A_LookEx(LookFlags, MinSeeDist, MaxSeeDist, MaxHearDist, SeeFOV, JumpState); } action void A_SnapMonsterPain() { A_Pain(); if (bBoss == true) { // If you're a boss: try to focus-fire the Core in Invasion. A_PickBossTarget(); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapCurrentCheckpoint : Thinker { SnapCheckpoint curCheckpoint; SnapCurrentCheckpoint Init() { ChangeStatNum(STAT_INFO); return self; } static SnapCurrentCheckpoint Get() { ThinkerIterator it = ThinkerIterator.Create("SnapCurrentCheckpoint", STAT_INFO); let p = SnapCurrentCheckpoint(it.Next()); if (p == null) { p = new("SnapCurrentCheckpoint").Init(); } return p; } Vector3 GetPlayerRespawnPos(Actor pMobj, uint PlayerNum) { if (!curCheckpoint) { return (0, 0, 0); } Vector3 RespawnPos = curCheckpoint.Pos; if (!multiplayer) { // It's fine to spawn directly on top of it in single-player. return RespawnPos; } // In multiplayer, we don't want you to respawn in a way that gets you telefragged instantly... // So go ahead and move our respawn to the outer edges of the checkpoint, depending on our player number. int high = 0; for (high = MAXPLAYERS-1; high > 0; high--) { if (playeringame[high] == true) { break; } } double angleOffset = 360 / MAXPLAYERS; double startOffset = angleOffset * (high * 0.5); double finalAngle = curCheckpoint.angle + startOffset + (PlayerNum * angleOffset); RespawnPos.XY += pMobj.AngleToVector(finalAngle, curCheckpoint.radius); return RespawnPos; } } class SnapCheckpointGlow : SnapDynamicDecor { Default { RenderStyle "Add"; +BRIGHT } States { Spawn: CHEK D 2; TNT1 A 1; Loop; Death: CHEK D 1; TNT1 A 1; CHEK D 1; TNT1 A 1; CHEK D 1; TNT1 A 1; CHEK D 1; TNT1 A 1; CHEK D 1; TNT1 A 1; CHEK D 1; TNT1 A 1; CHEK D 1; TNT1 A 1; CHEK D 1; TNT1 A 1; CHEK D 1; TNT1 A 1; Stop; } } class SnapCheckpointText : SnapDynamicDecor { Default { RenderStyle "Add"; +NOBLOCKMAP +NOGRAVITY +NOINTERACTION +BRIGHT +WALLSPRITE } States { LocalizationSprites: CHPT ABC 1; Loop; Spawn: CHEK ABC 1; Loop; Death: TNT1 A 1; CHEK A 1; TNT1 A 1; CHEK B 1; TNT1 A 1; CHEK C 1; TNT1 A 1; CHEK A 1; TNT1 A 1; CHEK B 1; TNT1 A 1; CHEK C 1; TNT1 A 2; CHEK A 1; TNT1 A 2; CHEK B 1; TNT1 A 2; CHEK C 1; TNT1 A 2; CHEK A 1; TNT1 A 2; CHEK B 1; TNT1 A 2; CHEK C 1; Stop; } override void Tick() { super.Tick(); if (Sprite == GetSpriteIndex("CHEK")) { Sprite = GetSpriteIndex(Stringtable.Localize("$SNAP_SPRITE_CHEK")); } } } class SnapCheckpoint : Actor { Default { Radius 48; Height 96; SeeSound "misc/savepoint"; +SPECIAL +NOGRAVITY +BRIGHT +FLATSPRITE +NOTELEPORT } States { Spawn: CHEK E -1; Stop; } bool AllowSaving() { if (multiplayer == true) { // Not in multiplayer. return false; } // Use the user preference now. CVar AllowAutosave = CVar.FindCVar('disableautosave'); if (AllowAutosave != null && AllowAutosave.GetInt() != 2) { return true; } return false; } override void Touch(Actor toucher) { if (!(toucher is "PlayerPawn")) { return; } A_Log("$SNAP_SAVE_POINT"); int minHealth = toucher.SpawnHealth(); if (toucher.health < minHealth) { toucher.A_SetHealth(minHealth); } let data = SnapCurrentCheckpoint.Get(); if (data) { data.curCheckpoint = self; } target.SetStateLabel("Death"); tracer.SetStateLabel("Death"); toucher.A_StartSound(Default.SeeSound, CHAN_ITEM, CHANF_UI); let sp = SnapPlayer(toucher); if (sp != null) { sp.Combo.AddScore(); // Save the points you got up to this point... sp.Combo.TimeReset(); // ...and then reset the time remaining on it! } super.Touch(toucher); bSpecial = false; if (AllowSaving() == true) { SnapStaticEventHandler.DoSnapSave(); } } override void Tick() { if (target) { double newAngle = target.angle + 2; if (bSpecial == false) { newAngle += 10; target.Vel.Z = 1; } target.A_SetAngle(newAngle, SPF_INTERPOLATE); } } override void BeginPlay() { if (deathmatch) { Destroy(); return; } super.BeginPlay(); target = Spawn("SnapCheckpointText", (pos.x, pos.y, pos.z + 48), ALLOW_REPLACE); tracer = Spawn("SnapCheckpointGlow", pos, ALLOW_REPLACE); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class CityLampLight : SnapStaticDecor { Default { Radius 8; Height 8; +THRUACTORS +NOINTERACTION +NOBLOCKMAP +NOGRAVITY +DONTSPLASH +WALLSPRITE } States { Spawn: LAMP B -1; Stop; } override void PostBeginPlay() { super.PostBeginPlay(); A_AttachLight( "CityLampLight", DynamicLight.PointLight, Color(255, 255, 255, 0), 128, 128, DynamicLight.LF_SPOT|DynamicLight.LF_DONTLIGHTSELF, ( 0.0, 96.0 * Scale.X, 16.0 * Scale.Y ), self.Angle, 25, 35, 90.0 ); } } class CityLamp : Actor { Default { Radius 8; Height 112; +SOLID +NOGRAVITY +DONTTHRUST -WINDTHRUST +FORCEYBILLBOARD } States { Spawn: LAMP A -1; Stop; } override void BeginPlay() { super.BeginPlay(); Vector3 LightPos = Vec3Offset( cos(Angle) * 4.0 * Scale.X, sin(Angle) * 4.0 * Scale.X, 96.0 * Scale.Y ); Tracer = Spawn("CityLampLight", LightPos, ALLOW_REPLACE); if (Tracer != null) { Tracer.Angle = self.Angle + 90.0; } } } class FounderStatue : Actor { Default { Radius 32; Height 80; +SOLID } States { Spawn: FSTA A -1; Stop; } } class CityTrash : SnapDynamicDecor { Default { Gravity 0.5; -NOGRAVITY } States { Spawn: TRSH B 35; Stop; TRSH C 35; Stop; TRSH D 35; Stop; } override void BeginPlay() { super.BeginPlay(); SetState(SpawnState + random[snap_decor](0, 2)); Vel.X = frandom[snap_decor](-5, 5); Vel.Y = frandom[snap_decor](-5, 5); Vel.Z = frandom[snap_decor](5, 10); bInvisible = random[snap_decor](0, 1); } override void Tick() { super.Tick(); bInvisible = !bInvisible; } } class CityTrashBin : SnapMonster { Default { Radius 10; Height 40; Health 70; SnapMonster.Poise 0; -ISMONSTER -COUNTKILL +NOTARGETSWITCH +DONTTHRUST -SnapActor.CANDROPAMMO +SnapMonster.ISCONTAINER } void TrashExplode() { DoSnapMonsterDie(); for (uint i = 0; i < 8; i++) { Spawn("CityTrash", Pos + (0, 0, Height * 0.5), ALLOW_REPLACE); } } States { Spawn: TRSH A -1; Stop; Death: TRSH A 1; TNT1 A 35 TrashExplode(); Stop; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapPlayerGlobals { uint ComboPoints; } struct SnapCombo play { const COMBO_TIME = 8 * Object.TICRATE; const SMALL_ITEM_EXTENSION = COMBO_TIME / 8; const MAX_DAMAGE = COMBO_TIME / 2; const COMBO_BLINK_TIME = Object.TICRATE / 2; SnapPlayer Owner; uint Count; uint ScoreAlreadyAdded; uint Time; uint TimeAdd; uint Blink; Array Items; clearscope static uint GetScore(uint Combo) { if (Combo <= 1) { // That's not a real combo :P return 0; } uint Bonus = 0; for (uint i = 2; i <= Combo; i++) { // Give slightly higher points for higher combos. // We don't actually need to reward them THAT much more, // because starting more combos will lose you more and // more points if you have to do it more often. // For example: // 19 combo + 19 combo = 60pts + 60pts = 120pts total // 38 combo = 155pts total if (i >= 10) { // Add 5 points at a time. Bonus += 5; } else if (i >= 8) { // Add 2 points at a time. Bonus += 2; } else { // Add a measly single point at a time. Bonus += 1; } } return Bonus; } clearscope bool Active() { return (Count > 0); } void TimeReset() { TimeAdd += Time; Blink = 0; } void TimeResetDirect() { Time = 0; Blink = 0; } void TimeIncrease(uint Amount) { TimeAdd += min(Time, Amount); Blink = 0; } void TimeIncreaseDirect(uint Amount) { if (Time > Amount) { Time -= Amount; } else { Time = 0; } Blink = 0; } void TimeDecrease(uint Amount) { Time += Amount; if (Time > COMBO_TIME) { Time = COMBO_TIME; Blink++; if (Blink > COMBO_BLINK_TIME) { Blink = COMBO_BLINK_TIME; // Don't end through time out until // all combo-pausing items are taken care of int size = Items.Size(); for (int i = 0; i < size; i++) { if (Items[i] == null || Items[i].bDestroyed) { Items.Delete(i); i--; size--; } } if (size <= 0) { End(); } } } else { Blink = 0; } } void Increase() { Count++; TimeReset(); if (Owner != null && Owner.Player != null) { let sev = SnapStaticEventHandler.Get(); if (sev != null) { sev.SetStatComboBest(Owner.Player, Count); } } } void AddScore() { if (Owner == null) { // it's invalid?!! return; } uint baseScore = GetScore(Count); if (baseScore <= ScoreAlreadyAdded) { // Score hasn't changed return; } uint score = baseScore - ScoreAlreadyAdded; // Coop bonus Owner.AddScore(score * 10); if (Owner.SnapPlayerInfo != null) { // SP bonus Owner.SnapPlayerInfo.ComboPoints += score; } ScoreAlreadyAdded += score; } void End() { AddScore(); Count = 0; ScoreAlreadyAdded = 0; } void Tick() { if (Active() == false) { return; } if (SnapEventHandler.GetTimerPause() == true) { return; } if (TimeAdd > 0) { uint Add = max(1, TimeAdd / 3); TimeIncreaseDirect(Add); TimeAdd -= Add; } else { bool UsingPOW = false; if (Owner != null) { UsingPOW = (Owner.UsingPOW != 0); } if (UsingPOW == false) { TimeDecrease(1); } } } } extend class SnapPlayer { transient SnapCombo Combo; } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- mixin class SnapCommandBase { void CommandDraw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { UpdateScaleParameters(); Vector2 Pos = ((BASE_VID_WIDTH * 0.5) + xOffset + OPTIONS_SUBMENU_SPACE, yOffset); int col = Font.CR_UNTRANSLATED; if (DisplayGrayed() == true) { col = FontGrayColor; } else if (selected == true) { col = FontHighlightColor; } String text = String.Format("%s...", StringTable.Localize(mLabel)); SnapMenuText( FontSmall, col, RightAlignPos(FontSmall, text, Pos), text ); } } class OptionMenuItemSnapCommand : OptionMenuItemCommand { mixin SnapMenuDrawing; mixin SnapMenuItemCore; mixin SnapCommandBase; OptionMenuItemSnapCommand Init( String label, String tooltip, Name command, bool closeOnSelect = false) { super.Init(label, command, false, closeOnSelect); mTooltip = tooltip; return self; } override void OnMenuCreated() { super.OnMenuCreated(); PrecacheMenuDrawing(); } virtual int GetLineSpacing() { return FontSmall.GetHeight(); } virtual bool isGrayed() { return false; } virtual void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.DestPos = Delta + ((BASE_VID_WIDTH * 0.5) + OPTIONS_SUBMENU_SPACE, 0); String text = String.Format("%s...", StringTable.Localize(mLabel)); Cursor.DestPos.X -= SmallFont.StringWidth(text); Cursor.DestSmall = true; } virtual bool DisplayGrayed() { // I mostly only want to edit the // drawing, so this function exists now. if (Parent != null) { bool InList = Parent.ItemCurrentlyInList(self); if (InList == false) { return true; } } return isGrayed(); } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { CommandDraw(desc, yOffset, xOffset, selected); return xOffset; } override bool Activate() { bool ret = super.Activate(); if (ret == true) { CursorPlayFire(); } return ret; } } class OptionMenuItemSnapSafeCommand : OptionMenuItemSafeCommand { mixin SnapMenuDrawing; mixin SnapMenuItemCore; mixin SnapCommandBase; OptionMenuItemSnapSafeCommand Init( String label, String tooltip, Name command, String prompt = "") { super.Init(label, command, prompt); mTooltip = tooltip; return self; } override void OnMenuCreated() { super.OnMenuCreated(); PrecacheMenuDrawing(); } virtual int GetLineSpacing() { return FontSmall.GetHeight(); } virtual bool isGrayed() { return false; } virtual bool DisplayGrayed() { // I mostly only want to edit the // drawing, so this function exists now. if (Parent != null) { bool InList = Parent.ItemCurrentlyInList(self); if (InList == false) { return true; } } return isGrayed(); } virtual void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.DestPos = Delta + ((BASE_VID_WIDTH * 0.5) + OPTIONS_SUBMENU_SPACE, 0); String text = String.Format("%s...", StringTable.Localize(mLabel)); Cursor.DestPos.X -= SmallFont.StringWidth(text); Cursor.DestSmall = true; } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { CommandDraw(desc, yOffset, xOffset, selected); return xOffset; } override bool Activate() { bool ret = super.Activate(); if (ret == true) { CursorPlayFire(); } return ret; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapCompatibility : LevelPostProcessor { void ConvertHealthDropMonsters() { // Convert old HealthUp copies of SnapMonsters. // Will be removed if these thing IDs ever need used again. uint WarningCount = 0; for (uint i = 0; i < GetThingCount(); i++) { int DoomEdNum = GetThingEdNum(i); if (DoomEdNum >= 700 && DoomEdNum <= 710) { static const int Convert[] = { 20, 21, 22, 23, 24, 25, 0, 0, 28, 29, 31 }; SetThingEdNum(i, Convert[DoomEdNum - 700]); AddThing( 200, GetThingPos(i), GetThingAngle(i), GetThingSkills(i), GetThingFlags(i) & MODES_ALL ); WarningCount++; } } if (WarningCount > 0) { Console.Printf( "Found %d old-style 'drops health' enemies in the current map.\n" .. "These objects will be removed in the future.\n" .. "Change them into normal enemies, and place a Health Up on top of them instead.", WarningCount ); } } void ConvertExitActions() { for (int i = 0; i < Level.Lines.Size(); i++) { Line ln = Level.Lines[i]; if (ln == null) { continue; } if (ln.special == Exit_Normal) { SetLineSpecial( i, ACS_ExecuteAlways, -int('ExitWrapperNormal'), 0, ln.args[0], 0, 0 ); } else if (ln.special == Exit_Secret) { SetLineSpecial( i, ACS_ExecuteAlways, -int('ExitWrapperSecret'), 0, ln.args[0], 0, 0 ); } } } void ValidateSecrets() { let MapDef = SnapMapDef.Get(Level.MapName); if (MapDef == null) { // No map def to save to return; } let SaveVar = MapDef.SecretVar; if (SaveVar == null) { // No variable to save to return; } uint SecretSkill = SnapEventHandler.GetSecretSkill(); uint SecretSkillFlag = 1 << SecretSkill; uint SecretCount = MapDef.TotalSecrets[SecretSkill]; if (SecretCount == 0) { Console.PrintfEx(PRINT_HIGH|PRINT_NONOTIFY, "Level has secret var, but 0 secrets"); return; } uint ExpectedSecretFlags = ((1 << (SecretCount - 1)) * 2) - 1; uint LevelSecretFlags = 0; for (uint i = 0; i < GetThingCount(); i++) { int DoomEdNum = GetThingEdNum(i); if (DoomEdNum == 208) // Secret thing { int Skills = GetThingSkills(i); if ((Skills & SecretSkillFlag) == 0) { continue; } int SecretID = GetThingAngle(i); if (SecretID > 0 && SecretID <= int(SecretCount)) { uint SecretFlag = 1 << (SecretID - 1); if ((LevelSecretFlags & SecretFlag) != 0) { ThrowAbortException("Level has more than one secret disc using ID %d", SecretID); return; } LevelSecretFlags |= SecretFlag; } else { ThrowAbortException("Level has a secret disc with invalid ID %d (expected 1 - %d)", SecretID, SecretCount); return; } } } if (LevelSecretFlags != ExpectedSecretFlags) { if (LevelSecretFlags == 0) { // Allow playing levels with 0 secret discs, probably means it's an indev map. Console.PrintfEx(PRINT_HIGH|PRINT_NONOTIFY, "Level has no secret discs yet"); return; } for (uint i = 0; i < SecretCount; i++) { uint SecretFlag = 1 << i; if ((ExpectedSecretFlags & SecretFlag) && !(LevelSecretFlags & SecretFlag)) { ThrowAbortException("Level is missing a secret disc with ID %d", i + 1); return; } } ThrowAbortException("Level has secret disc flag mismatch (expected %x, got %x)", ExpectedSecretFlags, LevelSecretFlags); return; } } void LocalizeTextures() { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return; } MapIterator it; if (it.Init(ev.LocalizedTextureHeap) == false) { return; } while (it.Next()) { String OldTexture = it.GetKey(); String NewTexture = StringTable.Localize(it.GetValue()); if (OldTexture != NewTexture) { Level.ReplaceTextures(OldTexture, NewTexture, 0); } } } protected void Apply(Name checksum, String mapname) { ConvertHealthDropMonsters(); ConvertExitActions(); ValidateSecrets(); LocalizeTextures(); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapAchievementCondition abstract { abstract bool Achieved(); abstract String Hint(); virtual bool DisableFreeSpace() { // Usually false, but we set this to // true for any challenges that are // based on other challenge board // tiles, so that free spaces aren't // more valuable on them. return false; } virtual void Initialize() { // NOP } virtual void DeserializeArgs(JsonObject Obj) { // NOP } } class SnapConditionGenericStat : SnapAchievementCondition abstract { Name StatCVarName; CVar StatCVar; int Amount; String HintLocalization; override void Initialize() { HintLocalization = "$SNAPMENU_CHALLENGE_HINT_PLACEHOLDER"; } override bool Achieved() { if (StatCVar == null) { StatCVar = CVar.FindCVar(StatCVarName); if (StatCVar == null) { return false; } } return (StatCVar.GetInt() >= Amount); } override String Hint() { String ret = Stringtable.Localize(HintLocalization); if (ret.Length() != 0) { String finalized = ""; int chr; uint next; for (uint i = 0; i < ret.Length(); i = next) { [chr, next] = ret.GetNextCodePoint(i); if (chr == int("%")) { [chr, next] = ret.GetNextCodePoint(next); if (chr == int("n")) { finalized.AppendFormat("%d", Amount); } } else { finalized.AppendFormat("%c", chr); } } ret = finalized; } return ret; } override void DeserializeArgs(JsonObject Obj) { SnapDefinition.ParseForInt(Amount, Obj, "amount"); } } class SnapCondition_MapBeaten : SnapAchievementCondition { String MapLump; int Rank; int Skill; override bool Achieved() { if (MapLump.Length() > 0) { // Specific map. for (int i = Skill; i <= LAST_GRADED_SKILL; i++) { let record = SnapMapRecord.Get(MapLump, i); if (record == null) { continue; } if (record.Grade >= Rank) { return true; } } } else { // Any map. let ev = SnapStaticEventHandler.Get(); if (ev == null) { return false; } SnapDefinitions AllDefs = ev.SnapDefs; if (AllDefs == null) { return false; } MapIterator it; if (it.Init(AllDefs.MapHeap) == false) { return false; } while (it.Next() == true) { let def = it.GetValue(); for (int i = Skill; i <= LAST_GRADED_SKILL; i++) { let record = SnapMapRecord.Get(def.ID, i); if (record == null) { continue; } if (record.Grade >= Rank) { return true; } } } } return false; } override String Hint() { String MapName = ""; if (MapLump.Length() > 0) { MapName = String.Format( "%s: %s", MapLump, SnapMapDef.GetMapTitleOrHidden(MapLump) ); } else { MapName = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_MAPBEATEN_STAGE_ANY"); } String RankStr = ""; if (Rank > GRADE_E) { String RankLetter = ""; switch (Rank) { case GRADE_D: { RankLetter = "D"; break; } case GRADE_C: { RankLetter = "C"; break; } case GRADE_B: { RankLetter = "B"; break; } case GRADE_A: { RankLetter = "A"; break; } case GRADE__MAX: { RankLetter = "S"; break; } default: { RankLetter = Stringtable.Localize("$SNAPMENU_RECORD_NOTVISITED"); break; } } if (Rank >= GRADE_A) { RankStr = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_MAPBEATEN_GRADE_HI"); } else { RankStr = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_MAPBEATEN_GRADE_LO"); } if (RankStr.Length() != 0) { String finalized = ""; int chr; uint next; for (uint i = 0; i < RankStr.Length(); i = next) { [chr, next] = RankStr.GetNextCodePoint(i); if (chr == int("%")) { [chr, next] = RankStr.GetNextCodePoint(next); if (chr == int("o")) { finalized.AppendFormat("%s", RankLetter); } } else { finalized.AppendFormat("%c", chr); } } RankStr = finalized; } } else { RankStr = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_MAPBEATEN_GRADE_ANY"); } String SkillStr = ""; if (Skill > SNAP_SKILL_EASY) { String SkillName = ""; switch (Skill) { case SNAP_SKILL_NORMAL: { SkillName = Stringtable.Localize("$SNAPMENU_SKILL_NORMAL"); break; } case SNAP_SKILL_HARD: { SkillName = Stringtable.Localize("$SNAPMENU_SKILL_HARD"); break; } case SNAP_SKILL_VERYRUDE: { SkillName = Stringtable.Localize("$SNAPMENU_SKILL_RUDE"); break; } default: { SkillName = Stringtable.Localize("$SNAPMENU_RECORD_NOTVISITED"); break; } } if (Skill >= SNAP_SKILL_VERYRUDE) { SkillStr = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_MAPBEATEN_SKILL_HI"); } else { SkillStr = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_MAPBEATEN_SKILL_LO"); } if (SkillStr.Length() != 0) { String finalized = ""; int chr; uint next; for (uint i = 0; i < SkillStr.Length(); i = next) { [chr, next] = SkillStr.GetNextCodePoint(i); if (chr == int("%")) { [chr, next] = SkillStr.GetNextCodePoint(next); if (chr == int("o")) { finalized.AppendFormat("%s", SkillName); } } else { finalized.AppendFormat("%c", chr); } } SkillStr = finalized; } } String ret = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_MAPBEATEN"); if (ret.Length() != 0) { String finalized = ""; int chr; uint next; for (uint i = 0; i < ret.Length(); i = next) { [chr, next] = ret.GetNextCodePoint(i); if (chr == int("%")) { [chr, next] = ret.GetNextCodePoint(next); if (chr == int("a")) { finalized.AppendFormat("%s", RankStr); } else if (chr == int("b")) { finalized.AppendFormat("%s", MapName); } else if (chr == int("c")) { finalized.AppendFormat("%s", SkillStr); } } else { finalized.AppendFormat("%c", chr); } } ret = finalized; } return ret; } override void DeserializeArgs(JsonObject Obj) { SnapDefinition.ParseForString(MapLump, Obj, "map"); SnapDefinition.ParseForInt(Rank, Obj, "rank"); Rank = clamp(Rank, GRADE_E, GRADE__MAX); SnapDefinition.ParseForInt(Skill, Obj, "skill"); Skill = clamp(Skill, 0, 3); } } class SnapCondition_MapTimeAttack : SnapAchievementCondition { String MapLump; int Time; int Skill; override bool Achieved() { if (MapLump.Length() == 0) { return false; } // Specific map. for (int i = Skill; i <= LAST_GRADED_SKILL; i++) { let record = SnapMapRecord.Get(MapLump, i); if (record == null) { continue; } if (record.Time <= Time) { return true; } } return false; } override String Hint() { String MapName = ""; if (MapLump.Length() > 0) { MapName = String.Format( "%s: %s", MapLump, SnapMapDef.GetMapTitleOrHidden(MapLump) ); } else { MapName = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_MAPBEATEN_STAGE_ANY"); } String TimeStr = String.Format("%d:%02d", Time / 60, Time % 60); String SkillStr = ""; if (Skill > SNAP_SKILL_EASY) { String SkillName = ""; switch (Skill) { case SNAP_SKILL_NORMAL: { SkillName = Stringtable.Localize("$SNAPMENU_SKILL_NORMAL"); break; } case SNAP_SKILL_HARD: { SkillName = Stringtable.Localize("$SNAPMENU_SKILL_HARD"); break; } case SNAP_SKILL_VERYRUDE: { SkillName = Stringtable.Localize("$SNAPMENU_SKILL_RUDE"); break; } default: { SkillName = Stringtable.Localize("$SNAPMENU_RECORD_NOTVISITED"); break; } } if (Skill >= SNAP_SKILL_VERYRUDE) { SkillStr = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_MAPBEATEN_SKILL_HI"); } else { SkillStr = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_MAPBEATEN_SKILL_LO"); } if (SkillStr.Length() != 0) { String finalized = ""; int chr; uint next; for (uint i = 0; i < SkillStr.Length(); i = next) { [chr, next] = SkillStr.GetNextCodePoint(i); if (chr == int("%")) { [chr, next] = SkillStr.GetNextCodePoint(next); if (chr == int("o")) { finalized.AppendFormat("%s", SkillName); } } else { finalized.AppendFormat("%c", chr); } } SkillStr = finalized; } } String ret = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_MAPTIMEATTACK"); if (ret.Length() != 0) { String finalized = ""; int chr; uint next; for (uint i = 0; i < ret.Length(); i = next) { [chr, next] = ret.GetNextCodePoint(i); if (chr == int("%")) { [chr, next] = ret.GetNextCodePoint(next); if (chr == int("a")) { finalized.AppendFormat("%s", MapName); } else if (chr == int("b")) { finalized.AppendFormat("%s", SkillStr); } else if (chr == int("n")) { finalized.AppendFormat("%s", TimeStr); } } else { finalized.AppendFormat("%c", chr); } } ret = finalized; } return ret; } override void DeserializeArgs(JsonObject Obj) { SnapDefinition.ParseForString(MapLump, Obj, "map"); SnapDefinition.ParseForInt(Time, Obj, "time"); SnapDefinition.ParseForInt(Skill, Obj, "skill"); Skill = clamp(Skill, 0, 3); } } class SnapCondition_Robots : SnapConditionGenericStat { enum RobotsModifier { MOD_NONE = 0, MOD_MINESNAILCOLLATERAL, MOD_TRAFFICCOLLATERAL, MOD_SEPTACRASH, MOD_MINESNAILSTEPON, MOD_LOCKON, } uint Modifier; override void Initialize() { switch (Modifier) { case MOD_MINESNAILCOLLATERAL: { StatCVarName = "snap_stats_robots_minesnail_collateral"; break; } case MOD_TRAFFICCOLLATERAL: { StatCVarName = "snap_stats_robots_traffic_collateral"; break; } case MOD_SEPTACRASH: { StatCVarName = "snap_stats_robots_septacrash"; break; } case MOD_MINESNAILSTEPON: { StatCVarName = "snap_stats_robots_minesnail_stepon"; break; } case MOD_LOCKON: { StatCVarName = "snap_stats_robots_lockon"; break; } default: { StatCVarName = "snap_stats_robots"; break; } } } override String Hint() { String ret = ""; String UsingStr = ""; if (Modifier == MOD_MINESNAILSTEPON) { ret = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_ROBOTS_MINESNAIL_STEPON"); } else { ret = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_ROBOTS"); switch (Modifier) { case MOD_MINESNAILCOLLATERAL: { UsingStr = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_ROBOTS_MINESNAIL_COLLATERAL"); break; } case MOD_TRAFFICCOLLATERAL: { UsingStr = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_ROBOTS_TRAFFIC_COLLATERAL"); break; } case MOD_SEPTACRASH: { UsingStr = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_ROBOTS_SEPTACRASH"); break; } case MOD_LOCKON: { UsingStr = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_ROBOTS_LOCKON"); break; } default: { break; } } } if (ret.Length() != 0) { String finalized = ""; int chr; uint next; for (uint i = 0; i < ret.Length(); i = next) { [chr, next] = ret.GetNextCodePoint(i); if (chr == int("%")) { [chr, next] = ret.GetNextCodePoint(next); if (chr == int("a")) { finalized.AppendFormat("%s", UsingStr); } else if (chr == int("n")) { finalized.AppendFormat("%d", Amount); } } else { finalized.AppendFormat("%c", chr); } } ret = finalized; } return ret; } override void DeserializeArgs(JsonObject Obj) { super.DeserializeArgs(Obj); String ModStr = ""; SnapDefinition.ParseForString(ModStr, Obj, "mod"); if (ModStr ~== "None") { Modifier = MOD_NONE; } else if (ModStr ~== "MineSnailCollateral") { Modifier = MOD_MINESNAILCOLLATERAL; } else if (ModStr ~== "TrafficCollateral") { Modifier = MOD_TRAFFICCOLLATERAL; } else if (ModStr ~== "Septacrash") { Modifier = MOD_SEPTACRASH; } else if (ModStr ~== "MineSnailStepOn") { Modifier = MOD_MINESNAILSTEPON; } else if (ModStr ~== "LockOn") { Modifier = MOD_LOCKON; } } } class SnapCondition_PlayTime : SnapConditionGenericStat { int Hours; int Minutes; int TotalTime() { return ((Hours * 60) + Minutes) * 60; } override void Initialize() { StatCVarName = "snap_stats_playtime"; } override String Hint() { String ret = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_PLAYTIME"); if (ret.Length() != 0) { String HourString = ""; if (Hours > 0) { HourString = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_PLAYTIME_HOURS"); if (HourString.Length() != 0) { String finalized = ""; int chr; uint next; for (uint i = 0; i < HourString.Length(); i = next) { [chr, next] = HourString.GetNextCodePoint(i); if (chr == int("%")) { [chr, next] = HourString.GetNextCodePoint(next); if (chr == int("n")) { finalized.AppendFormat("%d", Hours); } } else { finalized.AppendFormat("%c", chr); } } HourString = finalized; } } String MinuteString = ""; if (Minutes > 0) { MinuteString = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_PLAYTIME_MINUTES"); if (MinuteString.Length() != 0) { String finalized = ""; int chr; uint next; for (uint i = 0; i < MinuteString.Length(); i = next) { [chr, next] = MinuteString.GetNextCodePoint(i); if (chr == int("%")) { [chr, next] = MinuteString.GetNextCodePoint(next); if (chr == int("n")) { finalized.AppendFormat("%d", Minutes); } } else { finalized.AppendFormat("%c", chr); } } MinuteString = finalized; } } String finalized = ""; int chr; uint next; for (uint i = 0; i < ret.Length(); i = next) { [chr, next] = ret.GetNextCodePoint(i); if (chr == int("%")) { [chr, next] = ret.GetNextCodePoint(next); if (chr == int("a")) { finalized.AppendFormat("%s", HourString); } else if (chr == int("b")) { finalized.AppendFormat("%s", MinuteString); } } else { finalized.AppendFormat("%c", chr); } } ret = finalized; } return ret; } override void DeserializeArgs(JsonObject Obj) { SnapDefinition.ParseForInt(Hours, Obj, "hours"); SnapDefinition.ParseForInt(Minutes, Obj, "minutes"); Amount = TotalTime(); } } class SnapCondition_MatchesPlayed : SnapConditionGenericStat { override void Initialize() { StatCVarName = "snap_stats_matches"; HintLocalization = "$SNAPMENU_CHALLENGE_HINT_MATCHESPLAYED"; } } class SnapCondition_Kicks : SnapConditionGenericStat { override void Initialize() { StatCVarName = "snap_stats_robots_kicked"; HintLocalization = "$SNAPMENU_CHALLENGE_HINT_KICKS"; } } class SnapCondition_Juggles : SnapConditionGenericStat { override void Initialize() { StatCVarName = "snap_stats_robots_juggled"; HintLocalization = "$SNAPMENU_CHALLENGE_HINT_JUGGLES"; } } class SnapCondition_VitalityBest : SnapConditionGenericStat { override void Initialize() { StatCVarName = "snap_stats_vitality_best"; HintLocalization = "$SNAPMENU_CHALLENGE_HINT_VITALITYBEST"; } } class SnapCondition_ComboBest : SnapConditionGenericStat { override void Initialize() { StatCVarName = "snap_stats_combo_best"; HintLocalization = "$SNAPMENU_CHALLENGE_HINT_COMBOBEST"; } } class SnapCondition_KickCombo : SnapConditionGenericStat { override void Initialize() { StatCVarName = "snap_stats_kick_combo"; HintLocalization = "$SNAPMENU_CHALLENGE_HINT_KICKCOMBO"; } } class SnapCondition_Tally : SnapAchievementCondition { int Tally; override bool Achieved() { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return false; } let defs = ev.SnapDefs; if (defs == null) { return false; } MapIterator it; if (it.Init(defs.AchievementMap) == false) { return false; } int Count = 0; while (it.Next() == true) { let Achievement = it.GetValue(); if (Achievement == null) { continue; } if (Achievement.Condition == self) { // Don't count yourself, obviously. continue; } if (Achievement.RewardUnlocked() == true) { Count++; } } return (Count >= Tally); } override String Hint() { String ret = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_TALLY"); if (ret.Length() != 0) { String finalized = ""; int chr; uint next; for (uint i = 0; i < ret.Length(); i = next) { [chr, next] = ret.GetNextCodePoint(i); if (chr == int("%")) { [chr, next] = ret.GetNextCodePoint(next); if (chr == int("n")) { finalized.AppendFormat("%d", Tally); } } else { finalized.AppendFormat("%c", chr); } } ret = finalized; } return ret; } override bool DisableFreeSpace() { return true; } override void DeserializeArgs(JsonObject Obj) { SnapDefinition.ParseForInt(Tally, Obj, "amount"); } } class SnapCondition_CustomRewards : SnapAchievementCondition { Name ID; override bool Achieved() { return (SnapReward_Custom.CustomUnlocked(ID) == true); } override String Hint() { String ret = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_CUSTOMREWARDS"); String UnlockStr = "???"; let ev = SnapStaticEventHandler.Get(); if (ev != null) { SnapDefinitions defs = ev.SnapDefs; if (defs != null) { Array RewardNames; MapIterator it; if (it.Init(defs.AchievementMap) == true) { while (it.Next() == true) { let Achievement = it.GetValue(); if (Achievement == null) { continue; } let Reward = SnapReward_Custom(Achievement.Reward); if (Reward == null) { continue; } if (ID != Reward.ID) { continue; } RewardNames.Push( StringTable.Localize(Reward.Label) ); } } uint NumRewards = RewardNames.Size(); if (NumRewards > 0) { if (NumRewards == 2) { UnlockStr = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_CUSTOMREWARDS_TWO"); if (UnlockStr.Length() != 0) { String finalized = ""; int chr; uint next; for (uint i = 0; i < UnlockStr.Length(); i = next) { [chr, next] = UnlockStr.GetNextCodePoint(i); if (chr == int("%")) { [chr, next] = UnlockStr.GetNextCodePoint(next); if (chr == int("a")) { finalized.AppendFormat("%s", RewardNames[0]); } else if (chr == int("b")) { finalized.AppendFormat("%s", RewardNames[1]); } } else { finalized.AppendFormat("%c", chr); } } UnlockStr = finalized; } } else if (NumRewards > 2) { UnlockStr = RewardNames[0]; for (uint j = 1; j < NumRewards; j++) { String UnlockPart = ""; if (j == NumRewards - 1) { UnlockPart = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_CUSTOMREWARDS_MORE_AND"); } else { UnlockPart = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_CUSTOMREWARDS_MORE_COMMA"); } if (UnlockPart.Length() != 0) { String finalized = ""; int chr; uint next; for (uint i = 0; i < UnlockPart.Length(); i = next) { [chr, next] = UnlockPart.GetNextCodePoint(i); if (chr == int("%")) { [chr, next] = UnlockPart.GetNextCodePoint(next); if (chr == int("a")) { finalized.AppendFormat("%s", UnlockStr); } else if (chr == int("b")) { finalized.AppendFormat("%s", RewardNames[j]); } } else { finalized.AppendFormat("%c", chr); } } UnlockPart = finalized; } UnlockStr = UnlockPart; } } else { UnlockStr = RewardNames[0]; } } } } if (ret.Length() != 0) { String finalized = ""; int chr; uint next; for (uint i = 0; i < ret.Length(); i = next) { [chr, next] = ret.GetNextCodePoint(i); if (chr == int("%")) { [chr, next] = ret.GetNextCodePoint(next); if (chr == int("o")) { finalized.AppendFormat("%s", UnlockStr); } } else { finalized.AppendFormat("%c", chr); } } ret = finalized; } return ret; } override bool DisableFreeSpace() { return true; } override void DeserializeArgs(JsonObject Obj) { SnapDefinition.ParseForName(ID, Obj, "id"); } } class SnapCondition_MapTrigger : SnapAchievementCondition { Name MapLump; Name ID; String Label; bool GotMapTrigger; override bool Achieved() { // This value only lasts for this session, // but will get saved into the achievement // immediately. // Consider changing the implementation // if persistence is needed for the // Achieved function later on. return GotMapTrigger; } override String Hint() { return StringTable.Localize(Label); } override void DeserializeArgs(JsonObject Obj) { SnapDefinition.ParseForName(ID, Obj, "id"); SnapDefinition.ParseForName(MapLump, Obj, "map"); SnapDefinition.ParseForString(Label, Obj, "hint"); } static play bool GiveMapTrigger(Name ID) { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return false; } SnapDefinitions defs = ev.SnapDefs; if (defs == null) { return false; } MapIterator it; if (it.Init(defs.AchievementMap) == false) { return false; } while (it.Next() == true) { let Achievement = it.GetValue(); if (Achievement == null) { continue; } let Cond = SnapCondition_MapTrigger(Achievement.Condition); if (Cond == null) { continue; } if (Level.MapName != Cond.MapLump) { continue; } if (ID != Cond.ID) { continue; } Cond.GotMapTrigger = true; SnapStaticEventHandler.CheckAchievements(); return true; } return false; } } class SnapCondition_Secrets : SnapAchievementCondition { int Amount; int Skill; override bool Achieved() { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return false; } let defs = ev.SnapDefs; if (defs == null) { return false; } MapIterator it; if (it.Init(defs.MapHeap) == false) { return false; } int Count = 0; while (it.Next() == true) { let MapDef = it.GetValue(); if (MapDef == null) { continue; } if (Skill < 0 || Skill >= SECRET_SAVE_SKILLS) { // Count across all difficulties for (uint sk = 0; sk < SECRET_SAVE_SKILLS; sk++) { Count += MapDef.CountSecretsGotten(sk); } } else { // Count across a single skill layout Count += MapDef.CountSecretsGotten(Skill); } } return (Count >= Amount); } override String Hint() { String ret = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_SECRETS"); if (ret.Length() != 0) { String SkillName = ""; switch (Skill) { case 0: { SkillName = Stringtable.Localize("$SNAPMENU_SKILL_NORMAL"); break; } case 1: { SkillName = Stringtable.Localize("$SNAPMENU_SKILL_HARD"); break; } default: { break; } } String LayoutStr = ""; if (SkillName.Length() != 0) { LayoutStr = Stringtable.Localize("$SNAPMENU_CHALLENGE_HINT_SECRETS_LAYOUT"); if (LayoutStr.Length() != 0) { String finalized = ""; int chr; uint next; for (uint i = 0; i < LayoutStr.Length(); i = next) { [chr, next] = LayoutStr.GetNextCodePoint(i); if (chr == int("%")) { [chr, next] = LayoutStr.GetNextCodePoint(next); if (chr == int("o")) { finalized.AppendFormat("%s", SkillName); } } else { finalized.AppendFormat("%c", chr); } } LayoutStr = finalized; } } String finalized = ""; int chr; uint next; for (uint i = 0; i < ret.Length(); i = next) { [chr, next] = ret.GetNextCodePoint(i); if (chr == int("%")) { [chr, next] = ret.GetNextCodePoint(next); if (chr == int("a")) { finalized.AppendFormat("%s", LayoutStr); } else if (chr == int("n")) { finalized.AppendFormat("%d", Amount); } } else { finalized.AppendFormat("%c", chr); } } ret = finalized; } return ret; } override void DeserializeArgs(JsonObject Obj) { SnapDefinition.ParseForInt(Amount, Obj, "amount"); Skill = -1; String SkillStr; SnapDefinition.ParseForString(SkillStr, Obj, "skill"); if (SkillStr ~== "Normal") { Skill = 0; } else if (SkillStr ~== "Hard") { Skill = 1; } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- const EPSILON = (1.0 / 65536.0); enum SnapStatNums { STAT_MAPBOMB = Thinker.STAT_USER, // Map Bomb objects STAT_DECOR, // SnapStaticDecor / SnapDynamicDecor STAT_INTERMISSION, // SnapIntermission // Ensure this doesn't ever exceed STAT_USER_MAX, // so we have about 20 to work with. // These needs to reuse anything after STAT_DEFAULT. // This seemed like the safest one. STAT_SHADOW = Thinker.STAT_ACTORMOVER, STAT_ANIMATOR = Thinker.STAT_ACTORMOVER, } enum SnapSoundChannels { CHAN_ANNOUNCER = 10, CHAN_DAMAGE = 20, CHAN_DAMAGE_REDUCED = 21, } enum SnapSkillLevels { SNAP_SKILL_EASY = 0, SNAP_SKILL_NORMAL, SNAP_SKILL_HARD, SNAP_SKILL_VERYRUDE, SNAP_SKILL__MAX, } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapMonster { Actor ContainPower; bool ContainSearched; virtual bool ContainerSet(Actor mo) { mo.bSolid = false; mo.bShootable = false; mo.bSpecial = false; mo.bNoGravity = true; let sa = SnapActor(mo); if (sa) { sa.bForceFreeze = true; } if (mo.bIsMonster == true) { mo.SetIdle(true); } if (bShowContents == false) { mo.bInvisible = true; } //Console.Printf("%s is containing a %s", GetClassName(), mo.GetClassName()); ContainPower = mo; ContainSearched = true; return true; } virtual void ContainerRelease() { if (ContainPower == null) { return; } ContainerUpdate(); ContainPower.bSolid = ContainPower.Default.bSolid; ContainPower.bShootable = ContainPower.Default.bShootable; ContainPower.bSpecial = ContainPower.Default.bSpecial; ContainPower.bNoGravity = ContainPower.Default.bNoGravity; ContainPower.bInvisible = ContainPower.Default.bInvisible; ContainPower.Scale = ContainPower.Default.Scale; let sa = SnapActor(ContainPower); if (sa) { sa.bForceFreeze = false; } ContainPower.Vel.Z = 8; ContainPower = null; } virtual void ContainerUpdate() { ContainPower.SetOrigin(Pos + (0, 0, Height * 0.5), false); } bool DoContainerSearch() { ThinkerIterator it = ThinkerIterator.Create("Actor", Thinker.STAT_DEFAULT); Actor mo; while (mo = Actor(it.Next())) { if (mo == self) { continue; } if (mo.bNoTeleport == true || mo.bNoInteraction == true || mo.bNoBlockmap == true || mo.bNoSector == true) { // Not safe to teleport. continue; } if (bIsMonster == true && mo.bIsMonster == true) { // Don't allow monsters to contain other monsters. continue; } let m = SnapMonster(mo); if (m != null) { if (m.bIsContainer == true) { // Don't allow the containee to have the container. continue; } if (m.ContainPower == self) { // No strange recursive containing. continue; } } Vector2 dis = ( abs(Pos.X - mo.Pos.X), abs(Pos.Y - mo.Pos.Y) ); if ((dis.X > Radius + mo.Radius) || (dis.Y > Radius + mo.Radius)) { continue; } if (Pos.Z > mo.Pos.Z + mo.Height) { continue; } else if (Pos.Z + Height <= mo.Pos.Z) { continue; } if (ContainerSet(mo) == true) { return true; } } return false; } virtual bool IsContainer() { if (bIsContainer == true) { return true; } return (bCanDropAmmo || bBoss); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapEnterKey : EnterKey { mixin SnapMenuDrawing; mixin SnapMenuCore; TextureID BoxTexture; Vector2 BoxSize; TextureID OptBG; uint TextWidth; BrokenLines MessageLines; void Init(Menu parent, OptionMenuItemControlBase owner) { super.Init(parent, owner); mParentMenu = parent; DontDim = true; PrecacheMenuDrawing(); PrecacheMenuCore(); BoxTexture = TexMan.CheckForTexture("MSGBG", TexMan.Type_MiscPatch); BoxSize = SnapMenuTextureSize(BoxTexture); OptBG = TexMan.CheckForTexture("HUDKEYBG", TexMan.Type_MiscPatch); String message = StringTable.Localize("$SNAPMENU_SET_BIND_MSG"); message.Replace("%k", StringTable.Localize(owner.mLabel)); TextWidth = uint(BoxSize.X - 56); MessageLines = FontSmall.BreakLines(message, TextWidth); TransitionMode = TM_LINEAR; TryTransitionIn(parent); } virtual void TryTransitionIn(Menu From) { TransitionSpeed = BASE_TRANSITION_SPEED; ClosingMenu = false; } virtual void TryTransitionOut(Menu To) { TransitionSpeed = -BASE_TRANSITION_SPEED; } override void OnReturn() { TryTransitionIn(GetCurrentMenu()); // TODO: ensure this is correct super.OnReturn(); } override void Ticker() { TransitionTick(); super.Ticker(); } void MessageClose() { //CloseSound(); TryTransitionOut(self); ClosingMenu = true; } override bool OnInputEvent(InputEvent ev) { // This menu checks raw keys, not GUI keys because it needs the raw codes for binding. if (ev.type == InputEvent.Type_KeyDown) { mOwner.SendKey(ev.KeyScan); menuactive = Menu.On; MessageClose(); mParentMenu.MenuEvent((ev.KeyScan == InputEvent.KEY_ESCAPE) ? Menu.MKEY_Abort : Menu.MKEY_Input, 0); return true; } return false; } override void Drawer() { UpdateScaleParameters(); if (mParentMenu) { mParentMenu.Drawer(); } Screen.Dim( Color(0, 0, 0), MenuTransition * 0.75, 0, 0, int(RealSize.X), int(RealSize.Y) ); Vector2 MsgPos = (160, 100); MsgPos.Y -= (1.0 - MenuTransition) * VirtualSize.X; DrawMessageBox(MsgPos); if (InMenuFade() == true) { SnapFader.DrawFadeOverlay(MenuData.Fader.FadeOffset); } } virtual void DrawMessageBox(Vector2 Pos) { int fHeight = FontSmall.GetHeight(); SnapMenuTexture(BoxTexture, Pos - (BoxSize * 0.5)); int lines = MessageLines.Count(); Vector2 TextPos = Pos - ( 0.0, (fHeight * 0.5 * lines) ); for (int i = 0; i < lines; i++) { SnapMenuText( FontSmall, Font.CR_UNTRANSLATED, TextPos - (MessageLines.StringWidth(i) * 0.5, 0), MessageLines.StringAt(i) ); TextPos.Y += fHeight; } } } class SnapMenuItemControl : OptionMenuItemControlBase { mixin SnapMenuDrawing; mixin SnapMenuItemCore; SnapMenuItemControl Init( String label, String tooltip, Name command, KeyBindings bindings) { super.Init(label, command, bindings); mTooltip = tooltip; return self; } virtual int GetLineSpacing() { return FontSmall.GetHeight(); } override void OnMenuCreated() { super.OnMenuCreated(); PrecacheMenuDrawing(); } virtual bool isGrayed() { return false; } virtual bool DisplayGrayed() { // I mostly only want to edit the // drawing, so this function exists now. if (Parent != null) { bool InList = Parent.ItemCurrentlyInList(self); if (InList == false) { return true; } } return isGrayed(); } virtual void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.DestPos = Delta + (BASE_VID_WIDTH * 0.5, 0); Cursor.DestPos = RightAlignPos(FontSmall, mLabel, Cursor.DestPos - (OPTIONS_MID_SPACE, 0)); Cursor.DestSmall = true; } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { UpdateScaleParameters(); Vector2 Pos = ((BASE_VID_WIDTH * 0.5) + xOffset, yOffset); int col = Font.CR_UNTRANSLATED; if (DisplayGrayed() == true) { col = FontGrayColor; } else if (selected == true) { col = FontHighlightColor; } SnapMenuText( FontSmall, col, RightAlignPos(FontSmall, mLabel, Pos - (OPTIONS_MID_SPACE, 0)), mLabel ); String description; Array keys; mBindings.GetAllKeysForCommand(keys, mAction); description = KeyBindings.NameAllKeys(keys); if (description.Length() > 0) { // Replace ZDoom black with Snap black description.Replace(TEXTCOLOR_BLACK, "\c[HPDark]"); SnapMenuText( FontSmall, col, Pos + (OPTIONS_MID_SPACE, 0), description ); } else { description = "Not bound..."; SnapMenuText( FontSmall, FontGrayColor, Pos + (OPTIONS_MID_SPACE, 0), description ); } return xOffset; } override bool Activate() { Menu.MenuSound("menu/choose"); mWaiting = true; let input = new("SnapEnterKey"); input.Init(Menu.GetCurrentMenu(), self); input.ActivateMenu(); return true; } override bool MenuEvent(int mkey, bool fromcontroller) { if (mkey == Menu.MKEY_Input) { mWaiting = false; mBindings.SetBind(mInput, mAction); CursorPlayFire(); return true; } else if (mkey == Menu.MKEY_Clear) { mBindings.UnbindACommand(mAction); CursorPlayFire(); return true; } else if (mkey == Menu.MKEY_Abort) { mWaiting = false; return true; } return false; } } class OptionMenuItemSnapControl : SnapMenuItemControl { OptionMenuItemSnapControl Init(String label, String tooltip, Name command) { super.Init(label, tooltip, command, Bindings); return self; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapIntermissionCoop : SnapIntermission { enum CoopStates { COOP_START, COOP_COUNT, COOP_PAUSE, COOP_READYUP, }; int FinalScores[MAXPLAYERS]; int UncountedMapScore; int CountedPlayerScores[MAXPLAYERS]; int OldRankSegs; int CurTime; int CurTotalTime; int CountedTime; int CountedTotalTime; ui TextureID MPFaces[4]; ui TextureID CoopBar; override void Precache() { super.Precache(); MPFaces[0] = TexMan.CheckForTexture("SMALFAC1", TexMan.Type_MiscPatch); MPFaces[1] = TexMan.CheckForTexture("SMALFAC2", TexMan.Type_MiscPatch); MPFaces[2] = TexMan.CheckForTexture("SMALFAC3", TexMan.Type_MiscPatch); MPFaces[3] = TexMan.CheckForTexture("SMALOCEN", TexMan.Type_MiscPatch); CoopBar = TexMan.CheckForTexture("COOPBAR", TexMan.Type_MiscPatch); } clearscope int GetTotalCoopBonus() { int total = 0; for (uint i = 0; i < MAXPLAYERS; i++) { total += PlayerData[i].BaseScore; } return total; } override int GetMapScore() { return (MaxRobotScore + MaxSecretScore + GetTotalCoopBonus()); } override int GetPlayerScore(int playerID) { return (PlayerData[playerID].RobotScore + PlayerData[playerID].SecretScore + PlayerData[playerID].BaseScore); } clearscope int MPRankometerSegs(int score) { // Same thing, but for the entire bar. if (score <= 0) { return 0; } int SegsToDraw = (score * (RANK_ALL_SEGS + 1)) / MaxScore; if (SegsToDraw < 1) { SegsToDraw = 1; } if (SegsToDraw > RANK_ALL_SEGS) { SegsToDraw = RANK_ALL_SEGS; } // Don't show the bar totally filled // until you've definitively reached that perfect score! if (SegsToDraw == RANK_ALL_SEGS && score < maxScore) { SegsToDraw--; } return SegsToDraw; } ui void DrawCoopRankometer(Vector2 Pos, int pnum, int trans) { PlayerInfo thisPlayer = null; int score = 0; if (ValidPlayerNum(pnum)) { thisPlayer = players[pnum]; if (thisPlayer) { score = CountedPlayerScores[pnum]; } } else { score = UncountedMapScore; } uint SegmentsDrawn = 0; DrawTexture(RankometerEnd, Pos); Pos.x++; int SegsToDraw = MPRankometerSegs(score); if (SegsToDraw > 0) { for (int j = 0; j < SegsToDraw; j++) { if (trans >= 0) { DrawTextureTranslated(RankometerImages[GRADE_B], Pos, trans); } else { DrawTexture(RankometerImages[GRADE_E], Pos); } SegmentsDrawn++; Pos.x += 4; } } int SegmentsLeft = RANK_ALL_SEGS - SegmentsDrawn; if (SegmentsLeft > 0) { for (int i = 0; i < SegmentsLeft; i++) { DrawTexture(RankometerEmpty, Pos); SegmentsDrawn++; Pos.x += 4; } } Pos.x--; DrawTexture(RankometerEnd, Pos); } virtual ui void DrawAllMPRanking() { Array sortedPlayers; // initialize for (int i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i]) { continue; } sortedPlayers.Push(i); } sortedPlayers.Push(-1); int s = sortedPlayers.Size(); if (s > 1) { // Sort by best score before drawing! for (int i = 0; i < s; i++) { for (int j = s-1; j > i; j--) { int iPNum = sortedPlayers[j-1]; int iScore = 0; if (ValidPlayerNum(iPNum)) { iScore = CountedPlayerScores[iPNum]; } else { iScore = UncountedMapScore; } int jPNum = sortedPlayers[j]; int jScore = 0; if (ValidPlayerNum(jPNum)) { jScore = CountedPlayerScores[jPNum]; } else { jScore = UncountedMapScore; } if (jScore > iScore) { sortedPlayers[j-1] = jPNum; sortedPlayers[j] = iPNum; } } } } if (s <= 0) { return; } Vector2 Pos = (48, 40); // Account for ties by recording best/worst score int goodScore = 0; int badScore = 0; if (ValidPlayerNum(sortedPlayers[0])) { goodScore = CountedPlayerScores[sortedPlayers[0]]; } else { goodScore = UncountedMapScore; } int checkBad = 0; while (ValidPlayerNum(sortedPlayers[checkBad])) { if (checkBad >= s-1) { break; } checkBad++; } // This makes it the position above Ocean checkBad--; if (checkBad < 0) { checkBad = 0; } if (checkBad >= s) { checkBad = s-1; } if (ValidPlayerNum(sortedPlayers[checkBad])) { badScore = CountedPlayerScores[sortedPlayers[checkBad]]; } else { badScore = UncountedMapScore; } // Anyone below Ocean will automatically be upset. goodScore = max(goodScore, UncountedMapScore+1); badScore = max(badScore, UncountedMapScore); for (int i = 0; i < s; i++) { int playerNumber = sortedPlayers[i]; PlayerInfo p = null; int score = 0; int trans = -1; uint faceID = 0; Vector2 TransitionOffset = ((1.0 - Transition) * TRANSITION_DIST, 0); double Stagger = ((s - (i+1)) * 32); if (HandleFinish == true) { TransitionOffset = -TransitionOffset; Stagger = ((i+1) * 32); TransitionOffset.X += Stagger; if (TransitionOffset.X > 0) { TransitionOffset.X = 0; } } else { TransitionOffset.X -= Stagger; if (TransitionOffset.X < 0) { TransitionOffset.X = 0; } } if (ValidPlayerNum(playerNumber)) { p = players[playerNumber]; trans = Translation.MakeID(TRANSLATION_Players, playerNumber); score = CountedPlayerScores[playerNumber]; if ((CurState >= COOP_READYUP) && (goodScore != badScore)) { if (score >= goodScore) { faceID = 1; } else if (score <= badScore) { faceID = 2; } } } else { faceID = 3; score = UncountedMapScore; } DrawTexture(CoopBar, Pos + (-48, 1) + TransitionOffset); if (trans != -1) { DrawTextureTranslated(MPFaces[faceID], Pos - (17, 0) + TransitionOffset, trans); } else { DrawTexture(MPFaces[faceID], Pos - (17, 0) + TransitionOffset); } DrawCoopRankometer(Pos + TransitionOffset, playerNumber, trans); drawNum( bonusFont, Pos + (242, 2) + TransitionOffset, score, 0, true, bonusColor ); if (ValidPlayerNum(playerNumber) && p != null && (PlayerData[playerNumber].Ready || p.Bot != null) && ((Level.maptime / 8) & 1)) { DrawTextCenterAligned( rankFont, rankColor, Pos + (100, 1) + TransitionOffset, "$INTER_READY" ); } Pos.y += 16; } } override void Start() { for (uint i = 0; i < MAXPLAYERS; i++) { if (playeringame[i]) { CountedPlayerScores[i] = 0; FinalScores[i] = GetPlayerScore(i); } } UncountedMapScore = MaxScore; CurTime = Thinker.Tics2Seconds(Level.MapTime); CurTotalTime = Thinker.Tics2Seconds(Level.TotalTime); GenericDelay = TICRATE; } override void Update() { switch (CurState) { case COOP_START: case COOP_PAUSE: GenericPauseState(COOP_PAUSE); break; case COOP_COUNT: bool allDone = true; int HighScore = 0; int HighCountedScore = 0; int HighRankSegs = 0; for (uint i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i]) { continue; } if (FinalScores[i] > HighScore) { HighScore = FinalScores[i]; } } for (uint i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i]) { continue; } if (CountedPlayerScores[i] < FinalScores[i]) { int add = IncrementScore(CountedPlayerScores[i], HighScore, 80); CountedPlayerScores[i] += add; UncountedMapScore -= add; if (CountedPlayerScores[i] >= FinalScores[i]) { PlaySound("intermission/nextstage"); } } if (CountedPlayerScores[i] > FinalScores[i]) { CountedPlayerScores[i] = FinalScores[i]; } else if (CountedPlayerScores[i] < FinalScores[i]) { allDone = false; } if (CountedPlayerScores[i] > HighCountedScore) { HighCountedScore = CountedPlayerScores[i]; HighRankSegs = MPRankometerSegs(HighCountedScore); } } if (UncountedMapScore < 0) { UncountedMapScore = 0; } bool RankTicked = (HighRankSegs > OldRankSegs); OldRankSegs = HighRankSegs; if (RankTicked == true) { double progress = (HighCountedScore * 1.0) / (MaxScore * 1.0); PlayRankSound(progress); } if (CountedTime < CurTime) { CountedTime += max(3, (CurTime - CountedTime) >> 2); if (CountedTime > CurTime) { CountedTime = CurTime; } else if (CountedTime < CurTime) { allDone = false; } } if (CountedTotalTime < CurTotalTime) { CountedTotalTime += max(3, (CurTotalTime - CountedTotalTime) >> 2); if (CountedTotalTime > CurTotalTime) { CountedTotalTime = CurTotalTime; } else if (CountedTotalTime < CurTotalTime) { allDone = false; } } if (allDone == true) { CurState++; } break; case COOP_READYUP: // Only do ready-up logic at last stage SkipStage = DoSkipLogic(); if (SkipStage == true) { PlaySound("intermission/paststats"); End(); } break; } } virtual ui void DrawBottomData(Vector2 Pos) { DrawTimeCompare(standardFont, standardColor, Pos, CountedTime, CountedTotalTime); } override void Drawer() { super.Drawer(); DrawAllMPRanking(); Vector2 TimeOffset = ((1.0 - Transition) * -TRANSITION_DIST, 0); if (HandleFinish == true) { TimeOffset = -TimeOffset; } DrawTexture(TitleStrip, (0, 182) + TimeOffset); DrawBottomData((288, 180) + TimeOffset); DrawTitle(); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class EnemyScalePattern { const MAX_SPOTS = 9; const MAX_INCREASE = MAX_SPOTS - 1; uint Size; Vector2 List[MAX_SPOTS]; void AddCoord(Vector2 coord) { List[Size] = coord; Size++; } } extend class SnapEventHandler { const NUM_ENEMY_PATTERNS = 36; EnemyScalePattern EnemyScalePatterns[NUM_ENEMY_PATTERNS]; const ENEMY_LARGE = 0; // Spawn large first, since they're less flexible. const ENEMY_SMALL = 1; const ENEMY__MAX = 2; const FAIL_COUNTER = 32; void InitEnemyScalePatterns() { EnemyScalePattern p; uint i = 0; p = new("EnemyScalePattern"); p.AddCoord((1, 0)); p.AddCoord((-1, 0)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, 1)); p.AddCoord((0, -1)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((1, 1)); p.AddCoord((-1, -1)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((-1, 1)); p.AddCoord((1, -1)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, 1)); p.AddCoord((1, -1)); p.AddCoord((-1, -1)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, -1)); p.AddCoord((1, 1)); p.AddCoord((-1, 1)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((-1, 1)); p.AddCoord((-1, -1)); p.AddCoord((1, 0)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((1, 1)); p.AddCoord((1, -1)); p.AddCoord((-1, 0)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, 0)); p.AddCoord((2, 0)); p.AddCoord((-2, 0)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, 0)); p.AddCoord((0, 2)); p.AddCoord((0, -2)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((1, 1)); p.AddCoord((-1, 1)); p.AddCoord((1, -1)); p.AddCoord((-1, -1)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((1, 0)); p.AddCoord((3, 0)); p.AddCoord((-1, 0)); p.AddCoord((-3, 0)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, 1)); p.AddCoord((0, 3)); p.AddCoord((0, -1)); p.AddCoord((0, -3)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, 2)); p.AddCoord((1, 0)); p.AddCoord((-1, 0)); p.AddCoord((1, -2)); p.AddCoord((-1, -2)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, -2)); p.AddCoord((1, 0)); p.AddCoord((-1, 0)); p.AddCoord((1, 2)); p.AddCoord((-1, 2)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((2, 0)); p.AddCoord((0, 1)); p.AddCoord((0, -1)); p.AddCoord((-2, 1)); p.AddCoord((-2, -1)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((-2, 0)); p.AddCoord((0, 1)); p.AddCoord((0, -1)); p.AddCoord((2, 1)); p.AddCoord((2, -1)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, 0)); p.AddCoord((2, 0)); p.AddCoord((4, 0)); p.AddCoord((-2, 0)); p.AddCoord((-4, 0)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, 0)); p.AddCoord((0, 2)); p.AddCoord((0, 4)); p.AddCoord((0, -2)); p.AddCoord((0, -4)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, 2)); p.AddCoord((1, 0)); p.AddCoord((-1, 0)); p.AddCoord((0, -2)); p.AddCoord((2, -2)); p.AddCoord((-2, -2)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, -2)); p.AddCoord((1, 0)); p.AddCoord((-1, 0)); p.AddCoord((0, 2)); p.AddCoord((2, 2)); p.AddCoord((-2, 2)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((2, 0)); p.AddCoord((0, 1)); p.AddCoord((0, -1)); p.AddCoord((-2, 0)); p.AddCoord((-2, 2)); p.AddCoord((-2, -2)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((-2, 0)); p.AddCoord((0, 1)); p.AddCoord((0, -1)); p.AddCoord((2, 0)); p.AddCoord((2, 2)); p.AddCoord((2, -2)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((1, 0)); p.AddCoord((1, 2)); p.AddCoord((1, -2)); p.AddCoord((-1, 0)); p.AddCoord((-1, 2)); p.AddCoord((-1, -2)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((2, 1)); p.AddCoord((2, -1)); p.AddCoord((0, 1)); p.AddCoord((0, -1)); p.AddCoord((-2, 1)); p.AddCoord((-2, -1)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, 0)); p.AddCoord((0, 2)); p.AddCoord((0, -2)); p.AddCoord((2, 1)); p.AddCoord((2, -1)); p.AddCoord((-2, 1)); p.AddCoord((-2, -1)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, 0)); p.AddCoord((2, 0)); p.AddCoord((-2, 0)); p.AddCoord((1, 2)); p.AddCoord((-1, 2)); p.AddCoord((1, -2)); p.AddCoord((-1, -2)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((-1, 0)); p.AddCoord((-1, 2)); p.AddCoord((-1, -2)); p.AddCoord((1, 1)); p.AddCoord((1, 3)); p.AddCoord((1, -1)); p.AddCoord((1, -3)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, -1)); p.AddCoord((2, -1)); p.AddCoord((-2, -1)); p.AddCoord((1, 1)); p.AddCoord((3, 1)); p.AddCoord((-1, 1)); p.AddCoord((-3, 1)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, 0)); p.AddCoord((2, 0)); p.AddCoord((-2, 0)); p.AddCoord((0, 2)); p.AddCoord((2, 2)); p.AddCoord((-2, 2)); p.AddCoord((1, -2)); p.AddCoord((-1, -2)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, 0)); p.AddCoord((2, 0)); p.AddCoord((-2, 0)); p.AddCoord((0, -2)); p.AddCoord((2, -2)); p.AddCoord((-2, -2)); p.AddCoord((1, 2)); p.AddCoord((-1, 2)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, 0)); p.AddCoord((0, 2)); p.AddCoord((0, -2)); p.AddCoord((2, 0)); p.AddCoord((2, 2)); p.AddCoord((2, -2)); p.AddCoord((-2, 1)); p.AddCoord((-2, -1)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, 0)); p.AddCoord((0, 2)); p.AddCoord((0, -2)); p.AddCoord((-2, 0)); p.AddCoord((-2, 2)); p.AddCoord((-2, -2)); p.AddCoord((2, 1)); p.AddCoord((2, -1)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((1, 1)); p.AddCoord((1, -1)); p.AddCoord((-1, -1)); p.AddCoord((-1, 1)); p.AddCoord((1, 3)); p.AddCoord((1, -3)); p.AddCoord((-1, -3)); p.AddCoord((-1, 3)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((1, 1)); p.AddCoord((1, -1)); p.AddCoord((-1, -1)); p.AddCoord((-1, 1)); p.AddCoord((3, 1)); p.AddCoord((3, -1)); p.AddCoord((-3, -1)); p.AddCoord((-3, 1)); EnemyScalePatterns[i] = p; i++; p = new("EnemyScalePattern"); p.AddCoord((0, 0)); p.AddCoord((0, 2)); p.AddCoord((0, -2)); p.AddCoord((2, 0)); p.AddCoord((2, 2)); p.AddCoord((2, -2)); p.AddCoord((-2, 0)); p.AddCoord((-2, 2)); p.AddCoord((-2, -2)); EnemyScalePatterns[i] = p; i++; } uint TryEnemyPattern( SnapMonster robot, EnemyScalePattern pattern, uint NumLeft, uint TotalToAdd, uint SpotsLeft) { uint WillAdd = pattern.Size - 1; if (WillAdd > NumLeft) { // Can't use this one, since it'd add // too many enemies. return 0; } if (WillAdd > max(NumLeft / 2, 1) && SpotsLeft > (TotalToAdd / 2)) { // Don't put them ALL in one spot, // unless if we're seriously running // out of space. return 0; } // Test all of the positions. Vector3 Origin = robot.Pos; double Offset = robot.Radius + 0.5; for (uint i = 0; i < pattern.Size; i++) { Vector3 NewPos = Origin; NewPos.XY += pattern.List[i] * Offset; if (robot.CheckMove(NewPos.XY) == false) { // One of the robots wouldn't fit here. return 0; } } // A robot can fit in all of the positions, // so start duplicating! for (uint i = 0; i < pattern.Size; i++) { Vector3 NewPos = Origin; NewPos.XY += pattern.List[i] * Offset; if (i == 0) { // Move the first robot. if (NewPos.XY != Origin.XY) { robot.TryMove(NewPos.XY, true); } } else { // Add new robots. Actor newRobot = Actor.Spawn( robot.GetClass(), NewPos, NO_REPLACE ); // Refreshes FloorZ newRobot.TryMove(NewPos.XY, true); if (newRobot.bFloat == true) { double FloatOffset = Offset * 0.5; if (newRobot.Pos.Z <= newRobot.FloorZ) { FloatOffset *= random[snap_coopscaling](0, 4); } else { FloatOffset *= random[snap_coopscaling](-2, 2); } newRobot.SetZ(Origin.Z + FloatOffset); } // Copy properties from the original robot. newRobot.Angle = robot.Angle; newRobot.CopyFriendliness(robot, true); newRobot.ChangeTID(robot.TID); newRobot.bAmbush = robot.bAmbush; if (robot.bDormant == true) { newRobot.Deactivate(robot); } } } return WillAdd; } void TryEnemyScaling(Array OrigEnemies, int OrigAdd, uint debug) { Array Enemies; Enemies.Copy(OrigEnemies); int NumOrigEnemies = Enemies.Size(); int NumEnemies = NumOrigEnemies; if (NumEnemies <= 0) { return; } int AddEnemies = OrigAdd; uint AddFailure = 0; while (AddEnemies > 0) { uint EnemyIndex = random[snap_coopscaling](0, NumEnemies - 1); SnapMonster BaseEnemy = Enemies[EnemyIndex]; int PatternIndex = NUM_ENEMY_PATTERNS-1; if ((NumEnemies * EnemyScalePattern.MAX_INCREASE) / 2 > AddEnemies) { // If we don't have enough enemies, // then we want to prioritize maximizing // the number of enemies around. // Otherwise, we can randomize for a more // natural looking spread. PatternIndex = random[snap_coopscaling](0, PatternIndex); } uint Added = 0; for (int i = 0; i < NUM_ENEMY_PATTERNS; i++) { EnemyScalePattern Pattern = EnemyScalePatterns[PatternIndex]; Added = TryEnemyPattern( BaseEnemy, Pattern, AddEnemies, OrigAdd, NumEnemies ); if (Added > 0) { break; } PatternIndex--; if (PatternIndex < 0) { PatternIndex = NUM_ENEMY_PATTERNS-1; } } if (Added > 0) { // Success! // Reset failure counter, and remove from // the total counter. AddFailure = 0; AddEnemies -= Added; } else { // Failure... AddFailure++; if (AddFailure >= FAIL_COUNTER) { // Too many failures in a row. // We're probably out of room // to add any more enemies. break; } } // Don't try this enemy again. Enemies.Delete(EnemyIndex); NumEnemies = Enemies.Size(); if (NumEnemies <= 0) { // No more enemies to add from. break; } } if (debug != 0) { if (AddEnemies > 0) { double percent = ((AddEnemies * 1.0) / (OrigAdd * 1.0)) * 100.0; Console.Printf("Was only able to place %d enemies (lost %d, %d%)", OrigAdd - AddEnemies, AddEnemies, percent); } else if (AddEnemies < 0) { Console.Printf("%d extra enemies were placed?", abs(AddEnemies)); } } } void TryHealthScaling(Array OrigHP, int OrigAdd, uint numPlayers, uint debug) { Array HPList; HPList.Copy(OrigHP); uint NumHP = HPList.Size(); if (NumHP <= 0) { return; } int AddHealth = OrigAdd; while (AddHealth > 0) { uint HealthIndex = random[snap_coopscaling](0, NumHP - 1); HealthUp BaseHP = HPList[HealthIndex]; int Adds = BaseHP.Amount * (numPlayers - 1); if (Adds <= AddHealth || Adds - AddHealth < BaseHP.Amount / 2) // Round up when there's not much health left to add anyway. { BaseHP.SetShareable(); AddHealth -= Adds; } // Don't try this HP again. HPList.Delete(HealthIndex); NumHP = HPList.Size(); if (NumHP <= 0) { // No more HP to add from. break; } } if (debug != 0) { if (AddHealth > 0) { double percent = ((AddHealth * 1.0) / (OrigAdd * 1.0)) * 100.0; Console.Printf("Was only able to add %d health (lost %d, %d%)", OrigAdd - AddHealth, AddHealth, percent); } else if (AddHealth < 0) { Console.Printf("%d extra health was placed", abs(AddHealth)); } } } static uint GetEnemySize(SnapMonster monster) { if (monster.bCountKill == false) { // Likely just a shootable object. return ENEMY__MAX; } if (monster.bBoss == true) { // We don't want multiple bosses! // They already scale their health anyway! return ENEMY__MAX; } if (monster.bRobotTough == true) { // It's a large enemy. return ENEMY_LARGE; } return ENEMY_SMALL; } static uint GetHealthSize(HealthUp hp) { if (hp.bBigPowerup == true) { // It's a large health. return ENEMY_LARGE; } // It's a small health. return ENEMY_SMALL; } static uint CoopScalingDebug() { let DebugCV = CVar.FindCVar("snap_debug_coopscale"); if (DebugCV) { return max(0, DebugCV.GetInt()); } return 0; } static uint CoopScalingPlayers() { if (multiplayer == false) { return 1; } uint numPlayers = 0; for (int i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] == false) { continue; } numPlayers++; } return numPlayers; } static double CoopScalingFactor(uint numPlayers = 0) { if (numPlayers <= 1) { // Alone in Coop, huh? return 1.0; } // 1P: x1.0, 2P: x1.65, 4P: x2.95, 8P: x5.55 return 1.0 + ((numPlayers - 1) * 0.65); } void RunCoopScaling() { uint debug = CoopScalingDebug(); uint playerCount = (debug > 0) ? debug : CoopScalingPlayers(); double scale = CoopScalingFactor(playerCount); if (debug != 0) { Console.Printf("Testing Coop scaling for %d players...", debug); Console.Printf("Using x%f multiplier", scale); } if (scale <= 1.0) { return; } // Set to a consistent seed, so that the // same player count going into the same // level always gets the same result. SetRandomSeed[snap_coopscaling](0x7FD09913); // Grab the number of enemies in the level, // and classify them. They're classified so // that when the count is randomized, there's // a more even proportion of new large enemies // to new small enemies. Array Enemies[ENEMY__MAX]; ThinkerIterator EnemyFinder = ThinkerIterator.Create("SnapMonster", Thinker.STAT_DEFAULT); SnapMonster monster = null; while (monster = SnapMonster(EnemyFinder.Next())) { uint EnemySize = GetEnemySize(monster); if (EnemySize < ENEMY__MAX) { Enemies[EnemySize].Push(monster); } } for (uint EnemySize = 0; EnemySize < ENEMY__MAX; EnemySize++) { uint NumEnemies = Enemies[EnemySize].Size(); int NewEnemyCount = int(ceil(NumEnemies * scale)); int AddEnemies = NewEnemyCount - NumEnemies; if (debug != 0) { Console.Printf("== ENEMY CLASS %d ==", EnemySize); Console.Printf("Adding %d enemies (%d -> %d)", AddEnemies, NumEnemies, NewEnemyCount); } TryEnemyScaling(Enemies[EnemySize], AddEnemies, debug); } // Now, replace some Health Ups with some that are given to every player. Array HealthList[ENEMY__MAX]; // Silly constant reuse uint NumHealth[ENEMY__MAX]; ThinkerIterator HealthFinder = ThinkerIterator.Create("HealthUp", Thinker.STAT_DEFAULT); HealthUp hp = null; while (hp = HealthUp(HealthFinder.Next())) { uint HealthSize = GetHealthSize(hp); if (HealthSize < ENEMY__MAX) { NumHealth[HealthSize] += hp.Amount; HealthList[HealthSize].Push(hp); } } for (uint HealthSize = 0; HealthSize < ENEMY__MAX; HealthSize++) { int NewHealthCount = int(floor(NumHealth[HealthSize] * scale)); int AddHealth = NewHealthCount - NumHealth[HealthSize]; if (debug != 0) { Console.Printf("== HEALTH CLASS %d ==", HealthSize); Console.Printf("Adding %d health (%d -> %d)", AddHealth, NumHealth[HealthSize], NewHealthCount); } TryHealthScaling(HealthList[HealthSize], AddHealth, playerCount, debug); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class BomberFlameSpawner : SuddenDeathFlameSpawner { Default { Obituary "$OB_COPTERBOMBER"; } } class BomberBomb : SuddenDeathBomb { Default { Obituary "$OB_COPTERBOMBER"; } } class CopterBomber : SnapMonster { const COPTER_BOMBER_HP = 200; void FakeKick() { if (kickTossed == true) { return; } kickTossed = true; kickTossDamage = COPTER_BOMBER_HP; double KickThrust = Vel.XY.Length() * 2.0; if (Vel.Z <= 0.0) { Vel.Z = KickThrust; } else { Vel.Z += KickThrust; } bNoGravity = false; Angle = VectorAngle(-Vel.X, -Vel.Y); } void BomberAttack() { A_FaceTarget(22.5); A_SnapMonsterProjectile("BomberBomb"); } const NEEDED_SPACE = 128.0; // Not quite the range of the explosive, because it's funny. override bool HandleChaseAttack(StateLabel MeleeStateLabel, StateLabel MissileStateLabel) { double FDiff = Pos.Z - FloorZ; double Room = CeilingZ - FloorZ; if (Pos.Z - FloorZ <= NEEDED_SPACE && Room > NEEDED_SPACE + Height) // The room they're in doesn't even have room to fly away in. { // Too close to the ground! // Prevent attacking! bJustAttacked = true; } return super.HandleChaseAttack(MeleeStateLabel, MissileStateLabel); } Default { SnapMonster.Poise 40; // These guys have an absurd amount of health, but die when losing their poise. Health COPTER_BOMBER_HP; Radius 32; Height 56; Speed 10; Mass 400; SeeSound "copterBomber/see"; ActiveSound "copterBomber/idle"; PainSound "copterBomber/hurt"; Obituary "$OB_COPTERBOMBER"; Tag "$TAG_COPTERBOMBER"; Species "Robot"; DamageFactor "Melee", 100.0; // hack to make actual kicks ALSO kill +FLOAT +NOGRAVITY //+AVOIDMELEE } States { Spawn: CYBS A 7 A_SnapMonsterLook(); CYBS B 3; CYBS B 4 A_SnapMonsterLook(); CYBS C 6; CYBS C 1 A_SnapMonsterLook(); Loop; See: CYBS DDEEFF 3 A_SnapChase(); Loop; Missile: CYBS HI 2 A_FaceTarget(22.5); CYBS GHI 2 A_FaceTarget(22.5); CYBS GHI 2 A_FaceTarget(22.5); CYBS G 2 BomberAttack(); Goto See; Pain: CYBS J 0 FakeKick(); Kicked: CYBS J 6; CYBS J 6 A_SnapMonsterPain(); KickLoop: CYBS J 3 A_EndKick(); Loop; Death: CYBS J 1; TNT1 A 35 DoSnapMonsterDie(); Stop; GiantDeath: CYBS J 1; TNT1 A 35 DoSnapMonsterDie(); Stop; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- // // ======== // MENU CORE // ======== // mixin class SnapMenuCore { SnapMenuData MenuData; const BASE_TRANSITION_SPEED = 0.65; const TRANSITION_EPSILSON = (1.0 / 320.0); enum TransitionModes { TM_EASE, TM_LINEAR, } uint TransitionDelay; uint TransitionMode; double TransitionSpeed; double MenuTransition; bool ClosingMenu; const SCROLL_PADDING = 36; const MOUSE_SCROLL_PIXELS = 36; Vector2 ScrollPos; Vector2 DestScrollPos; bool ScrollInit; enum MenuFadeModes { MFM_UNDEFINED, MFM_TITLE_TO_MAIN, MFM_MAIN_TO_TITLE, } uint MenuFadeMode; bool FadeHide; void PrecacheMenuCore() { MenuData = SnapMenuData.Get(); MenuTransition = 0.0; } Menu LookupParentRedirect(Menu parent) { if (parent != null && parent is "SnapLookupMenu") { return parent.mParentMenu; } return parent; } void DoMenuClose() { Close(); if (!(self is "MessageBoxMenu")) { let m = GetCurrentMenu(); if (m == null) { menuDelegate.MenuDismissed(); } } ClosingMenu = false; } bool InMenuFade() { return (MenuData.Fader.FadeOffset > 0.0); //((MenuData.Fader.FadeOffset > 0.0) && (MenuData.Fader.FadeInit == true)); } void TransitionTick() { if (InMenuFade() == true) { if (MenuData.Fader.FadeOffset >= 1.0 && MenuFadeMode != MFM_UNDEFINED) { // Finalize fade. SnapFader.StartGameFade(false); FadeHide = (MenuFadeMode == MFM_MAIN_TO_TITLE); if (MenuFadeMode == MFM_MAIN_TO_TITLE && ClosingMenu == true) { DoMenuClose(); } MenuFadeMode = MFM_UNDEFINED; } // Finish fades first. return; } if (TransitionDelay > 0) { TransitionDelay--; return; } if (TransitionSpeed != 0.0) { // Transition in. switch (TransitionMode) { case TM_EASE: default: // New eased style // Eased version double AbsSpeed = abs(TransitionSpeed); double DiffToOne = abs(1.0 - MenuTransition); double DiffToZero = abs(0.0 - MenuTransition); if (TransitionSpeed > 0.0) { if (DiffToOne < TRANSITION_EPSILSON) { MenuTransition = 1.0; } else { // Ease in MenuTransition += AbsSpeed * DiffToOne; } } else { // Ease out if (DiffToZero < TRANSITION_EPSILSON) { MenuTransition = 0.0; } else { double change = AbsSpeed * DiffToOne; // NOT DiffToZero if (change < TRANSITION_EPSILSON) { change = TRANSITION_EPSILSON; } MenuTransition -= change; } } break; case TM_LINEAR: // Old linear style MenuTransition += TransitionSpeed / 5.0; break; } if (MenuTransition >= 1.0 && TransitionSpeed > 0.0) { MenuTransition = 1.0; TransitionSpeed = 0.0; } else if (MenuTransition <= 0.0 && TransitionSpeed < 0.0) { MenuTransition = 0.0; TransitionSpeed = 0.0; if (ClosingMenu == true) { DoMenuClose(); } } } } bool InMenuTransition() { return ((MenuTransition < 1.0) || (TransitionDelay > 0) || (InMenuFade() == true)); } bool StepThru() { if (MenuData.StepThru == true) { return true; } SnapStaticEventHandler ev = SnapStaticEventHandler.Get(); if (ev != null && ev.ReturningFromTrial == true) { return true; } return false; } // // ZScript menus are like, the textbook definition // of the worst-case scenario involving inheritance. // // I apologize in advance for these functions. // int GetItemHeight(MenuItemBase item) { if (item is "SnapMenuItemBase") { let it = SnapMenuItemBase(item); return it.GetLineSpacing(); } else if (item is "SnapMenuItemSubmenu") { let it = SnapMenuItemSubmenu(item); return it.GetLineSpacing(); } else if (item is "SnapMenuItemControl") { let it = SnapMenuItemControl(item); return it.GetLineSpacing(); } else if (item is "OptionMenuItemSnapOption") { let it = OptionMenuItemSnapOption(item); return it.GetLineSpacing(); } else if (item is "OptionMenuItemSnapSlider") { let it = OptionMenuItemSnapSlider(item); return it.GetLineSpacing(); } else if (item is "OptionMenuItemSnapScaleSlider") { let it = OptionMenuItemSnapScaleSlider(item); return it.GetLineSpacing(); } else if (item is "OptionMenuItemSnapCommand") { let it = OptionMenuItemSnapCommand(item); return it.GetLineSpacing(); } else if (item is "OptionMenuItemSnapTextField") { let it = OptionMenuItemSnapTextField(item); return it.GetLineSpacing(); } else if (item is "OptionMenuItemSnapPlayerName") { let it = OptionMenuItemSnapPlayerName(item); return it.GetLineSpacing(); } else if (item is "OptionMenuItemSnapPlayerColor") { let it = OptionMenuItemSnapPlayerColor(item); return it.GetLineSpacing(); } else if (item is "OptionMenuItemSnapPlayerColorSlider") { let it = OptionMenuItemSnapPlayerColorSlider(item); return it.GetLineSpacing(); } else if (item is "OptionMenuItemSnapPlayerTeam") { let it = OptionMenuItemSnapPlayerTeam(item); return it.GetLineSpacing(); } else if (item is "SnapJoySensitivity") { let it = SnapJoySensitivity(item); return it.GetLineSpacing(); } else if (item is "SnapJoyScale") { let it = SnapJoyScale(item); return it.GetLineSpacing(); } else if (item is "SnapJoyDeadZone") { let it = SnapJoyDeadZone(item); return it.GetLineSpacing(); } else if (item is "SnapJoyMap") { let it = SnapJoyMap(item); return it.GetLineSpacing(); } else if (item is "SnapJoyInvert") { let it = SnapJoyInvert(item); return it.GetLineSpacing(); } if (item is "OptionMenuItem") { return OptionMenuSettings.mLinespacing * 2; } return 0; // whatever } String GetItemTooltip(MenuItemBase item) { if (item is "SnapMenuItemBase") { let it = SnapMenuItemBase(item); return it.Tooltip(); } else if (item is "SnapMenuItemSubmenu") { let it = SnapMenuItemSubmenu(item); return it.Tooltip(); } else if (item is "SnapMenuItemControl") { let it = SnapMenuItemControl(item); return it.Tooltip(); } else if (item is "OptionMenuItemSnapOption") { let it = OptionMenuItemSnapOption(item); return it.Tooltip(); } else if (item is "OptionMenuItemSnapSlider") { let it = OptionMenuItemSnapSlider(item); return it.Tooltip(); } else if (item is "OptionMenuItemSnapScaleSlider") { let it = OptionMenuItemSnapScaleSlider(item); return it.Tooltip(); } else if (item is "OptionMenuItemSnapCommand") { let it = OptionMenuItemSnapCommand(item); return it.Tooltip(); } else if (item is "OptionMenuItemSnapTextField") { let it = OptionMenuItemSnapTextField(item); return it.Tooltip(); } else if (item is "OptionMenuItemSnapPlayerName") { let it = OptionMenuItemSnapPlayerName(item); return it.Tooltip(); } else if (item is "OptionMenuItemSnapPlayerColor") { let it = OptionMenuItemSnapPlayerColor(item); return it.Tooltip(); } else if (item is "OptionMenuItemSnapPlayerColorSlider") { let it = OptionMenuItemSnapPlayerColorSlider(item); return it.Tooltip(); } else if (item is "OptionMenuItemSnapPlayerTeam") { let it = OptionMenuItemSnapPlayerTeam(item); return it.Tooltip(); } else if (item is "SnapJoySensitivity") { let it = SnapJoySensitivity(item); return it.Tooltip(); } else if (item is "SnapJoyScale") { let it = SnapJoyScale(item); return it.Tooltip(); } else if (item is "SnapJoyDeadZone") { let it = SnapJoyDeadZone(item); return it.Tooltip(); } else if (item is "SnapJoyMap") { let it = SnapJoyMap(item); return it.Tooltip(); } else if (item is "SnapJoyInvert") { let it = SnapJoyInvert(item); return it.Tooltip(); } return ""; } void SetItemParent(MenuItemBase item, SnapMenuBase parent) { if (item is "SnapMenuItemBase") { let it = SnapMenuItemBase(item); it.Parent = parent; } else if (item is "SnapMenuItemSubmenu") { let it = SnapMenuItemSubmenu(item); it.Parent = parent; } else if (item is "SnapMenuItemControl") { let it = SnapMenuItemControl(item); it.Parent = parent; } else if (item is "OptionMenuItemSnapOption") { let it = OptionMenuItemSnapOption(item); it.Parent = parent; } else if (item is "OptionMenuItemSnapSlider") { let it = OptionMenuItemSnapSlider(item); it.Parent = parent; } else if (item is "OptionMenuItemSnapScaleSlider") { let it = OptionMenuItemSnapScaleSlider(item); it.Parent = parent; } else if (item is "OptionMenuItemSnapCommand") { let it = OptionMenuItemSnapCommand(item); it.Parent = parent; } else if (item is "OptionMenuItemSnapTextField") { let it = OptionMenuItemSnapTextField(item); it.Parent = parent; } else if (item is "OptionMenuItemSnapPlayerName") { let it = OptionMenuItemSnapPlayerName(item); it.Parent = parent; } else if (item is "OptionMenuItemSnapPlayerColor") { let it = OptionMenuItemSnapPlayerColor(item); it.Parent = parent; } else if (item is "OptionMenuItemSnapPlayerColorSlider") { let it = OptionMenuItemSnapPlayerColorSlider(item); it.Parent = parent; } else if (item is "OptionMenuItemSnapPlayerTeam") { let it = OptionMenuItemSnapPlayerTeam(item); it.Parent = parent; } else if (item is "SnapJoySensitivity") { let it = SnapJoySensitivity(item); it.Parent = parent; } else if (item is "SnapJoyScale") { let it = SnapJoyScale(item); it.Parent = parent; } else if (item is "SnapJoyDeadZone") { let it = SnapJoyDeadZone(item); it.Parent = parent; } else if (item is "SnapJoyMap") { let it = SnapJoyMap(item); it.Parent = parent; } else if (item is "SnapJoyInvert") { let it = SnapJoyInvert(item); it.Parent = parent; } } void CallItemUpdateCursor(MenuItemBase item, Vector2 Delta, SnapMenuCursor Cursor) { if (item is "SnapMenuItemBase") { let it = SnapMenuItemBase(item); it.UpdateCursor(Delta, Cursor); } else if (item is "SnapMenuItemSubmenu") { let it = SnapMenuItemSubmenu(item); it.UpdateCursor(Delta, Cursor); } else if (item is "SnapMenuItemControl") { let it = SnapMenuItemControl(item); it.UpdateCursor(Delta, Cursor); } else if (item is "OptionMenuItemSnapOption") { let it = OptionMenuItemSnapOption(item); it.UpdateCursor(Delta, Cursor); } else if (item is "OptionMenuItemSnapSlider") { let it = OptionMenuItemSnapSlider(item); it.UpdateCursor(Delta, Cursor); } else if (item is "OptionMenuItemSnapScaleSlider") { let it = OptionMenuItemSnapScaleSlider(item); it.UpdateCursor(Delta, Cursor); } else if (item is "OptionMenuItemSnapCommand") { let it = OptionMenuItemSnapCommand(item); it.UpdateCursor(Delta, Cursor); } else if (item is "OptionMenuItemSnapSafeCommand") { let it = OptionMenuItemSnapSafeCommand(item); it.UpdateCursor(Delta, Cursor); } else if (item is "OptionMenuItemSnapTextField") { let it = OptionMenuItemSnapTextField(item); it.UpdateCursor(Delta, Cursor); } else if (item is "OptionMenuItemSnapPlayerName") { let it = OptionMenuItemSnapPlayerName(item); it.UpdateCursor(Delta, Cursor); } else if (item is "OptionMenuItemSnapPlayerColor") { let it = OptionMenuItemSnapPlayerColor(item); it.UpdateCursor(Delta, Cursor); } else if (item is "OptionMenuItemSnapPlayerColorSlider") { let it = OptionMenuItemSnapPlayerColorSlider(item); it.UpdateCursor(Delta, Cursor); } else if (item is "OptionMenuItemSnapPlayerTeam") { let it = OptionMenuItemSnapPlayerTeam(item); it.UpdateCursor(Delta, Cursor); } else if (item is "SnapJoySensitivity") { let it = SnapJoySensitivity(item); it.UpdateCursor(Delta, Cursor); } else if (item is "SnapJoyScale") { let it = SnapJoyScale(item); it.UpdateCursor(Delta, Cursor); } else if (item is "SnapJoyDeadZone") { let it = SnapJoyDeadZone(item); it.UpdateCursor(Delta, Cursor); } else if (item is "SnapJoyMap") { let it = SnapJoyMap(item); it.UpdateCursor(Delta, Cursor); } else if (item is "SnapJoyInvert") { let it = SnapJoyInvert(item); it.UpdateCursor(Delta, Cursor); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapHUD { const BOSSWARNBLINKFREQ = 5; const READY_BAR_START = -122.0; const READY_BAR_END = 35.0; const READY_BAR_LENGTH = READY_BAR_END - READY_BAR_START; void DrawVersusCountdown(double TicFrac) { if (ev == null) { return; } double InterpWordScale = ev.WordScale - (WORD_SCALE_CHANGE * TicFrac); if (InterpWordScale < 0.0) { InterpWordScale = 0.0; } Vector2 ImgScale = ( 1.0 + InterpWordScale, 1.0 + InterpWordScale ); Vector2 ImgShake = ( 0.0, ev.WordShake ); if (ev.VSCountdown == 0) { if (ev.BossWarning > 0) { int show = ((ev.BossWarning-1) / BOSSWARNBLINKFREQ); if (!(show & 1)) { DrawLocalizedImage("$SNAP_GFX_BOSSWARN", ImgShake, DI_ITEM_CENTER|DI_SCREEN_CENTER, scale: ImgScale); } } else if (ev.HurryUp > 0) { int show = ((ev.HurryUp-1) / BOSSWARNBLINKFREQ); if (!(show & 1)) { DrawLocalizedImage("$SNAP_GFX_HURRY", ImgShake, DI_ITEM_CENTER|DI_SCREEN_CENTER, scale: ImgScale); } } else if (ev.GoTime > 0) { DrawLocalizedImage("$SNAP_GFX_GO", ImgShake, DI_ITEM_CENTER|DI_SCREEN_CENTER, scale: ImgScale); } return; } else { double timeLeft = ev.VSCountdown + TicFrac; if (ev.LevelDone == true) { switch (ev.VSCountdownReason) { case VS_REASON_POINTLIMIT: default: DrawLocalizedImage("$SNAP_GFX_GAME", ImgShake, DI_ITEM_CENTER|DI_SCREEN_CENTER, scale: ImgScale); break; case VS_REASON_TIMELIMIT: DrawLocalizedImage("$SNAP_GFX_TIME", ImgShake, DI_ITEM_CENTER|DI_SCREEN_CENTER, scale: ImgScale); break; } } else { // Draw READY countdown. DrawLocalizedImage("$SNAP_GFX_READY", (0, 0), DI_ITEM_CENTER|DI_SCREEN_CENTER); int SegsLeft = ((ev.VSCountdown - (VS_READY_SEG_TIME/2)) / VS_READY_SEG_TIME) + 1; if (SegsLeft <= 3) { if (SegsLeft < 1) { SegsLeft = 1; } Vector2 offset = (91, -32); DrawImage(String.Format("READY%d", SegsLeft), offset, DI_ITEM_CENTER|DI_SCREEN_CENTER); } double Progress = ((ev.VSCountdown * 1.0) / (VS_READY_TIME * 1.0)); if (Progress < 0.0) { Progress = 0.0; } else if (Progress > 1.0) { Progress = 1.0; } double BarSize = (1.0 - Progress) * READY_BAR_LENGTH; SetClipRect( READY_BAR_START, -100.0, BarSize, 100.0, DI_ITEM_CENTER|DI_SCREEN_CENTER ); DrawImage("READYBAR", (0, 0), DI_ITEM_CENTER|DI_SCREEN_CENTER); ClearClipRect(); } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class FactoryCraneArm : SnapActor { Default { +NOINTERACTION +NOBLOCKMAP +NOGRAVITY +DONTSPLASH +WALLSPRITE } States { Spawn: CRAN B -1; Loop; See: CRAN C -1; Loop; } } class FactoryCraneSeg : SnapActor { Default { Radius 8; Height 16; +NOINTERACTION +NOBLOCKMAP +NOGRAVITY +DONTSPLASH +FORCEYBILLBOARD +ADDLIGHTLEVEL } States { Spawn: CRAN D -1; Loop; } } class FactoryCraneWire : SnapActor { Default { +NOINTERACTION +NOBLOCKMAP +NOGRAVITY +DONTSPLASH +WALLSPRITE } States { Spawn: CRAN E -1; Loop; } } class FactoryCrane : SnapMonster { Array CranePoints; bool CranePointsLoop; const NUM_ARMS = 3; const ARM_ANGLE = 360.0 / NUM_ARMS; const ROTATE_FACTOR = 8.0; Actor CraneArms[NUM_ARMS]; const NUM_SEGS = 32; Actor CraneSegs[NUM_SEGS]; Actor CraneWire; bool DeferRelease; const CRANE_LAG = 5; Default { Health TELEFRAG_DAMAGE; Radius 48; Height 212; PainChance 0; Mass 100; Speed 8; Species "Crane"; SnapActor.DamageFlash ""; -ISMONSTER -COUNTKILL +NOBLOOD +PUSHABLE +DROPOFF +CANTSEEK +NOGRAVITY +DONTTHRUST -FLOORCLIP -WINDTHRUST +FORCEYBILLBOARD +SnapActor.NOFOOTSTEPS -SnapActor.CANDROPAMMO +SnapMonster.ISCONTAINER +SnapMonster.SHOWCONTENTS } States { Spawn: CRAN A -1; Loop; } void CraneGatherPoints() { // Save our patrol path into a list. // Needed over just regular patrol point traversal // since the crane can move backwards CranePoints.Clear(); CranePointsLoop = false; let startIt = Level.CreateActorIterator(self.Args[1], "PatrolPoint"); self.Special = 0; PatrolPoint Point = PatrolPoint(startIt.Next()); while (Point != null) { if (CranePoints.Find(Point) != CranePoints.Size()) { // Our path loops. CranePointsLoop = true; break; } CranePoints.Push(Point); Console.Printf("Added point"); let it = Level.CreateActorIterator(Point.Args[0], "PatrolPoint"); Point = PatrolPoint(it.Next()); } ResetCraneWaypoints(); } void CraneGrab() { if (ContainPower != null) { if (ContainPower.Health <= 0) { // Our item died. Drop it. ContainerRelease(); } return; } // We aren't holding anything. // Check for stuff to grab! DoContainerSearch(); } int CraneDir() { if (ContainPower != null || CranePointsLoop == true) { return 1; } return -1; } void UpdateCraneWaypoints(int ID) { int NumPoints = CranePoints.Size(); if (NumPoints == 0) { Target = null; Tracer = null; return; } ID = min(max(ID, 0), NumPoints); int Next = ID + 1; if (Next >= NumPoints) { if (CranePointsLoop == true) { Next = 0; } else { Next = NumPoints - 1; } } int Prev = ID - 1; if (Prev < 0) { if (CranePointsLoop == true) { Prev = NumPoints - 1; } else { Prev = 0; } } Target = CranePoints[Next]; Tracer = CranePoints[Prev]; } void ResetCraneWaypoints() { // Try to repair for the next frame. UpdateCraneWaypoints(0); } void CraneMove() { // Default momentum. Vel = (0, 0, 0); int NumPoints = CranePoints.Size(); if (NumPoints == 0) { // No path to travel. //Console.Printf("No path"); return; } PatrolPoint Point = PatrolPoint(Target); int CurCraneDir = CraneDir(); if (CurCraneDir < 0) { Point = PatrolPoint(Tracer); } if (Point == null) { // Path is invalid. Console.Printf("No destination"); ResetCraneWaypoints(); return; } int ID = CranePoints.Find(Point); if (ID == NumPoints) { // Wait... we're not on our own path? Console.Printf("Destination isn't on path"); ResetCraneWaypoints(); return; } Vector3 dir = Vec3To(Point); double dist = dir.Length(); if (dist ~== 0.0) { // We got to our destination! SetOrigin(Point.Pos, true); // Set our position to it exactly. UpdateCraneWaypoints(ID); } else { // Move towards the Goal. double spd = Speed; if (CurCraneDir >= 0 && CranePointsLoop == false) { spd *= 2.0; } Vel = dir.Unit() * min(dist, spd); } } void CraneArmsClose() { A_StartSound("crane/attach"); for (int i = 0; i < NUM_ARMS; i++) { if (CraneArms[i] == null) { continue; } CraneArms[i].SetStateLabel("See"); } } void CraneArmsOpen() { A_StartSound("crane/detach"); for (int i = 0; i < NUM_ARMS; i++) { if (CraneArms[i] == null) { continue; } CraneArms[i].SetStateLabel("Spawn"); } } void UpdateCranePieces() { for (int i = 0; i < NUM_ARMS; i++) { if (CraneArms[i] == null) { continue; } CraneArms[i].SetOrigin(self.Pos, true); CraneArms[i].A_SetAngle(self.Angle + (i * ARM_ANGLE), SPF_INTERPOLATE); //CraneArms[i].Vel = self.Vel; } for (int i = 0; i < NUM_SEGS; i++) { if (CraneSegs[i] == null) { continue; } CraneSegs[i].SetOrigin(Vec3Offset(0, 0, self.Height + (CraneSegs[i].Height * i)), true); CraneSegs[i].LightLevel = -8 * i; //CraneSegs[i].Vel = self.Vel; } if (CraneWire != null) { CraneWire.SetOrigin(self.Pos, true); //CraneWire.Vel = self.Vel; } } override void BeginPlay() { super.BeginPlay(); for (int i = 0; i < NUM_ARMS; i++) { CraneArms[i] = Spawn("FactoryCraneArm", Pos, ALLOW_REPLACE); let sa = SnapActor(CraneArms[i]); if (sa != null) { sa.SetHitstunParent(self); } } for (int i = 0; i < NUM_SEGS; i++) { CraneSegs[i] = Spawn("FactoryCraneSeg", Pos, ALLOW_REPLACE); let sa = SnapActor(CraneSegs[i]); if (sa != null) { sa.SetHitstunParent(self); } } CraneWire = Spawn("FactoryCraneWire", Pos, ALLOW_REPLACE); CraneWire.Angle = random[snap_decor](-180, 180); let sa = SnapActor(CraneWire); if (sa != null) { sa.SetHitstunParent(self); } UpdateCranePieces(); } override void PostBeginPlay() { super.PostBeginPlay(); if (self.Special == Thing_SetGoal && self.Args[0] == 0) { CraneGatherPoints(); } } override void Tick() { super.Tick(); if (TickPaused() == true) { return; } if (DeferRelease == true) { ContainerRelease(); } CraneGrab(); CraneMove(); Angle += (Vel.Length() * CraneDir()) / ROTATE_FACTOR; UpdateCranePieces(); } override bool CanCollideWith(Actor other, bool passive) { if (ContainPower == null) { return false; } return super.CanCollideWith(other, passive); } override bool ContainerSet(Actor mo) { if (mo != null && mo.Vel.Z < 0.0) { // Don't grab things moving downwards. return false; } let sa = SnapActor(mo); if (sa != null && sa.bForceFreeze == true) { // Don't grab already-grabbed things. return false; } bool ret = super.ContainerSet(mo); if (ret == true) { // Object was set! CraneArmsClose(); } return ret; } override void ContainerRelease() { DeferRelease = false; Actor PrevContainer = ContainPower; super.ContainerRelease(); // Object was released! CraneArmsOpen(); if (PrevContainer != null) { // Undo the momentum. PrevContainer.Vel = (0, 0, -0.001); } } override void ContainerUpdate() { ContainPower.SetOrigin( Vec3Offset( 0, 0, -ContainPower.Height * 0.1 ), true ); ContainPower.Vel = Vel; } override int TakeSpecialDamage(Actor inflictor, Actor source, int damage, Name mod) { if (ContainPower == null) { // No item held return 0; } DeferRelease = true; //ContainerRelease(); AddHitstun(CRANE_LAG, true); return 0; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class BotScreenClear : ScreenClear { Default { Speed 1.0; Obituary "$OB_SNAPBOT"; } override double ScreenClearSize() { return SCVSFINALSIZE; } } extend class SnapBot { bool HavePOW; void GivePOW(bool OnSpawn = false) { if (HavePOW == false && OnSpawn == false) { A_StartSound("septacrash/ready", CHAN_BODY, CHANF_UI, 1.0, ATTN_NORM); } HavePOW = true; } void SpawnPOW() { Actor powActor = Spawn("BotScreenClear", Pos + (0, 0, Height * 0.5), ALLOW_REPLACE); let pow = SnapActor(powActor); if (pow) { pow.target = self; pow.translation = GetDefaultTranslation(); pow.A_SnapScreenShake(1536, 1536, 9.0, 0.5); } } void StartPOW() { bInvulnerable = true; bNoGravity = true; Vel = (0, 0, 0); A_StartSound("septacrash/use"); HavePOW = false; } void EndPOW() { bInvulnerable = Default.bInvulnerable; bNoGravity = Default.bNoGravity; ReactionTime = Default.ReactionTime; } void POWTick() { if (Health <= 0) { HavePOW = false; return; } if (HavePOW && (Level.maptime % 7 == 0)) { double a = Level.maptime * (360 / (TICRATE * 0.1)); if (Level.maptime & 2) { a += 90; } for (int i = 0; i < 2; i++) { let Particle = Spawn("ScreenClearParticle", Pos - (0, 0, Height), ALLOW_REPLACE); if (Particle != null) { Particle.Scale *= 0.5; Particle.Translation = GetDefaultTranslation(); Particle.Target = self; Particle.Angle = a + 90; Particle.bInvisible = true; let scp = ScreenClearParticle(Particle); if (scp) { scp.SCPSpin = a; scp.SCPDist = Radius * 3.0; scp.Vel.Z = 8.0; scp.SCPBlink = (i == 0); } } a += 180; } } } States { Power: PPOW A 0 StartPOW(); PPOW A 15; PPOW B 2; PPOW A 0 SpawnPOW(); PPOW B 2; PPOW CDEFGH 1; PPOW CDEFGH 1; PPOW CDEFGH 1; PPOW CDEFGH 1; PPOW CDEFGH 1; PPOW CDEFGH 1; PPOW CDEFGH 1; PPOW CDEFGH 1; PPOW CDEFGH 1; PPOW CDEFGH 1; PPOW CDEFGH 1; PPOW CDEFGH 1; PPOW CDEFGH 1; PPOW CDEFGH 1; PPOW CDEFGH 1; PPOW CDEFGH 1; PPOW A 0 EndPOW(); Goto See; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapPlayer { const CRASHLAYERMOVE = 19; double CrashOffset; double CrashClap; double CrashClapVel; const CLAPVELADD = 2.0; const CLAPVELSTART = 2.0; void MoveWeapLayer(PSprite pspr, double amt) { if (pspr == null) { return; } pspr.y += amt; } virtual void MoveCrashLayers() { let weap = SnapGun(player.ReadyWeapon); if (weap == null) { return; } double Prev = CrashOffset; double Dest = 0.0; if (UsingPOW > 12) { Dest = weap.CRASHSHIFT; } double Dis = Dest - CrashOffset; if (abs(Dis) <= CRASHLAYERMOVE) { CrashOffset = Dest; } else { if (CrashOffset > Dest) { CrashOffset -= CRASHLAYERMOVE; } else { CrashOffset += CRASHLAYERMOVE; } } if (CrashOffset == Prev) { return; } double Delta = CrashOffset - Prev; for (uint i = 0; i < uint(weap.WeaponLayers.Size()); i++) { let pspr = player.GetPSprite(weap.WeaponLayers[i]); MoveWeapLayer(pspr, Delta); } for (uint i = 0; i < uint(weap.CrashLayers.Size()); i++) { let pspr = player.GetPSprite(weap.CrashLayers[i]); MoveWeapLayer(pspr, Delta * -2); // Because the layers have ADDWEAPON } } virtual void TickPOWPSprites() { let weap = SnapGun(player.ReadyWeapon); if (weap == null) { return; } // Continue ticking crash even during the pause. for (uint i = 0; i < uint(weap.CrashLayers.Size()); i++) { let pspr = player.GetPSprite(weap.CrashLayers[i]); if (pspr != null) { pspr.Tick(); } } } void UpdateCrashClap() { if (CrashClap <= 0) { return; } CrashClap -= CrashClapVel; CrashClapVel += CLAPVELADD; } void StartCrashClap() { CrashClapVel = CLAPVELSTART; CrashClap = 320.0; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapStaticEventHandler { ui bool CRTShaderStatus; ui void CheckCRTShaderStatus() { bool NewValue = false; CVar CRTCVar = CVar.FindCVar("snap_crt"); if (CRTCVar != null) { NewValue = CRTCVar.GetBool(); } if (NewValue != CRTShaderStatus) { PPShader.SetEnabled("SnapCRT", NewValue); CRTShaderStatus = NewValue; } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapMenuCursorExplosion ui { Vector2 Pos; uint Time; bool Small; } class SnapMenuCursor ui { mixin SnapMenuDrawing; enum CursorTextureTypes { CTEX_IDLE, CTEX_FIRE1, CTEX_FIRE2, CTEX_FIRE3, CTEX_FIRE4, CTEX_FIRE5, CTEX_IDLE_SMALL, CTEX_FIRE1_SMALL, CTEX_FIRE2_SMALL, CTEX_FIRE3_SMALL, CTEX_FIRE4_SMALL, CTEX_FIRE5_SMALL, CTEX_TRANSITION, CTEX__MAX, } TextureID CursorTextures[CTEX__MAX]; uint Size; uint FireTime; bool DestSmall; Vector2 Pos; Vector2 DestPos; const FIRE_ANIM_LENGTH = 15; const FIRE_ANIM_DELAY = 5; const NUM_TRANSITION_TICS = 3; const NUM_EXPLOSION_FRAMES = 4; TextureID ExplosionTextures[2][NUM_EXPLOSION_FRAMES]; Array Explosions; virtual void Precache() { CursorTextures[CTEX_IDLE] = TexMan.CheckForTexture("CURSORL0", TexMan.Type_MiscPatch); CursorTextures[CTEX_FIRE1] = TexMan.CheckForTexture("CURSORL1", TexMan.Type_MiscPatch); CursorTextures[CTEX_FIRE2] = TexMan.CheckForTexture("CURSORL2", TexMan.Type_MiscPatch); CursorTextures[CTEX_FIRE3] = TexMan.CheckForTexture("CURSORL3", TexMan.Type_MiscPatch); CursorTextures[CTEX_FIRE4] = TexMan.CheckForTexture("CURSORL4", TexMan.Type_MiscPatch); CursorTextures[CTEX_FIRE5] = TexMan.CheckForTexture("CURSORL5", TexMan.Type_MiscPatch); CursorTextures[CTEX_IDLE_SMALL] = TexMan.CheckForTexture("CURSORS0", TexMan.Type_MiscPatch); CursorTextures[CTEX_FIRE1_SMALL] = TexMan.CheckForTexture("CURSORS1", TexMan.Type_MiscPatch); CursorTextures[CTEX_FIRE2_SMALL] = TexMan.CheckForTexture("CURSORS2", TexMan.Type_MiscPatch); CursorTextures[CTEX_FIRE3_SMALL] = TexMan.CheckForTexture("CURSORS3", TexMan.Type_MiscPatch); CursorTextures[CTEX_FIRE4_SMALL] = TexMan.CheckForTexture("CURSORS4", TexMan.Type_MiscPatch); CursorTextures[CTEX_FIRE5_SMALL] = TexMan.CheckForTexture("CURSORS5", TexMan.Type_MiscPatch); CursorTextures[CTEX_TRANSITION] = TexMan.CheckForTexture("CURSORT", TexMan.Type_MiscPatch); ExplosionTextures[0][0] = TexMan.CheckForTexture("CURSEXL1", TexMan.Type_MiscPatch); ExplosionTextures[0][1] = TexMan.CheckForTexture("CURSEXL2", TexMan.Type_MiscPatch); ExplosionTextures[0][2] = TexMan.CheckForTexture("CURSEXL3", TexMan.Type_MiscPatch); ExplosionTextures[0][3] = TexMan.CheckForTexture("CURSEXL4", TexMan.Type_MiscPatch); ExplosionTextures[1][0] = TexMan.CheckForTexture("CURSEXS1", TexMan.Type_MiscPatch); ExplosionTextures[1][1] = TexMan.CheckForTexture("CURSEXS2", TexMan.Type_MiscPatch); ExplosionTextures[1][2] = TexMan.CheckForTexture("CURSEXS3", TexMan.Type_MiscPatch); ExplosionTextures[1][3] = TexMan.CheckForTexture("CURSEXS4", TexMan.Type_MiscPatch); Size = 2; DestSmall = false; Offscreen(); } virtual void Offscreen() { DestPos = (0, -(VirtualOffset.Y + 32)); } virtual void PlayFire() { Pos = DestPos; FireTime = FIRE_ANIM_LENGTH + FIRE_ANIM_DELAY; Size = (DestSmall == true) ? 0 : NUM_TRANSITION_TICS; let exp = new("SnapMenuCursorExplosion"); exp.Pos = Pos; exp.Time = 0; exp.Small = DestSmall; Explosions.Push(exp); Menu.MenuSound("menu/gun"); } virtual bool FirePlaying() { return (FireTime > 0); } virtual void Tick() { if (FirePlaying()) { FireTime--; } else { if (DestSmall == true) { if (Size > 0) { Size--; } } else { if (Size < NUM_TRANSITION_TICS) { Size++; } } } Vector2 Diff = (DestPos - Pos); if (Diff.Length() < 1.0) { Pos = DestPos; } else { Pos += Diff * 0.35; } for (uint i = 0; i < Explosions.Size(); i++) { let exp = Explosions[i]; if (exp.Time > NUM_EXPLOSION_FRAMES) { exp.Destroy(); Explosions.Delete(i); i--; continue; } exp.Time++; } } virtual void Draw() { UpdateScaleParameters(); for (uint i = 0; i < Explosions.Size(); i++) { let exp = Explosions[i]; int Frame = exp.Time - 1; if (Frame >= 0 && Frame < NUM_EXPLOSION_FRAMES) { TextureID ExpTex = ExplosionTextures[exp.Small][Frame]; Vector2 ExpSize = SnapMenuTextureSize(ExpTex); Vector2 ExpPos = exp.Pos - (ExpSize.Y, ExpSize.Y * 0.5); SnapMenuTexture(ExpTex, ExpPos); } } TextureID Texture; if (Size > 0 && Size < NUM_TRANSITION_TICS) { // Transition frame Texture = CursorTextures[CTEX_TRANSITION]; } else { uint index = CTEX_IDLE; if (FireTime > 0) { int Time = FireTime - FIRE_ANIM_DELAY; if (FireTime > FIRE_ANIM_DELAY+5+6+3) { index = CTEX_IDLE; } else if (FireTime > FIRE_ANIM_DELAY+5+6+2) { index = CTEX_FIRE1; } else if (FireTime > FIRE_ANIM_DELAY+5+6+1) { index = CTEX_FIRE2; } else if (FireTime > FIRE_ANIM_DELAY+5+6) { index = CTEX_FIRE3; } else if (FireTime > FIRE_ANIM_DELAY+5) { index = CTEX_FIRE4; } else if (FireTime > FIRE_ANIM_DELAY) { index = CTEX_FIRE5; } else { index = CTEX_IDLE; } } if (Size == 0) { index += CTEX_IDLE_SMALL; } Texture = CursorTextures[index]; } Vector2 TexSize = SnapMenuTextureSize(Texture); Vector2 DrawPos = Pos - (TexSize.X, TexSize.Y * 0.5); SnapMenuTexture(Texture, DrawPos); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapMenuItemCustomGameOption : SnapMenuItemOptionLocked { uint RewardType; SnapMenuItemCustomGameOption Init(String Title, String ToolTip, Name Option, Name OptionVals, uint rt) { super.Init(Title, ToolTip, Option, OptionVals); RewardType = rt; return self; } override bool Locked() { if (SnapReward_CustomGameOption.CustomOptionUnlocked(RewardType) == false) { return true; } return super.Locked(); } } class OptionMenuItemSnapCustomWeapon : SnapMenuItemCustomGameOption { Array WeaponNames; int WeaponID; void UpdateWeaponNames() { WeaponNames.Clear(); WeaponNames.Push("$SNAPMENU_OFF"); WeaponNames.Push("$SNAPMENU_WEAPON_BASIC"); let ev = SnapStaticEventHandler.Get(); if (ev != null) { for (int i = 0; i < ev.WeaponProps.Size(); i++) { let Props = ev.WeaponProps[i]; WeaponNames.Push(Props.NiceName); } } if (WeaponID < 0 || WeaponID >= WeaponNames.Size()) { WeaponID = 0; } } OptionMenuItemSnapCustomWeapon Init() { super.Init( "$SNAPMENU_CUSTOM_WEAPON", "$SNAPMENU_CUSTOM_WEAPON_TOOLTIP", "snap_menu_custom_weapon", "", SnapReward_CustomGameOption.TYPE_SINGLEWEAPON ); UpdateWeaponNames(); return self; } override bool MenuEvent(int mKey, bool gamepad) { if (Locked() == true) { return false; } UpdateWeaponNames(); int cnt = WeaponNames.Size(); if (cnt > 0) { if (mKey == Menu.MKEY_Left) { if (WeaponID < 0) WeaponID = 0; else if (--WeaponID < 0) WeaponID = cnt - 1; } else if (mKey == Menu.MKEY_Right || mKey == Menu.MKEY_Enter) { if (++WeaponID >= cnt) WeaponID = 0; } else { return false; } let cv = CVar.FindCVar("snap_menu_custom_weapon"); if (cv != null) { cv.SetInt(WeaponID); } Menu.MenuSound("menu/change"); CursorPlayFire(); } else { return false; } return true; } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { if (Locked() == true) { return super.Draw(desc, yOffset, xOffset, selected); } UpdateScaleParameters(); Vector2 Pos = ((BASE_VID_WIDTH * 0.5) + xOffset, yOffset); int col = Font.CR_UNTRANSLATED; if (DisplayGrayed() == true) { col = FontGrayColor; } else if (selected == true) { col = FontHighlightColor; } SnapMenuText( FontSmall, col, RightAlignPos(FontSmall, mLabel, Pos - (OPTIONS_MID_SPACE, 0)), mLabel ); String text = ""; UpdateWeaponNames(); int cnt = WeaponNames.Size(); if (cnt > 0) { if (WeaponID >= 0 && WeaponID < cnt) { text = StringTable.Localize(WeaponNames[WeaponID]); } } if (text.Length() == 0) { text = "Unknown"; } SnapMenuText( FontSmall, col, Pos + (OPTIONS_MID_SPACE, 0), text ); return xOffset; } } class OptionMenuItemSnapCustomCharacter : SnapMenuItemCustomGameOption { int CharacterID; OptionMenuItemSnapCustomCharacter Init() { super.Init( "$SNAPMENU_CUSTOM_CHARACTER", "$SNAPMENU_CUSTOM_CHARACTER_TOOLTIP", "snap_menu_character", "", 0 ); return self; } override bool Locked() { for (int i = 1; i < PlayerClasses.Size(); i++) { if (SnapReward_BonusCharacter.BonusCharacterUnlocked(i) == true) { return false; } } return true; } override bool MenuEvent(int mKey, bool gamepad) { if (Locked() == true) { return false; } int cnt = PlayerClasses.Size(); if (cnt > 0) { if (mKey == Menu.MKEY_Left) { do { if (CharacterID < 0) CharacterID = 0; else if (--CharacterID < 0) CharacterID = cnt - 1; } while (SnapReward_BonusCharacter.BonusCharacterUnlocked(CharacterID) == false); } else if (mKey == Menu.MKEY_Right || mKey == Menu.MKEY_Enter) { do { if (++CharacterID >= cnt) CharacterID = 0; } while (SnapReward_BonusCharacter.BonusCharacterUnlocked(CharacterID) == false); } else { return false; } SnapMenuData.SetSelectedCharacter(CharacterID); Menu.MenuSound("menu/change"); CursorPlayFire(); } else { return false; } return true; } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { if (Locked() == true) { return super.Draw(desc, yOffset, xOffset, selected); } UpdateScaleParameters(); Vector2 Pos = ((BASE_VID_WIDTH * 0.5) + xOffset, yOffset); int col = Font.CR_UNTRANSLATED; if (DisplayGrayed() == true) { col = FontGrayColor; } else if (selected == true) { col = FontHighlightColor; } SnapMenuText( FontSmall, col, RightAlignPos(FontSmall, mLabel, Pos - (OPTIONS_MID_SPACE, 0)), mLabel ); String text = ""; int cnt = PlayerClasses.Size(); if (cnt > 0) { if (CharacterID >= 0 && CharacterID < cnt) { text = PlayerPawn.GetPrintableDisplayName(PlayerClasses[ CharacterID ].Type); } } if (text.Length() == 0) { text = "Unknown"; } SnapMenuText( FontSmall, col, Pos + (OPTIONS_MID_SPACE, 0), text ); return xOffset; } } class OptionMenuItemSnapCustomExplosiveRobots : SnapMenuItemCustomGameOption { OptionMenuItemSnapCustomExplosiveRobots Init() { super.Init( "$SNAPMENU_CUSTOM_ROBOTS_EXPLODE", "$SNAPMENU_CUSTOM_ROBOTS_EXPLODE_TOOLTIP", "snap_menu_custom_robots_explode", "OnOff", SnapReward_CustomGameOption.TYPE_ROBOTSEXPLODE ); return self; } } class OptionMenuItemSnapCustomSeptacrashRations : SnapMenuItemCustomGameOption { OptionMenuItemSnapCustomSeptacrashRations Init() { super.Init( "$SNAPMENU_CUSTOM_SEPTACRASH_RATIONS", "$SNAPMENU_CUSTOM_SEPTACRASH_RATIONS_TOOLTIP", "snap_menu_custom_septacrash_rations", "OnOff", SnapReward_CustomGameOption.TYPE_CRASHRATIONS ); return self; } } class OptionMenuItemSnapCustomFastRobots : SnapMenuItemCustomGameOption { OptionMenuItemSnapCustomFastRobots Init() { super.Init( "$SNAPMENU_CUSTOM_ROBOTS_FAST", "$SNAPMENU_CUSTOM_ROBOTS_FAST_TOOLTIP", "snap_menu_custom_robots_fast", "OnOff", SnapReward_CustomGameOption.TYPE_ROBOTSFAST ); return self; } } class OptionMenuItemSnapCustomResistRobots : SnapMenuItemCustomGameOption { OptionMenuItemSnapCustomResistRobots Init() { super.Init( "$SNAPMENU_CUSTOM_ROBOTS_RESIST", "$SNAPMENU_CUSTOM_ROBOTS_RESIST_TOOLTIP", "snap_menu_custom_robots_resist", "OnOff", SnapReward_CustomGameOption.TYPE_ROBOTSRESIST ); return self; } } class OptionMenuItemSnapCustomDamageRobots : SnapMenuItemCustomGameOption { OptionMenuItemSnapCustomDamageRobots Init() { super.Init( "$SNAPMENU_CUSTOM_ROBOTS_DAMAGE", "$SNAPMENU_CUSTOM_ROBOTS_DAMAGE_TOOLTIP", "snap_menu_custom_robots_damage", "OnOff", SnapReward_CustomGameOption.TYPE_ROBOTSDAMAGE ); return self; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapCutsceneBase : SnapActor abstract { uint CutsceneID; // Set by event handler, used to determine if we've seen this cutscene in this session. Default { Health TELEFRAG_DAMAGE; -SOLID +NOBLOCKMAP +SHOOTABLE +INVULNERABLE +REFLECTIVE +DEFLECT +FLOORCLIP +LOOKALLAROUND +NOTARGETSWITCH +NOSPLASHALERT +NODAMAGE +NORADIUSDMG +NOTELEFRAG +NOBLOOD +NOPAIN +NEVERTARGET +DONTRIP +DONTBLAST +DONTDRAIN +DONTMORPH +DONTSQUASH +DONTGIB -WINDTHRUST -NOGRAVITY } action void A_CutsceneLook(float distance = 1280.0, StateLabel RegularState = null, StateLabel LongState = null) { if (LongState != null && bAmbush == true) { A_LookEx( LOF_NOSOUNDCHECK|LOF_DONTCHASEGOAL, 0, distance, 0, 360, LongState ); } else { A_LookEx( LOF_NOSOUNDCHECK|LOF_DONTCHASEGOAL, 0, distance, 0, 360, RegularState ); } } action void A_CutsceneEnd(bool ConsiderSeen = false) { A_CallSpecial(special, args[0], args[1], args[2], args[3], args[4]); if (ConsiderSeen == true) { let cs = SnapCutsceneBase(self); if (cs != null) { // Optional to save just a tiiiny bit of processing for cutscenes that don't need it. SnapStaticEventHandler.SetCutsceneSeen(cs.CutsceneID); } } } action void A_CutsceneVoice(Sound voice, bool SnapsLine = false, String Subtitle = "", uint SubtitleTics = 0) { if (SnapsLine == true && target != null) { let sp = SnapPlayer(target); if (sp != null) { sp.SnapVoiceInterrupt(); } target.A_StartSound( voice, CHAN_VOICE, CHANF_DEFAULT, 1.0, ATTN_NONE ); } else { A_StartSound( voice, CHAN_VOICE, CHANF_DEFAULT, 1.0, ATTN_NONE ); } A_CutsceneSubtitle(Subtitle, SubtitleTics); } action void A_CutsceneSubtitle(String Subtitle = "", uint SubtitleTics = 0) { if (Subtitle.Length() == 0) { return; } String RealSub = Stringtable.Localize(Subtitle); String OutputStr = String.Format("SUBTITLE|%s|%u", RealSub, SubtitleTics); A_PrintBold(OutputStr); } action void A_PauseTimer(bool value = true) { // Start / stop our own timer. // This was done so that the time bonus on the tally is consistent, // regardless of if the short or long cutscene is being played. let ev = SnapEventHandler(EventHandler.Find("SnapEventHandler")); if (ev != null) { ev.TimerPaused = value; } } void StartBossWarning() { SnapEventHandler.StartBossWarning(); } } #include "zscript/snap/cutscene/e1m1.zs" #include "zscript/snap/cutscene/e1m5.zs" #include "zscript/snap/cutscene/e1m6.zs" #include "zscript/snap/cutscene/e1m8.zs" #include "zscript/snap/cutscene/e1m10.zs" //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- // Cyber Brass, not Cyber Ass. class CybrassShotTrail : SnapActor { Default { Radius 16; Height 32; RenderStyle "Add"; +NOINTERACTION +NOGRAVITY +NOBLOCKMAP +RANDOMIZE +VISIBILITYPULSE +BRIGHT +SnapActor.MISSILESPRITEFIX } States { Spawn: TNT1 A 2; CBSH KLMN 1; Stop; } } class CybrassShot : SnapMissile { bool CybrassShotFired; action void A_CybrassShotCheck() { let ourselves = CybrassShot(self); if (!ourselves) { // this is so stupid return; } let t = Cybrass(ourselves.target); if (t && t.health > 0) { return; } // no owner ExplodeMissile(); } action void A_CybrassShotSeek() { let ourselves = CybrassShot(self); if (!ourselves) { // this is so stupid return; } if (bMissile == false || ourselves.CybrassShotFired == false) { // This shouldn't happen. ExplodeMissile(); return; } let t = Cybrass(ourselves.target); if (t && t.health > 0) { A_SeekerMissile(5, 8, SMF_LOOK, 256); let trail = SnapActor(Spawn("CybrassShotTrail", self.Pos, ALLOW_REPLACE)); if (trail) { trail.SetPhysicalSize(Scale); } return; } // no owner ExplodeMissile(); } Default { Radius 16; Height 32; Health 1; DamageFunction 10; Speed 15; BounceFactor 0.0; WallBounceFactor 0.0; RenderStyle "Add"; DeathSound "revolver/death"; Obituary "$OB_CYBRASS"; +RANDOMIZE +SEEKERMISSILE +SCREENSEEKER +BRIGHT } States { Spawn: CBSH ABCDEF 2 Light("CybrassShotLight") A_CybrassShotCheck; Loop; Fired: CBSH ABCDEF 2 Light("CybrassShotLight") A_CybrassShotSeek; Loop; Death: CBSH GHGHIJIJKLKLMNMN 1 Light("CybrassShotLight"); Stop; } } class CybrassPushEFX : SnapDynamicDecor { Default { RenderStyle "Translucent"; Alpha 0.6; Scale 0.5; +BRIGHT } States { Spawn: PUSH AEBECEDE 1; Stop; } override void Tick() { super.Tick(); Scale.X += 0.2; Scale.Y += 0.2; Alpha -= 0.05; } } class Cybrass : SnapMonster { CybrassShot CybrassShots[4]; bool PushStarted; uint CybrassRotateTick; const PUSHRANGE = 384.0; action state A_CybrassChase() { let ourselves = Cybrass(self); if (!ourselves) { // this is so stupid return null; } if (ourselves.bVeryRude == true && target != null && CheckSight(target) && movecount == 0) { double dist = (Pos - target.Pos).Length(); if (dist <= PUSHRANGE * Scale.X) { return ResolveState("Pushaway"); } } ourselves.PushStarted = false; A_SnapChase(); return null; } action state A_CybrassCreateShot() { A_FaceTarget(22.5); static const String firingSounds[] = { "cybrass/fire1", "cybrass/fire2", "cybrass/fire3", "cybrass/fire4" }; let ourselves = Cybrass(self); if (!ourselves) { // this is so stupid return null; } bool allShotsFull = true; for (int i = 0; i < 4; i++) { let shot = CybrassShot(ourselves.CybrassShots[i]); if (shot && shot.Health > 0 && shot.CybrassShotFired == false) { continue; } let newShot = CybrassShot(A_SnapMonsterProjectile("CybrassShot")); if (newShot) { newShot.A_StartSound(firingSounds[i]); // Prevent destroying when it clips geometry newShot.bMissile = false; newShot.bSlidesOnWalls = true; ourselves.CybrassShots[i] = newShot; } allShotsFull = false; break; } if (allShotsFull == true) { // Go to firing state return ResolveState("Firing"); } return null; } action void A_CybrassFireSound() { let ourselves = Cybrass(self); if (!ourselves) { // this is so stupid return; } bool allShotsEmpty = true; for (int i = 0; i < 4; i++) { let shot = CybrassShot(ourselves.CybrassShots[i]); if (shot && shot.health > 0) { if (shot.CybrassShotFired == true) { ourselves.CybrassShots[i] = null; continue; } allShotsEmpty = false; break; } } if (allShotsEmpty == false) { A_StartSound("cybrass/fire5"); } } action state A_CybrassFireShot() { A_FaceTarget(22.5); let ourselves = Cybrass(self); if (!ourselves) { // this is so stupid return null; } bool allShotsEmpty = true; for (int i = 0; i < 4; i++) { let shot = CybrassShot(ourselves.CybrassShots[i]); if (shot) { if (shot.health > 0 && shot.CybrassShotFired == false) { shot.CybrassShotFired = true; shot.bMissile = true; shot.A_FaceTracer(); shot.SetStateLabel("Fired"); } ourselves.CybrassShots[i] = null; allShotsEmpty = false; break; } } if (allShotsEmpty == true) { // Back to idle return ResolveState("See"); } return null; } action void A_CybrassPushaway() { let ourselves = Cybrass(self); if (!ourselves) { // this is so stupid return; } A_SnapScreenShake(64, 384, 5.0, 0.3); A_RadiusThrust(1000, 384, RTF_NOTMISSILE|RTF_NOIMPACTDAMAGE, 64); A_FaceTarget(22.5); if (Level.maptime & 1) { Vector3 pushPos = Pos; pushPos.Z += Height; Actor pushEFX = Spawn("CybrassPushEFX", pushPos, ALLOW_REPLACE); } bool isPlaying = (IsActorPlayingSound(CHAN_BODY, "cybrass/pushStart") || IsActorPlayingSound(CHAN_BODY, "cybrass/pushLoop")); if (isPlaying == false) { if (ourselves.PushStarted == true) { A_StartSound("cybrass/pushLoop"); } else { A_StartSound("cybrass/pushStart"); } ourselves.PushStarted = true; } } Default { Health 250; Radius 32; Height 56; Speed 10; Mass 600; SnapMonster.Poise 150; SnapActor.Score 1000; SeeSound "cybrass/see"; ActiveSound "cybrass/idle"; PainSound "cybrass/hurt"; Obituary "$OB_CYBRASS"; Tag "$TAG_CYBRASS"; Species "Robot"; +FLOAT //+FLOATBOB +NOGRAVITY +AVOIDMELEE +DONTFALL +SnapMonster.ROBOTTOUGH } States { Spawn: CYBS A 7 A_SnapMonsterLook(); CYBS B 3; CYBS B 4 A_SnapMonsterLook(); CYBS C 6; CYBS C 1 A_SnapMonsterLook(); Loop; See: CYBS DDEEFF 3 A_CybrassChase(); Loop; Missile: CYBS G 2 A_CybrassCreateShot(); CYBS HI 2; CYBS GHI 2; CYBS GHI 2; Loop; Firing: CYBS GH 4; CYBS I 4 A_CybrassFireSound(); FiringLoop: CYBS G 4 A_CybrassFireShot(); CYBS HI 4; Loop; Pushaway: CYBS GHIGHIGHI 1 A_CybrassPushaway(); Goto See; Pain: CYBS J 6; CYBS J 6 A_SnapMonsterPain(); Goto Firing; Kicked: CYBS J 6; CYBS J 6 A_SnapMonsterPain(); KickLoop: CYBS J 3 A_EndKick(); Loop; Death: CYBS J 1; CYBS JJJJJJJJ 4 DoSnapMonsterExplode(); TNT1 A 35 DoSnapMonsterDie(); Stop; GiantDeath: CYBS J 1; CYBS JJJJJ 4 DoSnapBossExplode(); CYBS J 4 DoSnapBossBigExplode(); CYBS JJJJJ 4 DoSnapBossExplode(); CYBS J 4 DoSnapBossBigExplode(); CYBS JJJJJ 4 DoSnapBossExplode(); CYBS J 4 DoSnapBossBigExplode(); CYBS JJJJJ 4 DoSnapBossExplode(); CYBS J 4 DoSnapBossBigExplode(); CYBS JJJJJ 4 DoSnapBossExplode(); TNT1 A 35 DoSnapBossDie(); Stop; } override void Tick() { super.Tick(); if (TickPaused() == false) { CybrassRotateTick++; } for (uint i = 0; i < 4; i++) { let shot = CybrassShot(CybrassShots[i]); if (shot && shot.Health > 0 && shot.CybrassShotFired == false) { double a = (CybrassRotateTick * 5) + (i * 90); double dist = Radius + shot.Radius + 2; Vector2 offset = AngleToVector(a, dist); Vector3 NewPos = Pos; NewPos.xy += offset; NewPos.z += (32.0 * Scale.Y) - (shot.Height * 0.5); shot.SetOrigin(NewPos, false); shot.angle = a + 90; shot.Vel = Vel; } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapDamageParticle : SnapDynamicDecor { Default { RenderStyle "Add"; +RANDOMIZE +BRIGHT } States { Spawn: PWPD ABCDE 3; Stop; } } class SnapDamagePower : PowerDamage { mixin SnapPowerupFix; Default { DamageFactor "Normal", 4; Powerup.Duration -30; } override bool HandlePickup(Inventory item) { return NewPowerupLogic(item); } override void DoEffect() { Super.DoEffect(); if (Owner == NULL || Owner.player == NULL) return; if (Owner.player.cheats & CF_PREDICTING) return; if (Level.maptime & 1) return; for (Inventory item = Inv; item != NULL; item = item.Inv) { let sitem = SnapDamagePower(item); if (sitem != null) { return; } } Vector3 startPos = Owner.Pos; startPos.X += frandom[snap_decor](-Owner.Radius, Owner.Radius); startPos.Y += frandom[snap_decor](-Owner.Radius, Owner.Radius); startPos.Z += frandom[snap_decor](0.0, Owner.Height); Actor particleObject = Spawn("SnapDamageParticle", startPos, ALLOW_REPLACE); if (particleObject) { particleObject.Vel = Owner.Vel * 0.75; particleObject.Vel.X += frandom[snap_decor](-2.0, 2.0); particleObject.Vel.Y += frandom[snap_decor](-2.0, 2.0); particleObject.Vel.Z += frandom[snap_decor](0.0, 6.0); particleObject.Angle = Owner.Angle; particleObject.target = Owner; particleObject.Scale = Owner.Scale; if (Owner == players[consoleplayer].camera && !(Owner.player.cheats & CF_CHASECAM)) { particleObject.bInvisible = true; } } } } class SnapDamagePowerup : SnapBigPowerup { Default { Inventory.PickupMessage "$POWERUP_DAMAGE"; SnapBigPowerup.VoiceSample "voice/damage"; Powerup.Type "SnapDamagePower"; } States { Spawn: PW_D A 10; PW_D A 10 Bright; Loop; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- // // Data / descriptor items // // // Background setter. // class OptionMenuItemSnapBG : SnapMenuItemBase { class mType; OptionMenuItemSnapBG Init(String type) { mType = type; return self; } override bool Selectable() { return false; } override void OnMenuCreated() { super.OnMenuCreated(); SnapMenuData MenuData = SnapMenuData.Get(); if (MenuData != null) { MenuData.SetBackground(mType); } } } // // Transition properties setter. // class OptionMenuItemSnapTransition : SnapMenuItemBase { enum TransitionTypes { TT_SLIDE, } uint mType; Vector2 mSlideDir; OptionMenuItemSnapTransition Init(uint Type, double SlideX = 0, double SlideY = 0) { mType = type; mSlideDir = (SlideX, SlideY); return self; } override bool Selectable() { return false; } } // // Tooltip disable. // class OptionMenuItemSnapNoTooltips : SnapMenuItemBase { OptionMenuItemSnapNoTooltips Init() { return self; } override bool Selectable() { return false; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- enum WeaponPatternTypes { WPT_SINGLEPLAYER, // Used in non-Deathmatch scenarios. WPT_NEUTRALSTART, // Simplified list for a neutral start. WPT_1V1_WINNING, // Winning in a 1v1. Also used if the players are tied. WPT_1V1_LOSING, // Losing in a 1v1 WPT_LEADER, // The most frags in a large game. WPT_WINNING, // Above-average frags in a large game. WPT_LOSING, // Losing a large game WPT__MAX, } class SnapDeathmatchCan : SnapItemCan { uint SpawnDelay; Default { DropItem "SnapDeathmatchWeapon"; +WEAPONSPAWN } void DMWeaponHide() { // Pesudo-death. Health = 0; bShootable = bFloat = bSkullFly = false; bDropoff = true; bKilled = true; bNoGravity = false; SetStateLabel("Hidden"); } void RestoreDMWeapon() { A_RestoreSpecialPosition(); A_StartSound("misc/spawn", CHAN_VOICE); Spawn("SnapItemFog", Pos, ALLOW_REPLACE); Vel.Z += 2; } States { Spawn: WP_X A 10; WP_X A 10 Bright; Loop; Death: ICAN B 1 Bright ItemCanDust(); ICAN B 0 ItemCanDestroy(); Hidden: TNT1 A -1; Stop; Raise: TNT1 A 0 RestoreDMWeapon(); Goto Spawn; } override void BeginPlay() { super.BeginPlay(); if (deathmatch == true) { DMWeaponHide(); } } override void Tick() { super.Tick(); if (isFrozen() == true) { return; } if (bKilled == true) { if (SpawnDelay > 0) { SpawnDelay--; } } else { SpawnDelay = 10*TICRATE; } } } class SnapDeathmatchWeapon : SnapInventory { const MAXSPINSPEED = 3; // 1 const STARTSPINSPEED = 12; const PROGRESSTIME = (30*TICRATE); const NEUTRALSTARTLEN = 1; // 2 const SPINOFFSET = 1; // Makes the fastest speed occur at 5min instead of 4.5. I'm picky :p Default { Inventory.MaxAmount 0; Inventory.PickupMessage ""; Inventory.RespawnTics -1; +INVENTORY.ALWAYSRESPAWN +INVENTORY.QUIET +WEAPONSPAWN +SnapInventory.PICKUPDESPAWNS } States { Spawn: WP_X B 10; WP_X B 10 Bright; Loop; } override void DoPickupSpecial(Actor toucher) { super.DoPickupSpecial(toucher); let sp = SnapPlayer(toucher); let player = toucher.player; if (sp != null && player != null) { if (sp.WeaponRoulette == true) { return; } let dmev = SnapEventHandler(EventHandler.Find("SnapEventHandler")); if (dmev == null) { return; } uint patternID = 0; if (deathmatch != true) { // Use the SP-specific all weapons fast pattern. sp.WRTics = sp.WRTicSpeed = MAXSPINSPEED; patternID = WPT_SINGLEPLAYER; } else { int RoundProgress = (dmev.LevelTimer / PROGRESSTIME); int RouletteSpeed = max(MAXSPINSPEED, STARTSPINSPEED - (RoundProgress - SPINOFFSET)); sp.WRTics = sp.WRTicSpeed = RouletteSpeed; if (RoundProgress < NEUTRALSTARTLEN) { // Neutral start weapons. patternID = WPT_NEUTRALSTART; } else { int BestFrags = 0; int WorstFrags = 9999999; uint NumPlayers = 0; for (uint i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i]) { continue; } NumPlayers++; BestFrags = max(BestFrags, players[i].fragcount); WorstFrags = min(WorstFrags, players[i].fragcount); } if (NumPlayers <= 2) { if (player.fragcount == BestFrags) { patternID = WPT_1V1_WINNING; } else { patternID = WPT_1V1_LOSING; } } else { int FragDiff = BestFrags - WorstFrags; double FragPos = 1.0; if (FragDiff > 0) { // 1.0 == the leader // 0.0 == last place FragPos = (player.fragcount - WorstFrags) / FragDiff; } if (FragPos >= 0.99) { // the 1% patternID = WPT_LEADER; } else if (FragPos >= 0.6) { // above average patternID = WPT_WINNING; } else { // losin' patternID = WPT_LOSING; } } } } sp.WRDelay = 16; sp.WRPattern = dmev.DMWeaponPatterns[patternID]; uint len = sp.WRPattern.List.Size(); sp.WRPos = sp.WROffset % len; sp.WROffset++; sp.WeaponRoulette = true; sp.A_StartSound("powerup/roulette", CHAN_ITEM, CHANF_UI|CHANF_LOCAL); GoAwayAndDie(); } } } class SnapDeathmatchPowerup : Actor { // Used to be an inventory item, // now it's a invisible spawn spot. uint SpawnDelay; const QUEUETIME = 10*TICRATE; const DELAYTIME = 5*TICRATE; Default { Radius 36; Height 72; +NOBLOCKMAP +NOGRAVITY +DONTSPLASH +INVISIBLE } States { Spawn: TNT1 A -1; Stop; } void CreateNewPowerupCopter() { uint listlen = 7; class bigPowerList[7]; bigPowerList[0] = "SnapSpeedPowerup"; bigPowerList[1] = "SnapSpeedPowerup"; bigPowerList[2] = "SnapShieldPowerup"; bigPowerList[3] = "SnapShieldPowerup"; bigPowerList[4] = "SnapDamagePowerup"; bigPowerList[5] = "SnapDogPowerup"; bigPowerList[6] = "SuperHealthUp"; uint r = random[snap_dmpowerup](0, listlen-1); Vector3 StartPos = Pos; if (bAmbush == false) { // Float flag StartPos += (0, 0, 256); } Actor Copter = Spawn("PowerupCopter", StartPos + (0, 0, 256), ALLOW_REPLACE); if (Copter != null) { Copter.A_StartSound("misc/swooce"); Actor Power = Spawn(bigPowerList[r], Copter.Pos, ALLOW_REPLACE); if (Power == null) { Copter.Destroy(); return; } let c = PowerupCopter(Copter); if (c != null) { c.DestPos = StartPos; c.ContainerSet(Power); } self.target = Power; //Copter } } override void BeginPlay() { super.BeginPlay(); SpawnDelay = DELAYTIME; } override void Tick() { super.Tick(); if (isFrozen() == true) { return; } if (target != null) { SpawnDelay = DELAYTIME; if (target.Health <= 0) { target = null; } } else { if (SpawnDelay > 0) { SpawnDelay--; } else { let dmev = SnapEventHandler(EventHandler.Find("SnapEventHandler")); if (dmev == null) { return; } if (dmev.LevelTimer % QUEUETIME == 0) { CreateNewPowerupCopter(); } } } } } class PowerupCopter : SnapMonster { Vector3 DestPos; Actor GlassOverlay; Default { Health 70; SnapMonster.Poise 0; Radius 36; Height 72; DeathSound "explosion/bigEnemy"; Speed 8; Mass 200; Species "PowerupCopter"; +FLOAT +NOGRAVITY -ISMONSTER -COUNTKILL +NOTARGETSWITCH +DONTTHRUST -SnapActor.CANDROPAMMO +SnapMonster.ISCONTAINER +SnapMonster.SHOWCONTENTS } States { Spawn: PWCP AEBFCGDD 1; PWCP AABECFDG 1; PWCP AGBBCEDF 1; PWCP AFBGCCDE 1; Loop; Death: PWCP A 1; PWCP A 0 CopterDeath(); PWCP AEBFCGDD 1; PWCP AABECFDG 1; PWCP AGBBCEDF 1; PWCP AFBGCCDE 1; PWCP AEBFCGDD 1; PWCP AABECFDG 1; PWCP AGBBCEDF 1; PWCP AFBGCCDE 1; Stop; } const GLASS_SPD = 16.0; void CopterDeath() { A_NoBlocking(); DoSnapBossDie(); Vel.Z -= 16.0; let c = PowerupCopter(self); if (c) { c.ContainerRelease(); if (c.GlassOverlay != null) { c.GlassOverlay.SetStateLabel("Death"); for (uint i = 0; i < 16; i++) { Actor shard = Spawn("PowerupCopterGlassShard", Pos + (0, 0, 24), ALLOW_REPLACE); shard.Roll = frandom[snap_decor](-180.0, 180.0); shard.Vel = ( frandom[snap_decor](-GLASS_SPD, GLASS_SPD), frandom[snap_decor](-GLASS_SPD, GLASS_SPD), frandom[snap_decor](0.0, GLASS_SPD) ); } } } } override bool ContainerSet(Actor mo) { if (GlassOverlay != null && mo == GlassOverlay) { return false; } bool result = super.ContainerSet(mo); if (result == true) { Vector2 MaxSize = ( 24, 40 ); Vector2 NewScale = ( MaxSize.X / mo.Radius, MaxSize.Y / mo.Height ); double ScaleMul = min(NewScale.X, NewScale.Y); if (ScaleMul < 1.0) { mo.Scale *= ScaleMul; } } return result; } override void ContainerUpdate() { ContainPower.SetOrigin(Pos + (0, 0, 8), true); } override void Tick() { super.Tick(); if (GlassOverlay != null) { GlassOverlay.bInvisible = bInvisible; GlassOverlay.bBright = bBright; GlassOverlay.Translation = Translation; } if (TickPaused() == true) { return; } if (Health <= 0) { //bInvisible = !bInvisible; DestPos += (Vel.X, Vel.Y, 10); } Vel *= 0.9; Vector3 NewPos = Pos + ((DestPos - Pos) * 0.2) + (0, 0, BobSin(Level.maptime) * 0.1); SetOrigin(NewPos, true); if (GlassOverlay != null) { GlassOverlay.SetOrigin(NewPos, true); } } override void BeginPlay() { super.BeginPlay(); DestPos = Pos; GlassOverlay = Spawn("PowerupCopterGlass", Pos, ALLOW_REPLACE); let sa = SnapActor(GlassOverlay); if (sa != null) { sa.SetHitstunParent(self); } } override void OnDestroy() { super.OnDestroy(); if (GlassOverlay != null) { GlassOverlay.Destroy(); } } } class PowerupCopterGlass : SnapActor { Default { Radius 36; Height 72; RenderStyle "Add"; +BRIGHT +NOINTERACTION +NOBLOCKMAP +NOGRAVITY +DONTSPLASH -SHOOTABLE +NONSHOOTABLE } States { Spawn: PWCP H -1; Stop; Death: PWCP I -1; Stop; } override void Tick() { super.Tick(); double a = 0.0, p = 0.0; PlayerInfo player = players[consoleplayer]; if (player && player.camera) { Vector3 result = Vec3To(player.camera).Unit(); a = VectorAngle(result.X, result.Y); p = VectorAngle(result.XY.Length(), -result.Z); } A_SetAngle(a, SPF_INTERPOLATE); A_SetPitch(p, SPF_INTERPOLATE); } } class PowerupCopterGlassShard : SnapDynamicDecor { Default { Radius 10; Height 10; RenderStyle "Add"; +RANDOMIZE +ROLLSPRITE +ROLLCENTER -NOGRAVITY } States { Spawn: PCSH ABCDEDCB 2; PCSH ABCDEDCB 2; Stop; AltSpawn: PCSH FGHIJIHG 2; PCSH FGHIJIHG 2; Stop; } override void BeginPlay() { super.BeginPlay(); if (random[snap_decor](0, 1)) { SetStateLabel("AltSpawn"); } } override void Tick() { super.Tick(); if (isFrozen() == true) { return; } A_SetRoll(Roll + 11.25, SPF_INTERPOLATE); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapDestructibleData play { Sector Origin; Array SecList; SnapHitstun Hitstun; Vector3 Pos; static void DoGenericQuake(Vector3 Location, double Dist, double Intensity, int Time) { let cp = players[consoleplayer]; if (cp == null || cp.mo == null) { return; } if (LevelLocals.Vec3Diff(cp.mo.Pos, Location).Length() > Dist) { return; } cp.mo.A_QuakeEx( Intensity, Intensity, Intensity, Time, 0, int(Dist), "", QF_SCALEDOWN, 1, 1, 1, int(Dist) ); } bool CheckDestruct() { if (Hitstun != null && Hitstun.Owner != null) { if (Hitstun.Active == true || Hitstun.Time > 0) { DoGenericQuake(Pos, 1280, 1, 2); return false; } } for (int i = 0; i < SecList.Size(); i++) { let sec = SecList[i]; SnapEventHandler.CreateBustUpParticles(Origin, sec, 32.0); } SnapEventHandler.Remove3DFloor(Origin); S_StartSound("explosion/boss", CHAN_VOICE, 0, 1.0, ATTN_NONE); DoGenericQuake(Pos, 1280, 9, TICRATE); return true; } } extend class SnapEventHandler { Array DestructiblesWaiting; int Is3DFloorDestructible(Sector sec) { return sec.GetUDMFInt("user_snapdestructible"); } void Try3DFloorDestruct(WorldEvent e) { if (e.DamageSector == null) { return; } if (e.DamageSectorPart != SECPART_3D) { return; } switch (Is3DFloorDestructible(e.DamageSector)) { case 2: { // Only destroy from explosions if (e.DamageIsRadius == false) { e.NewDamage = 0; } break; } case 1: { // It is destructible! break; } default: { // Not destructible return; } } if (e.DamageSector.GetHealth(SECPART_3D) > e.NewDamage) { return; } let NewData = SnapDestructibleData(new("SnapDestructibleData")); if (NewData == null) { return; } NewData.Origin = e.DamageSector; let sa = SnapActor(e.DamageSource); let sp = SnapPlayer(e.DamageSource); if (sp != null) { NewData.Hitstun = sp.Hitstun; } else if (sa != null) { NewData.Hitstun = sa.Hitstun; } for (int i = 0; i < e.DamageSector.GetAttachedCount(); i++) { let sec = e.DamageSector.GetAttached(i); NewData.SecList.Push(sec); } DestructiblesWaiting.Push(NewData); } void TickDestructibles() { for (int i = 0; i < DestructiblesWaiting.Size(); i++) { let Data = DestructiblesWaiting[i]; if (Data == null || Data.CheckDestruct() == true) { DestructiblesWaiting.Delete(i); i--; continue; } } } void ResetDestructibles() { for (int i = 0; i < DestructiblesWaiting.Size(); i++) { let Data = DestructiblesWaiting[i]; if (Data != null) { Data.Destroy(); } } DestructiblesWaiting.Clear(); } const DEFAULT_DESTRUCTIBLE_HP = 60; void InitDestructibles() { for (int i = 0; i < Level.Sectors.Size(); i++) { let sec = Level.Sectors[i]; if (Is3DFloorDestructible(sec) != 0) { int hp = sec.GetHealth(SECPART_3D); if (hp == 0) { // Set a reasonable default value. sec.SetHealth(SECPART_3D, DEFAULT_DESTRUCTIBLE_HP); } } } } void HitstunFromGeometry(WorldEvent e) { if (e.NewDamage > 0) { int stun = SnapActor.DoInflictorHitstun(e.NewDamage, e.DamageSource); SnapHitstunSpark.Create(stun, e.DamageSource); SnapActor.PlayDamageSound(e.NewDamage, null, e.DamageSource, e.DamageSource.Target); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class DevScruffie : SnapShadowActor { Default { Radius 16; Height 56; +SOLID } States { Spawn: DEVS BCDE 5; Loop; } } class DevOni : SnapShadowActor { Default { Radius 16; Height 56; +SOLID } States { Spawn: DEVO ABCD 2; Loop; } } class DevJeck : SnapShadowActor { Default { Radius 16; Height 56; +SOLID } States { Spawn: DEVJ BCDE 8; Loop; } } class DevDex : SnapShadowActor { Default { Radius 16; Height 56; +SOLID } States { Spawn: DEVD BCDEFG 4; Loop; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapDogPower : Powerup { mixin SnapPowerupFix; Array SummonedDogs; uint NumDogs; Default { Powerup.Duration -30; } Actor CreateDog() { if (Owner == null) { return null; } Actor dog = Spawn("PowerupScruffie", Owner.Pos, ALLOW_REPLACE); if (dog != null) { dog.CopyFriendliness(Owner, false); dog.tracer = Owner; Actor efx = Spawn("TerajoltTeleportEFX", Owner.Pos + (0, 0, Owner.Height * 0.5), ALLOW_REPLACE); SummonedDogs.Push(dog); let sp = SnapPlayer(Owner); if (sp != null) { dog.Translation = sp.GetDefaultTranslation(); } } return dog; } override void InitEffect() { super.InitEffect(); NumDogs++; } override bool HandlePickup(Inventory item) { bool result = NewPowerupLogic(item); if (item.GetClass() == GetClass()) { let power = Powerup(item); if (power.bPickupGood == true) { // Create a new dog every time it's picked up. // Does not run unless you pick up more than one, so InitEffect is still applicable. NumDogs++; } } return result; } override void DoEffect() { super.DoEffect(); if (Owner == null || Owner.player == null) { return; } if (EffectTics > 0) { uint DogSize = SummonedDogs.Size(); for (uint i = 0; i < DogSize; i++) { let dog = SummonedDogs[i]; if (dog == null || dog.Health == 0) { // Cleanup dogs list SummonedDogs.Delete(i); DogSize--; i--; } } int AddDogs = NumDogs - DogSize; while (AddDogs > 0) { CreateDog(); AddDogs--; } } } override void EndEffect() { super.EndEffect(); uint DogSize = SummonedDogs.Size(); if (DogSize > 0) { for (uint i = 0; i < DogSize; i++) { let dog = SummonedDogs[i]; if (dog != null && dog.Health > 0) { dog.Health = 0; dog.Die(null, null); } } } } } class SnapDogPowerup : SnapBigPowerup { Default { Inventory.PickupMessage "$POWERUP_DOG"; SnapBigPowerup.VoiceSample "voice/dog"; Powerup.Type "SnapDogPower"; } States { Spawn: PW_P A 10; PW_P A 10 Bright; Loop; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- // // ======== // MENU DRAWING FUNCTIONS // ======== // mixin class SnapMenuDrawing { const BASE_VID_WIDTH = 320.0; const BASE_VID_HEIGHT = 200.0; const BASE_VID_RATIO = BASE_VID_HEIGHT / BASE_VID_WIDTH; ui Vector2 RealSize; ui bool SkinnyRes; // For fixes for the remaining 4:3 people ui Vector2 VirtualSize; ui double VirtualScale; ui Vector2 VirtualOffset; enum StickerParts { STICKER_M, STICKER_L, STICKER_R, STICKER__MAX, } ui TextureID HeaderSticker[STICKER__MAX]; ui TextureID TextSticker[STICKER__MAX]; enum StickerType { STICKER_TYPE_HEADER, STICKER_TYPE_TEXT, STICKER_TYPE__MAX, } enum SliderParts { SLIDER_EMPTY, SLIDER_FULL, SLIDER_ARROWL, SLIDER_ARROWR, SLIDER__MAX, } ui TextureID Sliders[SLIDER__MAX]; const TOOLTIP_HEIGHT = 18; ui TextureID TooltipBG; ui Font FontHeader; ui Font FontMenu; ui Font FontBig; ui Font FontSmall; ui Font FontThin; ui int FontHighlightColor; ui int FontGrayColor; ui int FontHeaderColor; ui int PaletteizeMeCapn; ui void UpdateScaleParameters() { RealSize = ( Screen.GetWidth(), Screen.GetHeight() ); SkinnyRes = ((RealSize.Y / RealSize.X) > BASE_VID_RATIO); if (SkinnyRes) { VirtualScale = RealSize.X / BASE_VID_WIDTH; } else { VirtualScale = RealSize.Y / BASE_VID_HEIGHT; } VirtualSize = RealSize / VirtualScale; VirtualOffset = ( (VirtualSize.X - BASE_VID_WIDTH) * 0.5, (VirtualSize.Y - BASE_VID_HEIGHT) * 0.5 ); } ui void PrecacheMenuDrawing() { HeaderSticker[STICKER_M] = TexMan.CheckForTexture("HEADBGM", TexMan.Type_MiscPatch); HeaderSticker[STICKER_L] = TexMan.CheckForTexture("HEADBGL", TexMan.Type_MiscPatch); HeaderSticker[STICKER_R] = TexMan.CheckForTexture("HEADBGR", TexMan.Type_MiscPatch); TextSticker[STICKER_M] = TexMan.CheckForTexture("TXBGAM", TexMan.Type_MiscPatch); TextSticker[STICKER_L] = TexMan.CheckForTexture("TXBGAL", TexMan.Type_MiscPatch); TextSticker[STICKER_R] = TexMan.CheckForTexture("TXBGAR", TexMan.Type_MiscPatch); Sliders[SLIDER_EMPTY] = TexMan.CheckForTexture("SLIDER", TexMan.Type_MiscPatch); Sliders[SLIDER_FULL] = TexMan.CheckForTexture("SLIDEL", TexMan.Type_MiscPatch); Sliders[SLIDER_ARROWL] = TexMan.CheckForTexture("SARRL0", TexMan.Type_MiscPatch); Sliders[SLIDER_ARROWR] = TexMan.CheckForTexture("SARRR0", TexMan.Type_MiscPatch); TooltipBG = TexMan.CheckForTexture("TOOLTIP", TexMan.Type_MiscPatch); FontHeader = Font.GetFont("MenuHeader"); FontMenu = Font.GetFont("MenuFont"); FontBig = Font.GetFont("BigFont"); FontSmall = Font.GetFont("SmallFont"); FontThin = Font.GetFont("ThinFont"); FontHighlightColor = Font.FindFontColor("HPYellow"); FontGrayColor = Font.FindFontColor("HPDark"); FontHeaderColor = Font.FindFontColor("MenuLabel"); PaletteizeMeCapn = Translate.GetID("PaletteMe"); } ui Vector2 SnapMenuTextureSize(TextureID Tex) { int x, y; [x, y] = TexMan.GetSize(Tex); return (x, y); } ui void SnapMenuTexture(TextureID Tex, Vector2 Pos) { Screen.DrawTexture( Tex, true, Pos.X + VirtualOffset.X, Pos.Y + VirtualOffset.Y, DTA_TranslationIndex, PaletteizeMeCapn, DTA_VirtualWidthF, VirtualSize.X, DTA_VirtualHeightF, VirtualSize.Y, DTA_KeepRatio, true // I experimented with a lot of options to try and make // KeepRatio false look good, because it kind of DOES // bother me that the menus are a different ratio than // the rest of the game, but frankly, I can't stand it // on menus! ); } ui void SnapMenuTextureAlpha(TextureID Tex, Vector2 Pos, double Alpha) { Screen.DrawTexture( Tex, true, Pos.X + VirtualOffset.X, Pos.Y + VirtualOffset.Y, DTA_Alpha, Alpha, DTA_TranslationIndex, PaletteizeMeCapn, DTA_VirtualWidthF, VirtualSize.X, DTA_VirtualHeightF, VirtualSize.Y, DTA_KeepRatio, true ); } ui void SnapMenuTextureTranslated(TextureID Tex, Vector2 Pos, int Trans) { Screen.DrawTexture( Tex, true, Pos.X + VirtualOffset.X, Pos.Y + VirtualOffset.Y, DTA_TranslationIndex, Trans != 0 ? Trans : PaletteizeMeCapn, DTA_VirtualWidthF, VirtualSize.X, DTA_VirtualHeightF, VirtualSize.Y, DTA_KeepRatio, true ); } ui void SnapMenuText( Font fnt, int col, Vector2 Pos, String str, bool shadow = false) { Screen.DrawText( fnt, col, Pos.X + VirtualOffset.X, Pos.Y + VirtualOffset.Y, str, DTA_Shadow, shadow, DTA_TranslationIndex, PaletteizeMeCapn, DTA_VirtualWidthF, VirtualSize.X, DTA_VirtualHeightF, VirtualSize.Y, DTA_KeepRatio, true ); } ui Vector2 SnapMenuCharPatch( Font fnt, int charcode, Vector2 Pos, int trans = Font.CR_UNTRANSLATED) { int width = fnt.GetCharWidth(charcode); Screen.DrawChar( fnt, trans, Pos.X + VirtualOffset.X, Pos.Y + VirtualOffset.Y, charcode, DTA_TranslationIndex, PaletteizeMeCapn, DTA_VirtualWidthF, VirtualSize.X, DTA_VirtualHeightF, VirtualSize.Y, DTA_KeepRatio, true ); Pos.X -= width; return Pos; } ui Vector2 RightAlignPos(Font fnt, String str, Vector2 Pos) { int Width = fnt.StringWidth(str); return Pos - (Width, 0); } ui Vector2 CenterAlignPos(Font fnt, String str, Vector2 Pos) { int Width = fnt.StringWidth(str); return Pos - (Width * 0.5, 0); } ui void DrawSticker(Vector2 Center, uint Width, uint Type = STICKER_TYPE_HEADER) { TextureID Textures[STICKER__MAX]; switch (Type) { case STICKER_TYPE_HEADER: default: Textures[STICKER_M] = HeaderSticker[STICKER_M]; Textures[STICKER_L] = HeaderSticker[STICKER_L]; Textures[STICKER_R] = HeaderSticker[STICKER_R]; break; case STICKER_TYPE_TEXT: Textures[STICKER_M] = TextSticker[STICKER_M]; Textures[STICKER_L] = TextSticker[STICKER_L]; Textures[STICKER_R] = TextSticker[STICKER_R]; break; } if (Width == 0) { // span the entire screen size Width = Screen.GetWidth(); } Vector2 TexSize = SnapMenuTextureSize(Textures[STICKER_M]); uint NumParts = max(int(Width / TexSize.X), 1); Vector2 StartPos = Center - (TexSize.X * 0.5 * NumParts, 0); Vector2 Pos = StartPos; for (uint i = 0; i < NumParts; i++) { SnapMenuTexture(Textures[STICKER_M], Pos); Pos.X += TexSize.X; } Vector2 LSize = SnapMenuTextureSize(Textures[STICKER_L]); SnapMenuTexture(Textures[STICKER_L], StartPos - (LSize.X, 0)); SnapMenuTexture(Textures[STICKER_R], Pos); } ui void DrawMenuHeader(String str, Vector2 Pos, int col = Font.CR_UNTRANSLATED) { int Length = FontHeader.StringWidth(str); Vector2 Center = Pos + (Length * 0.5, 2.0); DrawSticker(Center, Length + 48, STICKER_TYPE_HEADER); SnapMenuText(FontHeader, col, Pos, str); } const CHAR_SPACE = 0x20; const CHAR_TAB = 0x09; const CHAR_LF = 0x0A; const CHAR_CR = 0x0D; const CHAR_QUESTION = 0x3F; ui String MakeSecretString(String Input) { String Output = ""; Input = Input.Filter(); for (uint i = 0; i < Input.Length();) { int chr, next; [chr, next] = Input.GetNextCodePoint(i); if (chr == CHAR_SPACE || chr == CHAR_TAB || chr == CHAR_LF || chr == CHAR_CR) { // Leave these alone! Output.AppendCharacter(chr); } else { // Replace actual characters with ??? Output.AppendCharacter(CHAR_QUESTION); } i = next; } return Output; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapBossTrail : SnapMonsterShrapnel { States { Spawn: TNT1 A 3; Goto Super::Spawn; } } class OceanBullet : SnapBasicShot { Default { DamageFunction 3; Speed 25; SeeSound "revolver/fire"; Obituary "$OB_BOSSMECH"; } } class OceanFlameSpawner : ArsonTopFlameSpawner { Default { Obituary "$OB_BOSSMECH"; //Speed 2; } States { Spawn: TNT1 A 1; TNT1 AAAAAAAAAAAAAAA 5 A_CreateFlame; TNT1 AAAAAAAAAAAAAAA 5 A_CreateFlame; Stop; } } class OceanLaser : TerajoltLaser { Default { Obituary "$OB_BOSSMECH"; } } class OceanBomb : SnapMissile { String OceanBombDrop; void OceanBombExplode() { for (int i = 0; i < 8; i++) { double a = i * 45; double h = 10; double v = 8; String type = "SnapDamageExplode"; Vector2 speed; if (i & 1) { h = 4; v = 12; type = "SnapDamageExplodeSmall"; } speed = AngleToVector(a, h); A_SpawnItemEx( type, 0, 0, 8, speed.x, speed.y, v ); } for (int i = 0; i < 8; i++) { double a = i * 45; Actor spawner = Spawn("OceanFlameSpawner", self.Pos, ALLOW_REPLACE); if (spawner) { spawner.A_StartSound(GetDefaultByType("OceanFlameSpawner").SeeSound); spawner.target = self.target; spawner.tracer = self.tracer; spawner.angle = self.angle + a; spawner.Vel.XY = AngleToVector(spawner.angle, spawner.Default.Speed); spawner.Vel.Z = self.Vel.Z + 6; } } A_SnapExplode(75, 192, XF_THRUSTZ|XF_CIRCULAR|XF_NOTMISSILE); if (OceanBombDrop.Length() > 0) { A_DropItem(OceanBombDrop); } } Default { Radius 18; Height 32; DamageFunction 10; Speed 15; SeeSound "revolver/explode"; Obituary "$OB_BOSSMECH"; WallBounceFactor 0.5; Projectile; +RANDOMIZE +BOUNCEONWALLS -NOGRAVITY } States { Spawn: OBOM A -1 Bright; Loop; Death: OBOM A 1; OBOM A 0 OceanBombExplode(); Stop; } } class HyperHoming : SnapMissile { void HyperHomingCheckOwner() { let t = DummyOcean(target); if (t && t.health > 0) { return; } // no owner ExplodeMissile(); } void HyperHomingSlow() { double spd = Default.Speed * 0.5; Vel = (spd * cos(Angle), spd * sin(Angle), 0.0); A_SpawnItemEx("CybrassShotTrail"); HyperHomingCheckOwner(); } void HyperHomingSeek() { A_SeekerMissile(10, 22, SMF_LOOK|SMF_PRECISE, 256); let trail = SnapActor(Spawn("CybrassShotTrail", self.Pos, ALLOW_REPLACE)); if (trail) { trail.SetPhysicalSize(Scale); } HyperHomingCheckOwner(); } void HyperHomingStop() { Vel.X = Vel.Y = Vel.Z = 0; A_FaceTracer(22.5); } Default { Radius 16; Height 32; DamageFunction 10; Speed 21.5; Scale 1.5; BounceFactor 0.0; WallBounceFactor 0.0; RenderStyle "Add"; SeeSound "revolver/homing"; DeathSound "revolver/death"; Obituary "$OB_BOSSMECH"; Species "Robot"; +RANDOMIZE +SEEKERMISSILE +SCREENSEEKER +BRIGHT } States { Spawn: HHOM ABCDEFABCDEF 2 Light("HyperHomingLight") HyperHomingSlow(); HHOM ABCDEFABCDEF 2 Light("HyperHomingLight") HyperHomingStop(); HHOM ABCDEFABCDEF 2 Light("HyperHomingLight") HyperHomingSeek(); HHOM ABCDEFABCDEF 2 Light("HyperHomingLight") HyperHomingStop(); HHOM ABCDEFABCDEF 2 Light("HyperHomingLight") HyperHomingSeek(); HHOM ABCDEFABCDEF 2 Light("HyperHomingLight") HyperHomingStop(); HHOM ABCDEFABCDEF 2 Light("HyperHomingLight") HyperHomingSeek(); HHOM ABCDEFABCDEF 2 Light("HyperHomingLight") HyperHomingStop(); HHOM ABCDEFABCDEF 2 Light("HyperHomingLight") HyperHomingSeek(); Death: HHOM A 0 HyperHomingStop(); HHOM GHGHIJIJKLKLMNMN 1 Light("HyperHomingLight"); Stop; } } class OceanRudeScreenClear : ScreenClear { Default { Speed 1.0; Translation "Ice"; Obituary "$OB_BOSSMECH"; } override double ScreenClearSize() { return SCVSFINALSIZE; } } class DummyOcean : SnapBoss { uint OceanPatternPos; uint OceanWeaponPos; uint OceanRapidTick; bool OceanDropsHealth; int OceanLaserSign; const OCEANCRASHMAX = 2000; const OCEANCRASHSEARCH = 384.0; uint OceanCrashMeter; bool OceanCrashReadySnd; const OCEANINITDELAYCALLS = 2; uint OceanInitDelay; bool OceanIntroFall; Default { Health 10000; Radius 48; Height 112; Speed 16; Mass 1000; WallBounceFactor 1.0; SnapMonster.Poise 600; SeeSound "boss/see"; PainSound "boss/hurt"; Obituary "$OB_BOSSMECH"; Tag "$TAG_BOSSMECH"; ReactionTime 16; +DONTTHRUST +MISSILEMORE +AVOIDMELEE +DONTCORPSE +SnapActor.CANDI +SnapMonster.ROBOTTOUGH } state PickOceanAttack() { OceanRapidTick = 10; A_PickBossTarget(); if (target == null) { OceanInitDelay = OCEANINITDELAYCALLS; return null; } if (OceanInitDelay > 0) { // Prevents his first attack's voice line from // interrupting his see sound OceanInitDelay--; return null; } state attackState = null; uint maxPattern = 0; if (bVeryRude == true && OceanCrashMeter >= OCEANCRASHMAX) { for (uint i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i]) { continue; } let mo = players[i].mo; if (mo != null && mo.Health > 0 && Distance3D(mo) < OCEANCRASHSEARCH) { // Close enough to crash. return ResolveState("RudeAtk"); } } } if (bBossHard == true) { statelabel AttackPattern[24]; maxPattern = 24; AttackPattern[0] = "BombSpread"; AttackPattern[1] = "Bomb"; AttackPattern[2] = "Rapid"; AttackPattern[3] = "Homing"; AttackPattern[4] = "Bomb"; AttackPattern[5] = "Laser"; AttackPattern[7] = "Bomb"; AttackPattern[8] = "Homing"; AttackPattern[9] = "Homing"; AttackPattern[10] = "Bomb"; AttackPattern[11] = "Rapid"; AttackPattern[12] = "Laser"; AttackPattern[13] = "Bomb"; AttackPattern[14] = "BombSpread"; AttackPattern[15] = "Laser"; AttackPattern[16] = "Bomb"; AttackPattern[17] = "BombSpread"; AttackPattern[18] = "Homing"; AttackPattern[19] = "BombSpread"; AttackPattern[20] = "Laser"; AttackPattern[21] = "Bomb"; AttackPattern[22] = "Rapid"; AttackPattern[23] = "Bomb"; attackState = ResolveState(AttackPattern[OceanPatternPos]); } else { statelabel AttackPattern[12]; maxPattern = 12; AttackPattern[0] = "Rapid"; AttackPattern[1] = "Bomb"; AttackPattern[2] = "Homing"; AttackPattern[3] = "Bomb"; AttackPattern[4] = "Rapid"; AttackPattern[5] = "Homing"; AttackPattern[6] = "Bomb"; AttackPattern[7] = "Rapid"; AttackPattern[8] = "Homing"; AttackPattern[9] = "Bomb"; AttackPattern[10] = "Homing"; AttackPattern[11] = "Rapid"; attackState = ResolveState(AttackPattern[OceanPatternPos]); } OceanPatternPos++; if (OceanPatternPos >= maxPattern) { OceanPatternPos = 0; } return attackState; } void OceanRapid(double a, bool altMode = false) { double BaseOffset = 0; Vector3 SpawnOffset = (44, -60, 0); double SpawnAngle = VectorAngle(SpawnOffset.X, SpawnOffset.Y) * 0.125; A_FaceTarget(11.25); if (altMode == true) { BaseOffset = -5.625; for (int i = 0; i < 2; i++) { A_SnapMonsterProjectile("OceanBullet", SpawnOffset, BaseOffset - SpawnAngle); BaseOffset += 11.25; } } else { BaseOffset = -11.25; for (int i = 0; i < 3; i++) { A_SnapMonsterProjectile("OceanBullet", SpawnOffset, BaseOffset - SpawnAngle); BaseOffset += 11.25; } } } state OceanRapidEnd() { if (OceanRapidTick > 0) { OceanRapidTick--; } else { return ResolveState("RapidEnd"); } return null; } void UpdateOceanLaserSign() { if (SnapUtils.SafeVec2Unit(target.Vel.XY) dot AngleToVector(angle + 90) < 0.0) { OceanLaserSign = -1; } else { OceanLaserSign = 1; } } void OceanLaserTurn(uint phase = 0) { if (target == null || target.Health <= 0) { return; } double a = 0.0; switch (phase) { case 0: a += 22.5; break; case 1: a -= 22.5; break; default: break; } a = AngleTo(target) + (a * OceanLaserSign); Angle = SnapUtils.AngleTowardsAngle(Angle, a); } void DoOceanLaser() { //OceanLaserTurn(phase); A_SnapMonsterProjectile("OceanLaser", (44, 60, 0), angle, 0, SMP_ABSOLUTEANGLE|SMP_ABSOLUTEPITCH|SMP_DONTAIM); } void OceanLongDelay() { ReactionTime = max(ReactionTime, Default.ReactionTime * 2); } void OceanBombSpread() { A_FaceTarget(45); for (int i = 0; i < 16; i++) { double a = (22.5 * i); Actor b = A_SnapMonsterProjectile("OceanBomb", (40, -20, 128), a); let bomb = OceanBomb(b); if (bomb) { if (i & 1) { bomb.Vel.Z = 30; } else { bomb.Vel.Z = 20; } } } OceanLongDelay(); } void DoOceanHyperHoming() { double a = 45; A_FaceTarget(); for (int i = 0; i < 4; i++) { A_SnapMonsterProjectile("HyperHoming", (40, 20, 128), a); a += 90; } } void DoOceanBomb(int item = 0) { A_FaceTarget(45); let bomb = OceanBomb(A_SnapMonsterProjectile("OceanBomb", (-72, 0, 64))); if (bomb) { bomb.Vel.Z = 20; switch (item) { case 2: if (OceanDropsHealth == true) { bomb.OceanBombDrop = "HealthUp"; } else { bomb.OceanBombDrop = ""; } OceanDropsHealth = !OceanDropsHealth; break; case 1: String WeaponPattern[9]; WeaponPattern[0] = "SnapRapidCan"; WeaponPattern[1] = "SnapSpreadCan"; WeaponPattern[2] = "SnapRapidCan"; WeaponPattern[3] = "SnapFlameCan"; WeaponPattern[4] = "SnapSpreadCan"; WeaponPattern[5] = "SnapMirrorCan"; WeaponPattern[6] = "SnapRapidCan"; WeaponPattern[7] = "SnapHomingCan"; WeaponPattern[8] = "SnapExplodeCan"; bomb.OceanBombDrop = WeaponPattern[OceanWeaponPos]; OceanWeaponPos++; if (OceanWeaponPos >= 9) { OceanWeaponPos = 0; } OceanLongDelay(); break; default: bomb.OceanBombDrop = ""; break; } } } void DoOceanRudeCrash() { OceanCrashMeter = 0; Actor powActor = Spawn("OceanRudeScreenClear", Pos + (0, 0, Height * 0.5), ALLOW_REPLACE); let pow = SnapActor(powActor); if (pow) { pow.target = self; pow.A_SnapScreenShake(1536.0, 1536.0, 9); } } void OceanAllowPoise(bool val) { bNoPain = !val; } void StartOceanFling() { A_FaceTarget(); Vel.Z = 48; Vel.XY = AngleToVector(random[snap_decor](0, 7) * 45, 16); DamageFlash = 0; A_SetTranslation(""); bBright = false; bCrashed = false; bDontCorpse = false; bCorpse = true; bBounceOnWalls = true; } const RAPIDSPREADB = 11.125; const RAPIDSPREADA = RAPIDSPREADB * 0.5; States { Spawn: BOS1 A 3 A_SnapMonsterLook(); BOS1 B 3; BOS1 A 3; BOS1 B 3; Loop; See: BOS1 CD 3 A_SnapChase(); Loop; Missile: BOS1 A 0 PickOceanAttack(); Goto See; Laser: BOS1 A 0 A_StartSound("boss/fire4"); BOS1 A 0 UpdateOceanLaserSign(); BOS1 EEEEEEEEEE 1 OceanLaserTurn(0); BOS1 FFFFFFFFFF 1 OceanLaserTurn(0); BOS1 GGGGGGGGGG 1 OceanLaserTurn(0); BOS1 HHHHHHHHHH 1 OceanLaserTurn(0); BOS1 JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ 1 OceanLaserTurn(0); BOS1 I 0 A_StartSound("prism/fire"); BOS1 IJIJIJIJIJIJIJIJIJIJ 1 Light("DummyOceanLaserMuzzleLight") DoOceanLaser(); BOS1 JJJJJJJJJJJJJJJJJJJJ 1 OceanLaserTurn(1); BOS1 I 0 A_StartSound("prism/fire"); BOS1 IJIJIJIJIJIJIJIJIJIJ 1 Light("DummyOceanLaserMuzzleLight") DoOceanLaser(); BOS1 JJJJJJJJJJJJJJJJJJJJ 1 OceanLaserTurn(2); BOS1 I 0 A_StartSound("prism/fire"); BOS1 IJIJIJIJIJIJIJIJIJIJ 1 Light("DummyOceanLaserMuzzleLight") DoOceanLaser(); BOS1 J 20; BOS1 K 5; Goto See; Rapid: BOS1 A 0 A_StartSound("boss/fire1"); BOS1 LLLLMMMMNNNNOOOO 1 A_FaceTarget(22.5); RapidLoop: BOS1 P 1 Light("DummyOceanRapidMuzzleLight") OceanRapid(0, false); BOS1 PP 1 Light("DummyOceanRapidMuzzleLight") A_FaceTarget(22.5); BOS1 Q 1 OceanRapid(0, true); BOS1 QQ 1 A_FaceTarget(22.5); BOS1 R 1 Light("DummyOceanRapidMuzzleLight") OceanRapid(RAPIDSPREADA, false); BOS1 RR 1 Light("DummyOceanRapidMuzzleLight") A_FaceTarget(22.5); BOS1 S 1 OceanRapid(RAPIDSPREADA, true); BOS1 SS 1 A_FaceTarget(22.5); BOS1 T 1 Light("DummyOceanRapidMuzzleLight") OceanRapid(RAPIDSPREADB, false); BOS1 TT 1 Light("DummyOceanRapidMuzzleLight") A_FaceTarget(22.5); BOS1 U 1 OceanRapid(RAPIDSPREADB, true); BOS1 UU 1 A_FaceTarget(22.5); BOS1 P 1 Light("DummyOceanRapidMuzzleLight") OceanRapid(0, false); BOS1 PP 1 Light("DummyOceanRapidMuzzleLight") A_FaceTarget(22.5); BOS1 Q 1 OceanRapid(0, true); BOS1 QQ 1 A_FaceTarget(22.5); BOS1 R 1 Light("DummyOceanRapidMuzzleLight") OceanRapid(-RAPIDSPREADB, false); BOS1 RR 1 Light("DummyOceanRapidMuzzleLight") A_FaceTarget(22.5); BOS1 S 1 OceanRapid(-RAPIDSPREADB, true); BOS1 SS 1 A_FaceTarget(22.5); BOS1 T 1 Light("DummyOceanRapidMuzzleLight") OceanRapid(-RAPIDSPREADA, false); BOS1 TT 1 Light("DummyOceanRapidMuzzleLight") A_FaceTarget(22.5); BOS1 U 1 OceanRapid(-RAPIDSPREADA, true); BOS1 UU 1 A_FaceTarget(22.5); BOS1 U 0 OceanRapidEnd(); BOS1 U 0 A_MonsterRefire(0, "RapidEnd"); Loop; RapidEnd: BOS1 V 3; Goto See; Homing: BOS1 A 0 A_StartSound("boss/fire3"); BOS2 A 6; BOS2 B 6; BOS2 C 60 Light("HyperHomingMuzzleLight") DoOceanHyperHoming(); BOS2 D 6; Goto See; BombSpread: BOS1 A 0 A_StartSound("boss/fire2"); BOS2 E 3; BOS2 F 3 OceanBombSpread(); BOS2 G 40; BOS2 H 3; Goto See; Bomb: BOS1 A 0 A_StartSound("boss/fire5"); BOS2 I 0 OceanAllowPoise(false); // Ensure you can't interrupt this really important attack BOS2 I 1 DoOceanBomb(0); BOS2 JKLMNOP 1; BOS2 I 1 DoOceanBomb(0); BOS2 JKLMNOP 1; BOS2 I 1 DoOceanBomb(2); BOS2 JKLMNOP 1; BOS2 I 1 DoOceanBomb(0); BOS2 JKLMNOP 1; BOS2 I 1 DoOceanBomb(0); BOS2 JKLMNOP 1; BOS2 I 1 DoOceanBomb(1); BOS2 JKLMNOP 1; BOS2 A 0 OceanAllowPoise(true); Goto See; RudeAtk: BOS2 I 0 A_StartSound("boss/crash"); BOS2 I 0 A_StartSound("boss/crashUse", CHAN_WEAPON); BOS2 I 24; // Wait a bit... BOS2 I 0 OceanAllowPoise(true); BOS2 I 70 DoOceanRudeCrash(); BOS2 I 0 OceanAllowPoise(false); Goto See; Pain: BOS2 Q 0 A_StopSound(CHAN_WEAPON); BOS2 Q 0 OceanAllowPoise(true); BOS2 Q 10 A_SnapMonsterPain(); Goto See; Death: BOS2 Q 1; BOS2 QQQQQ 4 DoSnapBossExplode(); BOS2 Q 4 DoSnapBossBigExplode(); BOS2 QQQQQ 4 DoSnapBossExplode(); BOS2 Q 4 DoSnapBossBigExplode(); BOS2 QQQQQ 4 DoSnapBossExplode(); BOS2 Q 4 DoSnapBossBigExplode(); BOS2 QQQQQ 4 DoSnapBossExplode(); BOS2 Q 4 DoSnapBossBigExplode(); BOS2 QQQQQ 4 DoSnapBossExplode(); BOS2 Q 0 DoSnapBossDie(); BOS2 Q 0 StartOceanFling(); DeathLoop: BOSD ABCDEFGHIJ 1 A_SpawnItemEx("SnapBossTrail"); BOSD J 0 A_StartSound("boss/death", CHAN_AUTO); Goto DeathLoop2; DeathLoop2: BOSD KLMNOPQRSTUVWXABCDEFGHIJ 1 A_SpawnItemEx("SnapBossTrail"); Loop; Crash: BOSD Y 70; BOSD Y -1 A_BossDeath(); Stop; IntroFall: BOS2 J -1; Loop; IntroLand: BOS2 N 15; Goto See; } override void PostBeginPlay() { super.PostBeginPlay(); OceanInitDelay = OCEANINITDELAYCALLS; if (bVeryRude == true) { OceanCrashMeter = OCEANCRASHMAX; } } override void Deactivate(Actor activator) { super.Deactivate(activator); bNoGravity = true; bInvisible = true; if (Pos.Z > FloorZ) { OceanIntroFall = true; SetStateLabel("IntroFall"); } } override void Activate(Actor activator) { super.Activate(activator); bNoGravity = Default.bNoGravity; bInvisible = Default.bInvisible; if (OceanIntroFall == true) { A_SnapMonsterLook(SeeFOV: 360); if (target != null) { A_FaceTarget(); } } } override void Tick() { super.Tick(); if (Health <= 0) { OceanCrashMeter = 0; return; } if (bDormant == true) { return; } if (OceanIntroFall == true) { if (Pos.Z <= FloorZ) { A_StartSound("auger/drop", CHAN_BODY, 0, 1.0, ATTN_NONE); SetStateLabel("IntroLand"); OceanIntroFall = false; } else { bool ok = false; Actor below = null; [ok, below] = TestMobjZ(true); if (below != null && below.Health > 0 && below.bShootable == true) { below.DamageMobj(self, self, TELEFRAG_DAMAGE, "Crush"); } } } if (TickPaused() == true) { return; } if (bVeryRude == false) { OceanCrashMeter = 0; return; } if (OceanCrashMeter < OCEANCRASHMAX) { OceanCrashMeter++; } if (OceanCrashMeter >= OCEANCRASHMAX) { if (OceanCrashReadySnd == false) { A_StartSound("boss/crashReady", CHAN_WEAPON); OceanCrashReadySnd = true; } if (Level.maptime % 7 == 0) { double a = Level.maptime * (360 / (TICRATE * 0.1)); if (Level.maptime & 2) { a += 90; } for (int i = 0; i < 2; i++) { let Particle = Spawn("ScreenClearParticle", Pos, ALLOW_REPLACE); if (Particle != null) { Particle.Scale *= 0.5; Particle.A_SetTranslation("Ice"); Particle.Target = self; Particle.Angle = a + 90; Particle.bInvisible = true; let scp = ScreenClearParticle(Particle); if (scp) { scp.SCPSpin = a; scp.SCPDist = Radius * 3.0; scp.Vel.Z = 8.0; scp.SCPBlink = (i == 0); } } a += 180; } } } else { OceanCrashReadySnd = false; } } override int TakeSpecialDamage(Actor inflictor, Actor source, int dmg, Name mod) { int result = super.TakeSpecialDamage(inflictor, source, dmg, mod); if (bVeryRude == true && result > 0) { OceanCrashMeter += result; if (OceanCrashMeter > OCEANCRASHMAX) { OceanCrashMeter = OCEANCRASHMAX; } } return result; } override Actor CreateShiftDIGhost(Vector3 SpawnPos) { return DefaultShiftDIGhost("DummyOceansGhost", SpawnPos, Pos, true); } } class DummyOceansGhost : SnapDIGhostBase { Default { StencilColor "94 94 ac"; } States { Spawn: BOS2 Q 8; Stop; LoadSprites: BOS1 A 0; BOS2 A 0; BOSD A 0; Stop; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class OilRoboCutscene : SnapCutsceneBase { Actor OurOilRobo; Default { +NOSECTOR +INVISIBLE +NOGRAVITY } void CreateOilRobo() { Vector3 SpawnPos = Pos; SpawnPos.Z = CeilingZ - GetDefaultByType("OilRobo").Height; OurOilRobo = Spawn("OilRobo", SpawnPos, ALLOW_REPLACE); let oor = OilRobo(OurOilRobo); if (oor != null) { oor.Angle = self.SpawnAngle; oor.DestZ = self.Pos.Z; oor.A_StartSound("misc/swooce"); } } state OilRoboStatus() { let oor = OilRobo(OurOilRobo); if (oor == null || oor.Health <= 0) { if (bAmbush == true) { /* bool DontPlay = false; if (target == null || target.Health <= 0) { DontPlay = true; } else { if (Distance2D(target) > 768.0 && CheckSight(target) == false) { DontPlay = true; } } if (DontPlay == false) { if (G_SkillPropertyInt(SKILLP_FastMonsters) == true) { return ResolveState("RudeVA"); } else { return ResolveState("EndVA"); } } */ if (G_SkillPropertyInt(SKILLP_FastMonsters) == true) { bool DontPlay = false; if (target == null || target.Health <= 0) { DontPlay = true; } else { if (Distance2D(target) > 768.0 && CheckSight(target) == false) { DontPlay = true; } } if (DontPlay == false) { return ResolveState("RudeVA"); } } } return ResolveState("End"); } return null; } States { Spawn: TNT1 A 5 A_CutsceneLook(); Loop; See: TNT1 A 70; TNT1 A 1 CreateOilRobo(); OilRoboCheck: TNT1 A 5 OilRoboStatus(); Loop; End: TNT1 A 1 A_CutsceneEnd(); Stop; EndVA: TNT1 A 70; TNT1 A 0 A_CutsceneVoice("cutscene/e1m1a/1", true, "$CUTSCENE_E1M1A_1", 80); TNT1 A 90; TNT1 A 0 A_CutsceneVoice("cutscene/e1m1a/2", true, "$CUTSCENE_E1M1A_2A", 60); TNT1 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M1A_2B", 60); TNT1 A 145; TNT1 A 0 A_CutsceneVoice("cutscene/e1m1a/3", true, "$CUTSCENE_E1M1A_3A", 36); TNT1 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M1A_3B", 60); TNT1 A 115; TNT1 A 70 A_CutsceneVoice("cutscene/e1m1a/4", true, "$CUTSCENE_E1M1A_4", 60); TNT1 A 1 A_CutsceneEnd(true); Stop; RudeVA: TNT1 A 70; TNT1 A 0 A_CutsceneSubtitle("$CUTSCENE_SNAPDOTDOTDOT", 55); TNT1 A 55; TNT1 A 70 A_CutsceneVoice("cutscene/e1m1a/5", true, "$CUTSCENE_E1M1A_5", 70); TNT1 A 1 A_CutsceneEnd(true); Stop; } } class OilRobo : SnapMonster { double DestZ; bool FlyAway; OilRoboBarrel OurBarrel; // This is duplicated from the Guard Robo definition... // Maybe move to SnapMonster so they can share? action void A_GuardJetpackPuffs(double momentum) { if (Level.maptime & 1) { return; } double a = angle + 180.0; double dist = 16.0; Vector3 offset = ( dist * cos(a), dist * sin(a), height * 0.75 ); Actor particle = Spawn("SnapSmoke", Pos + offset, ALLOW_REPLACE); if (particle) { particle.Vel.Z -= momentum + random[snap_decor](-1, 1); particle.Vel.XY += ( random[snap_decor](-1, 1), random[snap_decor](-1, 1) ); } } action void A_OilRoboFlyAway() { let us = OilRobo(self); if (us == null) { return; } us.DestZ = CeilingZ - Height; us.FlyAway = true; A_StartSound("misc/swooce"); } action void A_OilDumping(bool input) { let us = OilRobo(self); if (us == null) { return; } let barrel = OilRoboBarrel(us.OurBarrel); if (barrel != null) { if (input == true) { A_StartSound(SeeSound); barrel.DestRoll = 180.0; } else { A_StartSound(ActiveSound); ACS_ScriptCall("OilRoboDone"); } barrel.DumpingOil = input; } } action void A_DestroyOurBarrel() { let us = OilRobo(self); if (us == null) { return; } if (us.OurBarrel != null) { us.OurBarrel.A_Die(); } } Default { Health 1; Radius 28; Height 72; Speed 8; Mass 200; SnapMonster.Poise 0; SeeSound "guardRobo/see"; ActiveSound "guardRobo/idle"; PainSound "guardRobo/hurt"; Obituary "$OB_GUARDROBO"; Species "Robot"; DropItem "HealthUp"; +NOPAIN +NOGRAVITY +DONTTHRUST -COUNTKILL -SnapActor.CANDROPAMMO } States { Spawn: ORBO ABCD 4; ORBO ABCD 4; ORBO ABCD 4; ORBO ABCD 4; ORBO ABCD 4; ORBO A 0 A_OilDumping(true); ORBO ABCD 4; ORBO ABCD 4; ORBO ABCD 4; ORBO ABCD 4; ORBO ABCD 4; ORBO ABCD 4; ORBO A 0 A_OilDumping(false); ORBO ABCD 4; ORBO A 0 A_OilRoboFlyAway(); FlyLoop: ORBO ABCD 4; Loop; Kicked: ORBO E 3; ORBO E 3 A_Pain(); KickLoop: ORBO E 3 A_EndKick(); Loop; Death: ORBO E 1 A_Pain(); TNT1 A 0 A_DestroyOurBarrel(); TNT1 A 35 DoSnapMonsterDie(); Stop; } override void BeginPlay() { super.BeginPlay(); OurBarrel = OilRoboBarrel(Spawn("OilRoboBarrel", Pos, ALLOW_REPLACE)); if (OurBarrel != null) { OurBarrel.tracer = self; OurBarrel.SetHitstunParent(self); } } override void OnDestroy() { super.OnDestroy(); if (OurBarrel != null && OurBarrel.Health > 0) { OurBarrel.Destroy(); } } override void Tick() { super.Tick(); if (TickPaused() == true || Health <= 0) { return; } A_GuardJetpackPuffs(4.0); double ZDiff = (DestZ - Pos.Z); Vel.Z = ZDiff * 0.1; if (FlyAway == true) { if (ZDiff <= 8.0) { Destroy(); return; } } else if (OurBarrel == null || OurBarrel.Health <= 0) { A_OilRoboFlyAway(); } } override bool CanCollideWith(Actor other, bool passive) { if (other is "OilRoboBarrel") { return false; } return super.CanCollideWith(other, passive); } } class OilRoboDrops : Actor { Default { Projectile; +THRUACTORS -NOGRAVITY } States { Spawn: OBUB ABCDE 1; Loop; Death: TNT1 A 1; Stop; } } class OilRoboBarrel : SnapBarrel { bool DumpingOil; double DestRoll; Default { Health 1; +NOGRAVITY //-SHOOTABLE +ROLLSPRITE +ROLLCENTER +SnapMonster.ROBOTTOUGH +SnapMonster.ROBOTEXPLODES } States { Death: BARL A 1; BARL A 1 DoSnapMonsterDie(); TNT1 A 35; Stop; } const BARRELSPIN = 22.5; const OILH = 3.0; const OILVMIN = 1.0; const OILVMAX = 2.0; const OILRAD = 32.0; override void Tick() { super.Tick(); if (TickPaused() == true || Health <= 0) { return; } if (tracer != null) { Vector3 NewPos = tracer.Pos; NewPos.XY += ( cos(tracer.Angle), sin(tracer.Angle) ) * 64.0; NewPos.Z += tracer.Height * 0.5; /* if (DumpingOil == true) { NewPos.Z += sin(Level.maptime * 128.0) * 8.0; } */ SetOrigin(NewPos, true); } double Delta = -DeltaAngle(Roll, DestRoll); if (BARRELSPIN < abs(Delta)) { if (Delta > 0) { A_SetRoll(Roll - BARRELSPIN, SPF_INTERPOLATE); } else { A_SetRoll(Roll + BARRELSPIN, SPF_INTERPOLATE); } } else { A_SetRoll(DestRoll, SPF_INTERPOLATE); } if (DumpingOil == true && (Level.maptime & 1)) { Vector3 oilPos = Pos - (0, 0, 16); double oilAng = random[snap_decor](0, 359); double oilDis = random[snap_decor](0, OILRAD); oilPos.XY += ( cos(oilAng), sin(oilAng) ) * oilDis; Actor oil = Spawn("OilRoboDrops", oilPos, ALLOW_REPLACE); if (oil != null) { oil.Vel = ( random[snap_decor](-OILH, OILH), random[snap_decor](-OILH, OILH), random[snap_decor](-OILVMAX, -OILVMIN) ); } } } } class OceanTeleportCutscene : SnapCutsceneBase { bool TurnPlease; void OceanTurns() { TurnPlease = true; } void OceanTeleports() { Actor teleEFX = Spawn("SnapTeleportFog", Pos, ALLOW_REPLACE); } States { Spawn: CS11 ABCD 5 A_CutsceneLook(LongState: "Long"); Loop; See: CS11 A 0 A_PauseTimer(true); CS11 A 0 OceanTurns(); CS11 ABCD 5; CS11 ABCD 5; CS11 ABCD 5; CS11 F 32; CS11 G 16; CS11 H 30; CS11 H 0 OceanTeleports(); CS11 H 30; CS11 H 0 A_PauseTimer(false); CS11 H 0 A_CutsceneEnd(); Stop; Long: CS11 A 0 A_PauseTimer(true); CS11 A 0 A_CutsceneVoice("cutscene/e1m1b/1", true, "$CUTSCENE_E1M1B_1", 70); CS11 ABCD 5; CS11 ABCD 5; CS11 ABCD 5; CS11 ABCD 5; CS11 A 0 A_CutsceneVoice("cutscene/e1m1b/2", true, "$CUTSCENE_E1M1B_2A", 60); CS11 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M1B_2B", 60); CS11 ABCD 5; CS11 ABCD 5; CS11 ABCD 5; CS11 ABCD 5; CS11 ABCD 5; CS11 ABCD 5; CS11 A 0 OceanTurns(); CS11 A 0 A_CutsceneVoice("cutscene/e1m1b/3", false, "$CUTSCENE_E1M1B_3A", 115); CS11 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M1B_3B", 65); CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AE 5; CS11 A 0 A_CutsceneVoice("cutscene/e1m1b/4", true, "$CUTSCENE_E1M1B_4A", 65); CS11 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M1B_4B", 80); CS11 ABCD 5; CS11 ABCD 5; CS11 ABCD 5; CS11 ABCD 5; CS11 ABCD 5; CS11 ABCD 5; CS11 ABCD 5; CS11 ABCD 5; CS11 A 0 A_CutsceneVoice("cutscene/e1m1b/5", false, "$CUTSCENE_E1M1B_5A", 115); CS11 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M1B_5B", 85); CS11 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M1B_5C", 65); CS11 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M1B_5D", 115); CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 A 0 A_CutsceneVoice("cutscene/e1m1b/6", false, "$CUTSCENE_E1M1B_6A", 50); CS11 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M1B_6B", 90); CS11 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M1B_6C", 60); CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 AEAEAE 5; CS11 A 0 A_CutsceneVoice("cutscene/e1m1b/7", true, "$CUTSCENE_E1M1B_7", 40); CS11 F 32; CS11 G 16; CS11 H 30; CS11 H 0 OceanTeleports(); CS11 H 30; TNT1 A 80 A_CutsceneVoice("cutscene/e1m1b/8", true, "$CUTSCENE_E1M1B_8", 80); TNT1 A 80 A_CutsceneVoice("cutscene/e1m1b/9", true, "$CUTSCENE_E1M1B_9", 80); TNT1 A 0 A_PauseTimer(false); TNT1 A 0 A_CutsceneEnd(true); Stop; } override void Tick() { super.Tick(); if (TickPaused() == true) { return; } if (target != null && TurnPlease == true) { A_FaceTarget(16.875); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class OceanMonologueCutscene : SnapCutsceneBase { States { Spawn: TNT1 A 1 A_CutsceneLook(LongState: "Long"); Loop; See: // Only a boss warning. TNT1 A 0 A_PauseTimer(true); TNT1 A (3*TICRATE) StartBossWarning(); TNT1 A 0 A_PauseTimer(false); TNT1 A 0 A_CutsceneEnd(); Stop; Long: TNT1 A 0 A_PauseTimer(true); TNT1 A 0 A_CutsceneVoice("cutscene/e1m10/1", true, "$CUTSCENE_E1M10_1", 90); TNT1 A 90; TNT1 A 0 A_CutsceneVoice("cutscene/e1m10/2", false, "$CUTSCENE_E1M10_2A", 115); TNT1 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M10_2B", 45); TNT1 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M10_2C", 60); TNT1 A 210; TNT1 A 0 A_CutsceneVoice("cutscene/e1m10/3", true, "$CUTSCENE_E1M10_3A", 50); TNT1 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M10_3B", 50); TNT1 A 100; TNT1 A 0 A_CutsceneVoice("cutscene/e1m10/4", false, "$CUTSCENE_E1M10_4A", 100); TNT1 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M10_4B", 105); TNT1 A 160; TNT1 A (3*TICRATE) StartBossWarning(); TNT1 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M10_5", 70); TNT1 A 0 A_PauseTimer(false); TNT1 A 0 A_CutsceneEnd(true); Stop; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class OceanJetpackCutsceneBase : SnapCutsceneBase abstract { const PUFFDIST = 40.0; const PUFFHEIGHT = -16.0; const PUFFANGLE = 22.5; const JETHEIGHT = 24.0; double JetZ; double JetThrust; property JetThrust: JetThrust; double DecelThrust; property DecelThrust: DecelThrust; Default { Radius 32; Height 56; Gravity 0.5; Speed 16.0; OceanJetpackCutsceneBase.JetThrust 3.0; OceanJetpackCutsceneBase.DecelThrust 3.0; } void JetpackPuff(double momentum) { double a = angle + 180.0; if (Level.maptime & 1) { a -= PUFFANGLE; } else { a += PUFFANGLE; } Vector3 offset = ( PUFFDIST * cos(a), PUFFDIST * sin(a), PUFFHEIGHT ); Actor particle = Spawn("SnapMonsterExplodeSmall", Pos + offset, ALLOW_REPLACE); if (particle) { particle.Vel.Z -= momentum + random[snap_decor](-1, 1); particle.Vel.XY += ( random[snap_decor](-1, 1), random[snap_decor](-1, 1) ); } } override void Tick() { super.Tick(); if (TickPaused() == true) { return; } double mul = 0.0; if (JetZ - Pos.Z > JETHEIGHT) { if (Vel.Z < 0.0) { mul = DecelThrust; } else { mul = JetThrust; } } if (mul > 0.0) { Vel.Z += Gravity * mul; JetpackPuff(mul); } } override void PostBeginPlay() { super.PostBeginPlay(); JetZ = Pos.Z + (JETHEIGHT * 2.0); } } class OceanJetpackBomb : SnapMissile { action void A_JetpackBombExplode() { A_SnapScreenShake(1280, 1536, 5.0, 1.0); for (int i = 0; i < 8; i++) { double a = i * 45; double h = 10; double v = 8; Vector2 speed; if (i & 1) { h = 4; v = 12; } speed = AngleToVector(a, h); class type = "SnapMonsterExplode"; double zh = 8 - (GetDefaultByType(type).Height * 0.5); Actor particle = Spawn(type, Pos + (0, 0, zh), ALLOW_REPLACE); particle.Vel = (speed.x, speed.y, v); } for (int i = 0; i < 8; i++) { double a = (i * 45) + 22.5; double h = 4; double v = 12; Vector2 speed; if (i & 1) { h = 16; v = 16; } speed = AngleToVector(a, h); class type = "SnapMonsterExplode"; double zh = 8 - (GetDefaultByType(type).Height * 0.5); Actor particle = Spawn(type, Pos + (0, 0, zh), ALLOW_REPLACE); particle.Vel = (speed.x, speed.y, v); } double starta = random[snap_decor](0,7) * 45; for (int i = 0; i < 4; i++) { double a = starta + (i * 90); double h = 12; double v = 16; Vector2 speed; speed = AngleToVector(a, h); class type = "SnapMonsterShrapnelSpawner"; double zh = 8 - (GetDefaultByType(type).Height * 0.5); Actor particle = Spawn(type, Pos + (0, 0, zh), ALLOW_REPLACE); particle.Vel = (speed.x, speed.y, v); } } Default { Radius 18; Height 32; Damage 0; Speed 15; Projectile; SeeSound "revolver/flame"; DeathSound "explosion/bigEnemy"; +RANDOMIZE +BOUNCEONWALLS -NOGRAVITY +THRUACTORS } States { Spawn: OBOM A -1 Bright; Loop; Death: OBOM A 1; OBOM A 0 A_JetpackBombExplode(); TNT1 A 35; Stop; } } class OceanJetpackBombCutscene : OceanJetpackCutsceneBase { const NUMBOMBS = 4; const DIPTICKS = 48; const DIPMUL = 3.0; Actor Bombs[NUMBOMBS]; bool LiftOff; uint LiftOffPushDown; action void A_OceanBombs(uint i) { let us = OceanJetpackBombCutscene(self); if (us == null) { return; } let NewBomb = Spawn("OceanJetpackBomb", Pos + (0, 0, Height), ALLOW_REPLACE); if (NewBomb != null) { double cone = 22.5; if (i > 1) { cone *= 2.0; } if (i & 1) { cone = -cone; } NewBomb.Angle = Angle + cone; NewBomb.Vel.XY = NewBomb.Speed * ( cos(NewBomb.Angle), sin(NewBomb.Angle) ); NewBomb.Vel.Z = 10.0; PlaySpawnSound(NewBomb); us.Bombs[i] = NewBomb; } } action state A_CheckOceanBombs(StateLabel JumpState = "BombsDone") { let us = OceanJetpackBombCutscene(self); if (us == null) { return null; } for (uint i = 0; i < NUMBOMBS; i++) { let bomb = us.Bombs[i]; if (bomb != null && bomb.Health > 0 && bomb.bMissile == true) { // Wait until all bombs land. return null; } } // All exploded, move on. return ResolveState(JumpState); } action void A_OceanLiftoff() { let us = OceanJetpackBombCutscene(self); if (us == null) { return; } us.JetZ = GetZAt(0, 0, 0, GZF_CEILING) - (Height * 1.5); us.LiftOff = true; us.LiftOffPushDown = DIPTICKS; Vel.XY = -2.0 * ( cos(angle), sin(angle) ); } States { Spawn: CS15 AB 3 A_CutsceneLook(LongState: "Long"); Loop; See: CS15 A 0 A_PauseTimer(true); CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 D 2; CS15 D 0 A_OceanBombs(0); CS15 EFG 2; CS15 H 4; CS15 D 2; CS15 D 0 A_OceanBombs(1); CS15 EFG 2; CS15 H 4; CS15 D 2; CS15 D 0 A_OceanBombs(2); CS15 EFG 2; CS15 H 4; CS15 D 2; CS15 D 0 A_OceanBombs(3); CS15 EFG 2; CS15 H 16; CS15 A 0 StartBossWarning(); Goto BombCheck; BombCheck: CS15 AB 3 A_CheckOceanBombs(); Loop; BombsDone: CS15 A 0 A_CutsceneVoice("cutscene/e1m5/x", false); CS15 A 0 A_PauseTimer(false); CS15 A 0 A_CutsceneEnd(); // Run the cutscene end special. CS15 A 0 A_OceanLiftoff(); Goto Liftoff; Long: CS15 A 0 A_PauseTimer(true); CS15 A 0 A_CutsceneVoice("cutscene/e1m5/1", true, "$CUTSCENE_E1M5_1", 40); CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 AB 3; CS15 A 0 A_CutsceneVoice("cutscene/e1m5/2", false, "$CUTSCENE_E1M5_2A", 85); CS15 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M5_2B", 65); CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 AC 5; CS15 A 0 A_CutsceneVoice("cutscene/e1m5/3", false, "$CUTSCENE_E1M5_3A", 95); CS15 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M5_3B", 95); CS15 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M5_3C", 65); CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 A 0 A_CutsceneVoice("cutscene/e1m5/4", true, "$CUTSCENE_E1M5_4A", 60); CS15 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M5_4B", 65); CS15 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M5_4C", 50); CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 ABAB 3; CS15 A 0 A_CutsceneVoice("cutscene/e1m5/5", false, "$CUTSCENE_E1M5_5A", 140); CS15 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M5_5B", 95); CS15 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M5_5C", 60); CS15 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M5_5D", 65); CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 A 0 A_CutsceneVoice("cutscene/e1m5/6", false, "$CUTSCENE_E1M5_6A", 150); CS15 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M5_6B", 110); CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 D 2; CS15 D 0 A_OceanBombs(0); CS15 EFG 2; CS15 H 4; CS15 D 2; CS15 D 0 A_OceanBombs(1); CS15 EFG 2; CS15 H 4; CS15 A 0 A_CutsceneVoice("cutscene/e1m5/7", true, "$CUTSCENE_E1M5_7", 40); CS15 D 2; CS15 D 0 A_OceanBombs(2); CS15 EFG 2; CS15 H 4; CS15 D 2; CS15 D 0 A_OceanBombs(3); CS15 EFG 2; CS15 H 16; Goto LongBombCheck; LongBombCheck: CS15 AB 3 A_CheckOceanBombs("LongBombsDone"); Loop; LongBombsDone: CS15 A 0 A_QuakeEx( 1, 1, 9, 180, 0, 2048, "grumble"); CS15 A 0 A_CutsceneVoice("cutscene/e1m5/8", false, "$CUTSCENE_E1M5_8", 175); CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 A 0 StartBossWarning(); CS15 ACAC 5; CS15 A 0 A_PauseTimer(false); CS15 A 0 A_CutsceneEnd(true); CS15 A 0 A_CutsceneVoice("cutscene/e1m5/9", false, "$CUTSCENE_E1M5_9", 90); CS15 ACAC 5; CS15 ACAC 5; CS15 A 0 A_OceanLiftoff(); CS15 ACAC 5; CS15 ACAC 5; CS15 ACAC 5; CS15 A 0 A_CutsceneVoice("cutscene/e1m5/10", true, "$CUTSCENE_E1M5_10", 100); Goto Liftoff; Liftoff: CS15 AB 3; // Liftoff into the sunset. Loop; } override void Tick() { super.Tick(); if (TickPaused() == true) { return; } if (LiftOffPushDown > 0) { // Dip down before taking off. Vel.Z -= Gravity * ((DIPMUL * LiftOffPushDown) / DIPTICKS); LiftOffPushDown--; } if (Liftoff == true && Pos.Z > JetZ) { Destroy(); return; } } } class OceanJetpackFollowCutscene : OceanJetpackCutsceneBase { bool FollowPath; Default { //Gravity 2; OceanJetpackCutsceneBase.JetThrust 1.5; OceanJetpackCutsceneBase.DecelThrust 3.0; } action void A_OceanFollowPath() { let us = OceanJetpackFollowCutscene(self); if (us != null) { us.FollowPath = true; } } States { Spawn: CS15 AB 3 A_CutsceneLook(); Loop; See: CS15 A 0 A_OceanFollowPath(); Follow: CS15 AB 3; Loop; Death: CS15 ABABABABAB 3 A_SetRenderStyle(Alpha - 0.1, STYLE_Translucent); Stop; } override void Tick() { super.Tick(); if (TickPaused() == true || Health <= 0) { return; } if (FollowPath == true) { if (Goal == null) { Vel.XY = (0, 0); SetStateLabel("Death"); FollowPath = false; return; } JetZ = Goal.Pos.Z; Vector2 DirTo = Vec2To(Goal); A_SetAngle(SnapUtils.AngleTowardsDir(Angle, DirTo, 4.0), SPF_INTERPOLATE); bool touching = true; if (DirTo.Length() <= Radius * 8.0) { Vel.XY *= 0.9; } else { Vel.XY = DirTo.Unit() * Speed; touching = false; } if (Pos.Z > Goal.Pos.Z + Goal.Height || Pos.Z + Height < Goal.Pos.Z) { touching = false; } if (touching == true) { // Go to the next patrol point. let iterator = Level.CreateActorIterator(goal.args[0], "PatrolPoint"); let specit = Level.CreateActorIterator(goal.TID, "PatrolSpecial"); Actor spec = null; // Execute the specials of any PatrolSpecials with the same TID // as the goal. while (spec = specit.Next()) { A_CallSpecial(spec.special, spec.args[0], spec.args[1], spec.args[2], spec.args[3], spec.args[4]); } int delay = 0; Actor NewGoal = iterator.Next(); if (NewGoal != null) { delay = NewGoal.args[1]; reactiontime = delay * TICRATE + Level.maptime; } goal = NewGoal; } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class OceanWalkCutscene : SnapCutsceneBase { bool FollowPath; void OceanFollowPath() { FollowPath = true; } Default { Speed 8.0; +DROPOFF Height 96.0; } States { Spawn: CS16 ABCD 5 A_CutsceneLook(LongState: "Long"); Loop; See: CS16 A 0 OceanFollowPath(); CS16 A 0 A_CutsceneEnd(); FollowLoop: CS16 EFGH 5; Loop; Long: CS16 A 0 OceanFollowPath(); CS16 A 0 A_CutsceneVoice("cutscene/e1m6/1", true, "$CUTSCENE_E1M6_1", 90); CS16 EFGH 5; CS16 EFGH 5; CS16 EFGH 5; CS16 EFGH 5; CS16 EFGH 5; CS16 A 0 A_CutsceneVoice("cutscene/e1m6/2", true, "$CUTSCENE_E1M6_2", 110); CS16 A 0 A_CutsceneEnd(true); Goto FollowLoop; Death: CS16 EFGHEFGHE 5 A_SetRenderStyle(Alpha - 0.1, STYLE_Translucent); Stop; } override void Tick() { super.Tick(); if (TickPaused() == true || Health <= 0) { return; } if (FollowPath == true) { if (Goal == null) { Vel.XY = (0, 0); SetStateLabel("Death"); FollowPath = false; return; } Vector2 DirTo = Vec2To(Goal); A_SetAngle(SnapUtils.AngleTowardsDir(Angle, DirTo, 16.875), SPF_INTERPOLATE); if (DirTo.Length() > Radius) { Vector2 Step = DirTo.Unit() * min(DirTo.Length(), Speed); TryMove(Pos.XY + Step, 2); } else { // Go to the next patrol point. let iterator = Level.CreateActorIterator(goal.args[0], "PatrolPoint"); let specit = Level.CreateActorIterator(goal.TID, "PatrolSpecial"); Actor spec = null; // Execute the specials of any PatrolSpecials with the same TID // as the goal. while (spec = specit.Next()) { A_CallSpecial(spec.special, spec.args[0], spec.args[1], spec.args[2], spec.args[3], spec.args[4]); } int delay = 0; Actor NewGoal = iterator.Next(); if (NewGoal != null) { delay = NewGoal.args[1]; reactiontime = delay * TICRATE + Level.maptime; } goal = NewGoal; } } } } class OceanLatteCutscene : SnapCutsceneBase { Actor OurArsontop; bool Interrupted; void OceanTeleports() { Actor teleEFX = Spawn("SnapTeleportFog", Pos, ALLOW_REPLACE); } void EndLatteScene() { if (Health <= 0) { return; } Health = 0; SetStateLabel("Death"); } const SEARCHDIS = 640 * 640; state LatteSearchForPlayers() { for (uint i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] == false) { continue; } let p = players[i].mo; if (p == null || p.Health <= 0) { continue; } if (Distance2DSquared(p) <= SEARCHDIS) { target = p; return SeeState; } } return null; } States { Spawn: CS11 ABCD 5 LatteSearchForPlayers(); // No long version, since the player can interrupt at any time. Loop; See: CS11 A 0 A_CutsceneVoice("cutscene/e1m6rude/1", false, "$CUTSCENE_E1M6RUDE_1", 85); CS11 AEAE 5; CS11 AEAE 5; CS11 A 0 A_CutsceneVoice("arson/see", false); CS11 ABCD 5; CS11 ABCD 5; CS11 A 0 A_CutsceneVoice("cutscene/e1m6rude/2", false, "$CUTSCENE_E1M6RUDE_2", 115); CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 A 0 A_CutsceneVoice("arson/idle", false); CS11 ABCD 5; CS11 ABCD 5; CS11 A 0 A_CutsceneVoice("cutscene/e1m6rude/3", false, "$CUTSCENE_E1M6RUDE_3A", 35); CS11 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M6RUDE_3B", 90); CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 A 0 A_CutsceneVoice("cutscene/e1m6rude/4", false, "$CUTSCENE_E1M6RUDE_4A", 65); CS11 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M6RUDE_4B", 70); CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 A 0 A_CutsceneVoice("arson/hurt", false); CS11 ABCD 5; CS11 A 0 A_CutsceneVoice("cutscene/e1m6rude/5", false, "$CUTSCENE_E1M6RUDE_5A", 130); CS11 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M6RUDE_5B", 35); CS11 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M6RUDE_5C", 40); CS11 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M6RUDE_5D", 40); CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 AEAE 5; CS11 ABCD 5; CS11 ABCD 5; CS11 ABCD 5; CS11 A 0 EndLatteScene(); Stop; Death: CS11 F 16; CS11 G 5; CS11 G 0 OceanTeleports(); CS11 G 30; CS11 G 0 A_CutsceneEnd(); Stop; } const STANDINGAWAYSPACE = 128.0; override void PostBeginPlay() { super.PostBeginPlay(); Vector3 APos = Vec3Offset( cos(Angle) * STANDINGAWAYSPACE, sin(Angle) * STANDINGAWAYSPACE, 0.0 ); OurArsontop = Spawn("ArsonTop", APos, ALLOW_REPLACE); if (OurArsontop != null) { OurArsontop.Angle = self.Angle + 180.0; } } override void Tick() { super.Tick(); if (TickPaused() == true) { return; } if (Health <= 0) { if (Interrupted == true) { A_FaceTarget(22.5); } return; } if (OurArsontop == null || OurArsontop.Health <= 0 || (OurArsontop.target != null && OurArsontop.target.Health > 0)) { // Player interruption, end early. A_StopSound(CHAN_VOICE); target = OurArsontop.target; Interrupted = true; EndLatteScene(); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapTrafficJabber : SnapCutsceneBase { state CheckForSpeedrunCutscene() { if (Level.Time < (50 * TICRATE)) { return ResolveState("Speedrun"); } return null; } States { Spawn: TNT1 A 5 A_CutsceneLook(); Loop; See: TNT1 A 0 CheckForSpeedrunCutscene(); TNT1 A 0 A_CutsceneVoice("voice/trafficjam", true, "$CUTSCENE_E1M8_1", 89); TNT1 A 89; TNT1 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M8_2A", 110); TNT1 A 0 A_CutsceneSubtitle("$CUTSCENE_E1M8_2B", 50); TNT1 A 160; TNT1 A 0 A_CutsceneEnd(true); Stop; Speedrun: TNT1 A 0 A_CutsceneVoice("voice/beatrushhour", true, "$CUTSCENE_E1M8_3", 105); TNT1 A 105; TNT1 A 0 A_CutsceneEnd(true); Stop; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class Ease { // Most of this code is sourced from this project: https://easings.net/ // It is also licensed under GPL v3.0. static double Linear(double x, double start = 0.0, double end = 1.0) { return ((1.0 - x) * start) + (x * end); } static double InSine(double x, double start = 0.0, double end = 1.0) { return Linear( 1.0 - cos(x * M_PI_2), start, end ); } static double OutSine(double x, double start = 0.0, double end = 1.0) { return Linear( cos(x * M_PI_2), start, end ); } static double InOutSine(double x, double start = 0.0, double end = 1.0) { return Linear( -(cos(x * M_PI) - 1.0) * 0.5, start, end ); } static double InPow(int power, double x, double start = 0.0, double end = 1.0) { return Linear( x ** power, start, end ); } static double OutPow(int power, double x, double start = 0.0, double end = 1.0) { return Linear( 1.0 - ((1.0 - x) ** power), start, end ); } static double InOutPow(int power, double x, double start = 0.0, double end = 1.0) { if (x < 0.5) { return Linear( (1 << (power - 1)) * (x ** power), start, end ); } else { return Linear( 1.0 - ((-2.0 * x + 2.0) ** power) * 0.5, start, end ); } } static double InQuad(double x, double start = 0.0, double end = 1.0) { return InPow(2, x, start, end); } static double OutQuad(double x, double start = 0.0, double end = 1.0) { return OutPow(2, x, start, end); } static double InOutQuad(double x, double start = 0.0, double end = 1.0) { return InOutPow(2, x, start, end); } static double InCubic(double x, double start = 0.0, double end = 1.0) { return InPow(3, x, start, end); } static double OutCubic(double x, double start = 0.0, double end = 1.0) { return OutPow(3, x, start, end); } static double InOutCubic(double x, double start = 0.0, double end = 1.0) { return InOutPow(3, x, start, end); } static double InQuart(double x, double start = 0.0, double end = 1.0) { return InPow(4, x, start, end); } static double OutQuart(double x, double start = 0.0, double end = 1.0) { return OutPow(4, x, start, end); } static double InOutQuart(double x, double start = 0.0, double end = 1.0) { return InOutPow(4, x, start, end); } static double InQuint(double x, double start = 0.0, double end = 1.0) { return InPow(5, x, start, end); } static double OutQuint(double x, double start = 0.0, double end = 1.0) { return OutPow(5, x, start, end); } static double InOutQuint(double x, double start = 0.0, double end = 1.0) { return InOutPow(5, x, start, end); } static double InExpo(double x, double start = 0.0, double end = 1.0) { if (x == 0.0) { return start; } return Linear( 2 ** (10.0 * x - 10.0), start, end ); } static double OutExpo(double x, double start = 0.0, double end = 1.0) { if (x == 1.0) { return end; } return Linear( 1.0 - (2 ** (-10.0 * x)), start, end ); } static double InOutExpo(double x, double start = 0.0, double end = 1.0) { if (x == 0.0) { return start; } if (x == 1.0) { return end; } if (x < 0.5) { return Linear( (2 ** (20.0 * x - 10.0)) * 0.5, start, end ); } else { return Linear( (2.0 - (2 ** (-20.0 * x + 10.0))) * 0.5, start, end ); } } static double InCirc(double x, double start = 0.0, double end = 1.0) { return Linear( 1.0 - sqrt(1.0 - (x ** 2)), start, end ); } static double OutCirc(double x, double start = 0.0, double end = 1.0) { return Linear( sqrt(1.0 - ((x - 1.0) ** 2)), start, end ); } static double InOutCirc(double x, double start = 0.0, double end = 1.0) { if (x < 0.5) { return Linear( (1.0 - sqrt(1.0 - ((2.0 * x) ** 2))) * 0.5, start, end ); } else { return Linear( (sqrt(1.0 - ((-2.0 * x + 2.0) ** 2)) + 1.0) * 0.5, start, end ); } } const BACK_C1 = 1.70158; const BACK_C2 = BACK_C1 * 1.525; const BACK_C3 = BACK_C1 + 1.0; static double InBack(double x, double start = 0.0, double end = 1.0) { return Linear( BACK_C3 * (x ** 3) - BACK_C1 * (x ** 2), start, end ); } static double OutBack(double x, double start = 0.0, double end = 1.0) { return Linear( 1.0 + (BACK_C3 * ((x - 1.0) ** 3) + BACK_C1 * ((x - 1.0) ** 2)), start, end ); } static double InOutBack(double x, double start = 0.0, double end = 1.0) { if (x < 0.5) { return Linear( (((2.0 * x) ** 2) * ((BACK_C2 + 1.0) * 2.0 * x - BACK_C2)) * 0.5, start, end ); } else { return Linear( (((2.0 * x - 2.0) ** 2) * ((BACK_C2 + 1.0) * (x * 2.0 - 2.0) + BACK_C2) + 2.0) * 0.5, start, end ); } } const ELASTIC_C1 = (2.0 * M_PI) / 3.0; const ELASTIC_C2 = (2.0 * M_PI) / 4.5; static double InElastic(double x, double start = 0.0, double end = 1.0) { if (x == 0.0) { return start; } if (x == 1.0) { return end; } return Linear( -(2 ** (10.0 * x - 10.0)) * sin((x * 10.0 - 10.75) * ELASTIC_C1), start, end ); } static double OutElastic(double x, double start = 0.0, double end = 1.0) { if (x == 0.0) { return start; } if (x == 1.0) { return end; } return Linear( (2 ** (-10.0 * x)) * sin((x * 10.0 - 0.75) * ELASTIC_C1) + 1.0, start, end ); } static double InOutElastic(double x, double start = 0.0, double end = 1.0) { if (x == 0.0) { return start; } if (x == 1.0) { return end; } if (x < 0.5) { return Linear( -((2 ** (20.0 * x - 10.0)) * sin((20.0 * x - 11.125) * ELASTIC_C2)) * 0.5, start, end ); } else { return Linear( ((2 ** (-20.0 * x + 10.0)) * sin((20.0 * x - 11.125) * ELASTIC_C2)) * 0.5 + 1.0, start, end ); } } const BOUNCE_C1 = 7.5625; const BOUNCE_C2 = 2.75; static double InBounce(double x, double start = 0.0, double end = 1.0) { return 1.0 - OutBounce(x, start, end); } static double OutBounce(double x, double start = 0.0, double end = 1.0) { if (x < 1.0 / BOUNCE_C2) { return Linear( BOUNCE_C1 * (x ** 2), start, end ); } else if (x < 2.0 / BOUNCE_C2) { x -= 1.5 / BOUNCE_C2; return Linear( BOUNCE_C1 * (x ** 2) + 0.75, start, end ); } else if (x < 2.5 / BOUNCE_C2) { x -= 2.25 / BOUNCE_C2; return Linear( BOUNCE_C1 * (x ** 2) + 0.9375, start, end ); } else { x -= 2.625 / BOUNCE_C2; return Linear( BOUNCE_C1 * (x ** 2) + 0.984375, start, end ); } } static double InOutBounce(double x, double start = 0.0, double end = 1.0) { if (x < 0.5) { return (1.0 - OutBounce(1.0 - 2.0 * x, start, end)) * 0.5; } else { return (1.0 + OutBounce(2.0 * x - 1.0, start, end)) * 0.5; } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapStaticDecor : Actor abstract { // "Static" decoration: // No animation or movement, // simply display one frame. uint DecorFlags; flagdef MissileSpriteFix: DecorFlags, 0; Default { //DistanceCheck "snap_decordrawdist"; +NOINTERACTION +NOBLOCKMAP +NOGRAVITY +NOCLIP +THRUACTORS +DONTSPLASH +DONTBLAST } override void BeginPlay() { super.BeginPlay(); ChangeStatNum(STAT_DECOR); if (bMissileSpriteFix == true) { SpriteOffset.Y = Height * -0.5; } } override void PostBeginPlay() { super.PostBeginPlay(); UnlinkFromWorld(); SetXYZ(Vec3Offset(Vel.X, Vel.Y, Vel.Z)); CheckPortalTransition(false); LinkToWorld(); if (CurState == null) { Destroy(); return; } if (CheckNoDelay() == false) { return; } } override void Tick() { // NOP } } class SnapDynamicDecor : SnapStaticDecor abstract { // "Dynamic" decoration: // These have reimplemented momentum, // state logic, and even optional gravity. override void Tick() { super.Tick(); if (isFrozen()) { return; } // Update origin with velocity. SetOrigin(Pos + Vel, true); if (bNoGravity == false) { // Apply fake gravity. Vel.Z -= Gravity; } // Recreate basic state animation. if (Tics != -1) { if (Tics > 0) { Tics--; } while (Tics == 0) { if (CurState == null) { Destroy(); return; } if (SetState(CurState.NextState) == false) { // Object was removed return; } } } } } class SnapPuff : SnapDynamicDecor replaces BulletPuff { // Generic puff effect. Default { Radius 12; Height 24; VSpeed 1; Mass 5; +RANDOMIZE } States { Spawn: PUFF ABCDEFGH 2; Stop; } } class SnapHitConfirm : SnapDynamicDecor { // Effect spawned when a player damages something. Default { +WALLSPRITE +BRIGHT } States { Spawn: CNFM A random(1,3); CNFM B random(1,3); CNFM CDEFGHI 1; Stop; } } class SnapRadiusDamageEFX : SnapDynamicDecor { // Base effect to show the hitbox of explosion damage. Vector3 RDOrigPos; double RDJitter; double RDSize; static double GetDMGAlpha() { bool reduce = SnapUtils.ShouldReduceFlashing(); if (reduce == true) { return 0.33; } else { return 1.0; } } Default { Radius 16; Height 16; +BRIGHT } States { Spawn: RDEX A 2 NoDelay A_SetRenderStyle(GetDMGAlpha(), STYLE_Translucent); RDEX B 2 Light("RadiusExplosionLight") A_SetRenderStyle(GetDMGAlpha(), STYLE_Add); RDEX C 2 Light("RadiusExplosionLightBlue1"); RDEX D 2 Light("RadiusExplosionLightBlue2"); RDEX E 2 Light("RadiusExplosionLightBlue3"); Stop; } override void PostBeginPlay() { super.PostBeginPlay(); if (RDSize <= 0.0) { RDSize = Default.Radius; } RDOrigPos = Pos; Scale = ( RDSize / Default.Radius, RDSize / Default.Radius ); } override void Tick() { super.Tick(); if (isFrozen() == true) { return; } Vector3 JitterPos = RDOrigPos; if (RDJitter > 0.01) { double a = random[snap_decor](-180, 180); double p = random[snap_decor](-180, 180); RDOrigPos += ( RDJitter * cos(a) * sin(p), RDJitter * cos(a) * sin(p), RDJitter * cos(p) ); } SetOrigin(JitterPos, false); RDJitter *= 0.1; } } class SnapRadiusDamageEFXRed : SnapRadiusDamageEFX { States { Spawn: RDER A 2 NoDelay A_SetRenderStyle(GetDMGAlpha(), STYLE_Translucent); RDER B 1 Light("RadiusExplosionLight") A_SetRenderStyle(GetDMGAlpha(), STYLE_Add); RDER C 2 Light("RadiusExplosionLightRed1"); RDER D 2 Light("RadiusExplosionLightRed2"); RDER E 2 Light("RadiusExplosionLightRed3"); Stop; } } class SnapOverheal : SnapDynamicDecor { // Effect spawned when an object is above their base health. Default { RenderStyle "Add"; +BRIGHT } States { Spawn: OVHL AABCDE 1; Stop; } } class SnapDIPuff : SnapPuff { // Directional Influence big puff. Default { Radius 24; Height 20; } States { Spawn: DIDS ABCDEFGHIJ 2; Stop; } } class SnapDIEnergy : SnapDynamicDecor { // Directional Influence energy. Vector3 PushVel; uint DustParticles; bool FadeIn; const BASESPEED = 24.0; const PARTICLEADD = 5.0; const BASEPARTICLES = 3; Default { Radius 24; Height 20; RenderStyle "Add"; Alpha 0.0; +BRIGHT +ROLLSPRITE +WALLSPRITE } bool CheckHitlagDone() { if (Target == null || Target.Health <= 0) { return true; } let sa = SnapActor(Target); let sp = SnapPlayer(Target); if ((sa != null && sa.Hitstun != null && sa.Hitstun.Time > 0) || (sp != null && sp.Hitstun != null && sp.Hitstun.Time > 0)) { return false; } double v = Target.Vel.Length(); if (v >= BASESPEED) { DustParticles = BASEPARTICLES + int((v - BASESPEED) / PARTICLEADD); } return true; } bool CheckDustDone() { if (DustParticles > 0) { return false; } Destroy(); return true; } States { Spawn: DIRI ABCD 1; Loop; Death: DIRI EFGHIJKLMNOP 1; DeathCheck: TNT1 A 1 CheckDustDone(); Loop; } void UpdateDIEnergy(bool OnSpawn = false) { if (Target == null) { return; } PushVel = Target.Vel; if (Target.bNoGravity == false) { // Try to adjust for default gravity, at least. PushVel.Z *= 0.5; } Vector2 dir = SnapUtils.SafeVec2Unit(PushVel.XY); double dis = 64.0; Vector3 NewPos = Target.Pos + ( -dir.X * dis, -dir.Y * dis, Target.Height * 0.5 ); SetOrigin(NewPos, !OnSpawn); A_SetAngle(VectorAngle(dir.X, dir.Y), SPF_INTERPOLATE); double v = Target.Vel.Length(); if (v >= BASESPEED) { FadeIn = true; } if (FadeIn) { A_FadeIn(0.1, FTF_CLAMP); } if (Target != players[consoleplayer].camera) { bInvisible = true; } } override void PostBeginPlay() { super.PostBeginPlay(); UpdateDIEnergy(true); } override void Tick() { super.Tick(); if (isFrozen() == true) { return; } A_SetRoll(Roll + 22.5, SPF_INTERPOLATE); if (Health > 0) { if (CheckHitlagDone() == true) { Health = 0; Die(null, null); if (FadeIn) { A_SetRenderStyle(1.0, STYLE_Add); bInvisible = false; } } else { UpdateDIEnergy(false); } return; } else { // Start spawning DI dust when dead. if (DustParticles > 0 && (Level.maptime & 1)) { Vector3 NewPos = Pos; NewPos += ( frandom[snap_decor](-4.0, 4.0), frandom[snap_decor](-4.0, 4.0), frandom[snap_decor](-4.0, 4.0) ); Actor dust = Spawn("SnapDIPuff", Pos, ALLOW_REPLACE); dust.Vel = PushVel * 0.75; dust.Vel += ( frandom[snap_decor](-1.0, 1.0), frandom[snap_decor](-1.0, 1.0), frandom[snap_decor](-1.0, 1.0) ); DustParticles--; } } } } class SnapDIGhostBase : SnapDynamicDecor abstract { Default { Radius 16; Height 56; Alpha 0.5; RenderStyle "AddStencil"; StencilColor "FF2200"; +BRIGHT } override void Tick() { super.Tick(); if (isFrozen() == true) { return; } Alpha -= 0.0625; if (Alpha <= 0.0) { Destroy(); } } } class FactoryGlassShard : PowerupCopterGlassShard { States { Spawn: WISH ABCDEDCB 2; WISH ABCDEDCB 2; Stop; AltSpawn: WISH FGHIJIHG 2; WISH FGHIJIHG 2; Stop; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- enum MenuGameTypes { GT_CAMPAIGN = 0, GT_TRIAL, GT_RECORD, GT_CUSTOM, } class OptionMenuItemSnapGameType : SnapMenuItemBase { uint mGameType; OptionMenuItemSnapGameType Init(uint Type) { mGameType = Type; return self; } override bool Selectable() { return false; } } class SnapEpisodeItem : OptionMenuItemSnapBigSubmenu { SnapEpisodeDef mEpisode; SnapEpisodeItem Init() { super.Init("", "", 'None', 0); return self; } override bool Locked() { if (mEpisode == null) { // Invalid episode. return true; } uint MenuGameType = GT_CAMPAIGN; let p = SnapEpisodeMenu(Parent); if (p != null) { MenuGameType = p.EpisodeType; } return mEpisode.Locked(MenuGameType); } override bool Activate() { if (Locked() == true) { Menu.MenuSound("menu/cant"); return true; } let p = SnapEpisodeMenu(Parent); if (p != null) { Name NextMenu = 'None'; switch (p.EpisodeType) { case GT_CAMPAIGN: SnapMenuData.SetSelectedMap(""); // Don't copy Trial selection to Campaign. NextMenu = "SnapCampaignSkill"; break; case GT_TRIAL: NextMenu = "SnapTrialMap"; break; case GT_CUSTOM: NextMenu = "SnapCustomMap"; break; case GT_RECORD: NextMenu = "SnapRecord"; break; default: // bad menu setup return false; } SnapMenuData.SetSelectedEpisode(mEpisode.ID); CursorPlayFire(); Menu.MenuSound("menu/advance"); Menu.SetMenu(NextMenu); return true; } return false; } } class SnapEpisodeMenu : SnapMenuBase { uint EpisodeType; SnapEpisodeItem CreateEpisodeItem(SnapEpisodeDef EpDef) { let item = SnapEpisodeItem( new("SnapEpisodeItem") ); item.Init(); mDesc.mItems.Push(item); item.OnMenuCreated(); item.Parent = self; item.mEpisode = EpDef; item.mLabel = EpDef.Title; item.mTooltip = EpDef.Tagline; if (item.Locked() == true) { switch (EpisodeType) { case GT_CAMPAIGN: item.mTooltip = "$SNAPMENU_EPISODE_LOCKED_CAMPAIGN"; break; case GT_TRIAL: case GT_CUSTOM: item.mTooltip = "$SNAPMENU_EPISODE_LOCKED_TRIAL"; break; default: item.mTooltip = "$SNAPMENU_SKILL_LOCKED"; break; } } return item; } SnapEpisodeItem CreateBonusEpisodeItem() { let EpDef = SnapEpisodeDef.ConstructBonusLevelsEpisode(); if (EpDef == null) { return null; } let item = SnapEpisodeItem( new("SnapEpisodeItem") ); item.Init(); mDesc.mItems.Push(item); item.OnMenuCreated(); item.Parent = self; item.mEpisode = EpDef; item.mLabel = EpDef.Title; item.mTooltip = EpDef.Tagline; if (item.Locked() == true) { item.mTooltip = "$SNAPMENU_SKILL_LOCKED"; } return item; } override void Init(Menu parent, OptionMenuDescriptor desc) { super.Init(parent, desc); uint NumItems = mDesc.mItems.Size(); for (uint i = 0; i < NumItems; i++) { let item = mDesc.mItems[i]; let n = OptionMenuItemSnapGameType(item); if (n != null) { EpisodeType = n.mGameType; } if (item is "SnapEpisodeItem") { item.Destroy(); mDesc.mItems.Delete(i); i--; NumItems--; continue; } } SnapMenuData.SetCustomGame( (EpisodeType == GT_CUSTOM) ); Array EpisodeList; SnapDefinitions.GetSortedEpisodes(EpisodeList); for (int i = 0; i < EpisodeList.Size(); i++) { CreateEpisodeItem(EpisodeList[i]); } if (EpisodeType != GT_CAMPAIGN) { // Create bonus levels episode CreateBonusEpisodeItem(); } NumItems = mDesc.mItems.Size(); SnapEpisodeDef LastEpisode = SnapMenuData.GetSelectedEpisode(); if (LastEpisode != null) { for (uint i = 0; i < NumItems; i++) { let item = mDesc.mItems[i]; let n = SnapEpisodeItem(item); if (n != null) { if (n.mEpisode.ID == LastEpisode.ID) { SetSelectedItem(i); return; } } } } // Default to first one SetSelectedItem(FirstSelectable()); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapEventHandler : EventHandler { static clearscope SnapEventHandler Get() { return SnapEventHandler( Find("SnapEventHandler") ); } override void OnRegister() { InitWeaponPatterns(); InitEnemyScalePatterns(); } override void WorldLoaded(WorldEvent e) { UpdateTrialStatus(); ResetCutscenes(); ResetSecretQueue(); ResetLevelTimer(); ResetWeaponRespawn(); ResetLevelDone(); ResetVSCountdown(); ResetSuddenDeath(); LoadMapBombs(); InitDestructibles(); RunCoopScaling(); if (deathmatch == true) { VersusStartingCountdown(); } } override void WorldUnloaded(WorldEvent e) { UnloadMapBombs(); ResetDestructibles(); } override void PlayerSpawned(PlayerEvent e) { PlayerInfo player = players[e.PlayerNumber]; let pMobj = SnapPlayer(player.mo); let spi = SnapPlayerGlobals.GetForPlayerNum(e.PlayerNumber); if (pMobj) { PlayerLevelInit(pMobj, spi); PlayerRespawnStuff(pMobj, spi); // Ignore sv_respawnprotect and just always do this if (deathmatch == true) { pMobj.SetRespawnInvul(); } } } override void PlayerRespawned(PlayerEvent e) { PlayerInfo player = players[e.PlayerNumber]; let pMobj = SnapPlayer(player.mo); let spi = SnapPlayerGlobals.GetForPlayerNum(e.PlayerNumber); if (pMobj) { // Init new player animator pMobj.InitPlayerAnimator(); PlayerRespawnStuff(pMobj, spi); pMobj.SetRespawnInvul(); PlayerCheckpoint(pMobj, e.PlayerNumber); } } override void PlayerDisconnected(PlayerEvent e) { let spi = SnapPlayerGlobals.GetForPlayerNum(e.PlayerNumber); if (spi) { // Destroy existing animator spi.Animator.Destroy(); } } override void WorldThingSpawned(WorldEvent e) { AddCutscene(e.Thing); AddDMWeaponSpot(e.Thing); InvasionThinker.AddInvasionItemSpot(e.Thing); InvasionThinker.AddInvasionMonsterSpot(e.Thing); } override void WorldThingDamaged(WorldEvent e) { DoHitConfirm(e); } override void WorldThingDestroyed(WorldEvent e) { RemoveDMWeaponSpot(e.Thing); } override void WorldLineDamaged(WorldEvent e) { HitstunFromGeometry(e); } override void WorldSectorDamaged(WorldEvent e) { Try3DFloorDestruct(e); HitstunFromGeometry(e); } override void WorldTick() { UpdateLevelTimer(); UpdateBossWarning(); TickMapBombs(); TickDestructibles(); if (deathmatch == true) { HandleDMWeaponSpawns(); } VSCountdownTick(); } override void CheckReplacement(ReplaceEvent e) { if (e.Replacee == "SnapCar") { e.Replacement = GetCarReplacement(false); } else if (e.Replacee == "SnapCarMoving") { e.Replacement = GetCarReplacement(true); } } override bool InputProcess(InputEvent e) { if (ProcessInputIntermission(e) == true) { return false; } return false; } override void NetworkProcess(ConsoleEvent e) { if (e.Player < 0 || e.Player >= MAXPLAYERS || playeringame[e.Player] == false) { return; } if (e.Name == "SnapIntermission:KeyDown") { IntermissionKeyChanged(e, true); } else if (e.Name == "SnapIntermission:KeyUp") { IntermissionKeyChanged(e, false); } else if (e.Name ~== "ForceWave") { InvasionForceWave(e.Args[0]); } } } class SnapStaticEventHandler : StaticEventHandler { static clearscope SnapStaticEventHandler Get() { return SnapStaticEventHandler( Find("SnapStaticEventHandler") ); } override void OnRegister() { SetOrder(1); CreateFader(); ReadTextureLocalizations(); } override void OnEngineInitialize() { ReadSnapDefs(); InitWeaponProps(); // TODO: move to SNAPDEFS LoadRecords(); LoadSecretFlags(); CheckAchievements(); UpdateIWADResult(); } override void NewGame() { ResetInvasionCheckpoint(); ResetLandmark(); ResetLastSaveTimer(); } override void WorldLoaded(WorldEvent e) { Fader.LevelFadeOut(); if (Level.MapName != InvasionCPMap) { // Reset checkpoint in other maps. ResetInvasionCheckpoint(); } if (e.IsSaveGame == true) { PlayerInfo player = players[consoleplayer]; let pMobj = SnapPlayer(player.mo); let spi = SnapPlayerGlobals.GetForPlayerNum(consoleplayer); if (pMobj != null && spi != null && spi.POWMeter >= pMobj.SnapPOWMax) { // Remind the player that it's ready. pMobj.PlayPOWReady(); } // Save was loaded. SaveLoaded(); FixTrialMenuStatus(); } else { ResetLastSaveTimer(); } for (uint i = 0; i < MAXPLAYERS; i++) { CheckLandmarks(i); } ResetLandmark(); if (IsBadIWAD() == true) { InitBadIWADState(); } } override void WorldUnloaded(WorldEvent e) { if (PrevLandmark == null || e.IsSaveGame == true) { Fader.LevelFadeIn(); Fader.FadeInit = false; } } override void PlayerRespawned(PlayerEvent e) { if (e.PlayerNumber == consoleplayer) { Fader.RespawnFadeOut(); } } override void WorldTick() { UpdateLastSaveTimer(); } override void WorldThingDamaged(WorldEvent e) { AddStatRobotOnDamage(e.Thing, e.Inflictor, e.DamageSource, e.Damage, e.DamageType); if (e.Thing.Health <= 0) { AddStatRobots(e.Thing, e.Inflictor, e.DamageSource, e.DamageType); } } override void UITick() { CheckCRTShaderStatus(); if (MenuData != null) { MenuData.Tick(); } Fader.FadeTick(); } override void RenderOverlay(RenderEvent e) { ThinkerIterator IntermissionFinder = ThinkerIterator.Create("SnapIntermission", STAT_INTERMISSION); SnapIntermission inter = SnapIntermission( IntermissionFinder.Next() ); if (inter != null) { inter.Drawer(); } if (IsBadIWAD() == true) { DrawBadIWADScreen(); } Fader.DrawFadeOverlay(Fader.FadeOffset); } } #include "./event/iwad.zs" #include "./event/announcer.zs" #include "./event/boss.zs" #include "./event/timer.zs" #include "./event/suddendeath.zs" #include "./event/cutscene.zs" #include "./event/player.zs" #include "./event/hitconfirm.zs" #include "./event/destructible.zs" #include "./event/replace.zs" #include "./event/coopscaling.zs" #include "./event/newgame.zs" #include "./event/localization.zs" #include "./event/snapdefs.zs" #include "./event/weapon.zs" #include "./event/record.zs" #include "./event/secret.zs" #include "./event/deathmatch.zs" #include "./event/invasion.zs" #include "./event/intermission.zs" #include "./event/countdown.zs" #include "./event/stats.zs" #include "./event/fades.zs" #include "./event/crt.zs" // See also: zscript/snap/mapmisc/bombs.zs //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapExplodeProps : SnapWeaponProps { override void Init() { WeaponName = "Explode"; NiceName = "$SNAPMENU_WEAPON_EXPLODE"; PickupType = "SnapExplodePowerup"; WeaponIcon = "WP_EXPLD"; FireState = "FireExplode"; DropFreq = 15; } } class SnapExplodeCan : SnapItemCan { Default { DropItem "SnapExplodePowerup"; } States { Spawn: WP_E A 10; WP_E A 10 Bright; Loop; } } class SnapExplodePowerup : SnapWeaponPowerup { Default { SnapWeaponPowerup.WeaponPower "Explode"; Inventory.PickupMessage "$POWERUP_EXPLODE"; SnapInventory.VoiceSample "voice/explode"; } States { Spawn: WP_E B 10; WP_E B 10 Bright; Loop; } } class BombDowngradeParticle : SnapDynamicDecor { Default { RenderStyle "Add"; +BRIGHT } States { Spawn: BOMD AABCDEFGHIJ 1; Stop; } } class SnapExplodeShot : SnapBasicShot { // Explode is a weapon designed to fill the void of ultra-effective // crowd control, by adding a weapon with large radius damage. // It explodes if it does a direct hit, but will bounce a few times // instead when missing. // Originally only the first 4 weapons were planned, but Explode and // Mirror were both added for extra fun and variety when mapping. uint ExplodeShotFuse; bool ExplodedAlready; action void A_StartBouncingOnActors() { if (bThruActors == false) { Actor particle = Spawn("BombDowngradeParticle", Pos + (0, 0, Height * 0.5), ALLOW_REPLACE); } bThruActors = true; } action void A_DoExplodeShotExplode() // Lovely name { let e = SnapExplodeShot(self); if (e != null) { if (e.ExplodedAlready == true) { return; } e.ExplodedAlready = true; } bUseBounceState = false; bNoGravity = true; Vel = (0, 0, 0); for (int i = 0; i < 8; i++) { double a = i * 45; double h = 10; double v = 8; String type = "SnapDamageExplode"; Vector2 speed; if (i & 1) { h = 4; v = 12; type = "SnapDamageExplodeSmall"; } speed = AngleToVector(a, h); A_SpawnItemEx( type, 0, 0, 8, speed.x, speed.y, v ); } A_SnapExplode(50, 192); } Default { Radius 16; Height 12; DamageFunction 20; DamageType "Explode"; Obituary "$OB_EXPLODE"; BounceType "Grenade"; BounceFactor 0.6; WallBounceFactor 0.4; DeathSound "explosion/enemy"; -NOGRAVITY +BOUNCEONWALLS +BOUNCEONFLOORS +BOUNCEONCEILINGS +USEBOUNCESTATE -ALLOWBOUNCEONACTORS -BOUNCEONACTORS +DONTBOUNCEONSHOOTABLES } States { Spawn: EBUL ABCD 2 Light("ExplodeShotLight"); Loop; Bounce: EBUL E 1 Light("ExplodeShotLight") A_StartBouncingOnActors; BounceLoop: EBUL GFGE 1 Light("ExplodeShotLight"); Loop; Death: EBUL G 2 Light("ExplodeShotLight"); TNT1 A 2 A_DoExplodeShotExplode; Stop; } override void PostBeginPlay() { Vel.Z += 3.0; } override void Tick() { super.Tick(); if (TickPaused() == true) { return; } if (ExplodedAlready == false) { ExplodeShotFuse++; if (ExplodeShotFuse > 35) { ExplodeMissile(); } } } override void DoClink(Actor victim) { if (ExplodedAlready == false && bThruActors == false) { SetStateLabel("Bounce"); } super.DoClink(victim); } } extend class SnapGun { action void A_SnapgunExplode() { if (player == null || player.mo == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } A_SnapgunFlash('ExplodeFlash'); A_SnapgunMomentumProjectile("SnapExplodeShot"); A_StartSound("revolver/explode", CHAN_WEAPON); SoundAlert(self); player.mo.TakeInventory("SnapPowerupAmmo", 1, false, true); } States { FireExplode: SGUN A 1 A_SnapgunExplode; SGUN BCD 1; SGUN E 6; SGUN F 2; SGUN A 0 A_SnapGunRefire(); SGUN F 3; Goto GunIdle; ExplodeFlash: TNT1 A 1 Bright A_Light(2); SFL4 A 1 Bright A_Light(1); SFL4 B 1 Bright A_Light(0); SFL4 C 1 Bright; SFL4 D 1 Bright; Goto LightDone; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- // // Lamp // class FactoryLampWire : SnapStaticDecor { default { Radius 2; Height 256; +FORCEYBILLBOARD } states { Spawn: FLMP B -1; Stop; } } class FactoryLamp : SnapStaticDecor { default { Radius 34; Height 36; +SPAWNCEILING } states { Spawn: FLMP A -1; Stop; } override void PostBeginPlay() { super.PostBeginPlay(); A_AttachLight( "FactoryLampLight", DynamicLight.PointLight, Color(255, 127, 95, 87), 384, 384, DynamicLight.LF_SPOT|DynamicLight.LF_DONTLIGHTSELF, (0, 0, 0), self.Angle, 25, 30, 90.0 ); Target = Spawn("FactoryLampWire", Vec3Offset(0, 0, Height), ALLOW_REPLACE); if (Target != null) { Target.Scale.Y = (self.CeilingZ - Target.Pos.Z) / Target.Height; } } } // // Gears // class SnapGearPart : SnapDynamicDecor abstract { Default { RenderRadius 192; } void GearSpeed() { Tics += 5; } } // // Wall gear // class SnapGearWallLight : SnapGearPart { Default { VisibleAngles -90,90; VisiblePitch -180,180; +MASKROTATION +WALLSPRITE } States { Spawn: SGER A 1 GearSpeed(); SGER B 1; SGER C 1 GearSpeed(); SGER D 1; Loop; } override void PostBeginPlay() { super.PostBeginPlay(); Tracer = Spawn("SnapGearWallDark", Pos, ALLOW_REPLACE); Tracer.Target = Target; Tracer.Scale = Scale; Tracer.Angle = Angle + 180.0; Tracer.bXFlip = bXFlip; } } class SnapGearWallDark : SnapGearPart { Default { VisibleAngles -90,90; VisiblePitch -180,180; +MASKROTATION +WALLSPRITE } States { Spawn: SGER E 1 GearSpeed(); SGER F 1; SGER G 1 GearSpeed(); SGER H 1; Loop; } } class SnapGearWall : SnapStaticDecor { Default { Radius 24; Height 48; } override void PostBeginPlay() { super.PostBeginPlay(); double x = cos(Angle) * Radius; double y = sin(Angle) * Radius; Target = Spawn("SnapGearWallLight", Vec3Offset(x, y, 0.0), ALLOW_REPLACE); Target.Target = self; Target.Scale = Scale; Target.Angle = Angle; Target.bXFlip = bAmbush; Tracer = Spawn("SnapGearWallLight", Vec3Offset(-x, -y, 0.0), ALLOW_REPLACE); Tracer.Target = self; Tracer.Scale = Scale; Tracer.Angle = Angle + 180.0; Tracer.bXFlip = !bAmbush; } } // // Flat gear // I did my best, but these still have pretty bad sorting. // class SnapGearFlatLight : SnapGearPart { Default { VisibleAngles -180,180; VisiblePitch -180,0; +MASKROTATION +FLATSPRITE +ROLLSPRITE } States { Spawn: SGER A 1 GearSpeed(); SGER B 1; SGER C 1 GearSpeed(); SGER D 1; Loop; } override void PostBeginPlay() { super.PostBeginPlay(); Tracer = Spawn("SnapGearFlatDark", Pos, ALLOW_REPLACE); Tracer.Target = Target; Tracer.Scale = Scale; Tracer.Pitch = Pitch + 180.0; Tracer.bXFlip = bXFlip; } override void Tick() { super.Tick(); if (Tracer != null) { Tracer.SetOrigin(Pos, true); } } } class SnapGearFlatDark : SnapGearPart { Default { VisibleAngles -180,180; VisiblePitch -180,0; +MASKROTATION +FLATSPRITE +ROLLSPRITE } States { Spawn: SGER E 1 GearSpeed(); SGER F 1; SGER G 1 GearSpeed(); SGER H 1; Loop; } } class SnapGearFlat : SnapStaticDecor { Default { Radius 24; Height 48; } override void PostBeginPlay() { super.PostBeginPlay(); Target = Spawn("SnapGearFlatLight", Vec3Offset(0, 0, Radius * 0.8), ALLOW_REPLACE); Target.Target = self; Target.Scale = Scale; Target.Pitch = Pitch; Target.bXFlip = bAmbush; Tracer = Spawn("SnapGearFlatLight", Vec3Offset(0, 0, -Radius * 0.8), ALLOW_REPLACE); Tracer.Target = self; Tracer.Scale = Scale; Tracer.Pitch = Pitch + 180.0; Tracer.bXFlip = !bAmbush; } int PitchSign(double p) { if (p < 0.0) { return -1; } return 1; } override void Tick() { super.Tick(); // Goofy shit to make the sprites sort properly... if (Target != null) { Target.SetOrigin( (Pos.X, Pos.Y, Target.Pos.Z) - SnapShadow.ShadowAdjust(Target.Pos.Z), true ); } if (Tracer != null) { Tracer.SetOrigin( (Pos.X, Pos.Y, Tracer.Pos.Z) + SnapShadow.ShadowAdjust(Tracer.Pos.Z), true ); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapFader { const LEVELFADESPEED = 0.06; double FadeSpeed; bool FadingIn; bool FadeInit; bool FadeStartup; ui double FadeOffset; static void StartGameFade(bool frv, double spd = LEVELFADESPEED) { let ev = SnapStaticEventHandler(StaticEventHandler.Find("SnapStaticEventHandler")); if (ev == null) { return; } ev.Fader.FadingIn = frv; ev.Fader.FadeSpeed = spd; } void LevelFadeIn() { FadingIn = true; FadeSpeed = LEVELFADESPEED; } void LevelFadeOut() { FadingIn = false; FadeSpeed = LEVELFADESPEED; } void RespawnFadeOut() { FadingIn = false; FadeSpeed = LEVELFADESPEED * 2.0; } ui void FadeWasInit() { FadeInit = true; FadeStartup = false; } ui void FadeTick() { double DestOffset = 0.0; if (FadingIn == true) { DestOffset = 1.0; } if (FadeInit == false) { // Tiny bit extra, to make up for the tiny level load hitch. FadeOffset = 1.2; if (FadeStartup == true) { // Massive extra for engine startup, since that has a // much more massive hitch. FadeOffset += 1.0; } FadeWasInit(); } if (FadeSpeed > 0.0) { double OffsetDiff = DestOffset - FadeOffset; if (abs(OffsetDiff) <= FadeSpeed) { FadeOffset = DestOffset; } else { if (OffsetDiff > 0.0) { FadeOffset += FadeSpeed; } else { FadeOffset -= FadeSpeed; } } } } static ui void DrawFadeOverlay(double FO) { // This is static, as we want to also draw these for menus, // and RenderOverlay doesn't cover that. if (FO <= 0.0) { return; } if (FO > 1.0) { FO = 1.0; } TextureID LTex = TexMan.CheckForTexture("FADE00L"); TextureID RTex = TexMan.CheckForTexture("FADE00R"); double ts = 200; double sc = Screen.GetHeight() / ts; double w = Screen.GetWidth() / sc; double h = Screen.GetHeight() / sc; double o = FO * (w + ts); Screen.DrawTexture(LTex, true, o, 0.0, DTA_VirtualWidthF, w, DTA_VirtualHeightF, h, DTA_KeepRatio, true ); Screen.DrawTexture(RTex, true, w - o, 0.0, DTA_VirtualWidthF, w, DTA_VirtualHeightF, h, DTA_KeepRatio, true ); } } extend class SnapStaticEventHandler { SnapFader Fader; void CreateFader() { Fader = new("SnapFader"); Fader.LevelFadeIn(); Fader.FadeStartup = true; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- mixin class SnapTextFieldBase { void TextFieldDraw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { UpdateScaleParameters(); Vector2 Pos = ((BASE_VID_WIDTH * 0.5) + xOffset, yOffset); int col = Font.CR_UNTRANSLATED; if (DisplayGrayed() == true) { col = FontGrayColor; } else if (selected == true) { col = FontHighlightColor; } SnapMenuText( FontSmall, col, RightAlignPos(FontSmall, mLabel, Pos - (OPTIONS_MID_SPACE, 0)), mLabel ); String text = Represent(); SnapMenuText( FontSmall, col, Pos + (OPTIONS_MID_SPACE, 0), text ); } } class OptionMenuItemSnapTextField : OptionMenuItemTextField { mixin SnapMenuDrawing; mixin SnapMenuItemCore; mixin SnapTextFieldBase; OptionMenuItemSnapTextField Init(String label, String tooltip, Name command, CVar graycheck = null) { super.Init(label, command, graycheck); mTooltip = tooltip; return self; } virtual int GetLineSpacing() { return FontSmall.GetHeight(); } override void OnMenuCreated() { super.OnMenuCreated(); PrecacheMenuDrawing(); } virtual bool isGrayed() { return false; } virtual bool DisplayGrayed() { // I mostly only want to edit the // drawing, so this function exists now. if (Parent != null) { bool InList = Parent.ItemCurrentlyInList(self); if (InList == false) { return true; } } return isGrayed(); } virtual void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.DestPos = Delta + (BASE_VID_WIDTH * 0.5, 0); Cursor.DestPos = RightAlignPos(FontSmall, mLabel, Cursor.DestPos - (OPTIONS_MID_SPACE, 0)); Cursor.DestSmall = true; } override String Represent() { if (mEnter) { return mEnter.GetText() .. FontSmall.GetCursor(); } return super.Represent(); } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { TextFieldDraw(desc, yOffset, xOffset, selected); return xOffset; } override bool MenuEvent(int mKey, bool gamepad) { if (mKey == Menu.MKEY_Input) { CursorPlayFire(); } return super.MenuEvent(mKey, gamepad); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapFlameProps : SnapWeaponProps { override void Init() { WeaponName = "Flame"; NiceName = "$SNAPMENU_WEAPON_FLAME"; PickupType = "SnapFlamePowerup"; WeaponIcon = "WP_FLAME"; FireState = "FireFlame"; DropFreq = 7; } } class SnapFlameCan : SnapItemCan { Default { DropItem "SnapFlamePowerup"; } States { Spawn: WP_F A 10; WP_F A 10 Bright; Loop; } } class SnapFlamePowerup : SnapWeaponPowerup { Default { SnapWeaponPowerup.WeaponPower "Flame"; Inventory.PickupMessage "$POWERUP_FLAME"; SnapInventory.VoiceSample "voice/flame"; } States { Spawn: WP_F B 10; WP_F B 10 Bright; Loop; } } class SnapFlameParticle : SnapDynamicDecor { Default { Radius 8; Height 16; RenderStyle "Add"; +BRIGHT +RANDOMIZE } States { Spawn: VFIR ABCDE 2; Stop; } } class SnapFlameShot : SnapBasicShot { // Flame is a ripper that deals 8 damage per tick. // This leads to it being the single best weapon in the game, DPS wise. // However, it also requires you to get into a dangerous close distance to // the enemy, and chews through ammo extremely fast. uint FlameShotDamageAdd; action void A_UpdateFlameScale() { let flame = SnapFlameShot(self); if (flame) { double addSize = flame.FlameShotDamageAdd; double addMax = 6; //double OldHeight = Height; double size = Default.Scale.X + ((addSize * 0.75) / addMax); flame.SetPhysicalSize((size, size)); //double NewZ = Pos.Z - ((Height - OldHeight) * 0.5); //flame.SetOrigin((Pos.X, Pos.Y, NewZ), false); } } action void A_SpawnFlamePuffs() { A_UpdateFlameScale(); Vel = (0,0,0); Vector3 HOffset = (0, 0, Height * 0.5); Actor puff = Spawn("SnapSmoke", Pos + HOffset, ALLOW_REPLACE); puff.Vel.Z = random(0,6); for (int i = 0; i < 3; i++) { double a = i * 120; puff = Spawn("SnapSmoke", Pos + HOffset, ALLOW_REPLACE); puff.Vel.XY = AngleToVector(angle + a, random(1,6)); puff.Vel.Z = random(0,6); } } action void A_SpawnFlameParticles() { let flame = SnapFlameShot(self); if (!flame) { return; } double s = Scale.X; double r = radius * 0.75; double h = height * 0.75; Vector3 Offset = ( frandom[snap_decor](-r, r), frandom[snap_decor](-r, r), frandom[snap_decor](-h, h) ); Offset -= (Vel * 0.25); Actor particle = Spawn( "SnapFlameParticle", Pos + Offset, ALLOW_REPLACE ); if (particle) { particle.Vel = ( frandom[snap_decor](-1, 1), frandom[snap_decor](-1, 1), frandom[snap_decor](0, 4) ); particle.Vel -= (Vel * 0.1); particle.Vel *= s; particle.Scale = (s, s); } } action void A_IncreaseFlameDamage() { let flame = SnapFlameShot(self); if (flame) { flame.FlameShotDamageAdd++; A_UpdateFlameScale(); } A_SpawnFlameParticles(); } action void A_EndFlame() { ExplodeMissile(); SetStateLabel("End"); } int FlameShotDamage() { let flame = SnapFlameShot(self); if (flame) { return 4 + flame.FlameShotDamageAdd; } return 6; } override int DoSpecialDamage(Actor victim, int damage, name damagetype) { int dmg = super.DoSpecialDamage(victim, damage, damagetype); if (SnapUtils.PlayerOrBot(victim)) { // Deals tons of extra damage towards players. dmg *= 2; } return dmg; } Default { Radius 8; Height 12; Scale 0.25; Speed 30; DamageFunction FlameShotDamage(); DamageType "Fire"; Obituary "$OB_FLAME"; +RIPPER +NODAMAGETHRUST +BOUNCEONUNRIPPABLES -SnapMissile.MISSILESCALEDAMAGE } States { Spawn: FBAL ABCD 1 Light("FlameShotLight"); FBAL EFABCDEF 1 Light("FlameShotLight") A_IncreaseFlameDamage(); FBAL A 0 A_EndFlame(); Stop; End: FBAL GHIJK 1 Light("FlameShotLight"); Stop; Death: FBAL G 1 Light("FlameShotLight"); FBAL G 0 A_SpawnFlamePuffs; FBAL HIJK 1 Light("FlameShotLight"); Stop; } } extend class SnapGun { action void A_SnapgunFlame() { if (player == null || player.mo == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } A_SnapgunFlash('FlameFlash'); A_SnapgunMomentumProjectile("SnapFlameShot"); A_StartSound("revolver/flame", CHAN_WEAPON); SoundAlert(self); player.mo.TakeInventory("SnapPowerupAmmo", 1, false, true); } States { FireFlame: SGUN A 1 A_SnapgunFlame; SGUN BC 1; SGUN A 0 A_SnapGunRefire(); Goto GunIdle; FlameFlash: TNT1 A 1 Bright A_Light(2); TNT1 A 1 Bright A_Light(1); TNT1 A 1 Bright A_Light(0); Goto LightDone; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapHUD { HUDFont SnapNumFont; HUDFont SnapTinyNumFont; HUDFont SnapHPFont; HUDFont SnapSmallFont; HUDFont SnapLEDFont; HUDFont SnapComboFont; void InitFonts() { Font Nums = "SmallNums"; SnapNumFont = HUDFont.Create(Nums, 0); Font TinyNums = "TinyNums"; SnapTinyNumFont = HUDFont.Create(TinyNums, 0); Font HP = "HPNums"; SnapHPFont = HUDFont.Create(HP, 0); Font Small = "SmallFont"; SnapSmallFont = HUDFont.Create(Small, 0); Font LED = "LEDFont"; SnapLEDFont = HUDFont.Create(LED, 0); Font Combo = "ComboBonus"; SnapComboFont = HUDFont.Create(Combo, 0); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapPlayer { const MinFootstepSpeed = 2.0; uint FootstepTick; void TryPlayerFootstep(void) { if (player.onground == false) { return; } double spd = Vel.XY.Length(); if (spd <= MinFootstepSpeed) { return; } uint freq = SnapAnimationData.SpeedUpTics(5, spd) * 2; if (freq > 1) { FootstepTick++; if (FootstepTick % freq != 0) { return; } } DoFootstep(spd * 0.5, true); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapWaterFountain : Actor { const WATERPUSHEFXTIME = 20; Default { Radius 32; Height 64; Speed 1.0; +NOGRAVITY +DONTSPLASH +DONTTHRUST +FORCEYBILLBOARD +SOLID } States { Spawn: WGYR ABCDE 2; Loop; Top: WGYR FGHIJ 2; Loop; } override bool CanCollideWith(Actor Other, bool passive) { if (Other is "SnapWaterFountain") { return false; } if (Other.bDontThrust == true) { return false; } if ((Pos.Z > Other.Pos.Z + Other.Height) || (Pos.Z + Height < Other.Pos.Z)) { return false; } double vspd = Speed; if (Other.Vel.Z < 0.0) { vspd *= 2.0; } Other.Vel.Z += vspd; double hspd = Speed * 8.0; if (Other.bIsMonster == true && Other.bNoGravity == false && Other.Vel.XY.Length() < hspd) { // This monster can't move in the air! // Push them in their movedir, please! Other.FaceMovementDirection(); Vector2 pushDir = ( cos(Other.angle), sin(Other.angle) ); Other.Vel.XY = pushDir * hspd; } let sa = SnapActor(Other); if (sa) { if (sa.WaterPushed == 0) { sa.A_StartSound("splash/water"); } sa.WaterPushed = WATERPUSHEFXTIME; } let sp = SnapPlayer(Other); if (sp) { if (sp.WaterPushed == 0) { sp.A_StartSound("splash/water"); } sp.WaterPushed = WATERPUSHEFXTIME; } return false; } } class SnapWaterFountainSpot : SnapStaticDecor { Array FountainObjs; Default { Radius 32; Height 64; +INVISIBLE } States { Spawn: TNT1 A -1; Stop; } override void PostBeginPlay() { super.PostBeginPlay(); int numSegs = int(Scale.Y); if (numSegs < 0) { Destroy(); return; } Spawn("SnapWaterfallSpot", Pos, ALLOW_REPLACE); for (int i = 0; i <= numSegs; i++) { Actor fountain = Spawn("SnapWaterFountain", Pos, ALLOW_REPLACE); if (fountain) { if (i == numSegs) { fountain.SetStateLabel('Top'); } FountainObjs.Push(fountain); } } } override void Tick() { super.Tick(); if (Level.isFrozen()) { return; } double bs = abs(sin(Level.maptime * 5.625)); double ZShift = bs * 8.0; Vector3 NextPos = Pos; NextPos.Z -= ZShift; for (int i = 0; i < FountainObjs.Size(); i++) { let seg = Actor(FountainObjs[i]); if (!seg || seg.bDestroyed) { continue; } seg.SetOrigin(NextPos, true); NextPos.Z += Height - ZShift; } if (bs == 0.0) { NextPos.Z -= Height * 0.5; uint numParticles = 12; for (uint i = 0; i < numParticles; i++) { Actor Droplet = Spawn("SnapWaterDrops", NextPos, ALLOW_REPLACE); if (Droplet) { double a = random[snap_splash](0, 359); double hMom = 6.0; double vMom = 2.0 * Scale.Y; hMom += (hMom * 0.3) * random[snap_splash](-2, 4); vMom += (vMom * 0.3) * random[snap_splash](-2, 4); Droplet.Vel.XY = ( hMom * cos(a), hMom * sin(a) ); Droplet.Vel.Z = vMom; Droplet.Scale = (2.0, 2.0); } } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapPlayerGlobals { uint VSPoints; uint VSDeaths; void ResetVersusData() { VSPoints = VSDeaths = 0; } } extend class SnapPlayer { clearscope uint GetFragCount() { int t = player.GetTeam(); if (teamplay == true && t != Team.NoTeam) { // Count total frags for this player's team int count = 0; for (int i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i] && players[i].GetTeam() == t) { let mo = SnapPlayer(players[i].mo); if (mo != null) { let PInfo = SnapPlayerGlobals(mo.SnapPlayerInfo); if (PInfo != null) { count += PInfo.VSPoints; } } } } return count; } else { let PInfo = SnapPlayerGlobals(self.SnapPlayerInfo); if (PInfo == null) { return 0; } return PInfo.VSPoints; } } void AddFrags(uint add = 1) { SnapEventHandler ev = SnapEventHandler(EventHandler.Find("SnapEventHandler")); if (ev != null) { if (ev.TimerPaused == true) { // Not playing. return; } } let PInfo = SnapPlayerGlobals(self.SnapPlayerInfo); if (PInfo == null) { return; } PInfo.VSPoints += add; // Frags were updated. Send a message to // check for the win conditions. // Not done here so that ties are handled properly. ev.FragsUpdated = true; } void UpdateFrags(SnapPlayer source = null) { int pnum = PlayerNumber(); let PInfo = SnapPlayerGlobals(self.SnapPlayerInfo); if (PInfo != null) { PInfo.VSDeaths++; } if (source == self) { // Hey now, don't give YOURSELF credit! source = null; } if (source == null) { // If it was an environment / self-destruct, // try to see if we were pushed into it, // and award it to whoever did it. source = SnapPlayer(PushSource); } if (source != null) { // Successful kill, give them a point. source.AddFrags(); } else { // Give a point to everyone if it was // a self-destruct / environment kill // with no one to blame. for (int i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i]) { continue; } if (i == pnum) { // Don't give to yourself. continue; } let pMobj = SnapPlayer(players[i].mo); if (pMobj == null) { // Not a SnapPlayer continue; } if (self.IsTeammate(pMobj) == true) { // No farming points for teammates. continue; } pMobj.AddFrags(); } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class GeneratorZapChargedTrail : SnapActor { Default { RenderStyle "Add"; +NOINTERACTION +NOGRAVITY +NOBLOCKMAP +RANDOMIZE +BRIGHT } States { Spawn: GNBL A 3; GNBL BABAB 1; Stop; } } class GeneratorZapChargedTrailGreat : GeneratorZapChargedTrail { States { Spawn: GNBL C 3 Light("GeneratorZapWimpLight"); GNBL DECDF 1 Light("GeneratorZapWimpLight"); GNBL ABAB 1; Stop; } } class GeneratorZapChargedTrailPerfect : GeneratorZapChargedTrailGreat { States { Spawn: GNBL G 3 Light("GeneratorZapGoodLight"); GNBL HIGHJ 1 Light("GeneratorZapGoodLight"); GNBL CDECDF 1 Light("GeneratorZapWimpLight"); GNBL ABAB 1; Stop; } } class GeneratorZap : SnapChargeShot { override void SpawnChargeHitConfirm(Actor victim, Actor source) { return; } Default { SnapChargeShot.ChargeDamage 10; SnapChargeShot.ChargeSwerve 0.0; SnapChargeShot.ChargeRadius 8.0; Scale 2.0; Speed 15; Obituary "$OB_GENERATOR"; SeeSound "revolver/chargeFire1"; } States { Spawn: GNBL AB 1 Light("GeneratorZapWimpLight"); Loop; Death: GNBL A 1 Light("GeneratorZapWimpLight"); Stop; } } class GeneratorZapCharged : GeneratorZap { void ChargedZapTrail() { if (Level.maptime & 1) { return; } uint timer = Level.maptime / 2; double ha = angle + 90; double va = (timer % 8) * 45; double dist = 16.0 * Scale.X; Vector3 offset = ( dist * cos(ha) * cos(va), dist * sin(ha) * cos(va), (dist * 0.8) * sin(va) ); offset.Z += Height * 0.5; SnapActor particle = SnapActor(Spawn("GeneratorZapChargedTrail", Pos + offset, ALLOW_REPLACE)); if (particle) { particle.Scale = self.Scale; particle.target = self; particle.SetHitstunParent(self); } } action void ChargedZapExplode() { double ha = angle + 90; double spd = 8.0 * Scale.X; for (int i = 0; i < 4; i++) { double va = 45 + (i * 90); Vector3 spawnPos = Pos; spawnPos.Z += Height * 0.5; SnapActor particle = SnapActor(Spawn("GeneratorZapChargedTrail", spawnPos, ALLOW_REPLACE)); if (particle) { particle.Scale = self.Scale; particle.target = self; particle.SetHitstunParent(self); particle.Vel = ( spd * cos(ha) * cos(va), spd * sin(ha) * cos(va), spd * sin(va) ); } } } Default { SnapChargeShot.ChargeDamage 20; SnapChargeShot.ChargeSwerve 0.0; SnapChargeShot.ChargeRadius 16.0; SeeSound "revolver/chargeFire2"; } States { Spawn: GNBL CDECDF 1 Light("GeneratorZapGoodLight") ChargedZapTrail(); Loop; Death: GNBL C 1 Light("GeneratorZapGoodLight"); TNT1 A 1 ChargedZapExplode(); Stop; } } class GeneratorZapChargedGreat : GeneratorZapCharged { void GreatChargedZapTrail() { if (Level.maptime & 1) { return; } uint timer = Level.maptime / 2; double ha = angle + 90; double va = (timer % 8) * 45; double dist = 32.0 * Scale.X; Vector3 offset = ( dist * cos(ha) * cos(va), dist * sin(ha) * cos(va), (dist * 0.8) * sin(va) ); offset.Z += Height * 0.5; SnapActor particle = SnapActor(Spawn("GeneratorZapChargedTrailGreat", Pos + offset, ALLOW_REPLACE)); if (particle) { particle.Scale = self.Scale; particle.target = self; particle.SetHitstunParent(self); } va += 180.0; offset = ( dist * cos(ha) * cos(va), dist * sin(ha) * cos(va), (dist * 0.8) * sin(va) ); offset.Z += Height * 0.5; particle = SnapActor(Spawn("GeneratorZapChargedTrail", Pos + offset, ALLOW_REPLACE)); if (particle) { particle.Scale = self.Scale; particle.target = self; particle.SetHitstunParent(self); } } void GreatChargedZapExplode() { double ha = angle + 90; for (int i = 0; i < 8; i++) { double va = i * 45; double spd = 16.0 * Scale.X; SnapActor particle = null; Vector3 spawnPos = Pos; spawnPos.Z += Height * 0.5; if (i & 1) { particle = SnapActor(Spawn("GeneratorZapChargedTrailGreat", spawnPos, ALLOW_REPLACE)); } else { particle = SnapActor(Spawn("GeneratorZapChargedTrail", spawnPos, ALLOW_REPLACE)); spd *= 0.5; } if (particle) { particle.Scale = self.Scale; particle.target = self; particle.SetHitstunParent(self); particle.Vel = ( spd * cos(ha) * cos(va), spd * sin(ha) * cos(va), spd * sin(va) ); } } } Default { SnapChargeShot.ChargeDamage 40; SnapChargeShot.ChargeSwerve 0.0; SnapChargeShot.ChargeRadius 32.0; SeeSound "revolver/chargeFire3"; } States { Spawn: GNBL GHIGHJ 1 Light("GeneratorZapGreatLight") GreatChargedZapTrail(); Loop; Death: GNBL G 1 Light("GeneratorZapGreatLight"); TNT1 A 1 GreatChargedZapExplode(); Stop; } } class GeneratorZapChargedPerfect : GeneratorZapChargedGreat { void PerfectChargedZapTrail() { if (Level.maptime & 1) { return; } uint timer = Level.maptime / 2; double ha = angle + 90; double va = (timer % 8) * 45; double dist = 32.0 * Scale.X; Vector3 offset = ( dist * cos(ha) * cos(va), dist * sin(ha) * cos(va), (dist * 0.8) * sin(va) ); offset.Z += Height * 0.5; SnapActor particle = SnapActor(Spawn("GeneratorZapChargedTrailGreat", Pos + offset, ALLOW_REPLACE)); if (particle) { particle.target = self; particle.SetHitstunParent(self); } va += 180.0; offset = ( dist * cos(ha) * cos(va), dist * sin(ha) * cos(va), (dist * 0.8) * sin(va) ); offset.Z += Height * 0.5; particle = SnapActor(Spawn("GeneratorZapChargedTrail", Pos + offset, ALLOW_REPLACE)); if (particle) { particle.target = self; particle.SetHitstunParent(self); } } void PerfectChargedZapExplode() { double ha = angle + 90; for (int i = 0; i < 8; i++) { double va = i * 45; double spd = 16.0 * Scale.X; SnapActor particle = null; Vector3 spawnPos = Pos; spawnPos.Z += Height * 0.5; if (i & 1) { particle = SnapActor(Spawn("GeneratorZapChargedTrailGreat", spawnPos, ALLOW_REPLACE)); } else { particle = SnapActor(Spawn("GeneratorZapChargedTrail", spawnPos, ALLOW_REPLACE)); spd *= 0.5; } if (particle) { particle.Scale = self.Scale; particle.target = self; particle.SetHitstunParent(self); particle.Vel = ( spd * cos(ha) * cos(va), spd * sin(ha) * cos(va), spd * sin(va) ); } } } Default { SnapChargeShot.ChargeDamage 80; SnapChargeShot.ChargeSwerve 0.0; SnapChargeShot.ChargeRadius 48.0; Speed 10; SeeSound "revolver/chargeFire4"; } States { Spawn: GNBL KLOMNP 1 Light("GeneratorZapPerfectLight") PerfectChargedZapTrail(); Loop; Death: GNBL L 1 Light("GeneratorZapPerfectLight"); TNT1 A 1 PerfectChargedZapExplode(); Stop; } } class BustableGenerator : SnapBoss { int GeneratorCharge; const GENCHARGEA = 30; const GENCHARGEB = GENCHARGEA * 2; const GENCHARGEMAX = GENCHARGEA * 3; Default { Health 1000; Radius 48; Height 76; SnapShadowActor.ShadowSize 32; DamageFactor "Melee", 0.0; Obituary "$OB_GENERATOR"; +NOBLOOD +DONTGIB +NOICEDEATH +DONTTHRUST -FLOORCLIP -WINDTHRUST -COUNTKILL -CANPUSHWALLS -CANUSEWALLS -ACTIVATEMCROSS -ISMONSTER -SnapActor.CANDROPAMMO +NOGRAVITY +DONTFALL +RELATIVETOFLOOR +MOVEWITHSECTOR +NODROPOFF } action void A_GeneratorDead() { Vector3 SpawnPos = Pos + (0, 0, Height * 0.5); double a = frandom[snap_decor](0.0, 180.0); SpawnPos.XY += frandom[snap_decor](-8.0, 8.0) * ( cos(a), sin(a) ); SpawnPos.Z += frandom[snap_decor](-8.0, 8.0); Actor flame = Spawn("SnapMonsterExplode", SpawnPos, ALLOW_REPLACE); if (flame != null) { flame.Vel.X = frandom[snap_decor](-1.0, 1.0) + (4.0 * cos(Angle)); // add some "wind" flame.Vel.Y = frandom[snap_decor](-1.0, 1.0); flame.Vel.Z = 1.0 + frandom[snap_decor](0.0, 6.0); flame.bNoGravity = true; } } void GeneratorPainFlags(bool val) { A_StopSound(CHAN_BODY); bNoPain = val; } void GeneratorFire() { if (bAmbush == true) { // Legacy generator behavior return; } if (bBossHard == false) { // Never fire on Normal return; } A_PickBossTarget(); class missileType = "GeneratorZap"; if (bVeryRude == true) { if (GeneratorCharge >= GENCHARGEMAX) { missileType = "GeneratorZapChargedPerfect"; A_StartSound("revolver/chargeFire4", CHAN_WEAPON, attenuation: ATTN_NONE); } else if (GeneratorCharge >= GENCHARGEB) { missileType = "GeneratorZapChargedGreat"; A_StartSound("revolver/chargeFire3", CHAN_WEAPON, attenuation: ATTN_NONE); } else if (GeneratorCharge >= GENCHARGEA) { missileType = "GeneratorZapCharged"; A_StartSound("revolver/chargeFire2", CHAN_WEAPON, attenuation: ATTN_NONE); } else { A_StartSound("revolver/chargeFire1", CHAN_ITEM, attenuation: ATTN_NONE); } } else { A_StartSound("revolver/chargeFire1", CHAN_ITEM, attenuation: ATTN_NONE); } A_SnapMonsterProjectile(missileType); GeneratorCharge = 0; } state DoGeneratorCharge() { if (bAmbush == true) { // Legacy generator behavior return null; } if (bBossHard == false) { // Never fire on Normal return null; } bNoPain = false; GeneratorCharge++; double ParticleSpeed = 0; if (GeneratorCharge >= GENCHARGEB) { A_StartSound("revolver/charge3", CHAN_BODY); ParticleSpeed = 8; } else if (GeneratorCharge >= GENCHARGEA) { A_StartSound("revolver/charge2", CHAN_BODY); ParticleSpeed = 4; } else { A_StartSound("revolver/charge1", CHAN_BODY); } if (ParticleSpeed > 0) { double ha = frandom[snap_decor](-180, 180); double va = frandom[snap_decor](-180, 180); uint ticsActive = 8; Vector3 spawnPos = Vec3Offset( ticsActive * -ParticleSpeed * cos(ha) * sin(va), ticsActive * -ParticleSpeed * sin(ha) * sin(va), (ticsActive * -ParticleSpeed * cos(va)) + (Height * 0.5) ); Actor particle = Spawn("GeneratorZapChargedTrail", spawnPos, ALLOW_REPLACE); if (particle != null) { particle.Vel = ( ParticleSpeed * cos(ha) * sin(va), ParticleSpeed * sin(ha) * sin(va), ParticleSpeed * cos(va) ); particle.Scale *= 2.0; let sa = SnapActor(particle); if (sa != null) { sa.SetHitstunParent(self); } } } if (GeneratorCharge >= GENCHARGEMAX) { return ResolveState("Missile"); } return null; } States { Spawn: GENR ABCDCBA 2 DoGeneratorCharge(); Loop; Missile: Pain: GENR A 0 GeneratorPainFlags(true); GENR ABC 1; GENR D 1 GeneratorFire(); GENR CBA 1; GENR A 0 GeneratorPainFlags(false); Goto Spawn; Death: GENR D 1; GENR D 0 A_SnapNoBlocking(); GENR D 0 A_BossDeath(); GENR E 3 DoSnapBossDie(); DeathLoop: GENR E 3 A_GeneratorDead(); Loop; } override void InitBossMeter() { return; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapPlayerGlobals : Thinker { // Since there's not really any other way to handle persistent data, // store it all in an inventory item. // Other files extend this. int PlayerID; SnapPlayerGlobals Init(int ID) { ChangeStatNum(STAT_STATIC); PlayerID = ID; return self; } static SnapPlayerGlobals GetForPlayerNum(int ID) { if (ID < 0 || ID >= MAXPLAYERS) { return null; } ThinkerIterator it = ThinkerIterator.Create("SnapPlayerGlobals", STAT_STATIC); SnapPlayerGlobals spi; while (spi = SnapPlayerGlobals(it.Next())) { if (spi.PlayerID == ID) { return spi; } } return new("SnapPlayerGlobals").Init(ID); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class GuardRoboBullet : SnapBasicShot { Default { DamageFunction 4; Speed 15; SeeSound "revolver/fire"; Obituary "$OB_GUARDROBO"; } } class GuardRobo : SnapMonster { bool UsingJetpack; bool NoJetpack; action void A_GuardChase() { let guard = GuardRobo(self); if (!guard) { A_SnapChase(); return; } guard.NoJetpack = false; if (guard.bVeryRude == true) { double targetDist = 10000.0; double jetDist = 1024.0; double jetRange = 640.0; uint wantJet = 0; if (target) { targetDist = (target.Pos - Pos).Length(); } if (targetDist > jetDist) { // Deactivate jetpack. wantJet = 2; } else if (targetDist < jetRange) { // Deactivate jetpack. wantJet = 1; } if (wantJet == 1 && guard.UsingJetpack == false) { // Activate your jetpack soon. A_SnapChase(null, 'Jetpack'); } else if (wantJet == 2 && guard.UsingJetpack == true) { // Not feeling threatened, deactivate it. guard.UsingJetpack = false; } else { // Business as usual A_SnapChase(); } return; } // Normal mode A_SnapChase(); } action void A_GuardJetpack() { let guard = GuardRobo(self); if (!guard) { return; } A_FaceTarget(22.5); VelFromAngle(-8.0); guard.UsingJetpack = true; A_StartSound("misc/swooce"); } action void A_GuardHurt() { let guard = GuardRobo(self); if (!guard) { return; } A_SnapMonsterPain(); // Just setting UsingJetpack = false doesn't work, // so just set this until the pain state's over. // A benefit to this is that they remember that they were using it, // so they don't have to redo the jetpack. guard.NoJetpack = true; } action void A_GuardJetpackPuffs(double momentum) { if (Level.maptime & 1) { return; } double a = angle + 180.0; double dist = 16.0; Vector3 offset = ( dist * cos(a), dist * sin(a), height * 0.75 ); Actor particle = Spawn("SnapSmoke", Pos + offset, ALLOW_REPLACE); if (particle) { particle.Vel.Z -= momentum + random[snap_decor](-1, 1); particle.Vel.XY += ( random[snap_decor](-1, 1), random[snap_decor](-1, 1) ); } } Default { Health 70; Radius 28; Height 72; Speed 8; Mass 200; SnapMonster.Poise 35; SeeSound "guardRobo/see"; ActiveSound "guardRobo/idle"; PainSound "guardRobo/hurt"; Obituary "$OB_GUARDROBO"; Tag "$TAG_GUARDROBO"; Species "Robot"; } States { Spawn: GRBO A 10 A_SnapMonsterLook(0, 0, 0, 0, 0, "WakeUp"); Loop; Idle: GRBO E 5 A_SnapMonsterLook(0, 0, 0, 0, 0, "See"); GRBO F 5; GRBO G 5 A_SnapMonsterLook(0, 0, 0, 0, 0, "See"); GRBO H 5; Loop; WakeUp: GRBO ABCDE 3; See: GRBO EFGH 4 A_GuardChase(); Loop; Missile: GRBO JLJL 4 A_FaceTarget(22.5); MissileLoop: GRBO I 4 Light("GuardRoboMuzzleLight") A_SnapMonsterProjectile("GuardRoboBullet", (32, -16, 12)); GRBO J 4 A_MonsterRefire(0, "See"); GRBO K 4 Light("GuardRoboMuzzleLight") A_SnapMonsterProjectile("GuardRoboBullet", (32, -16, 12)); GRBO L 4 A_MonsterRefire(0, "See"); Goto MissileLoop; Jetpack: GRBO E 1 A_GuardJetpack(); GRBO FGH 1; GRBO EFGH 1; Goto See; Pain: GRBO M 3; GRBO M 3 A_GuardHurt(); Goto See; Kicked: GRBO M 3; GRBO M 3 A_GuardHurt(); KickLoop: GRBO M 3 A_EndKick(); Loop; Death: GRBO M 1; TNT1 A 35 DoSnapMonsterDie(); Stop; GiantDeath: GRBO M 1; GRBO MMMMMMMM 4 DoSnapMonsterExplode(); TNT1 A 35 DoSnapMonsterDie(); Stop; } override void Tick() { super.Tick(); if (TickPaused() == true || Health <= 0) { return; } if (UsingJetpack == true && NoJetpack == false) { Gravity = Default.Gravity * 0.5; bCanJump = true; double f = GetZAt(); double c = GetZAt(0, 0, 0, GZF_CEILING); double floorDist = (Pos.Z + Vel.Z) - f; double ceilingDist = c - (Pos.Z + Height); if (ceilingDist >= 48.0) { double mul = 0.0; if (floorDist <= 64.0) { mul = 2.5; } else if (floorDist <= 128.0) { mul = 1.5; } if (mul != 0.0) { Vel.Z += Gravity * mul; A_GuardJetpackPuffs(4.0 * mul); } } } else { Gravity = Default.Gravity; bCanJump = false; } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapGunPickup : SnapInventory { Default { Inventory.PickupMessage "$POWERUP_GUN"; +FLOORCLIP +WEAPONSPAWN } States { Spawn: WP_7 A 10; WP_7 A 10 Bright; Loop; } override void DoPickupSpecial(Actor toucher) { PlayVoiceSample(toucher); ItemExtendCombo(toucher, true); super.DoPickupSpecial(toucher); } override bool TryPickup(in out Actor toucher) { let sp = SnapPlayer(toucher); if (sp == null || sp.SnapPlayerInfo == null) { // Needs to be a SnapPlayer return false; } if (sp.SnapPlayerInfo.NoGunMode == false) { // Already has a gun. return false; } // Give us back our gun! sp.SnapPlayerInfo.NoGunMode = false; if (multiplayer == true && deathmatch == false) { // Give everyone their gun back! for (int i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] == false) { continue; } PlayerInfo player = players[i]; if (player == null) { continue; } let other = SnapPlayer(player.mo); if (other != null) { if (other == sp || other.SnapPlayerInfo == null) { continue; } DoShareEffects(player); other.SnapPlayerInfo.NoGunMode = false; } } } GoAwayAndDie(); return true; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class HealthUp : Health { mixin SnapShadowCarryover; mixin SnapShadowCode; mixin SnapPickupCode; bool Shared; meta String SharedMessage; property SharedMessage: SharedMessage; override void BeginPlay() { super.BeginPlay(); ShadowBegin(); } override void Tick() { super.Tick(); ShadowTick(); } override void OnDestroy() { super.OnDestroy(); ShadowDestroy(); } Default { Radius 20; Height 24; Inventory.Amount 20; Inventory.PickupMessage "$POWERUP_HEALTH"; HealthUp.SharedMessage "$POWERUP_HEALTH_SHARED"; Inventory.PickupSound "powerup/health"; HealthUp.ShadowSize 16; +INVENTORY.AUTOACTIVATE +INVENTORY.ALWAYSPICKUP //+INVENTORY.NOSCREENFLASH +FLOORCLIP } States { Spawn: PW_H A 10; PW_H A 10 Bright; Loop; Share: PW_H C 10; PW_H C 10 Bright; Loop; } override void DoPickupSpecial(Actor toucher) { PlayVoiceSample(toucher); super.DoPickupSpecial(toucher); } override String PickupMessage() { if (Shared == true) { String message = SharedMessage; if (message.Length() != 0) { message = StringTable.Localize(message); String userName = "A friend"; if (Target != null && Target.Player != null) { userName = Target.Player.GetUserName(); } String finalized = ""; int chr; uint next; for (uint i = 0; i < message.Length(); i = next) { [chr, next] = message.GetNextCodePoint(i); if (chr == 37) // % { [chr, next] = message.GetNextCodePoint(next); if (chr == 111) // o { finalized.AppendFormat("%s", userName); } } else { finalized.AppendFormat("%c", chr); } } return finalized; } } return super.PickupMessage(); } override bool TryPickup(in out Actor toucher) { let sev = SnapStaticEventHandler.Get(); PrevHealth = (toucher.player != null) ? toucher.player.health : toucher.health; if (toucher.GiveBody(Amount, MaxAmount) == true) { ItemExtendCombo(toucher, (Amount >= 50)); Target = toucher; if (sev != null && toucher.player != null) { sev.SetStatVitalityBest(toucher.player, toucher.player.Health); } if (Shared == true && multiplayer == true && deathmatch == false) { // Big health pickups are shared! for (int i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] == false) { continue; } PlayerInfo player = players[i]; if (player == null) { continue; } let pmo = player.mo; if (pmo != null && pmo.health > 0) { if (pmo == toucher) { continue; } DoShareEffects(player); pmo.GiveBody(Amount, MaxAmount); if (sev != null) { sev.SetStatVitalityBest(player, player.Health); } } } } GoAwayAndDie(); return true; } return false; } const SHARE_RESIZE = 1.35; void SetShareable() { // For Coop scaling Shared = true; SetStateLabel("Share"); //A_SetSize(Radius * SHARE_RESIZE); ShadowSize *= SHARE_RESIZE; } } class SuperHealthUp : HealthUp { Default { Inventory.Amount 100; Inventory.PickupMessage "$POWERUP_SUPERHEALTH"; HealthUp.SharedMessage "$POWERUP_SUPERHEALTH_SHARED"; Inventory.PickupSound "powerup/bigHealth"; +INVENTORY.BIGPOWERUP } States { Spawn: PW_H B 10; PW_H B 10 Bright; Loop; Share: PW_H D 10; PW_H D 10 Bright; Loop; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapEventHandler { void DoHitConfirm(WorldEvent e) { SnapActor.PlayDamageSound(e.Damage, e.Thing, e.Inflictor, e.DamageSource); let p = PlayerPawn(e.DamageSource); if (!p) { return; } Actor confirmSpawnFrom = null; bool meleeHack = false; if (e.Inflictor && e.DamageSource && e.Inflictor == e.DamageSource) { // hack to prevent it from spawning inside of a player confirmSpawnFrom = e.Thing; meleeHack = true; } else if (e.Inflictor) { confirmSpawnFrom = e.Inflictor; } let monster = SnapMonster(e.Thing); if (monster) { if (monster.kickTossed == true && e.DamageType == "Melee") { // ULTRA HACK, to prevent it from spawning when landing on the ground from kick confirmSpawnFrom = null; } } if (confirmSpawnFrom != null) { let sa = SnapActor(e.Thing); if (sa) { sa.A_HitConfirm(confirmSpawnFrom, p, meleeHack); } let sp = SnapPlayer(e.Thing); if (sp) { sp.A_HitConfirm(confirmSpawnFrom, p, meleeHack); } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapHUD { const NumHitlagFrames = 4; static const String HitlagLines[] = { "HLSL1", "HLSL2", "HLSL3", "HLSL4" }; static const String HitlagStatic[] = { "HLST1", "HLST2", "HLST3", "HLST4" }; void DrawHitlagScreenEFX(SnapPlayer sp, Vector2 stOffset) { SnapHitstun Hitstun = sp.Hitstun; if (Hitstun == null) { return; } int time = Hitstun.Time; if (sp.bPauseEffect == true) { time = max(time, 1); } if (time == 0) { return; } bool UseStatic = Hitstun.FromDamage; double mul = (1.0 * time) / SnapHitstun.MAX_HITSTUN; uint frame = (Level.maptime % NumHitlagFrames); for (uint i = 0; i < 4; i++) { uint Align = 0; Vector2 OffsetDir = (0, 0); switch (i) { case 0: Align = DI_ITEM_RIGHT_TOP|DI_SCREEN_LEFT_BOTTOM; OffsetDir = (1, -1); break; case 1: Align = DI_ITEM_RIGHT_BOTTOM|DI_SCREEN_LEFT_TOP|DI_MIRRORY; OffsetDir = (1, 1); break; case 2: Align = DI_ITEM_LEFT_TOP|DI_SCREEN_RIGHT_BOTTOM|DI_MIRROR; OffsetDir = (-1, -1); break; case 3: Align = DI_ITEM_LEFT_BOTTOM|DI_SCREEN_RIGHT_TOP|DI_MIRROR|DI_MIRRORY; OffsetDir = (-1, 1); break; default: return; } Vector2 Offset = (0, 0); if (UseStatic == true) { Offset = 208.0 * OffsetDir; Offset += OffsetDir * 48.0 * mul; // Alternative: // Looks rounder, but doesn't cover as much of the screen. //Offset += (OffsetDir.X, 0.0) * 64.0 * mul; } else { Offset = 64.0 * OffsetDir; Offset += OffsetDir * 192.0 * mul; } if (!(Align & DI_MIRRORY)) { Offset += stOffset; } if (UseStatic == true) { DrawImage( HitlagStatic[frame], Offset, Align, 0.25 + mul, style: STYLE_Add ); } else { DrawImage( HitlagLines[frame], Offset, Align, 0.5, style: STYLE_Add ); } frame = ((frame + 1) % NumHitlagFrames); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapHitstun play { const MAX_HITSTUN = 10; Actor Owner; bool Active; uint Time; uint Prev; bool FromDamage; Actor Victim; Actor Inflictor; Actor Source; const SHIFT_DI_DIST = 16.0; bool ShiftDI; // 1.0 == 45 degrees const VEL_DI_MUL_H = 1.0; const VEL_DI_MUL_V = 0.2; const STUN_BREAK_MAX = 110; const STUN_BREAK_ADD = 1; const STUN_BREAK_DECAY = 1; // 1 uint StunBreak; uint StunDecayDelay; const BURST_TIME = TICRATE; const BURST_DMG_FACTOR = 0.5; uint Burst; const JITTER_DIST = 32.0; const JITTER_RESOLVE = 6; static clearscope int DamageToHitstun(int dmg) { // Minimum value: 1 frame. Add a frame for every 5 dmg above 10. return min(1 + (max(dmg - 10, 0) / 5), SnapHitstun.MAX_HITSTUN); } } class SnapHitstunSpark : SnapDynamicDecor { const TOO_CLOSE = 0.25; const WAY_TOO_CLOSE = 0.06; const INVISIBLE_TICS = 1; // Number of distinct effects. const NUM_EFFECTS = SnapHitstun.MAX_HITSTUN - INVISIBLE_TICS; Default { //RenderStyle "Add"; YScale (1.0 / 1.2); +BRIGHT +MASTERNOSEE } States { Spawn: TNT1 A 1; Stop; Effect1: HST1 A INVISIBLE_TICS; HST1 A 1; Stop; Effect2: HST2 A INVISIBLE_TICS; HST2 AB 1; Stop; Effect3: HST3 A INVISIBLE_TICS; HST3 ABC 1; Stop; Effect4: HST4 A INVISIBLE_TICS; HST4 ABCD 1; Stop; Effect5: HST5 A INVISIBLE_TICS; HST5 ABCDE 1; Stop; Effect6: HST6 A INVISIBLE_TICS; HST6 ABCDEF 1; Stop; Effect7: HST7 A INVISIBLE_TICS; HST7 ABCDEFG 1; Stop; Effect8: HST8 A INVISIBLE_TICS; HST8 ABCDEFGH 1; Stop; Effect9: HST9 A INVISIBLE_TICS; HST9 ABCDEFGHI 1; Stop; } static SnapHitstunSpark Create(int Added, Actor Victim, Actor Inflictor = null, Actor Source = null) { if (Added <= INVISIBLE_TICS) { return null; } if (Victim == null) { return null; } int Effect = Added - INVISIBLE_TICS - 1; if (Effect >= NUM_EFFECTS) { Effect = NUM_EFFECTS - 1; } Actor Other = (Inflictor == null) ? Source : Inflictor; Vector3 Dir = (0, 0, 0); if (Other != null) { Dir = Victim.Vec3To(Other); Dir.Z = Dir.Z + (Other.Height * 0.5) - (Victim.Height * 0.5); Dir = SnapUtils.SafeVec3Unit(Dir); } else { Dir.XY = Victim.AngleToVector(Victim.Angle); } Vector3 ParticlePos = Victim.Vec3Offset( Victim.Radius * Dir.X, Victim.Radius * Dir.Y, (Victim.Radius * Dir.Z) + (Victim.Height * 0.5) ); let Particle = SnapHitstunSpark(Spawn("SnapHitstunSpark", ParticlePos, ALLOW_REPLACE)); if (Particle == null) { return null; } static const StateLabel EffectStates[] = { "Effect1", "Effect2", "Effect3", "Effect4", "Effect5", "Effect6", "Effect7", "Effect8", "Effect9" }; Particle.SetStateLabel(EffectStates[Effect]); Particle.Master = Victim; double farScale = SnapUtils.GetFarawayScale(Victim) - WAY_TOO_CLOSE; if (farScale < 1.0) { // way too close too the screen Particle.bInvisible = true; } farScale -= TOO_CLOSE; farScale *= farScale; double victimScale = max(Victim.Scale.X, Victim.Scale.Y); Particle.Scale = ( Particle.Scale.X * victimScale, Particle.Scale.Y * victimScale ) * farScale; Particle.bXFlip = random[snap_decor](0, 1); Particle.bYFlip = random[snap_decor](0, 1); if (Particle.GetCVar("gl_weaponlight") ~== 0) { Particle.A_SetRenderStyle(0.5, STYLE_Add); } return Particle; } } mixin class SnapHitstunFuncs { SnapHitstun Hitstun; uint SuperShotIncr; uint HitstunFlags; flagdef ForceFreeze: HitstunFlags, 0; flagdef PauseEffect: HitstunFlags, 1; flagdef NoHitstun: HitstunFlags, 2; flagdef RipperHitstun: HitstunFlags, 3; flagdef CanDI: HitstunFlags, 4; virtual bool TickPaused() { if (isFrozen() == true) { return true; } if (bForceFreeze == true) { return true; } if (InHitstun() == true) { return true; } return false; } // - AddHitstun - // Set hitlag for the object. void AddHitstun(int Frames, bool FromDamage) { if (Hitstun == null) { // No hitstun initialized for this actor. return; } if (bNoHitstun == true) { return; } if (Frames <= 0) { // Not actually adding anything? return; } if (FromDamage == true) { let pmo = PlayerPawn(self); if (pmo != null && pmo.player != null && pmo.player.crouchfactor < 1.0) { // Crouch canceling. Frames = int(Frames * 0.65); if (Frames <= 0) { // Well, no more hitstun!! return; } } if (bCanDI == true && Hitstun.FromDamage == false) { // Create DI effect. Actor efx = Spawn("SnapDIEnergy", Pos, ALLOW_REPLACE); if (efx != null) { efx.Target = self; } } Hitstun.FromDamage = true; if (Hitstun.Time > 0) { // New source of hitlag, try shift DI. TryShiftDI(false); } } Hitstun.Time += Frames; if (Hitstun.Time > SnapHitstun.MAX_HITSTUN) { Hitstun.Time = SnapHitstun.MAX_HITSTUN; } } bool InHitstun() { if (Hitstun == null) { // No hitstun initialized for this actor. return false; } return (Hitstun.Time > 0); } bool TryBurst() { if (Hitstun == null) { // No hitstun initialized for this actor. return false; } if (Hitstun.StunBreak < SnapHitstun.STUN_BREAK_MAX) { // Not reached the point for burst. return false; } if (player != null) { // TODO: Allow players to burst? return false; } // Monsters always attempt to burst // at the earliest oppritunity, // as long as they can DI. return bCanDI; } void DoBurst() { if (Hitstun == null) { // No hitstun initialized for this actor. return; } Hitstun.StunBreak = 0; Hitstun.StunDecayDelay = 0; Hitstun.Burst = SnapHitstun.BURST_TIME; } Vector2 MonsterShiftDIDir(bool TryVelDI = false) { Vector2 DirInfluence = (0, 0); if (SnapUtils.ValidVec2Unit(Vel.XY) == true) { DirInfluence = SnapUtils.SafeVec2Unit(Vel.XY); } else if (target != null) { DirInfluence = SnapUtils.SafeVec2Unit(Vec2To(target)) * -1; } if (TryVelDI == true && TryBurst() == false) { int DodgeSign = 0; if (target != null && target.Health) { if (SnapUtils.SafeVec2Unit(Vec2To(target)) dot AngleToVector(angle + 90) < 0.0) { DodgeSign = -1; } else { DodgeSign = 1; } } if (DodgeSign != 0) { DirInfluence = (DirInfluence.Y, -DirInfluence.X) * -DodgeSign; } } return DirInfluence; } Vector2, double GetDIInput(bool HitstunEnd = false) { Vector2 DirInfluence = (0, 0); double DIMove = 0.0; let pmo = SnapPlayer(self); let player = self.player; if (pmo && player) { UserCmd cmd = player.cmd; Vector2 input = ( cmd.forwardmove, cmd.sidemove ); double MinInput = 10.0; double Length = input.Length(); if (Length < 0.0) { Length = 0.0; } else if (Length > 50.0) { Length = 50.0; } if (Length >= MinInput) { double SideAngle = Angle - 90; DIMove = SnapHitstun.SHIFT_DI_DIST; DirInfluence = (Length / 50.0) * SnapUtils.SafeVec2Unit(( (input.x * cos(angle)) + (input.y * cos(SideAngle)), (input.x * sin(angle)) + (input.y * sin(SideAngle)) )); } } else if (bCanDI == true) { DIMove = SnapHitstun.SHIFT_DI_DIST; DirInfluence = MonsterShiftDIDir(HitstunEnd); } return DirInfluence, DIMove; } void TryShiftDI(bool HitstunEnd = false) { if (Health <= 0) { // Dead, no DI. return; } if (Hitstun == null) { return; } // "Shift DI" is direction influence when a hit is interrupted. // A hit is interrupted whenever a new source of hitlag is added. // This lets you shift around a small distance during multi-hits. if (Hitstun.ShiftDI != true) { // Prevent several stacked hits in the same frame // from giving you a massive teleport. return; } if (Hitstun.FromDamage == false) { // Only when damaged. return; } Vector2 DirInfluence; double DIShift; [DirInfluence, DIShift] = GetDIInput(HitstunEnd); if (DirInfluence ~== (0, 0)) { // Too close to 0. return; } if (DIShift <= 0.0) { // I didn't want to remove the code for monster DI, // in case I changed my mind, so here's a check for this. return; } // Create afterimage Vector3 OldPos = Pos; uint DISteps = 8; if (Radius > 0) { while (DIShift >= radius * DISteps) { // We need to take smaller steps. DISteps += DISteps; } } Vector2 DIFrac = (DirInfluence * DIShift) / DISteps; for (uint i = 0; i < DISteps; i++) { if (TryMove(Pos.XY + DIFrac, true, false) == false) { // Don't continue into the wall. break; } } CreateShiftDIGhost(OldPos); Hitstun.ShiftDI = false; } void TryVelocityDI() { // "Velocity DI" lets your velocity's angle after hitlag ends. // This lets you adjust the momentum angle when it ends. if (Health <= 0) { // Dead, no DI. return; } if (Hitstun.FromDamage == false) { // Only when damaged. return; } Vector2 DirInfluence; double DIMove; [DirInfluence, DIMove] = GetDIInput(true); if (DirInfluence ~== (0, 0)) { // Too close to 0. return; } if (DIMove <= 0.0) { // I didn't want to remove the code for monster DI, // in case I changed my mind, so here's a check for this. return; } Vector3 VelDir = SnapUtils.SafeVec3Unit(Vel); Vector2 VelXYDir = SnapUtils.SafeVec2Unit(Vel.XY); double VelDot = (DirInfluence dot VelXYDir); double InvDot = 1.0 - abs(VelDot); Vector3 NewDir = VelDir; NewDir.XY += DirInfluence * InvDot * SnapHitstun.VEL_DI_MUL_H; double NewSpeed = Vel.Length(); if (TryBurst() == true) { // Burst has huge DI NewSpeed *= 1.5; if (NewSpeed < 48.0) { NewSpeed = 48.0; } DoBurst(); } bool CanModifyZ = true; let player = self.player; if (player) { // You can only adjust vertical angle if you're already in the air, // or if the knockback is significant enough. // Prevents tiny hops from Guard Robo bullets. CanModifyZ = (NewSpeed > 16.0 || !player.onground); } if (CanModifyZ) { NewDir.Z += DirInfluence.Length() * VelDot * SnapHitstun.VEL_DI_MUL_V; } NewDir = SnapUtils.SafeVec3Unit(NewDir); Vel = NewSpeed * NewDir; } virtual bool StunLocked() { let sm = SnapMonster(self); if (sm != null) { return sm.kickTossed; } let sp = SnapPlayer(self); if (sp != null) { return sp.kickTossed; } return false; } bool RunHitstun() { let pmo = SnapPlayer(self); let player = self.player; if (pmo != null && player != null) { if ((player.IsTotallyFrozen() == true) || (player.cheats & CF_FROZEN)) { return true; } } else { if (isFrozen() == true) { return true; } } if (Hitstun == null) { if (bNoHitstun == false) { HitstunBegin(); } return false; } else { if (bNoHitstun == true) { Hitstun.Destroy(); return false; } } if (Hitstun.Owner == null || Hitstun.Owner.bDestroyed == true) { // The existing hitstun instance became invalid. // Create our own, copying the properties from the old one. HitstunCopy(); } // Handle hitstun sparks. Doing this in Tick instead of // directly in HandleDamageHitstun because it allows // for stacked hitstun (like Spread Shot) to have // bigger hitstun sparks. if (Hitstun.Victim == self && Hitstun.FromDamage == true) { int Added = Hitstun.Time - Hitstun.Prev; if (Added > 0) { Hitstun.StunBreak += Added + SnapHitstun.STUN_BREAK_ADD; SnapHitstunSpark.Create(Added, self, Hitstun.Inflictor, Hitstun.Source); } Hitstun.Victim = Hitstun.Inflictor = Hitstun.Source = null; } // Children actors may be using our // hitstun instance, so only run if // we own this instance. if (Hitstun.Owner == self) { Hitstun.Active = false; if (Hitstun.Time > 0) { Hitstun.ShiftDI = true; if (Hitstun.StunBreak > SnapHitstun.MAX_HITSTUN * 2) { Hitstun.StunDecayDelay = SnapHitstun.STUN_BREAK_DECAY; } Hitstun.Active = InHitstun(); Hitstun.Time--; if (Hitstun.Time <= 0) { TryShiftDI(true); TryVelocityDI(); SuperShotIncr = 0; } } else { Hitstun.FromDamage = Hitstun.Active = Hitstun.ShiftDI = false; if (StunLocked() == false) { if (Hitstun.StunDecayDelay > 0) { Hitstun.StunDecayDelay--; } else if (Hitstun.StunBreak > 0) { Hitstun.StunBreak--; } } if (Hitstun.Burst > 0) { Hitstun.Burst--; } } Hitstun.Prev = Hitstun.Time; } if (Hitstun.Active == true) { bPauseEffect = true; if (GetCVar("gl_weaponlight") ~== 0) { bBright = Default.bBright; Translation = GetDefaultTranslation(); } else { bBright = true; A_SetTranslation("Paused"); } if (Hitstun.FromDamage == true) { double dist = (min(Hitstun.Time + 1, SnapHitstun.JITTER_RESOLVE) * SnapHitstun.JITTER_DIST) / SnapHitstun.JITTER_RESOLVE; dist *= SnapUtils.GetFarawayScale(self); Vector3 dir = SnapUtils.SafeVec3Unit(( frandom[snap_decor](-1.0, 1.0), frandom[snap_decor](-1.0, 1.0), (Pos.Z <= FloorZ) ? 0.0 : frandom[snap_decor](-1.0, 1.0) )); WorldOffset = ( dir.X * dist, dir.Y * dist, dir.Z * (dist / 1.2) ); } } else if (bPauseEffect == true) { bPauseEffect = false; bBright = Default.bBright; Translation = GetDefaultTranslation(); WorldOffset = (0, 0, 0); } return Hitstun.Active; } static int DoInflictorHitstun(int Damage, Actor Inflictor = null) { int Add = SnapHitstun.DamageToHitstun(Damage); let inf = SnapActor(Inflictor); if (inf != null) { if (inf.bRipper == true && inf.TouchDamage == 0 && inf.bRipperHitstun == false) { // No hitstun for ripper damage Add = 0; } else { inf.AddHitstun(Add, false); } } else { let sp = SnapPlayer(Inflictor); if (sp != null) { sp.AddHitstun(Add, false); } } return Add; } void HandleDamageHitstun(int Damage, Actor Inflictor = null, Actor Source = null) { if (Hitstun == null) { return; } if (bNoHitstun == true) { return; } if (Damage <= 0) { return; } if (Hitstun.Burst > 0) { // In burst -- don't get stopped. return; } int Add = DoInflictorHitstun(Damage, Inflictor); AddHitstun(Add, true); Hitstun.Victim = self; Hitstun.Inflictor = Inflictor; Hitstun.Source = Source; } Actor DefaultShiftDIGhost(class type, Vector3 SpawnPos, Vector3 DestPos, bool MatchSprites = false) { Actor ghost = Spawn(type, SpawnPos, ALLOW_REPLACE); if (ghost == null) { return null; } ghost.Angle = Angle; ghost.Pitch = Pitch; ghost.Roll = Roll; ghost.Target = self; ghost.FloorClip = FloorClip; ghost.Scale = Scale; ghost.Tics = 8; ghost.Vel = Level.Vec3Diff(SpawnPos, DestPos) / ghost.Tics; if (MatchSprites == true) { ghost.Sprite = Sprite; ghost.Frame = Frame; } ghost.Translation = Translation; return ghost; } void SetHitstunParent(Actor parent) { if (parent == null) { return; } let sa = SnapActor(parent); if (sa != null) { Hitstun = sa.Hitstun; return; } let sp = SnapPlayer(parent); if (sp != null) { Hitstun = sp.Hitstun; return; } } void HitstunBegin() { if (bNoHitstun == true) { return; } if (Hitstun == null) { Hitstun = SnapHitstun(new("SnapHitstun")); Hitstun.Owner = self; } } void HitstunCopy() { SnapHitstun Other = Hitstun; Hitstun = SnapHitstun(new("SnapHitstun")); Hitstun.Owner = self; if (Other != null) { Hitstun.Time = Other.Time; Hitstun.Prev = Other.Prev; Hitstun.StunBreak = Other.StunBreak; Hitstun.StunDecayDelay = Other.StunDecayDelay; Hitstun.Burst = Other.Burst; Hitstun.FromDamage = Other.FromDamage; Hitstun.ShiftDI = Other.ShiftDI; Hitstun.Active = Other.Active; } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapHomingProps : SnapWeaponProps { override void Init() { WeaponName = "Homing"; NiceName = "$SNAPMENU_WEAPON_HOMING"; PickupType = "SnapHomingPowerup"; WeaponIcon = "WP_HOMIN"; FireState = "FireHoming"; } } class SnapHomingCan : SnapItemCan { Default { DropItem "SnapHomingPowerup"; } States { Spawn: WP_H A 10; WP_H A 10 Bright; Loop; } } class SnapHomingPowerup : SnapWeaponPowerup { Default { SnapWeaponPowerup.WeaponPower "Homing"; Inventory.PickupMessage "$POWERUP_HOMING"; SnapInventory.VoiceSample "voice/homing"; } States { Spawn: WP_H B 10; WP_H B 10 Bright; Loop; } } class SnapHomingShotTrail : SnapActor { Default { Radius 16; Height 32; RenderStyle "Add"; +NOINTERACTION +NOGRAVITY +NOBLOCKMAP +RANDOMIZE +VISIBILITYPULSE +SnapActor.MISSILESPRITEFIX } States { Spawn: TNT1 A 2; HBUL KLMN 1 Bright; Stop; } } class SnapHomingShot : SnapBasicShot { // Homing does slightly less damage than Rapid or Spread, // but in exchange, very rarely will any of the damage/ammo // ever be wasted, because it homes in. // It also seeks out other targets instead of requiring aim. // This can be advantageous for long-range encounters // or encounters against a few powerful enemies, // but the slower firing and inability to aim yourself // can make it less useful for large groups. // While making this weapon I noted that it would hit walls // frequently when dealing with enemies on ledges, so I tried // adding a small period at the start where it's shot like a // normal projectile, and that fixed the problem. // At the time of writing, I don't know if we'll // have time to add Deathmatch, but just in case, I also made it // use Cybrass' weak homing when it targets a player. bool IsHoming; void DoHoming() { IsHoming = true; if (tracer) { Actor trail = Spawn("SnapHomingShotTrail", Pos, ALLOW_REPLACE); if (trail != null) { trail.target = self; let sa = SnapActor(trail); if (sa != null) { sa.SetHitstunParent(self); } } } } Default { Radius 16; Height 32; Speed 20; DamageFunction 25; DamageType "Homing"; Obituary "$OB_HOMING"; -RANDOMIZE +SEEKERMISSILE +SCREENSEEKER +SnapMissile.DIEWHENOWNERDIES } States { Spawn: HBUL ABCDEF 1 Light("HomingShotLight"); HomeIn: HBUL ABCDEF 2 Light("HomingShotLight") DoHoming(); Loop; Death: HBUL GHGHIJIJKLKLMNMN 1 Light("HomingShotLight"); Stop; } const HOMEDIST = 2048.0; override void Tick() { super.Tick(); if (TickPaused() == true) { return; } if (Health <= 0 || bMissile == false) { // Stopped being a missile. return; } double CurSpeed = Vel.Length(); if (CurSpeed < Speed) { CurSpeed = Speed; } Vel = ( CurSpeed * cos(Angle) * cos(-Pitch), CurSpeed * sin(Angle) * cos(-Pitch), CurSpeed * sin(-Pitch) ); if (IsHoming == false) { // Goes forward for a little bit before finding a tracer. tracer = null; return; } if (Vel == (0, 0, 0)) { // Can't really do much with no momentum. return; } if (tracer == null || tracer.Health <= 0) { // Find new tracer. Actor NewTracer = null; let owner = SnapPlayer(target); if (owner != null && owner.LockOn != null) { NewTracer = owner.LockOn; } else { Vector3 OrigDir = SnapUtils.SafeVec3Unit(Vel); double hd = HOMEDIST * Scale.X; NewTracer = FindHomingTarget(hd, VectorAngle(Vel.X, Vel.Y), target); } if (NewTracer != null && NewTracer.Health > 0) { // new tracer! tracer = NewTracer; } return; } // Move your angle values towards the victim. double MaxTurn = 22.5; if (SnapUtils.PlayerOrBot(tracer)) { // Make dodgeable in Versus. MaxTurn = 3.0; } Vector3 DirToTracer = Vec3To(tracer); DirToTracer.Z += tracer.Height * 0.5; A_SetAngle(SnapUtils.AngleTowardsDir(Angle, (DirToTracer.X, DirToTracer.Y), MaxTurn), SPF_INTERPOLATE); A_SetPitch(SnapUtils.AngleTowardsDir(Pitch, (DirToTracer.XY.Length(), -DirToTracer.Z), MaxTurn), SPF_INTERPOLATE); } } extend class SnapGun { action void A_SnapgunHoming() { if (player == null || player.mo == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } A_SnapgunFlash('HomingFlash'); A_SnapgunMomentumProjectile("SnapHomingShot"); A_StartSound("revolver/homing", CHAN_WEAPON); SoundAlert(self); player.mo.TakeInventory("SnapPowerupAmmo", 1, false, true); } States { FireHoming: SGUN A 1 A_SnapgunHoming; SGUN BCD 1; SGUN E 5; SGUN A 0 A_SnapGunRefire(); SGUN E 1; SGUN F 5; Goto GunIdle; HomingFlash: TNT1 A 1 Bright A_Light(2); SFL3 A 1 Bright A_Light(1); SFL3 B 1 Bright A_Light(0); SFL3 C 1 Bright; SFL3 D 1 Bright; Goto LightDone; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- // Class to display menu items horizontally. // Requires completely new menu items that expect to // draw horizontally, though. class SnapHorizontalMenu : SnapMenuBase abstract { override int GetTotalScrollSpace() { return int(VirtualSize.X - VirtualOffset.X + 0.5); } override int GetItemPos(int DestItem) { Array Items; GetItemList(Items); int NumItems = Items.Size(); if (DestItem < 0 || DestItem >= NumItems) { return 0; } double ItemPos = 0; int h = 0; for (int i = 0; i < NumItems; i++) { let item = Items[i]; h = GetItemHeight(item); if (i == DestItem) { // Center on the item. ItemPos += (h * 0.5); break; } ItemPos += h; } return int(ItemPos + 0.5); } override void ClampScrollPos() { int first = FirstCorporeal(); int last = LastCorporeal(); int FirstPos = GetItemPos(first); int LastPos = GetItemPos(last); double Scroll = GetTotalScrollSpace() * 0.5; double Pad = Scroll - SCROLL_PADDING; double ScreenCenter = Scroll; double min = (FirstPos - ScreenCenter) + Pad; double max = (LastPos - ScreenCenter) - Pad; if (min > max) { DestScrollPos.X = (min + max) * 0.5; } else { DestScrollPos.X = clamp(DestScrollPos.X, min, max); } } override void UpdateDestScroll(int Selected, bool force) { Array Items; GetItemList(Items); int NumItems = Items.Size(); int first = FirstCorporeal(); int last = LastCorporeal(); if (Selected < 0 || Selected >= NumItems) { // Set to default value. Selected = first; } if (Selected < first) { Selected = first; } else if (Selected > last) { Selected = last; } DestScrollPos.X = GetItemPos(Selected); ClampScrollPos(); if (force == true) { ScrollPos = DestScrollPos; } } override bool MenuEvent(int mKey, bool gamepad) { if (InMenuTransition() == true) { return false; } Array Items; GetItemList(Items); int startedAt = GetSelectedItem(); int NewSelected = startedAt; int NumItems = Items.Size(); switch (mKey) { case MKEY_Left: if (NewSelected == -1) { SetSelectedItem(FirstSelectable()); break; } do { --NewSelected; if (NewSelected < 0) { NewSelected = NumItems-1; } } while (Items[NewSelected].Selectable() == false && NewSelected != startedAt); SetSelectedItem(NewSelected); break; case MKEY_Right: if (NewSelected == -1) { SetSelectedItem(FirstSelectable()); break; } do { ++NewSelected; if (NewSelected >= NumItems) { NewSelected = 0; } } while (Items[NewSelected].Selectable() == false && NewSelected != startedAt); SetSelectedItem(NewSelected); break; case MKEY_PageUp: SetSelectedItem(FirstSelectable()); break; case MKEY_PageDown: SetSelectedItem(LastSelectable()); break; case MKEY_Back: let m = GetCurrentMenu(); let p = m.mParentMenu; MenuSound(p != null ? "menu/backup" : "menu/clear"); TryTransitionOut(p); ClosingMenu = true; return true; case MKEY_Enter: if (NewSelected >= 0 && Items[NewSelected].Activate()) { return true; } /* FALLTHRU */ default: if (NewSelected >= 0 && Items[NewSelected].MenuEvent(mKey, gamepad) == true) { return true; } return false; } if (GetSelectedItem() != startedAt) { MenuSound("menu/cursor"); } return true; } override bool MouseEvent(int type, int x, int y) { if (InMenuTransition() == true) { return false; } if (mFocusControl) { mFocusControl.MouseEvent(type, x, y); return true; } else { Array Items; GetItemList(Items); int xLine = -1; double ItemStart = -ScrollPos.X + VirtualOffset.X; double ItemEnd = ItemStart; int NumItems = Items.Size(); for (int i = 0; i < NumItems; i++) { if (ItemStart >= VirtualSize.X) { break; } let item = Items[i]; double h = GetItemHeight(item); if (h <= 0) { continue; } ItemEnd += h; if (x >= ItemStart && x <= ItemEnd && item.Selectable() == true) { xLine = i; break; } ItemStart += h; } if (xLine >= 0 && xLine < NumItems) { if (xLine != GetSelectedItem()) { SetSelectedItem(xLine, false); } Items[xLine].MouseEvent(type, x, y); return true; } } SetSelectedItem(-1, false); return true; } override bool OnUIEvent(UIEvent ev) { if (InMenuTransition() == true) { return false; } if (ev.type == UIEvent.Type_WheelUp) { SetSelectedItem(-1, false); DestScrollPos.X -= MOUSE_SCROLL_PIXELS * 3.0; ClampScrollPos(); return true; } else if (ev.type == UIEvent.Type_WheelDown) { SetSelectedItem(-1, false); DestScrollPos.X += MOUSE_SCROLL_PIXELS * 3.0; ClampScrollPos(); return true; } return MouseEvents(ev); } override void DrawItemList(Vector2 Offset, in out Array Items, int Selected, bool ShowScroll) { int FirstDrawn = -1; int LastDrawn = -1; Vector2 TransitionOffset = (0, 0); uint NumItems = Items.Size(); for (uint i = 0; i < NumItems; i++) { let item = Items[i]; let t = OptionMenuItemSnapTransition(item); if (t != null) { if (MenuTransition < 1.0) { TransitionOffset = t.mSlideDir; TransitionOffset.X *= (VirtualSize.X + VirtualOffset.X); TransitionOffset.Y *= (VirtualSize.Y + VirtualOffset.Y); TransitionOffset *= (1.0 - MenuTransition); } continue; } int h = GetItemHeight(item); bool isSelected = (Selected == i); Vector2 Delta = Offset - ScrollPos; if (item.Selectable() == true && isSelected == true && GetCurrentMenu() == self) { CallItemUpdateCursor(item, Delta + (0, h * 0.5), MenuData.Cursor); } Delta += TransitionOffset; if (h != 0) { // If itemheight is 0, // then we always want to draw this if (/*Delta.X + h < 0.0 ||*/ Delta.X > VirtualSize.X) { Offset.X += h; continue; } } item.Draw(mDesc, int(Delta.Y), int(Delta.X), isSelected); if (FirstDrawn == -1) { FirstDrawn = i; } LastDrawn = i; Offset.X += h; } if (ShowScroll == true) { CanScrollUp = (FirstDrawn > FirstSelectable()); CanScrollDown = (LastDrawn < LastSelectable()); /* if (CanScrollUp) { DrawOptionText(screen.GetWidth() - 11 * CleanXfac_1, 0.0, OptionMenuSettings.mFontColorSelection, "â–²"); } if (CanScrollDown) { DrawOptionText(screen.GetWidth() - 11 * CleanXfac_1 , Offset - 8*CleanYfac_1, OptionMenuSettings.mFontColorSelection, "â–¼"); } */ } } override void ItemsDrawer() { Array Items; GetItemList(Items); int Selected = GetSelectedItem(); DrawItemList((0, 0), Items, Selected, true); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapHUD : BaseStatusBar { SnapEventHandler ev; override void Init() { super.Init(); SetSize(LEDHeight, 320, 200); SetSlideWidth(); InitFonts(); InitHP(); POWInterp = DynamicValueInterpolator.Create(0, 0.25, 5, 150); LockOnSlide = LinearValueInterpolator.Create(0, 16); } override void ScreenSizeChanged() { super.ScreenSizeChanged(); SetSlideWidth(); } override void Tick() { super.Tick(); if (Level.maptime <= 2) { // Reset variables on map load DisplayBoss = false; DefeatedBoss = 0; for (int i = 0; i < NumTutorialIDs; i++) { TutorialsSeen[i] = false; } InvasionRobots = 0; } if (ev == null) { ev = SnapEventHandler(EventHandler.Find("SnapEventHandler")); } StarsTick(); MessageTick(); BossTick(); SecretTick(); if (ev != null && ev.Invasion != null) { uint RobotsLeft = ev.Invasion.CountMonsters(); if (InvasionRobots > RobotsLeft) { InvasionRobots--; } else if (InvasionRobots < RobotsLeft) { InvasionRobots++; } if (ev.Invasion.CoreTID > 0) { uint CoreHealthTotal = 0; uint CoreHealthMax = 0; ActorIterator CoreFinder = Level.CreateActorIterator(ev.Invasion.CoreTID); Actor mo; while (mo = CoreFinder.Next()) { CoreHealthMax += mo.SpawnHealth(); if (mo.health > 0) { CoreHealthTotal += mo.health; } } CoreHP.HPTicker(CoreHealthTotal, 100); CoreTrans = InvasionCore.CoreTranslation(CoreHealthTotal, CoreHealthMax); } } if (CPlayer) { OurHP.HPTicker(CPlayer.health); let sp = SnapPlayer(CPlayer.mo); if (sp) { let PInfo = sp.SnapPlayerInfo; if (PInfo != null) { int DisplayPOW = int(PInfo.POWMeter); int FilledStars = int(PInfo.POWMeter / sp.SnapPOWRationMax); let robo = SnapPlayerRobo(sp); if (robo != null) { DisplayPOW += int(robo.BotPower); } POWInterp.Update(DisplayPOW); for (int i = 0; i < 7; i++) { double DestHop = 0.0; double Speed = 0.25; if (sp.POWIsReady() == true && i < FilledStars) { int nstar = (StarFrame + 1) % 7; if (i == StarFrame || i == nstar) { DestHop = 2.0; } } StarHop[i] += (DestHop - StarHop[i]) * 0.5; } } if (sp.LockOn != null) { LockOnSlide.Update(LOCKONSLIDEMAX); } else { LockOnSlide.Update(0); } UpdateComboHUD(sp); } } for (uint i = 0; i < MAXPLAYERS; i++) { int hp = 0; PlayerInfo p = players[i]; if (p != null) { hp = p.Health; } SmallHP[i].HPTicker(hp); } } void DrawSnapNum(uint fullNum, uint digits, Vector2 pos, int flags = 0, String prefix = "") { DrawString( SnapNumFont, prefix..String.Format("%0"..digits.."d", fullNum), pos, flags ); } void DrawDividedStr(HUDFont ft, String left, String mid, String right, Vector2 pos, int flags = 0) { int MidOffset = ft.mFont.StringWidth(mid) / 2; DrawString( ft, mid, pos, flags|DI_TEXT_ALIGN_CENTER ); DrawString( ft, left, pos - (MidOffset, 0), flags|DI_TEXT_ALIGN_RIGHT ); DrawString( ft, right, pos + (MidOffset + 1, 0), flags|DI_TEXT_ALIGN_LEFT ); } void DrawLocalizedImage( String languageStr, Vector2 pos, int flags = 0, double alpha = 1.0, Vector2 box = (-1.0, -1.0), Vector2 scale = (1.0, 1.0), ERenderStyle style = STYLE_Translucent, Color col = 0xffffffff, int translation = 0, double clipwidth = -1.0) { DrawImage( Stringtable.Localize(languageStr), pos, flags, alpha, box, scale, style, col, translation, clipwidth ); } void DrawMainHUD(double TicFrac, SnapPlayer sp, Vector2 stOffset) { DrawLocalizedImage("$SNAP_GFX_HUDBACK", stOffset, DI_ITEM_LEFT_BOTTOM|DI_SCREEN_LEFT_BOTTOM); if (sp != null) { let PInfo = sp.SnapPlayerInfo; DrawHPNum(OurHP, (76, -14) + stOffset, DI_SCREEN_LEFT_BOTTOM|DI_ITEM_LEFT_BOTTOM); DrawImage( String.Format("%sFAC%d", sp.SnapMugPrefix, sp.SnapMug + 1), (3, -3) + stOffset, DI_ITEM_LEFT_BOTTOM|DI_SCREEN_LEFT_BOTTOM|DI_TRANSLATABLE ); DrawPlayerWeapon(sp, (38, -12) + stOffset, TicFrac); DrawStars(sp, PInfo, (2, -31), stOffset); DrawCombo(sp, (0, -1) + stOffset); if (sp.player.crouchdir < 0) { DrawImage( "CRCHICON", (-56, -2) + stOffset, DI_ITEM_RIGHT_BOTTOM|DI_SCREEN_RIGHT_BOTTOM ); } DrawKeyFobs(sp, (-4, -4) + stOffset); DrawPowerupDisplay(sp, (-4, -15) + stOffset); } } override void Draw(int state, double TicFrac) { BeginHUD(); Vector2 stOffset = (0, 0); if (state == HUD_StatusBar) { stOffset.y = -LEDHeight; } let sp = SnapPlayer(CPlayer.mo); if (sp != null) { if (sp.UsingPOW > 0) { // NOP } else { DrawHitlagScreenEFX(sp, stOffset); } if (sp.CrashClap > 0.0) { DrawCrashClap( sp.CrashClap - (sp.CrashClapVel * TicFrac), Translate.MakeID(TRANSLATION_Players, sp.PlayerNumber()) ); } } if (state == HUD_None) { return; } if (!automapactive) { // For some reason crosshair broke, so I have to reimplement it with way less options :( DrawImage("XHAIR", stOffset * 0.5, DI_ITEM_CENTER|DI_SCREEN_CENTER); DrawLockOn(stOffset * 0.5, TicFrac); } if (multiplayer == true) { Array Sort; SortSmallPlayers(Sort); uint len = Sort.Size(); if (len > 0) { Vector2 so = stOffset; for (uint i = 0; i < len; i++) { let ssp = SnapPlayer(players[Sort[i]].mo); if (ssp != null) { DrawSmallHUD(TicFrac, Sort[i], ssp, so); so.y -= 20; } } } } DrawMainHUD(TicFrac, sp, stOffset); if (ev != null && ev.Invasion != null && ev.Invasion.CoreTID > 0) { DrawLocalizedImage("$SNAP_GFX_COREHP", (0, 0), DI_ITEM_RIGHT_TOP|DI_SCREEN_RIGHT_TOP|DI_TRANSLATABLE, translation: CoreTrans); DrawHPNum(CoreHP, (-69, 3), DI_ITEM_RIGHT_TOP|DI_SCREEN_RIGHT_TOP, 5, true, 999, 0, 0.5); } DrawVersusCountdown(TicFrac); if (state == HUD_StatusBar) { DrawSnapMessages(TicFrac); } } } #include "zscript/snap/hud/fonts.zs" #include "zscript/snap/hud/vitality.zs" #include "zscript/snap/hud/weapon.zs" #include "zscript/snap/hud/keys.zs" #include "zscript/snap/hud/powerups.zs" #include "zscript/snap/hud/lockon.zs" #include "zscript/snap/hud/crash.zs" #include "zscript/snap/hud/hitlag.zs" #include "zscript/snap/hud/combo.zs" #include "zscript/snap/hud/jumbotron.zs" #include "zscript/snap/hud/boss.zs" #include "zscript/snap/hud/secret.zs" #include "zscript/snap/hud/countdown.zs" #include "zscript/snap/hud/multi.zs" //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapImpactProps : SnapWeaponProps { override void Init() { WeaponName = "Impact"; NiceName = "$SNAPMENU_WEAPON_IMPACT"; PickupType = "SnapImpactPowerup"; WeaponIcon = "WP_IMPCT"; FireState = "FireImpact"; DropFreq = 15; } } class SnapImpactCan : SnapItemCan { Default { DropItem "SnapImpactPowerup"; } } class SnapImpactPowerup : SnapWeaponPowerup { Default { SnapWeaponPowerup.WeaponPower "Impact"; Inventory.PickupMessage "$POWERUP_IMPACT"; SnapInventory.VoiceSample "voice/impact"; } States { Spawn: WPSS A 10; WPSS A 10 Bright; Loop; } } class SnapImpactShot : SnapSpreadShot { const NOKICKDMG = 20; // Damage of a single bullet. const KICKDMG = 30; // Damage of multiple stacked bullets. const KICKTHRUST = 16.0; Default { DamageFunction NOKICKDMG; DamageType "Impact"; Obituary "$OB_IMPACT"; Mass 20; ProjectileKickback 2000; } override int SpecialMissileHit(Actor victim) { if (victim == null || victim.bNonShootable == true || victim.bNoInteraction == true || victim.bNoClip == true || victim.bShootable == false || victim.bInvulnerable == true) { // Default interaction. return -1; } if (target != null) { if (victim == target || victim.isFriend(target) || victim.isTeammate(target)) { // Don't interact with friendlies. return -1; } } bool DoKickEffect = false; int hpLeft = TELEFRAG_DAMAGE; let sp = SnapPlayer(victim); if (sp != null) { DoKickEffect = (sp.SuperShotIncr > 0); sp.SuperShotIncr++; hpLeft = sp.Health; } let sa = SnapActor(victim); if (sa != null) { DoKickEffect = (sa.SuperShotIncr > 0); sa.SuperShotIncr++; hpLeft = sa.Health; let sm = SnapMonster(sa); if (sm != null) { hpLeft -= sm.ApplyDamageFactor("Melee", sm.kickTossDamage); } } if (DoKickEffect == true && hpLeft <= 0) { // Let the projectiles pass thru monsters // that are already dying return 1; } if (DoKickEffect == true) { // Do kick effect. int hitstunFrames = int(SnapHitstun.DamageToHitstun(KICKDMG) * 0.667); bool friendly = victim.isFriend(target); double addSpeed = 0.0; double moVel = Vel.Length(); if (moVel) { Vector2 facingDir = AngleToVector(angle, 1.0); double mul = min(1.0, max(0.0, (SnapUtils.SafeVec2Unit(facingDir) dot SnapUtils.SafeVec2Unit(Vel.XY)))); addSpeed += moVel * mul; } Vector2 KickSpeed = AngleToVector(angle, KICKTHRUST + addSpeed); Vector3 KickVec3 = (KickSpeed.X, KickSpeed.Y, KICKTHRUST); ExplodeMissile(null, victim); SnapUtils.TryKick(victim, self, self, KICKDMG, KickVec3, hitstunFrames, friendly); return 0; } else { // Do normal damage. if (TryClink(victim) == true) { return 1; } ExplodeMissile(null, victim); DoMissileDamage(victim); return 0; } } } extend class SnapGun { const SUPER_SPREAD = 5.0; action void A_SnapgunImpact() { if (player == null || player.mo == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } A_SnapgunFlash('BigFlash'); // Ordered by "priority", so that the farther ones // are used to kill enemies first, then the center ones go thru them. A_SnapgunMomentumProjectile("SnapImpactShot", -SUPER_SPREAD * 2.0, 0.0); A_SnapgunMomentumProjectile("SnapImpactShot", SUPER_SPREAD * 2.0, 0.0); A_SnapgunMomentumProjectile("SnapImpactShot", -SUPER_SPREAD, -SUPER_SPREAD); A_SnapgunMomentumProjectile("SnapImpactShot", SUPER_SPREAD, -SUPER_SPREAD); A_SnapgunMomentumProjectile("SnapImpactShot", -SUPER_SPREAD, SUPER_SPREAD); A_SnapgunMomentumProjectile("SnapImpactShot", SUPER_SPREAD, SUPER_SPREAD); A_SnapgunMomentumProjectile("SnapImpactShot", 0.0, 0.0); A_StartSound("revolver/bigfire", CHAN_WEAPON); SoundAlert(self); player.mo.TakeInventory("SnapPowerupAmmo", 2, false, true); } States { FireImpact: SGUN A 1 A_SnapgunImpact; SGUN BCD 1; SGUN E 2; Goto Reload; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- // Dummy intermission code. // Intermissions are now handled by level events now, // so this isn't used anymore. This exists if the game // ever gets forced to the intermission screen, otherwise // levels should be using hub-style transitions. // See event/intermission.zs for the actual intermissions. class DummyStatusScreen : StatusScreen { override void Start(wbstartstruct startStruct) { // Create just enough stuff that it doesn't crash. wbs = startStruct; bg = InterBackground.Create(wbs); // End immediately End(); } override void Drawer() { // No drawing. return; } override void StartMusic() { // No music change. return; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class InvasionThinker : Thinker { bool Started; uint Delay; double Scalar; uint NumPlayers; static double PlayerScalar() { uint Debug = SnapEventHandler.CoopScalingDebug(); int NumPlayers = (Debug > 0) ? Debug : SnapEventHandler.CoopScalingPlayers(); // Designed for 2P return 1.0 + (0.4 * (NumPlayers - 2)); } uint ScaleAmount(uint amount) { if (amount <= 1) { return amount; } return uint(max(1, ceil(Amount * Scalar))); } int ScaleDelay(int tics) { if (tics <= 1) { return tics; } return int(max(1, floor(tics / Scalar))); } static InvasionThinker Find() { let ev = SnapEventHandler.Get(); if (ev == null) { return null; } // Get without creating return ev.Invasion; } static InvasionThinker Get() { let ev = SnapEventHandler.Get(); if (ev == null) { return null; } // Create if it doesn't exist if (ev.Invasion == null || ev.Invasion.bDestroyed == true) { ev.Invasion = InvasionThinker(new("InvasionThinker")); } return ev.Invasion; } static void StartInvasion() { let inv = InvasionThinker.Get(); if (inv == null) { return; } inv.Start(); } void Start() { if (Waves.Size() == 0) { // Invalid settings for Invasion. Console.Printf("No wave upload scripts given for Invasion"); self.Destroy(); return; } // Init properties for wave 0 InitNewWave(); // Fast forward to our checkpoint wave. uint Checkpoint = GetCheckpoint(); if (Checkpoint > 0) // Don't need to for wave 1, since we start there! { SetWaveDirectly(Checkpoint); } // Activate the thinker. Started = true; Delay = 7*TICRATE; // Wait a bit before doing things though. } override void Tick() { if (Started == false || Level.isFrozen() == true) { return; } if (Delay > 0) { Delay--; return; } if (CheckCore() == false) { return; } uint EntSize = EntranceData.Size(); if (EntSize > 0) { for (uint i = 0; i < EntSize; i++) { if (EntranceData[i] != null) { RunEntranceCycle(EntranceData[i]); } } } if (ItemData != null) { RunItemCycle(ItemData); } WaveTick(); } } extend class SnapEventHandler { InvasionThinker Invasion; void InvasionForceWave(int Num) { if (Invasion == null) { return; } Invasion.ForceWaveCheat(Num); } } #include "./invasion/subwave.zs" #include "./invasion/wave.zs" #include "./invasion/core.zs" #include "./invasion/monsters.zs" #include "./invasion/items.zs" #include "./invasion/checkpoint.zs" //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapPlayer { const INVULNTICKS = 3*TICRATE; int SnapInvulnTick; void SetRespawnInvul() { bRespawnInvul = true; bNoTelefrag = true; SnapInvulnTick = INVULNTICKS; SnapEventHandler ev = SnapEventHandler(EventHandler.Find("SnapEventHandler")); if (ev != null) { if (ev.VSCountdown > 0) { SnapInvulnTick = ev.VSCountdown; } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- // // ======== // WARNING // ======== // // If you add a new item base type, you need to update // mixin class SnapMenuCore in core.zs, as it has // several functions that need to individually // check for class type. // // If at all possible, try to use the generic // SnapMenuItemBase, because that lets you // circumvent the need to do this. // const OPTIONS_MID_SPACE = 8; const OPTIONS_SUBMENU_SPACE = 24; mixin class SnapMenuItemCore { SnapMenuBase Parent; String mTooltip; virtual String Tooltip() { return mTooltip; } void CursorPlayFire() { if (Parent != null && Parent.MenuData != null) { Parent.TransitionDelay = SnapMenuCursor.FIRE_ANIM_DELAY; Parent.MenuData.Cursor.PlayFire(); } } } // // Base for entirely new menu items. // class SnapMenuItemBase : OptionMenuItem abstract { mixin SnapMenuDrawing; mixin SnapMenuItemCore; virtual int GetLineSpacing() { return 0; } override void OnMenuCreated() { super.OnMenuCreated(); PrecacheMenuDrawing(); } virtual bool isGrayed() { return false; } virtual bool DisplayGrayed() { // I mostly only want to edit the // drawing, so this function exists now. if (Parent != null) { bool InList = Parent.ItemCurrentlyInList(self); if (InList == false) { return true; } } return isGrayed(); } virtual void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.Offscreen(); } } #include "./items/data.zs" #include "./items/static.zs" #include "./items/submenu.zs" #include "./items/command.zs" #include "./items/option.zs" #include "./items/slider.zs" #include "./items/field.zs" #include "./items/control.zs" #include "./items/player.zs" //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapStaticEventHandler { bool BadIWAD; void UpdateIWADResult() { uint otherIWad = 0; uint snapIWad = 0; BadIWAD = false; // Start at 1 to ignore gzdoom.pk3. // IWADs should prooobably be within the first 255 files? for (uint wadID = 1; wadID < 256; wadID++) { int snapID = Wads.CheckNumForName("snapid", Wads.NS_GLOBAL, wadID, true); if (snapID != -1) { // Found Snap. snapIWad = wadID; break; } else { // Some random, common files between lots of different IWADs, // but AREN'T in game_support.pk3. int mapLump = Wads.CheckNumForName("MAP01", Wads.NS_GLOBAL, wadID, true); int exmxLump = Wads.CheckNumForName("E1M1", Wads.NS_GLOBAL, wadID, true); if (mapLump != -1 || exmxLump != -1) { otherIWad = wadID; } } } if (snapIWad && otherIWad && otherIWad < snapIWad) { // CODE 12, CODE 12 // DOOM WAS LOADED BEFORE SNAP BadIWAD = true; } } clearscope bool IsBadIWAD() { if (gamestate != GS_LEVEL) { // Don't prevent from using the menu. return false; } return BadIWAD; } void InitBadIWADState() { // Freeze gameplay. Level.setFrozen(true); for (uint i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i]) { continue; } PlayerInfo player = players[i]; if (player == null) { continue; } player.cheats |= CF_FROZEN|CF_TOTALLYFROZEN; } // Change music. S_ChangeMusic("cuts02"); } const BADIWAD_NUM_STRINGS = 6; const BADIWAD_STRING_SPACE = 2.0; ui void DrawBadIWADScreen() { TextureID iws = TexMan.CheckForTexture("BADIWAD"); double w = Screen.GetWidth(); double h = Screen.GetHeight(); double sc = min(w / 320, h / 200); double vw = w / sc; double vh = h / sc; double vwm = (vw - 320) / 2; double vhm = (vh - 200) / 2; Screen.Clear( 0, 0, int(w), int(h), Color(255, 0, 0, 0) ); Screen.DrawTexture(iws, true, vwm, vhm, DTA_VirtualWidthF, vw, DTA_VirtualHeightF, vh, DTA_KeepRatio, true ); static const String strings[] = { "Snap the Sentinel was loaded as a Doom PWAD,", "when it is a standalone IWAD. This will", "cause several issues due to file conflicts.", "", "Please restart GZDoom and", "load 'snapgame.ipk3' as your IWAD." }; Font fn = Font.GetFont("smallfont"); int txh = int(fn.GetHeight() * BADIWAD_STRING_SPACE); double txy = (vh / 2) - (txh * ((BADIWAD_NUM_STRINGS-1) / 2.0)); for (uint i = 0; i < BADIWAD_NUM_STRINGS; i++) { if (strings[i] != "") { int txw = fn.StringWidth(strings[i]); double txx = (vw / 2) - (txw / 2); Screen.DrawText( fn, Font.CR_UNTRANSLATED, txx, txy, strings[i], DTA_VirtualWidthF, vw, DTA_VirtualHeightF, vh, DTA_KeepRatio, true ); } txy += txh; } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapJoySensitivity : OptionMenuSliderJoySensitivity { mixin SnapMenuDrawing; mixin SnapMenuItemCore; mixin SnapSliderBase; SnapJoySensitivity Init( String label, String tooltip, double min, double max, double step, int showval, JoystickConfig joy) { super.Init(label, min, max, step, showval, joy); mTooltip = tooltip; return self; } virtual int GetLineSpacing() { return FontSmall.GetHeight(); } override void OnMenuCreated() { super.OnMenuCreated(); PrecacheMenuDrawing(); } virtual bool DisplayGrayed() { // I mostly only want to edit the // drawing, so this function exists now. if (Parent != null) { bool InList = Parent.ItemCurrentlyInList(self); if (InList == false) { return true; } } return isGrayed(); } virtual void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.DestPos = Delta + (BASE_VID_WIDTH * 0.5, 0); Cursor.DestPos = RightAlignPos(FontSmall, mLabel, Cursor.DestPos - (OPTIONS_MID_SPACE, 0)); Cursor.DestSmall = true; } virtual String GetSliderString(double Value, double Percent) { return DefaultSliderString(Value, Percent); } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { SliderDraw(desc, yOffset, xOffset, selected); return xOffset; } } class SnapJoyScale : OptionMenuSliderJoyScale { mixin SnapMenuDrawing; mixin SnapMenuItemCore; mixin SnapSliderBase; SnapJoyScale Init( String label, String tooltip, int axis, double min, double max, double step, int showval, JoystickConfig joy) { super.Init(label, axis, min, max, step, showval, joy); mTooltip = tooltip; return self; } virtual int GetLineSpacing() { return FontSmall.GetHeight(); } override void OnMenuCreated() { super.OnMenuCreated(); PrecacheMenuDrawing(); } virtual bool DisplayGrayed() { // I mostly only want to edit the // drawing, so this function exists now. if (Parent != null) { bool InList = Parent.ItemCurrentlyInList(self); if (InList == false) { return true; } } return isGrayed(); } virtual void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.DestPos = Delta + (BASE_VID_WIDTH * 0.5, 0); Cursor.DestPos = RightAlignPos(FontSmall, mLabel, Cursor.DestPos - (OPTIONS_MID_SPACE, 0)); Cursor.DestSmall = true; } virtual String GetSliderString(double Value, double Percent) { return DefaultSliderString(Value, Percent); } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { SliderDraw(desc, yOffset, xOffset, selected); return xOffset; } } class SnapJoyDeadZone : OptionMenuSliderJoyDeadZone { mixin SnapMenuDrawing; mixin SnapMenuItemCore; mixin SnapSliderBase; SnapJoyDeadZone Init( String label, String tooltip, int axis, double min, double max, double step, int showval, JoystickConfig joy) { super.Init(label, axis, min, max, step, showval, joy); mTooltip = tooltip; return self; } virtual int GetLineSpacing() { return FontSmall.GetHeight(); } override void OnMenuCreated() { super.OnMenuCreated(); PrecacheMenuDrawing(); } virtual bool DisplayGrayed() { // I mostly only want to edit the // drawing, so this function exists now. if (Parent != null) { bool InList = Parent.ItemCurrentlyInList(self); if (InList == false) { return true; } } return isGrayed(); } virtual void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.DestPos = Delta + (BASE_VID_WIDTH * 0.5, 0); Cursor.DestPos = RightAlignPos(FontSmall, mLabel, Cursor.DestPos - (OPTIONS_MID_SPACE, 0)); Cursor.DestSmall = true; } virtual String GetSliderString(double Value, double Percent) { return DefaultSliderString(Value, Percent); } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { SliderDraw(desc, yOffset, xOffset, selected); return xOffset; } } class SnapJoyMap : OptionMenuItemJoyMap { mixin SnapMenuDrawing; mixin SnapMenuItemCore; mixin SnapOptionBase; SnapJoyMap Init( String label, String tooltip, int axis, Name values, int center, JoystickConfig joy) { super.Init(label, axis, values, center, joy); mTooltip = tooltip; return self; } virtual int GetLineSpacing() { return FontSmall.GetHeight(); } override void OnMenuCreated() { super.OnMenuCreated(); PrecacheMenuDrawing(); } virtual bool DisplayGrayed() { // I mostly only want to edit the // drawing, so this function exists now. if (Parent != null) { bool InList = Parent.ItemCurrentlyInList(self); if (InList == false) { return true; } } return isGrayed(); } virtual void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.DestPos = Delta + (BASE_VID_WIDTH * 0.5, 0); Cursor.DestPos = RightAlignPos(FontSmall, mLabel, Cursor.DestPos - (OPTIONS_MID_SPACE, 0)); Cursor.DestSmall = true; } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { OptionDraw(desc, yOffset, xOffset, selected); return xOffset; } } class SnapJoyInvert : OptionMenuItemInverter { mixin SnapMenuDrawing; mixin SnapMenuItemCore; mixin SnapOptionBase; SnapJoyInvert Init( String label, String tooltip, int axis, int center, JoystickConfig joy) { super.Init(label, axis, center, joy); mTooltip = tooltip; return self; } virtual int GetLineSpacing() { return FontSmall.GetHeight(); } override void OnMenuCreated() { super.OnMenuCreated(); PrecacheMenuDrawing(); } virtual bool DisplayGrayed() { // I mostly only want to edit the // drawing, so this function exists now. if (Parent != null) { bool InList = Parent.ItemCurrentlyInList(self); if (InList == false) { return true; } } return isGrayed(); } virtual void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.DestPos = Delta + (BASE_VID_WIDTH * 0.5, 0); Cursor.DestPos = RightAlignPos(FontSmall, mLabel, Cursor.DestPos - (OPTIONS_MID_SPACE, 0)); Cursor.DestSmall = true; } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { OptionDraw(desc, yOffset, xOffset, selected); return xOffset; } } class SnapGamepadItem : OptionMenuItemSnapSubmenu { JoystickConfig mJoy; SnapGamepadItem Init(String label, JoystickConfig joy) { super.Init(label, "", "SnapGamepadConfig"); mJoy = joy; return self; } override bool Activate() { let desc = OptionMenuDescriptor(MenuDescriptor.GetDescriptor("SnapGamepadConfig")); if (desc != null) { SetController(desc, mJoy); } bool res = super.Activate(); let joyMenu = SnapGamepadConfig(Menu.GetCurrentMenu()); if (res == true && joyMenu != null) { joyMenu.mJoy = mJoy; } return res; } static void SetController(OptionMenuDescriptor opt, JoystickConfig joy) { OptionMenuItem it; opt.mItems.Clear(); it = new("OptionMenuItemSnapTransition").Init(0, 0.0, 1.0); opt.mItems.Push(it); it.OnMenuCreated(); if (joy == null) { it = new("OptionMenuItemSnapStaticLabel").Init("$JOYMNU_INVALID"); opt.mItems.Push(it); it.OnMenuCreated(); } else { it = new("OptionMenuItemSnapStaticHeader").Init(joy.GetName()); opt.mItems.Push(it); it.OnMenuCreated(); it = new("SnapJoySensitivity").Init( "$JOYMNU_OVRSENS", "$SNAPMENU_JOYOVRSENS_TOOLTIP", 0, 2, 0.1, 3, joy ); opt.mItems.Push(it); it.OnMenuCreated(); if (joy.GetNumAxes() > 0) { for (int i = 0; i < joy.GetNumAxes(); ++i) { it = new("OptionMenuItemSnapStaticHeader").Init(joy.GetAxisName(i)); opt.mItems.Push(it); it.OnMenuCreated(); it = new("SnapJoyMap").Init( "$SNAPMENU_JOYMAP", "$SNAPMENU_JOYMAP_TOOLTIP", i, "JoyAxisMapNames", false, joy ); opt.mItems.Push(it); it.OnMenuCreated(); it = new("SnapJoyScale").Init( "$JOYMNU_OVRSENS", "$SNAPMENU_JOYSCALE_TOOLTIP", i, 0, 4, 0.1, 3, joy ); opt.mItems.Push(it); it.OnMenuCreated(); it = new("SnapJoyInvert").Init( "$JOYMNU_INVERT", "$SNAPMENU_JOYINVERT_TOOLTIP", i, false, joy ); opt.mItems.Push(it); it.OnMenuCreated(); it = new("SnapJoyDeadZone").Init( "$JOYMNU_DEADZONE", "$SNAPMENU_JOYDEADZONE_TOOLTIP", i, 0, 0.9, 0.05, 3, joy ); opt.mItems.Push(it); it.OnMenuCreated(); } } else { it = new("OptionMenuItemSnapStaticLabel").Init("$JOYMNU_NOAXES"); opt.mItems.Push(it); it.OnMenuCreated(); } } opt.mSelectedItem = -1; } } class SnapGamepadSelect : SnapMenuBase { // I do NOT feel like going through the same misery // as the menu items needing tons of functions that // simply check their type and call the proper thing. // So instead we watch the real joystick menu and // pass its information to the new one. bool ConfigureMsg; bool ConnectMsg; MenuItemBase GetDescItem(OptionMenuDescriptor opt, Name ItemName) { for (int i = 0; i < opt.mItems.Size(); i++) { if (opt.mItems[i].GetAction() == ItemName) { return opt.mItems[i]; } } return null; } SnapGamepadItem CreateGamepadItem(String JoyName, JoystickConfig JoyCfg) { let item = SnapGamepadItem( new("SnapGamepadItem") ); item.Init(JoyName, JoyCfg); mDesc.mItems.Push(item); item.OnMenuCreated(); item.Parent = self; return item; } void DetectJoystickChanges() { // Retrieve the menu descriptor for the real joystick menu. OptionMenuDescriptor RealDesc = OptionMenuDescriptor(MenuDescriptor.GetDescriptor("JoystickOptions")); if (RealDesc == null) { return; } JoystickConfig OldJoy = null; int Selected = GetSelectedItem(); if (Selected >= 0 && Selected < mDesc.mItems.Size()) { let item = SnapGamepadItem(mDesc.mItems[Selected]); if (item != null) { OldJoy = item.mJoy; } } bool HeaderMsgSwitch = false; let cfgIt = OptionMenuItemStaticTextSwitchable(GetDescItem(RealDesc, "ConfigureMessage")); if (cfgIt != null) { HeaderMsgSwitch = (cfgIt.mCurrent != 0); } mDesc.mItems.Clear(); let TransitionItem = new("OptionMenuItemSnapTransition").Init(0, 0, 1); mDesc.mItems.Push(TransitionItem); TransitionItem.OnMenuCreated(); let HeaderItem = OptionMenuItemSnapStaticHeader( new("OptionMenuItemSnapStaticHeader") ); if (HeaderMsgSwitch == true) { HeaderItem.Init("$SNAPMENU_CONFIGGAMEPADS"); } else { HeaderItem.Init("$SNAPMENU_NOGAMEPADS"); } mDesc.mItems.Push(HeaderItem); HeaderItem.OnMenuCreated(); bool SetSelected = false; for (int i = 0; i < RealDesc.mItems.Size(); i++) { let item = OptionMenuItemJoyConfigMenu(RealDesc.mItems[i]); if (item == null) { continue; } let newItem = CreateGamepadItem(item.mLabel, item.mJoy); if (item.mJoy == OldJoy || SetSelected == false) { SetSelectedItem(mDesc.mItems.Size() - 1); SetSelected = true; } } let cur = SnapGamepadConfig(GetCurrentMenu()); if (cur != null) { uint NumItems = mDesc.mItems.Size(); uint i = 0; for (i = 0; i < NumItems; i++) { let item = SnapGamepadItem(mDesc.mItems[i]); if (item != null && item.mJoy == cur.mJoy) { break; } } if (i >= NumItems) { cur.Close(); } } } override void Init(Menu parent, OptionMenuDescriptor desc) { super.Init(parent, desc); DetectJoystickChanges(); } override void Ticker() { DetectJoystickChanges(); super.Ticker(); } } class SnapGamepadConfig : SnapMenuBase { JoystickConfig mJoy; } class JsonArray : JsonElement { // pretty much just a wrapper for a dynamic array Array arr; static JsonArray make(){ return new("JsonArray"); } JsonElement get(uint index){ return arr[index]; } void set(uint index,JsonElement obj){ arr[index]=obj; } int push(JsonElement obj){ return arr.push(obj); } bool pop(){ return arr.pop(); } void insert(uint index,JsonElement obj){ arr.insert(index,obj); } void delete(uint index,int count=1){ arr.delete(index,count); } int size(){ return arr.size(); } void shrinkToFit(){ arr.shrinkToFit(); } void grow(uint count){ arr.grow(count); } void resize(uint count){ arr.resize(count); } void reserve(uint count){ arr.reserve(count); } int max(){ return arr.max(); } void clear(){ arr.clear(); } override string serialize(){ String s; bool first=true; s.AppendCharacter(JSON.SQUARE_OPEN); for(int i=0;i keys; } class JsonObjectTableElement { Array kv_for_hash; } class JsonObject : JsonElement { const table_size = 256; // rather small for a general hash table, but should be enough for a json object private Array table; private uint elems; static JsonObject make(){ let obj = new("JsonObject"); obj.table.resize(256); for(uint i = 0; i < 256; i++) { obj.table[i] = new("JsonObjectTableElement"); } return obj; } private uint hash(String s){ // djb2 hashing algorithm uint h = 5381; for(uint i = 0; i < s.length(); i++){ h = (h*33) + s.byteat(i); } return h; } private JsonElement getFrom(out Array arr, String key){ let n = arr.Size(); for(int i = 0; i < n; i++){ if(arr[i].key == key){ return arr[i].e; } } return null; } private bool setAt(out Array arr, String key, JsonElement e, bool replace){ let n = arr.Size(); for(int i = 0; i < n; i++){ if(arr[i].key == key){ if(replace){ arr[i].e = e; } return replace; } } arr.push(JsonObjectElement.make(key, e)); elems++; return true; } private bool delAt(out Array arr, String key){ let n = arr.Size(); for(int i = 0; i < n; i++){ if(arr[i].key == key){ arr.Delete(i); elems--; return true; } } return false; } JsonElement Get(String key){ uint sz = table_size; return getFrom(table[hash(key) % sz].kv_for_hash, key); } void Set(String key,JsonElement e){ uint sz = table_size; setAt(table[hash(key) % sz].kv_for_hash, key, e, true); } bool Insert(String key,JsonElement e){//only inserts if key doesn't exist, otherwise fails and returns false uint sz = table_size; return setAt(table[hash(key) % sz].kv_for_hash, key, e, false); } bool Delete(String key){ uint sz = table_size; return delAt(table[hash(key) % sz].kv_for_hash, key); } void GetKeysInto(out Array keys){ keys.Clear(); for(uint i = 0; i < table_size; i++) { let n = table[i].kv_for_hash.size(); for(int j = 0; j < n; j++) { keys.Push(table[i].kv_for_hash[j].key); } } } JsonObjectKeys GetKeys(){ JsonObjectKeys keys = new("JsonObjectKeys"); GetKeysInto(keys.keys); return keys; } deprecated("0.0", "Use IsEmpty Instead") bool empty() { return elems == 0; } bool IsEmpty(){ return elems == 0; } void Clear(){ for(uint i = 0; i < table_size; i++){ table[i].kv_for_hash.clear(); } } uint size(){ return elems; } override string serialize(){ String s; s.AppendCharacter(JSON.CURLY_OPEN); bool first = true; for(uint i = 0; i < table_size; i++){ let n = table[i].kv_for_hash.Size(); for(int j = 0; j < n; j++){ if(!first){ s.AppendCharacter(JSON.COMMA); } s.AppendFormat("%s:%s", JSON.serialize_string(table[i].kv_for_hash[j].key), table[i].kv_for_hash[j].e.serialize()); first = false; } } s.AppendCharacter(JSON.CURLY_CLOSE); return s; } } class JSON { //char literals const TAB = 0x9; // '\t' const LF = 0xA; // '\n' const CR = 0xD; // '\r' const SPACE = 0x20; // ' ' const NUM_0 = 0x30; // '0' const NUM_9 = 0x39; // '9' const _DOT = 0x2E; // '.' const COMMA = 0x2C; // ',' const COLON = 0x3A; // ':' const QUOTE_1 = 0x27; // '\'' const QUOTE_2 = 0x22; // '\"' const BACKSLASH = 0x5C; // '\\' const SLASH = 0x2F; // '/' const ASTERISK = 0x2A; // '*' const SQUARE_OPEN = 0x5B; // '[' const SQUARE_CLOSE = 0x5D; // ']' const CURLY_OPEN = 0x7B; // '{' const CURLY_CLOSE = 0x7D; // '}' const PLUS = 0x2B; // '+' const MINUS = 0x2D; // '-' private static bool isWhitespace(int c){ return c==TAB||c==LF||c==CR||c==SPACE; } private static bool isNumber(int c){ return c>=NUM_0&&c<=NUM_9; } private static int getEscape(int c){//DOESN'T SUPPORT UNICODE/HEX/OCTAL switch(c){ case 0x61://a return 0x07; case 0x62://b return 0x08; case 0x65://e return 0x1B; case 0x6E://n return 0x0A; case 0x72://r return 0x0D; case 0x74://t return 0x09; case 0x76://v return 0x0B; default: return c; } } private static int needsEscape(int c,bool single_quote){ switch(c){ case 0x07://a case 0x08://b case 0x1B://e case 0x0A://n case 0x0D://r case 0x09://t case 0x0B://v return true; case QUOTE_1: return single_quote; case QUOTE_2: return !single_quote; default: return false; } } private static int makeEscape(int c){ switch(c){ case 0x07://a return 0x61; case 0x08://b return 0x62; case 0x1B://e return 0x65; case 0x0A://n return 0x6E; case 0x0D://r return 0x72; case 0x09://t return 0x74; case 0x0B://v return 0x76; default: return c; } } //skip whitespace and comments private static void skipWhitespace(out string data,out uint i,uint len,out uint line){ if(i>=len)return; //while data[i] is whitespace, cr/lf or tab, advance index for(uint c,ii;i=len) return JsonError.make("Expected String, got EOF"); uint delim,ii; [delim,ii]=data.getNextCodePoint(i); if(delim!=QUOTE_1&&delim!=QUOTE_2){ return JsonError.make("Expected ''' or '\"' (String), got "..data.mid(i,1)); } i=ii; JsonString s=JsonString.make(); uint c,i3; for(;ii=len){ return JsonError.make("On String, expected Character, got EOF"); } s.s.appendFormat("%s",data.mid(i,ii-i)); [c,ii]=data.getNextCodePoint(i3); s.s.appendCharacter(getEscape(c)); i=ii; }else if(c==LF){ return JsonError.make("On String, expected Character, got EOL"); }else{ ii=i3; } } string delim_s=""; delim_s.appendCharacter(delim); return JsonError.make("On String, expected '"..delim_s.."', got EOF"); } //parse a json object, allows trailing commas private static JsonElementOrError parseObject(out string data,out uint i,uint len,out uint line) { if(i>=len) return JsonError.make("Expected Object, got EOF"); uint c,ii; [c,ii]=data.getNextCodePoint(i); if(c!=CURLY_OPEN){ return JsonError.make("Expected '{' (Object), got '"..data.mid(i,1).."'"); } i=ii; JsonObject obj=JsonObject.make(); string last_element; bool has_last_element=false; for(;i=len){ return JsonError.make("On Object value '"..last_element.."', expected ':', got EOF"); } [c,ii]=data.getNextCodePoint(i); if(c!=COLON){ return JsonError.make("On Object value '"..last_element.."', expected ':', got '"..data.mid(i,1).."'"); } i=ii; skipWhitespace(data,i,len,line); if(i>=len){ return JsonError.make("On Object value '"..last_element.."', expected element, got EOF"); } let elem=parseElement(data,i,len,line); if(elem is "JsonError"){ return JsonError.make("On Object value '"..last_element.."', "..JsonError(elem).what); } obj.set(JsonString(key).s,JsonElement(elem)); skipWhitespace(data,i,len,line); if(i>=len){ return JsonError.make("After Object value '"..last_element.."', expected ',', got EOF after element '"..last_element.."'"); } [c,ii]=data.getNextCodePoint(i); if(c!=COMMA){ if(c==CURLY_CLOSE){ continue; } return JsonError.make("After Object value '"..last_element.."', expected ',', got '"..data.mid(i,1).."'"); } i=ii; } if(has_last_element){ return JsonError.make("After Object value '"..last_element.."', expected }, got EOF"); }else{ return JsonError.make("On Empty Object, expected }, got EOF"); } } //parse a json array, allows trailing commas private static JsonElementOrError parseArray(out string data,out uint i,uint len,out uint line) { if(i>=len) return JsonError.make("Expected Array, got EOF"); uint c,ii; [c,ii]=data.getNextCodePoint(i); if(c!=SQUARE_OPEN){ return JsonError.make("Expected '[' (Array), got '"..data.mid(i,1).."'"); } i=ii; JsonArray arr=JsonArray.make(); for(;i=len){ return JsonError.make("On Array index "..(arr.size()-1)..", expected ',', got EOF"); } [c,ii]=data.getNextCodePoint(i); if(c!=COMMA){ if(c==SQUARE_CLOSE){ continue; } return JsonError.make("After Array index "..(arr.size()-1)..", expected ',', got '"..data.mid(i,1).."'"); } i=ii; } if(arr.size()==0){ return JsonError.make("On Empty Array, expected ], got EOF"); }else{ return JsonError.make("After Array index "..(arr.size()-1)..", expected ], got EOF"); } } //parse a number in the format [0-9]+(?:\.[0-9]+)? private static JsonElementOrError parseNumber(out string data,out uint i,uint len) { if(i>=len) return JsonError.make("Expected Number, got EOF"); uint ii,i3,c; [c,ii]=data.getNextCodePoint(i); if(!isNumber(c)) return JsonError.make("Expected '0'-'9' (Number), got '"..data.mid(i,1).."'"); ii=i; bool is_double=false; for(;ii=len){ return JsonError.make("Expected JSON Element, got EOF"); } uint c,ii; [c,ii]=data.getNextCodePoint(i); if(isNumber(c)){//number return parseNumber(data,i,len); }else if(c==PLUS||c==MINUS){ i=ii; skipWhitespace(data,i,len,line); let num=parseNumber(data,i,len); if(c==MINUS && num is "JsonNumber"){ return JsonNumber(num).negate(); }else{ return num; } }else if(c==SQUARE_OPEN){//array return parseArray(data,i,len,line); }else if(c==CURLY_OPEN){//object return parseObject(data,i,len,line); }else if(c==QUOTE_1||c==QUOTE_2){//string return parseString(data,i,len); }else if(data.mid(i,4)=="true"){//bool, true i+=4; return JsonBool.make(true); }else if(data.mid(i,5)=="false"){//bool, false i+=5; return JsonBool.make(false); }else if(data.mid(i,4)=="null"){//null i+=4; return JsonNull.make(); }else{ return JsonError.make("Expected JSON Element, got '"..data.mid(i,1).."'"); } } // roughly O(n), has extra complexity from data structures (DynArray, HashTable) and string copying static JsonElementOrError parse(string json_string,bool allow_data_past_end=false){ uint index=0; uint line=1; uint len=json_string.length(); JsonElementOrError elem=parseElement(json_string,index,len,line); if(!(elem is "JsonError")){ skipWhitespace(json_string,index,len,line); if(index MessageQueue; uint FinalMsgDelay; uint MsgSlide; uint MsgSlideIn; uint LEDOverlayFrame; const NumTutorialIDs = 10; bool TutorialsSeen[NumTutorialIDs]; const MaxDisplayTime = (6000*TICRATE)-1; const LEDOverlayMaxFrame = 5; static const String LEDOverlayFrames[] = { "LEDOV1", "LEDOV2", "LEDOV3", "LEDOV4", "LEDOV5", "LEDBACK" }; uint InvasionRobots; enum JumbotronStates { JUMBO_STATS, JUMBO_BOSS, JUMBO_SECRETS, } uint JumbotronState; uint NewJumbotronState() { if (ShowSecrets > 0) { return JUMBO_SECRETS; } if (DisplayBoss == true) { return JUMBO_BOSS; } else { return JUMBO_STATS; } } void InsertSnapMessage(String message) { bool emptyStr = true; for (uint i = 0; i < message.Length(); ) { int chr, next; [chr, next] = message.GetNextCodePoint(i); if ((chr > 0x1F && chr < 0x7F) || (chr > 0x7F && chr < 0x80) || (chr > 0x9F)) { emptyStr = false; break; } i = next; } if (emptyStr == true) { // Don't add empty messages. return; } int IsControlString = message.IndexOf("TUTORIALSTR|"); int IsSubtitleString = message.IndexOf("SUBTITLE|"); int IsClearString = message.IndexOf("!!CLEARMESSAGES"); int button = 0; int priority = 0; int DelayOverride = 0; // This is my BIGGEST dipshit hack of the century // Seems like the only non-annoying way to get the game to communicate // to the HUD other than via Log / Print. if (IsClearString == 0) { FlushNotify(); return; } else if (IsSubtitleString == 0) { priority = 2; Array SubtitleStrs; message.Split(SubtitleStrs, "|"); uint NumSubtitleStrs = SubtitleStrs.Size(); if (NumSubtitleStrs <= 1) { return; } message = SubtitleStrs[1]; if (NumSubtitleStrs >= 3) { int newDelay = SubtitleStrs[2].ToInt(10); newDelay -= MSGMaxSlide * 2; DelayOverride = max(5, newDelay); } } else if (IsControlString == 0) { priority = 1; Array ControlStrs; message.Split(ControlStrs, "|"); uint NumControlStrs = ControlStrs.Size(); if (NumControlStrs < 3) { return; } int id = ControlStrs[1].ToInt(10); if (id < 0 || id > NumTutorialIDs) { return; } if (TutorialsSeen[id] == true) { return; } TutorialsSeen[id] = true; message = ControlStrs[2]; if (NumControlStrs >= 4) { Array keys; ControlStrs[3].Split(keys, " or "); String compileMsg = ""; int ks = keys.Size(); if (ks > 0) { for (int i = 0; i < keys.Size(); i++) { compileMsg = compileMsg.."\c[LEDYellow]"..keys[i].."\c[Untranslated]"; if (i < ks-1) { compileMsg = compileMsg.." / "; } } } message = compileMsg.Filter().." ... "..message; } if (NumControlStrs >= 5) { button = ControlStrs[4].ToInt(10); } } uint NumMsg = MessageQueue.Size(); if (NumMsg > 0) { for (uint i = 0; i < NumMsg; i++) { if (MessageQueue[i].msg == message && MessageQueue[i].delay > 0) { MessageQueue[i].delay = MSGDelay; return; } } } else { MsgSlideIn = MSGMaxSlide; } SnapMessage data = new("SnapMessage"); data.msg = message; data.WaitForButton = button; data.Priority = priority; if (button != 0) { data.delay = 5; FinalMsgDelay = 5; } else if (DelayOverride > 0) { data.delay = DelayOverride; FinalMsgDelay = DelayOverride; } else { data.delay = MSGDelay; FinalMsgDelay = MSGDelay * 2; } // If anything in front of us has less priority, remove them. if (NumMsg > 0) { Array CleanupLater; for (uint i = 0; i < NumMsg; i++) { if (MessageQueue[i].Priority < data.Priority) { if (i == 0) { // Scroll the current one off-screen ASAP MessageQueue[i].delay = min(MessageQueue[i].delay, 5); MessageQueue[i].WaitForButton = 0; } else { // We don't even need to show it. CleanupLater.Push(MessageQueue[i]); } } else if (MessageQueue[i].Priority > data.Priority) { // Don't add our message, actually. return; } } uint NumCleanup = CleanupLater.Size(); if (NumCleanup > 0) { for (uint i = 0; i < NumCleanup; i++) { uint it = MessageQueue.Find(CleanupLater[i]); if (it != MessageQueue.Size()) { MessageQueue.Delete(it); } } } } MessageQueue.Push(data); } override bool ProcessNotify(EPrintLevel printlevel, String outline) { if (printlevel & PRINT_NONOTIFY) { return true; } /* if (!(printlevel & PRINT_NOTIFY)) { return true; } */ switch (printlevel & PRINT_TYPES) { case PRINT_LOW: case PRINT_MEDIUM: case PRINT_HIGH: case PRINT_BOLD: InsertSnapMessage(outline); break; case PRINT_LOG: case PRINT_CHAT: case PRINT_TEAMCHAT: return false; default: break; } return true; } override bool ProcessMidPrint(Font fnt, String msg, bool bold) { InsertSnapMessage(msg); return true; } override void FlushNotify() { MessageQueue.Clear(); MsgSlide = MsgSlideIn = FinalMsgDelay = 0; } void SetSlideWidth() { double scrWidth = double(Screen.GetWidth()); Vector2 hudFactor = GetHUDScale(); MSGSlideWidth = scrWidth / hudFactor.X; } bool IsClimaxMap() { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return false; } if (ev.Trial.Active == true) { // Only in campaign return false; } SnapDefinitions AllDefs = ev.SnapDefs; if (AllDefs == null) { return false; } MapIterator it; if (it.Init(AllDefs.EpisodeHeap) == false) { return false; } while (it.Next() == true) { let def = it.GetValue(); uint MapListLen = def.MapList.Size(); if (MapListLen == 0) { continue; } let LastMap = def.MapList[MapListLen - 1]; if (LastMap != null && LastMap.ID == Level.MapName) { return true; } } return false; } void MessageTick() { if (Level.MapTime == LevelIntroTime) { // Level intro text. FlushNotify(); // Clear the save point text InsertSnapMessage(Stringtable.Localize("$HUD_INTRO_A")); String title = Stringtable.Localize("$HUD_INTRO_B"); title.Replace("%l", Level.LevelName); InsertSnapMessage(title); /* if (IsClimaxMap() == true) { // HERE COMES THE CLIMAX!! InsertSnapMessage(Stringtable.Localize("$HUD_INTRO_CX")); } else { // Misc other string int index = random[snap_intro](1, 12); InsertSnapMessage(Stringtable.Localize("$HUD_INTRO_C"..index)); } */ } SnapMessage CurMessage = null; SnapMessage NextMessage = null; int CurIndex = -1; bool DoneWith = false; MessageQueue.ShrinkToFit(); int NumMsg = MessageQueue.Size(); for (int i = 0; i < NumMsg; i++) { let data = MessageQueue[i]; if (data == null) { continue; } if (CurMessage == null) { CurIndex = i; CurMessage = data; continue; } else if (NextMessage == null) { NextMessage = data; break; } break; } if (CurMessage != null) { if (CurMessage.WaitForButton != 0) { if (CPlayer && (CPlayer.buttons & CurMessage.WaitForButton)) { CurMessage.WaitForButton = 0; } } if (LEDOverlayFrame < LEDOverlayMaxFrame) { LEDOverlayFrame++; } else if (CurMessage.delay <= 0) { if (NextMessage == null && FinalMsgDelay > 0) { FinalMsgDelay--; } else if (CurMessage.WaitForButton == 0) { if (MsgSlide >= MSGMaxSlide) { MsgSlide = 0; DoneWith = true; } else { MsgSlide++; } } } else { if (MsgSlideIn > 0) { MsgSlideIn--; } else { CurMessage.delay--; } } } else { uint NewState = NewJumbotronState(); if (LEDOverlayFrame == LEDOverlayMaxFrame) { // Switch state while it is hidden JumbotronState = NewState; } if (Level.maptime < LevelIntroTime) { LEDOverlayFrame = LEDOverlayMaxFrame; } else if (JumbotronState != NewState // Switching state || ev.LevelDone == true) // Hide jumbotron when the level is over { if (LEDOverlayFrame < LEDOverlayMaxFrame) { LEDOverlayFrame++; } } else { if (LEDOverlayFrame > 0) { LEDOverlayFrame--; } } } if (DoneWith == true && CurIndex >= 0) { MessageQueue.Delete(CurIndex); } } void DrawJumboBoss() { if (DefeatedBoss > 0 || DisplayBoss == false) { // Boss destroyed blinking text if (!((DefeatedBoss / DefeatedFreq) & 1)) { DrawString( SnapLEDFont, Stringtable.Localize("$HUD_BOSSDEAD"), (0, MsgHeight), DI_ITEM_CENTER_BOTTOM|DI_SCREEN_CENTER_BOTTOM|DI_TEXT_ALIGN_CENTER ); } } else if (BossVitalityLabel < DefeatedLen) { // Boss vitality blinking text if (!((BossVitalityLabel / DefeatedFreq) & 1)) { DrawString( SnapLEDFont, Stringtable.Localize("$HUD_BOSSVITALITY"), (0, MsgHeight), DI_ITEM_CENTER_BOTTOM|DI_SCREEN_CENTER_BOTTOM|DI_TEXT_ALIGN_CENTER ); } } else { // Just show the ominious health number DrawString( SnapLEDFont, String.Format("%d", BossHealth), (0, MsgHeight), DI_ITEM_CENTER_BOTTOM|DI_SCREEN_CENTER_BOTTOM|DI_TEXT_ALIGN_CENTER, Font.FindFontColor('LEDRed') ); } } const LED_SECRET_SPACE = 14.0; void DrawJumboSecrets() { uint AllFlags = NewSecrets; if (ShowSecrets > SecretTime - SecretBlink && !((ShowSecrets / DefeatedFreq) & 1)) { AllFlags = PrevSecrets; } Vector2 SecretPos = (-LED_SECRET_SPACE * 0.5 * NumSecrets, MsgHeight); for (uint i = 0; i < NumSecrets; i++) { uint Flag = (1 << i); bool Gotten = ((AllFlags & Flag) != 0); DrawString( SnapLEDFont, String.Format("%c", 0xe000), SecretPos, DI_ITEM_CENTER_BOTTOM|DI_SCREEN_CENTER_BOTTOM|DI_TEXT_ALIGN_CENTER, ((Gotten == true) ? Font.FindFontColor('LEDRed') : Font.FindFontColor('LEDBlack')) ); SecretPos.X += LED_SECRET_SPACE; } } void CalculateJumboStatOffsets(JumboStat stat, String paddedValue) { double LabelLen = SnapLEDFont.mFont.StringWidth(stat.Label); double ValueLen = SnapLEDFont.mFont.StringWidth(paddedValue); stat.Offsets.X = LabelLen * 0.5; stat.Offsets.Y = LabelLen + stat.SPACE + (ValueLen * 0.5); stat.Length = LabelLen + stat.SPACE + ValueLen; } void PushStat(out Array stats, String label, int value, int digits = 3) { JumboStat stat = new("JumboStat"); stat.Label = Stringtable.Localize(label); stat.Value[0] = String.Format("%d", value); String paddedValue = ""; for (int i = 0; i < digits; i++) { paddedValue.AppendCharacter(int("4")); } if (digits == 1) { // HACK: I want this to have more room paddedValue.AppendCharacter(int("1")); } CalculateJumboStatOffsets(stat, paddedValue); stats.Push(stat); } void PushStatDivided(out Array stats, String label, int valueLeft, String divider, int valueRight, int digits = 3) { JumboStat stat = new("JumboStat"); stat.Label = Stringtable.Localize(label); stat.Value[0] = String.Format("%d", valueLeft); stat.Value[1] = divider; stat.Value[2] = String.Format("%d", valueRight); String paddedValue = ""; for (int i = 0; i < digits; i++) { paddedValue.AppendCharacter(int("4")); } if (digits == 1) { // HACK: I want this to have more room paddedValue.AppendCharacter(int("1")); } paddedValue = String.Format("%s%s%s", paddedValue, divider, paddedValue); CalculateJumboStatOffsets(stat, paddedValue); stats.Push(stat); } void PushStatTime(out Array stats, int min, int sec) { JumboStat stat = new("JumboStat"); stat.Label = Stringtable.Localize("$HUD_TIME"); stat.Value[0] = String.Format("%02d", min); stat.Value[1] = ":"; stat.Value[2] = String.Format("%02d", sec); String paddedValue = "44:44"; CalculateJumboStatOffsets(stat, paddedValue); stats.Push(stat); } void UploadJumboStatsVersus(out Array stats, int min, int sec) { // SCORE DrawString( SnapLEDFont, Stringtable.Localize("$HUD_FRAGS"), (-55, MsgHeight), DI_ITEM_CENTER_BOTTOM|DI_SCREEN_CENTER_BOTTOM|DI_TEXT_ALIGN_CENTER ); int frag = 0; int fragmax = SnapUtils.GetPointLimit(); let sp = SnapPlayer(CPlayer.mo); if (sp != null) { frag = sp.GetFragCount(); } if (fragmax > 0) { DrawDividedStr( SnapLEDFont, String.Format("%d", frag), "/", String.Format("%d", fragmax), (-14, MsgHeight), DI_ITEM_CENTER_BOTTOM|DI_SCREEN_CENTER_BOTTOM ); } else { DrawString( SnapLEDFont, String.Format("%d", frag), (-14, MsgHeight), DI_ITEM_CENTER_BOTTOM|DI_SCREEN_CENTER_BOTTOM|DI_TEXT_ALIGN_CENTER ); } // TIME DrawString( SnapLEDFont, Stringtable.Localize("$HUD_TIME"), (22, MsgHeight), DI_ITEM_CENTER_BOTTOM|DI_SCREEN_CENTER_BOTTOM|DI_TEXT_ALIGN_CENTER ); int show = ((ev.VSSuddenDeath-1) / BOSSWARNBLINKFREQ); if (ev.VSSuddenDeath == 0 || (show & 1)) { DrawDividedStr( SnapLEDFont, String.Format("%02d", min), ":", String.Format("%02d", sec), (57, MsgHeight), DI_ITEM_CENTER_BOTTOM|DI_SCREEN_CENTER_BOTTOM ); } } void UploadJumboStatsInvasion(out Array stats, int min, int sec) { // ROBOTS PushStat( stats, Stringtable.Localize("$HUD_MONSTERS"), InvasionRobots, 4 ); // WAVE uint NumWaves = ev.Invasion.Waves.Size(); uint CurWave = min(ev.Invasion.CurWave + 1, NumWaves); PushStatDivided( stats, Stringtable.Localize("$HUD_WAVE"), CurWave, "/", NumWaves, 1 ); // TIME PushStatTime(stats, min, sec); } void UploadJumboStatsStandard(out Array stats, int min, int sec) { // ROBOTS PushStatDivided( stats, Stringtable.Localize("$HUD_MONSTERS"), Level.killed_monsters, "/", Level.total_monsters, 3 ); // SECRETS PushStatDivided( stats, Stringtable.Localize("$HUD_SECRETS"), Level.found_secrets, "/", Level.total_secrets, 1 ); // TIME PushStatTime(stats, min, sec); } void DrawJumboStats() { int time = 0; if (ev != null) { time = min(ev.LevelTimer, MaxDisplayTime); } int limit = 0; if (deathmatch == true) { limit = SnapUtils.GetTimeLimit(); if (limit > 0) { time = limit - time; } } time = min(max(time, 0), MaxDisplayTime) / TICRATE; int min = time / 60; int sec = time % 60; Array stats; if (deathmatch == true) { UploadJumboStatsVersus(stats, min, sec); } else if (ev != null && ev.Invasion != null) { UploadJumboStatsInvasion(stats, min, sec); } else { UploadJumboStatsStandard(stats, min, sec); } if (stats.Size() == 0) { return; } double BaseOffset = 0.0; for (int i = 0; i < stats.Size(); i++) { JumboStat stat = stats[i]; BaseOffset -= stat.Length * 0.5; } BaseOffset -= JumboStat.SPACE_BIG * (stats.Size() - 1) * 0.5; for (int i = 0; i < stats.Size(); i++) { JumboStat stat = stats[i]; DrawString( SnapLEDFont, stat.Label, (BaseOffset + stat.Offsets.X, MsgHeight), DI_ITEM_CENTER_BOTTOM|DI_SCREEN_CENTER_BOTTOM|DI_TEXT_ALIGN_CENTER ); if (stat.Value[1] != "") { DrawDividedStr( SnapLEDFont, stat.Value[0], stat.Value[1], stat.Value[2], (BaseOffset + stat.Offsets.Y, MsgHeight), DI_ITEM_CENTER_BOTTOM|DI_SCREEN_CENTER_BOTTOM ); } else { DrawString( SnapLEDFont, stat.Value[0], (BaseOffset + stat.Offsets.Y, MsgHeight), DI_ITEM_CENTER_BOTTOM|DI_SCREEN_CENTER_BOTTOM|DI_TEXT_ALIGN_CENTER ); } BaseOffset += stat.Length + JumboStat.SPACE_BIG; } } void DrawSnapMessages(double TicFrac) { int ExtraBacker = int(MSGSlideWidth / 560); for (int i = -ExtraBacker; i <= ExtraBacker; i++) { DrawImage("LEDBACK", (560 * i, 1), DI_ITEM_CENTER_BOTTOM|DI_SCREEN_CENTER_BOTTOM); } if (LEDOverlayFrame < LEDOverlayMaxFrame) { switch (JumbotronState) { case JUMBO_SECRETS: { DrawJumboSecrets(); break; } case JUMBO_BOSS: { DrawJumboBoss(); break; } default: // JUMBO_STATS { DrawJumboStats(); break; } } // OVERLAY! for (int i = -ExtraBacker; i <= ExtraBacker; i++) { DrawImage(LEDOverlayFrames[LEDOverlayFrame], (560 * i, 1), DI_ITEM_CENTER_BOTTOM|DI_SCREEN_CENTER_BOTTOM); } } double SlideVal = 0.0; double XOffset = 0.0; double MSGSlideAmount = MSGSlideWidth / MSGMaxSlide; if (MsgSlide != 0) { SlideVal = double(MsgSlide) + TicFrac; XOffset = -MSGSlideAmount * SlideVal; } else if (MsgSlideIn != 0) { SlideVal = double(MsgSlideIn) - TicFrac; XOffset = MSGSlideAmount * SlideVal; } int NumMsg = MessageQueue.Size(); bool Next = false; for (int i = 0; i < NumMsg; i++) { let data = MessageQueue[i]; if (data == null) { continue; } DrawString( SnapLEDFont, data.msg, (XOffset, MsgHeight), DI_ITEM_CENTER_BOTTOM|DI_SCREEN_CENTER_BOTTOM|DI_TEXT_ALIGN_CENTER ); if (Next == true) { break; } else { if (MsgSlide == 0) { break; } double SlideInvert = (MSGMaxSlide+1) - SlideVal; XOffset = MSGSlideAmount * SlideInvert; Next = true; } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapKey : Key { mixin SnapShadowCarryover; mixin SnapShadowCode; mixin SnapPickupCode; override void BeginPlay() { super.BeginPlay(); ShadowBegin(); } override void Tick() { super.Tick(); ShadowTick(); } override void OnDestroy() { super.OnDestroy(); ShadowDestroy(); } Default { Radius 20; Height 16; Inventory.PickupSound "powerup/pickup"; +NOTDMATCH } override void DoPickupSpecial(Actor toucher) { if (multiplayer) { // Share keys in Coop for (int i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i]) { continue; } let mpmo = SnapPlayer(players[i].mo); if (mpmo) { if (mpmo == toucher) { continue; } mpmo.GiveInventory(self.GetClassName(), 1, true); } } // You get a point bonus for keys! :) let sp = SnapPlayer(toucher); if (sp != null) { sp.AddScore(10000); } } ItemExtendCombo(Toucher, true); super.DoPickupSpecial(toucher); } override bool HandlePickup(Inventory item) { if (GetClass() == item.GetClass()) { item.bPickupGood = true; return true; } return false; } override bool ShouldStay() { return false; } } class SnapRedKey : SnapKey { Default { Inventory.PickupMessage "$KEYGET_RED"; } States { Spawn: SKEY A 10; SKEY A 10 Bright; Loop; } } class SnapGreenKey : SnapKey { Default { Inventory.PickupMessage "$KEYGET_GREEN"; } States { Spawn: SKEY B 10; SKEY B 10 Bright; Loop; } } class SnapBlueKey : SnapKey { Default { Inventory.PickupMessage "$KEYGET_BLUE"; } States { Spawn: SKEY C 10; SKEY C 10 Bright; Loop; } } class SnapBossKey : SnapKey { Default { Inventory.PickupMessage "$KEYGET_BOSS"; } States { Spawn: SKEY D 10; SKEY D 10 Bright; Loop; } } class SnapImpossibleKey : SnapKey { Default { Inventory.PickupMessage "$KEYGET_IMPOSSIBLE"; Inventory.MaxAmount 0; } States { Spawn: SKEY Z 10; SKEY Z 10 Bright; Loop; } override bool CanPickup(Actor toucher) { return false; } override bool ShouldSpawn() { return false; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapBot { void BotKick() { if (target == null) { return; } if (CheckMeleeRange()) { A_StartSound("kick/hit"); Actor hitPuff = Spawn("SnapPuff", (Pos + target.Pos) * 0.5, ALLOW_REPLACE); int hitlagFr = int(SnapHitstun.DamageToHitstun(SnapPlayer.KICKDMG) * 0.667); bool friendly = target.isFriend(self); double addSpeed = 0.0; double moVel = Vel.Length(); if (moVel) { Vector2 facingDir = AngleToVector(angle, 1.0); double mul = min(1.0, max(0.0, (SnapUtils.SafeVec2Unit(facingDir) dot SnapUtils.SafeVec2Unit(Vel.XY)))); addSpeed += moVel * mul; } Vector2 KickSpeed = AngleToVector(angle, SnapPlayer.KICKTHRUST + addSpeed); Vector3 KickVec3 = (KickSpeed.x, KickSpeed.y, SnapPlayer.KICKTHRUST); let tsp = SnapPlayer(target); if (tsp != null) { tsp.WasKicked(self, hitPuff, SnapPlayer.KICKDMG, KickVec3, hitlagFr, friendly); return; } let sa = SnapActor(target); if (sa != null) { sa.WasKicked(self, hitPuff, SnapPlayer.KICKDMG, KickVec3, hitlagFr, friendly); return; } // USE GENERIC FUNCTION IF IT'S NOT A SNAPACTOR SnapActor.GenericKick(target, self, hitPuff, SnapPlayer.KICKDMG, KickVec3, hitlagFr, friendly); } else { A_StartSound("kick/miss"); } } States { Melee: ANIM A 5; ANIM A 0 PlayKick(); ANIM A 2; ANIM A 0 BotKick(); ANIM A 8; ANIM A 0 BotRefire("Missile"); Goto See; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapMonster { bool kickTossed; Actor kickInflictor; uint kickTossDamage; // Used solely for stat tracking. // Don't use for gameplay unless if you want to // also rewrite how these are tracked. transient bool WasJuggled; transient uint KickCombo; action state A_EndKick(statelabel st = "See") { // Helps end the kick, if the pain chance didn't occur to break it let ourselves = SnapMonster(self); if (ourselves) { if (ourselves.kickTossed == true) { return null; } } return ResolveState(st); } override void WasKicked( Actor source, Actor hitPuff, uint KickDamage, Vector3 KickSpeed, int HitlagFrames, bool FromFriendly) { if (Health <= 0) { // Already dead. return; } if (bShootable == false || bDormant == true) { // Non-interactable. return; } if (FromFriendly == true) { // Friendly. return; } // Reduce the monster's poise extra ReduceSnapMonsterPoise(KickDamage, "Melee"); state kickSt = FindState("Kicked"); let sp = SnapPlayer(source); let sa = SnapActor(source); int dr = 0; if (bDontThrust == true || kickSt == null) { // Can't be flung, just damage them directly dr = DamageMobj(source, source, KickDamage, 'Melee'); if (dr > 0) { if (sp) { sp.AddHitstun(HitlagFrames, false); } else if (sa) { sa.AddHitstun(HitlagFrames, false); } } } else { // Update kick combo KickCombo++; // Fling them back! Vel = KickSpeed; A_HitConfirm(hitPuff, PlayerPawn(source)); let oldPlayer = SnapPlayer(kickInflictor); let newPlayer = SnapPlayer(Source); if (oldPlayer != newPlayer) { if (oldPlayer != null) { int index = oldPlayer.Combo.Items.Find(self); if (index != oldPlayer.Combo.Items.Size()) { oldPlayer.Combo.Items.Delete(index); } } if (newPlayer != null && bCountKill == true) { newPlayer.Combo.Items.Push(self); } } if (kickTossed == true) { // Deal the damage of the previous kicker so it doesn't get lost DamageMobj(null, kickInflictor, kickTossDamage, 'Melee'); kickTossDamage = 0; } if (Health > 0) { if (bShootable == true && bNoDamage == false && bInvulnerable == false && bNonShootable == false) { AddHitstun(HitlagFrames, true); if (sp) { sp.AddHitstun(HitlagFrames, false); } else if (sa) { sa.AddHitstun(HitlagFrames, false); } } // For monsters, kickTossed handles the dust trail, // kick state logic, flag effects, bouncing behaviors, // and damage when hitting the ground. kickTossed = true; kickInflictor = source; kickTossDamage = KickDamage; bNoGravity = false; Angle = VectorAngle(-Vel.X, -Vel.Y); SetState(kickSt); } } } virtual void KickTossEnd() { // End the kick toss state kickTossed = false; bNoGravity = Default.bNoGravity; // Deal the kick damage & end the kick toss state. DamageMobj(null, kickInflictor, kickTossDamage, "Melee"); kickTossDamage = 0; WasJuggled = false; let ev = SnapStaticEventHandler.Get(); if (ev != null && kickInflictor != null) { ev.SetStatKickCombo(kickInflictor.Player, KickCombo); } KickCombo = 0; let sp = SnapPlayer(kickInflictor); if (sp != null) { int index = sp.Combo.Items.Find(self); if (index != sp.Combo.Items.Size()) { sp.Combo.Items.Delete(index); } } kickInflictor = null; } virtual void KickTossThink() { int result = CheckSolidFooting(); if ((result & CSF_FLOORMASK) != 0) { // Bounce off the ground Vel.Z = 5; // If you're on a real floor, finish the kick. if ((result & CSF_ACTORFLOOR) == 0) { KickTossEnd(); } } else { Vector2 kickedWallBounce = GetWallBounceDir(); if (kickedWallBounce.Length() > 0) { Vel.XY = kickedWallBounce * Vel.XY.Length() * 0.8; } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapLandmark : Actor { // Landmark object. // These are used to determine where // to spawn the player in level // transitions. Default { //+NOBLOCKMAP //+NOSECTOR +NOCLIP +INVISIBLE -NOGRAVITY } States { Spawn: MCFG F -1; Stop; } } class SnapLandmarkData { int TID; Vector3 Pos; double Angle; Vector3 PlayerDelta[MAXPLAYERS]; static SnapLandmarkData CreateFromActor(Actor mo) { SnapLandmarkData data = SnapLandmarkData( new("SnapLandmarkData") ); if (data == null) { return null; } data.TID = mo.TID; data.Pos = mo.Pos; data.Angle = mo.Angle; for (uint i = 0; i < MAXPLAYERS; i++) { data.PlayerDelta[i] = (0.0, 0.0, 0.0); if (playeringame[i] == false) { continue; } PlayerInfo player = players[i]; if (player == null) { continue; } let mo = player.mo; if (mo == null) { continue; } data.PlayerDelta[i] = mo.Pos - data.Pos; } return data; } } extend class SnapStaticEventHandler { SnapLandmarkData PrevLandmark; static void SetLandmark(int tid) { SnapStaticEventHandler ev = SnapStaticEventHandler(StaticEventHandler.Find("SnapStaticEventHandler")); if (ev == null) { // No event handler exists? return; } ActorIterator it = Level.CreateActorIterator(tid, "SnapLandmark"); SnapLandmark landmark = SnapLandmark( it.Next() ); if (landmark == null) { // No landmark exists. return; } ev.PrevLandmark = SnapLandmarkData.CreateFromActor(landmark); } void CheckLandmarks(int PlayerNumber) { if (playeringame[PlayerNumber] == false) { return; } PlayerInfo player = players[PlayerNumber]; if (player == null) { return; } let mo = PlayerPawn(player.mo); if (mo == null) { return; } if (PrevLandmark == null) { // We aren't coming from an exit with a landmark. return; } ActorIterator it = Level.CreateActorIterator(PrevLandmark.TID, "SnapLandmark"); SnapLandmark Landmark = SnapLandmark( it.Next() ); if (Landmark == null) { // No matching landmark exists in the new map. return; } Vector3 OldPos = mo.Pos; Vector3 PosDelta = PrevLandmark.PlayerDelta[PlayerNumber]; double AngleDelta = Landmark.DeltaAngle(PrevLandmark.Angle, Landmark.Angle); // Translate the player position to where they were // in the previous map. Vector2 RotateXY = ( PosDelta.X * cos(AngleDelta) - PosDelta.Y * sin(AngleDelta), PosDelta.Y * cos(AngleDelta) + PosDelta.X * sin(AngleDelta) ); Vector3 NewPos = Landmark.Pos + ( RotateXY.X, RotateXY.Y, PosDelta.Z ); mo.TeleportMove(NewPos, false); if (mo.TestMobjLocation() == false) { // If it's no good, then we're fine with just using the // default player spawn position. mo.TeleportMove(OldPos, false); mo.CalcHeight(); let sp = SnapPlayer(mo); if (sp != null) { // Reimplement the Coop spawn-in effect // for this specific instance. sp.CoopTeleport = true; } return; } // Success. We can update angle too. mo.Angle += AngleDelta; // View height will need recalculated. mo.CalcHeight(); } void ResetLandmark() { if (PrevLandmark != null) { PrevLandmark.Destroy(); PrevLandmark = null; } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapLaserProps : SnapWeaponProps { override void Init() { WeaponName = "Laser"; NiceName = "$SNAPMENU_WEAPON_LASER"; PickupType = "SnapLaserPowerup"; WeaponIcon = "WP_LASER"; FireState = "FireLaser"; } } class SnapLaserCan : SnapItemCan { Default { DropItem "SnapLaserPowerup"; } States { Spawn: WP_L A 10; WP_L A 10 Bright; Loop; } } class SnapLaserPowerup : SnapWeaponPowerup { Default { SnapWeaponPowerup.WeaponPower "Laser"; Inventory.PickupMessage "$POWERUP_LASER"; SnapInventory.VoiceSample "voice/laser"; } States { Spawn: WP_L B 10; WP_L B 10 Bright; Loop; } } class SnapLaserTrail : SnapActor { bool PinkLaser; Default { Radius 12; Height 12; RenderStyle "Add"; +RANDOMIZE +BRIGHT +SnapActor.MISSILESPRITEFIX +DONTSPLASH +NOINTERACTION +NOGRAVITY +NOBLOCKMAP +NOTELEPORT } States { Spawn: LBUL A 2 Light("LaserLight1"); Stop; LBUL B 2 Light("LaserLight1"); Stop; LBUL C 2 Light("LaserLight1"); Stop; LBUL D 2 Light("LaserLight1"); Stop; LBUL E 2 Light("LaserLight2"); Stop; LBUL F 2 Light("LaserLight2"); Stop; LBUL G 2 Light("LaserLight2"); Stop; } override int GetDefaultTranslation() { if (PinkLaser == true) { return Translate.GetID("LaserAlt"); } return super.GetDefaultTranslation(); } const NUMLASERFRAMES = 6; override void PostBeginPlay() { super.PostBeginPlay(); SetHitstunParent(Target); SetState(SpawnState + random[snap_decor](0, NUMLASERFRAMES - 1)); PinkLaser = random[snap_decor](0, 1); Translation = GetDefaultTranslation(); } } class SnapLaserShot : SnapBasicShot { Vector3 LaserPoint; double AngleBend; double PitchBend; bool PinkLaser; Vector2 DestScale; Vector2 OrigScale; Default { Speed 120; DamageFunction 7; DamageType "Laser"; Obituary "$OB_LASER"; MissileType "SnapLaserTrail"; MissileHeight 0; //+RIPPER //+SnapMissile.HEXENRIP +NODAMAGETHRUST +INTERPOLATEANGLES } States { Spawn: LBUL ABCD 1 Light("LaserLight1"); LBUL EFG 1 Light("LaserLight2"); Loop; Death: LBEX A 1 Light("LaserLight1"); LBEX B 1 Light("LaserLight1"); LBEX A 1 Light("LaserLight2"); TNT1 A 1; LBEX B 1 Light("LaserLight2"); TNT1 A 1; LBEX CDEF 1 Light("LaserLight1"); LBEX JKL 1 Light("LaserLight2"); LBEX GHI 1 Light("LaserLight1"); Stop; } override int GetDefaultTranslation() { if (PinkLaser == true) { return Translate.GetID("LaserAlt"); } return super.GetDefaultTranslation(); } const NUMLASERFRAMES = 6; override void PostBeginPlay() { super.PostBeginPlay(); if (bMissile == true) // Make sure it's only doing this if it didn't collide with a wall { SetState(SpawnState + random[snap_decor](0, NUMLASERFRAMES - 1)); } PinkLaser = random[snap_decor](0, 1); Translation = GetDefaultTranslation(); bXFlip = random[snap_decor](0, 1); bYFlip = random[snap_decor](0, 1); OrigScale = Scale; DestScale = Scale * 2.0; Scale *= 0.2; } const LASERANGSPEED = 22.5; const MAXBEND = 180.0; const SCALEUPSPEED = 0.2; override void Tick() { super.Tick(); //Roll = -Pitch; if (bMissile == false) { if (Scale.X < OrigScale.X) { Scale.X = OrigScale.X; } if (Scale.Y < OrigScale.Y) { Scale.Y = OrigScale.Y; } return; } if (TickPaused() == true) { return; } if (Scale.X < DestScale.X) { Scale.X += SCALEUPSPEED; if (Scale.X > DestScale.X) { Scale.X = DestScale.X; } } if (Scale.Y < DestScale.Y) { Scale.Y += SCALEUPSPEED; if (Scale.Y > DestScale.Y) { Scale.Y = DestScale.Y; } } double spd = Vel.Length(); if (spd < Speed - 1.0) { // The laser can have 0 or near 0 speed // when fired too close to the LaserPoint. // To fix this, make sure it doesn't go // below the default speed. spd = Speed; } Vel = ( spd * cos(Angle) * cos(-Pitch), spd * sin(Angle) * cos(-Pitch), spd * sin(-Pitch) ); if (AngleBend >= MAXBEND && PitchBend >= MAXBEND) { return; } Vector2 XYDiff = LevelLocals.Vec2Diff(Pos.XY, LaserPoint.XY); double OurCenter = Pos.Z + (Height * 0.5); double ZDiff = LaserPoint.Z - OurCenter; if (XYDiff ~== (0, 0) && ZDiff ~== 0) { AngleBend = PitchBend = MAXBEND; return; } if (AngleBend < MAXBEND) { double FinalAngle = VectorAngle(XYDiff.X, XYDiff.Y); double PrevAngle = Angle; Angle = SnapUtils.AngleTowardsAngle(Angle, FinalAngle, LASERANGSPEED); double AngleDiff = AbsAngle(Angle, PrevAngle); if (AngleDiff ~== 0) { // Pointing the correct way... Angle = FinalAngle; // Just in case of rounding error AngleBend = MAXBEND; } else { // Failsafe to prevent the Tornado Laser. AngleBend += AngleDiff; } } if (PitchBend < MAXBEND) { double FinalPitch = VectorAngle(XYDiff.Length(), -ZDiff); double PrevPitch = Pitch; Pitch = SnapUtils.AngleTowardsAngle(Pitch, FinalPitch, LASERANGSPEED); double PitchDiff = AbsAngle(Pitch, FinalPitch); if (PitchDiff ~== 0.0) { // Pointing the correct way... Pitch = FinalPitch; // Just in case of rounding error PitchBend = MAXBEND; } else { // Failsafe to prevent the Tornado Laser. PitchBend += PitchDiff; } Roll = -Pitch; } } override void DoClink(actor victim) { super.DoClink(victim); bNoGravity = true; } } extend class SnapGun { const LASERSPEED = 24.0; action void A_UpdateLaserPoint(bool instant = false) { if (player == null || player.mo == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } FLineTraceData HitTrace; double OurCenter = player.mo.Pos.Z + player.viewheight - player.mo.floorclip; player.mo.LineTrace( player.mo.angle, 2048.0, player.mo.pitch, TRF_THRUACTORS|TRF_ABSPOSITION, OurCenter, player.mo.Pos.X, player.mo.Pos.Y, HitTrace ); if (instant == true) { weap.LaserPoint = HitTrace.HitLocation; } else { Vector3 Diff = HitTrace.HitLocation - weap.LaserPoint; if (Diff ~== (0, 0, 0) || Diff.Length() <= LASERSPEED) { weap.LaserPoint = HitTrace.HitLocation; } else { weap.LaserPoint += Diff.Unit() * LASERSPEED; } // Get the laser point to hit a wall, if possible, // instead of being inside / outside it. Vector2 XYDiff = LevelLocals.Vec2Diff(player.mo.Pos.XY, weap.LaserPoint.XY); double ZDiff = weap.LaserPoint.Z - OurCenter; double FinalAngle = VectorAngle(XYDiff.X, XYDiff.Y); double FinalPitch = VectorAngle(XYDiff.Length(), -ZDiff); player.mo.LineTrace( FinalAngle, 2048.0, FinalPitch, TRF_THRUACTORS|TRF_ABSPOSITION, OurCenter, player.mo.Pos.X, player.mo.Pos.Y, HitTrace ); weap.LaserPoint = HitTrace.HitLocation; } //Actor test = Spawn("ProjectileTest", weap.LaserPoint); } action void A_SnapgunLaser(bool takeAmmo = true) { A_UpdateLaserPoint(); if (player == null || player.mo == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } A_SnapgunFlash('FlameFlash'); // Reuse Actor mo = A_SnapgunMomentumProjectile("SnapLaserShot"); if (mo) { let lsr = SnapLaserShot(mo); if (lsr) { lsr.LaserPoint = weap.LaserPoint; lsr.angle = player.mo.angle; lsr.pitch = player.mo.pitch; lsr.roll = -lsr.pitch; } } A_StartSound("revolver/laser", CHAN_WEAPON); SoundAlert(self); if (takeAmmo == true) { player.mo.TakeInventory("SnapPowerupAmmo", 1, false, true); } } action void A_LaserChargeAmmo() { // Takes extra ammo to initially charge player.mo.TakeInventory("SnapPowerupAmmo", 1, false, true); } action void A_CheckLaserRefire() { if (A_OutOfAmmo() == true) { // Go back to regular firing states. A_SnapGunRefire(); } else { // Try to keep looping the laser. A_SnapGunRefire(newSt: "LaserLoop"); } } States { FireLaser: SGUN A 0 A_SnapgunReload; SREL AAABBB 1 A_OverlayOffset(GUNLAYER, 0, -5.75, WOF_ADD); SREL CDE 2; SGUN A 0 A_SetSnapGunState(RELOADLAYER, 'OpenSesame'); SGUN A 0 A_StartSound("revolver/reload1", CHAN_WEAPON); SREL IFIGIH 1 A_LaserChargeAmmo(); SREL L 1 A_LaserChargeAmmo(); SREL K 1; SREL M 4; SGUN A 0 A_StartSound("revolver/reload3", CHAN_WEAPON); SREL KJI 1; SREL EDC 1; SREL BA 1 A_OverlayOffset(GUNLAYER, 0, 17.25, WOF_ADD); SGUN A 0 A_UpdateLaserPoint(true); LaserLoop: SGUN A 1 A_SnapgunLaser(true); SGUN BCABCABCABCABCABCABCABC 1 A_SnapgunLaser(false); SGUN A 0 A_CheckLaserRefire(); Goto GunIdle; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapLavaSpew : SnapShadowActor { Default { Radius 36; Height 24; Speed 10; BounceType "Grenade"; BounceFactor 0.75; WallBounceFactor 0.25; DamageFunction 20; SeeSound "revolver/flame"; Obituary "$OB_FIRESPEW"; Projectile; +RANDOMIZE +BRIGHT +NODAMAGETHRUST +BOUNCEONUNRIPPABLES +BOUNCEONWALLS +BOUNCEONFLOORS +BOUNCEONCEILINGS +DONTBOUNCEONSHOOTABLES //+NOEXPLODEFLOOR -USEBOUNCESTATE -ALLOWBOUNCEONACTORS -BOUNCEONACTORS -NOGRAVITY } States { Spawn: FBAL ABCDEF 3 Light("FlameShotLight") A_SpawnItemEx("SnapMonsterShrapnel"); FBAL ABCDEF 3 Light("FlameShotLight") A_SpawnItemEx("SnapMonsterShrapnel"); FBAL ABCDEF 3 Light("FlameShotLight") A_SpawnItemEx("SnapMonsterShrapnel"); FBAL ABCDEF 3 Light("FlameShotLight") A_SpawnItemEx("SnapMonsterShrapnel"); FBAL ABCDEF 3 Light("FlameShotLight") A_SpawnItemEx("SnapMonsterShrapnel"); FBAL A 0 { ExplodeMissile(); } Stop; Death: FBAL A 0 { Vel = (0, 0, 0); bNoGravity = true; } FBAL GHIJK 3 Light("FlameShotLight"); Stop; } override void Tick() { if (TickPaused() == false) { if (CheckSolidFooting() & CSF_SOLIDFLOOR) { Vel.XY = (0, 0); Vel.Z = max(Vel.Z, 16.0); } } super.Tick(); } override string GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack) { return StringTable.Localize("$OB_FIRESPEW"); } } class SnapLavaSpewSpot : SnapDynamicDecor { action void A_SnapSpawnSpewWarning(double intensity) { Vector3 spawnOffset = ( random[snap_decor](-64, 64), random[snap_decor](-64, 64), 0 ); Actor flameBubbling = Spawn("SnapLavaImpactWithDrops", Pos + spawnOffset, ALLOW_REPLACE); if (flameBubbling) { double scaleMul = 1.0 + (intensity * 0.25); flameBubbling.Scale = Scale * scaleMul; } A_StartSound("grumble", CHAN_BODY, CHANF_NOSTOP|CHANF_LOOP); } action void A_SnapSpawnLavaSpew() { if (target == null) { return; } A_SnapSpawnSpewWarning(4.0); A_FaceTarget(); double airTime = TICRATE * 1.25; double a = angle + (Level.maptime * 45); double dist = (Pos.XY - Target.Pos.XY).Length(); double h = (dist / airTime) * 0.75; double v = (gravity * airTime) * 0.5; Actor ball = Spawn("SnapLavaSpew", self.Pos, ALLOW_REPLACE); if (ball) { ball.A_StartSound(GetDefaultByType("SnapLavaSpew").SeeSound); ball.angle = a; ball.Vel = ( h * cos(a), h * sin(a), v ); } } Default { Radius 64; Height 8; +INVISIBLE } States { Delay: FBAL A 175; Spawn: FBAL A 175 A_CheckProximity( "Spew", "PlayerPawn", 1280.0, 1, CPXF_ANCESTOR|CPXF_NOZ|CPXF_SETTARGET|CPXF_CLOSEST ); Loop; Spew: FBAL AAAAAAAA 4 A_SnapSpawnSpewWarning(0.0); FBAL AAAAAAAA 3 A_SnapSpawnSpewWarning(1.0); FBAL AAAAAAAA 2 A_SnapSpawnSpewWarning(2.0); FBAL AAAAAAAA 1 A_SnapSpawnSpewWarning(4.0); FBAL AAAAAAAA 7 A_SnapSpawnLavaSpew; FBAL AAAAAAAA 5 A_SnapSpawnLavaSpew; FBAL AAAAAAAA 3 A_SnapSpawnLavaSpew; FBAL AAAAAAAA 3 A_SnapSpawnLavaSpew; FBAL AAAAAAAA 1 A_SnapSpawnLavaSpew; FBAL A 0 A_StopSound(CHAN_BODY); Goto Delay; } override string GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack) { return StringTable.Localize("$OB_FIRESPEW"); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // The license for these files are contained within // their respective folders as 'license.txt', please // refer to these for more details. //----------------------------------------------------------------------- // ZJSON // This is using an outdated version on purpose because // I need the key order to be deterministic, which gets // lost in the new version's associative map. // Maybe should eventually just write my own. #include "./lib/ZJSON/JsonBase.zs" #include "./lib/ZJSON/JsonObject.zs" #include "./lib/ZJSON/JsonArray.zs" #include "./lib/ZJSON/JsonParser.zs" //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- struct SnapSaveDate { int year; int month; int day; int hour; int minute; int second; } class SnapLoadMenu : LoadMenu { mixin SnapMenuDrawing; mixin SnapMenuCore; TextureID SaveIcon; TextureID BadSaveIcon; Array SortedSaves; bool LoadAfterFade; bool SaveIsBad(SaveGameNode Node) { return (Node.bOldVersion || Node.bMissingWads); } bool GetSaveDate(SaveGameNode Node, out SnapSaveDate date) { date.year = 1997; date.month = 1; date.day = 1; date.hour = 1; date.minute = 0; date.second = 0; String numStr = ""; int numberCount = 0; int nums[6] = { 0, 0, 0, 0, 0, 0 }; for (uint i = 0; i < Node.SaveTitle.Length();) { int chr; uint next; [chr, next] = Node.SaveTitle.GetNextCodePoint(i); if (chr >= 48 && chr <= 57) // is a digit { if (chr != 48 || numStr.Length() != 0) // if it starts with 0, it tries to interpret as an octal. stupid. { numStr.AppendCharacter(chr); } } else { if (numStr.Length() > 0) { nums[numberCount] = numStr.ToInt(); numberCount++; numStr = ""; if (numberCount >= 6) { break; } } } i = next; } if (numStr.Length() > 0) { nums[numberCount] = numStr.ToInt(); numberCount++; numStr = ""; } if (numberCount >= 6) { date.year = nums[0]; date.month = nums[1]; date.day = nums[2]; date.hour = nums[3]; date.minute = nums[4]; date.second = nums[5]; return true; } return false; } bool SortByDate(SnapSaveDate a, SnapSaveDate b) { /* Console.Printf( "%d-%d-%d %d:%d:%d vs %d-%d-%d %d:%d:%d", a.year, a.month, a.day, a.hour, a.minute, a.second, b.year, b.month, b.day, b.hour, b.minute, b.second ); */ if (a.year > b.year) { return true; } else if (a.year < b.year) { return false; } if (a.month > b.month) { return true; } else if (a.month < b.month) { return false; } if (a.day > b.day) { return true; } else if (a.day < b.day) { return false; } if (a.hour > b.hour) { return true; } else if (a.hour < b.hour) { return false; } if (a.minute > b.minute) { return true; } else if (a.minute < b.minute) { return false; } if (a.second > b.second) { return true; } else if (a.second < b.second) { return false; } return false; } bool SortTwoSaves(SaveGameNode a, SaveGameNode b) { bool aBad = SaveIsBad(a); bool bBad = SaveIsBad(b); // If we can't load it, toss it at the // end of the list. if (aBad != bBad) { return bBad; } SnapSaveDate aDate; bool aDateValid = GetSaveDate(a, aDate); SnapSaveDate bDate; bool bDateValid = GetSaveDate(b, bDate); // If only one of them has a date, then // we want to put the one with a date at // the start of the list. if (aDateValid != bDateValid) { return aDateValid; } // Now sort the ones at the top by date, // with the most recent ones first. return SortByDate(aDate, bDate); } void SortSaves() { SortedSaves.Clear(); for (int i = 0; i < manager.SavegameCount(); i++) { SaveGameNode node = manager.GetSavegame(i); SortedSaves.Push(node); } for (int i = 0; i < SortedSaves.Size() - 1; i++) { int minIdx = i; for (int j = i + 1; j < SortedSaves.Size(); j++) { if (SortTwoSaves(SortedSaves[j], SortedSaves[minIdx]) == true) { minIdx = j; } } SaveGameNode temp = SortedSaves[minIdx]; SortedSaves[minIdx] = SortedSaves[i]; SortedSaves[i] = temp; } if (Selected > SortedSaves.Size()) { SetSelectedItem(0); manager.UnloadSaveData(); manager.ExtractSaveData(ConvertSortedToUnsorted(Selected)); UpdateSaveComment(); } } void UpdateTooltipStatus() { MenuData.TooltipDest = 0.0; } override void Init(Menu parent, ListMenuDescriptor desc) { parent = LookupParentRedirect(parent); super.Init(parent, desc); mParentMenu = parent; DontDim = true; PrecacheMenuDrawing(); PrecacheMenuCore(); SaveIcon = TexMan.CheckForTexture("SAVEICON", TexMan.Type_MiscPatch); BadSaveIcon = TexMan.CheckForTexture("BADSAVE", TexMan.Type_MiscPatch); UpdateTooltipStatus(); let p = SnapMenuBase(parent); if (p != null) { p.TryTransitionOut(self); } TryTransitionIn(parent); SortSaves(); SetSelectedItem(0); manager.UnloadSaveData(); manager.ExtractSaveData(ConvertSortedToUnsorted(Selected)); UpdateSaveComment(); } virtual void TryTransitionIn(Menu From) { if (From is "MessageBoxMenu") { return; } if (From == null && MenuData.Background != null) { // Creating first menu with a background. // This is probably the main menu. // Do a fade-in transition instead. SnapFader.StartGameFade(true); MenuFadeMode = MFM_TITLE_TO_MAIN; FadeHide = true; MenuData.TooltipOffset = 0.0; UpdateTooltipStatus(); MenuTransition = 1.0; return; } TransitionSpeed = BASE_TRANSITION_SPEED; ClosingMenu = false; } virtual void TryTransitionOut(Menu To) { if (To is "MessageBoxMenu") { return; } if (To == null && MenuData.Background != null) { // Returning from Main Menu to TITLEMAP. // Do a fade-out transition. SnapFader.StartGameFade(true); MenuFadeMode = MFM_MAIN_TO_TITLE; FadeHide = false; MenuData.TooltipDest = 0.0; return; } TransitionSpeed = -BASE_TRANSITION_SPEED; } override void OnReturn() { UpdateTooltipStatus(); //ScrollInit = false; TryTransitionIn(GetCurrentMenu()); // TODO: ensure this is correct super.OnReturn(); SortSaves(); } virtual int GetSelectedItem() { return Selected; } virtual void SetSelectedItem(int value, bool updateScroll = true) { Selected = value; if (updateScroll == true) { UpdateDestScroll(GetSelectedItem()); } } int FirstSelectable() { return 0; } int LastSelectable() { return SortedSaves.Size() - 1; } int GetSaveHeight() { return 58; } int ConvertSortedToUnsorted(int index) { if (index < 0 || index > SortedSaves.Size()) { return -1; } if (manager.SavegameCount() == 0) { return -1; } for (int i = 0; i <= manager.SavegameCount(); i++) { SaveGameNode node = manager.GetSavegame(i); if (node == SortedSaves[index]) { return i; } } return -1; } int ConvertUnsortedToSorted(int index) { SaveGameNode node = manager.GetSavegame(index); for (int i = 0; i < SortedSaves.Size(); i++) { if (node == SortedSaves[index]) { return i; } } return -1; } virtual int MenuTotalHeight() { return SortedSaves.Size() * GetSaveHeight(); } virtual int GetTotalScrollSpace() { return int(VirtualSize.Y - VirtualOffset.Y); } virtual int GetItemPos(int DestItem) { int spacing = GetSaveHeight(); double ItemPos = (DestItem * spacing) + (spacing * 0.5); return int(ItemPos + 0.5); } virtual void ClampScrollPos() { int first = FirstSelectable(); int last = LastSelectable(); int h = GetSaveHeight(); int FirstPos = GetItemPos(first); int LastPos = GetItemPos(last); double Scroll = GetTotalScrollSpace() * 0.5; int Pad = int(Scroll - (h * 1.5)); double ScreenCenter = Scroll; double minX = (FirstPos * 0.5) - (h * 0.5); double maxX = (LastPos * 0.5) - (h * 0.5); double minY = (FirstPos - ScreenCenter) + Pad; double maxY = (LastPos - ScreenCenter) - Pad; if (minX > maxX) { DestScrollPos.X = (minX + maxX) * 0.5; } else { DestScrollPos.X = clamp(DestScrollPos.X, minX, maxX); } if (minY > maxY) { DestScrollPos.Y = (minY + maxY) * 0.5; } else { DestScrollPos.Y = clamp(DestScrollPos.Y, minY, maxY); } } virtual void UpdateDestScroll(int s = -1, bool force = false) { int first = FirstSelectable(); int last = LastSelectable(); if (s < first) { // Set to default value. s = first; } if (s > last) { // Set to default value. s = last; } int h = GetSaveHeight(); int ItemPos = GetItemPos(s); double Scroll = GetTotalScrollSpace() * 0.5; double ScreenCenter = Scroll; DestScrollPos.X = (ItemPos * 0.5) - (h * 0.5); DestScrollPos.Y = ItemPos - ScreenCenter; ClampScrollPos(); if (force == true) { ScrollPos = DestScrollPos; } } override bool MenuEvent(int mKey, bool gamepad) { if (InMenuTransition() == true) { return false; } int startedAt = GetSelectedItem(); int NewSelected = startedAt; int NumItems = SortedSaves.Size(); bool ForceUpdate = false; switch (mKey) { case MKEY_Up: if (NewSelected == -1) { SetSelectedItem(FirstSelectable()); break; } --NewSelected; if (NewSelected < 0) { NewSelected = NumItems-1; } SetSelectedItem(NewSelected); break; case MKEY_Down: if (NewSelected == -1) { SetSelectedItem(FirstSelectable()); break; } ++NewSelected; if (NewSelected >= NumItems) { NewSelected = 0; } SetSelectedItem(NewSelected); break; case MKEY_PageUp: SetSelectedItem(FirstSelectable()); break; case MKEY_PageDown: SetSelectedItem(LastSelectable()); break; case MKEY_Back: let m = GetCurrentMenu(); let p = m.mParentMenu; MenuSound(p != null ? "menu/backup" : "menu/clear"); TryTransitionOut(p); ClosingMenu = true; return true; case MKEY_Enter: if (NewSelected >= 0 && NewSelected < NumItems) { if (SaveIsBad(SortedSaves[NewSelected])) { MenuSound("menu/cant"); return true; } TransitionDelay = SnapMenuCursor.FIRE_ANIM_DELAY; MenuData.Cursor.PlayFire(); LoadAfterFade = true; SnapFader.StartGameFade(true); return true; } case MKEY_MBYes: if (NewSelected >= 0 && NewSelected < NumItems) { int s = ConvertSortedToUnsorted(NewSelected); if (s != -1) { TransitionDelay = SnapMenuCursor.FIRE_ANIM_DELAY; MenuData.Cursor.PlayFire(); manager.RemoveSaveSlot(s); SortSaves(); NewSelected--; if (NewSelected < 0) { NewSelected = 0; } else if (NewSelected >= NumItems) { NewSelected = NumItems-1; } ForceUpdate = true; } } break; default: return false; } if (ForceUpdate || GetSelectedItem() != startedAt) { MenuSound("menu/cursor"); manager.UnloadSaveData(); manager.ExtractSaveData(ConvertSortedToUnsorted(Selected)); UpdateSaveComment(); } return true; } override bool MouseEvent(int type, int x, int y) { if (InMenuTransition() == true) { return false; } if (mFocusControl) { mFocusControl.MouseEvent(type, x, y); return true; } else { double ItemStart = -ScrollPos.Y; double h = GetSaveHeight(); int yLine = (y - ItemStart) / h; if (yLine >= 0 && yLine < SortedSaves.Size()) { if (yLine != GetSelectedItem()) { SetSelectedItem(yLine, false); manager.UnloadSaveData(); manager.ExtractSaveData(ConvertSortedToUnsorted(Selected)); UpdateSaveComment(); } if (type == MOUSE_Release) { UpdateDestScroll(GetSelectedItem()); if (abs(ScrollPos.Y - DestScrollPos.Y) + abs(ScrollPos.X - DestScrollPos.X) >= 1.0) { MenuSound("menu/change"); if (m_use_mouse == 2) { return true; } } return MenuEvent(MKEY_Enter, true); } return true; } } SetSelectedItem(-1, false); return true; } bool SnapMouseEventBack(int type, int x, int y) { if (m_show_backbutton >= 0) { let tex = TexMan.CheckForTexture(gameinfo.mBackButton, TexMan.Type_MiscPatch); if (tex.IsValid()) { Vector2 size = SnapMenuTextureSize(tex); Vector4 boundingBox = (0.0, 0.0, size.X + 2.0, size.Y + 2.0); mBackbuttonSelected = ( x >= boundingBox.x && x <= boundingBox.z && y >= boundingBox.y && y < boundingBox.w ); if (mBackbuttonSelected) { SetSelectedItem(-1, false); if (type == MOUSE_Release) { if (m_use_mouse == 2) { mBackbuttonSelected = false; } MenuEvent(MKEY_Back, true); } } return mBackbuttonSelected; } } return false; } void MouseBackButtonDrawer() { if ( /*self == GetCurrentMenu() &&*/ BackbuttonAlpha > 0 && m_show_backbutton >= 0 && m_use_mouse) { let tex = TexMan.CheckForTexture(gameinfo.mBackButton, TexMan.Type_MiscPatch); if (tex.IsValid()) { Vector2 size = SnapMenuTextureSize(tex); Vector2 dir = (1.0, 1.0); Vector2 offset = ( Ease.OutCubic(BackbuttonAlpha, 0.0, (size.X + 1.0) * dir.X), Ease.OutCubic(BackbuttonAlpha, 0.0, (size.Y + 1.0) * dir.Y) ); Vector2 pos = offset - size - VirtualOffset; if (mBackbuttonSelected /*&& (mMouseCapture || m_use_mouse == 1)*/) { SnapMenuTextureTranslated(tex, pos, Translate.GetID("BackButtonHighlight")); } else { SnapMenuTexture(tex, pos); } } } } bool MouseEvents(UIEvent ev) { bool res = false; Vector2 mousePos = (ev.MouseX, ev.MouseY); if (VirtualScale == 0.0) { return false; } mousePos /= VirtualScale; if (ev.type == UIEvent.Type_LButtonDown) { res = SnapMouseEventBack(MOUSE_Click, mousePos.X, mousePos.Y); if (!res) { // don't override back button. res |= MouseEvent(MOUSE_Click, mousePos.X, mousePos.Y); } if (res) { SetCapture(true); } } else if (ev.type == UIEvent.Type_MouseMove) { BackbuttonTime = 4*GameTicRate; if (mMouseCapture || m_use_mouse == 1) { res = SnapMouseEventBack(MOUSE_Move, mousePos.X, mousePos.Y); if (!res) { res |= MouseEvent(MOUSE_Move, mousePos.X, mousePos.Y); } } } else if (ev.type == UIEvent.Type_LButtonUp) { if (mMouseCapture) { SetCapture(false); res = SnapMouseEventBack(MOUSE_Release, mousePos.X, mousePos.Y); if (!res) { res |= MouseEvent(MOUSE_Release, mousePos.X, mousePos.Y); } } } return false; } override bool OnUIEvent(UIEvent ev) { if (InMenuTransition() == true) { return false; } if (ev.type == UIEvent.Type_WheelUp) { SetSelectedItem(-1, false); DestScrollPos.X -= MOUSE_SCROLL_PIXELS * 0.5; DestScrollPos.Y -= MOUSE_SCROLL_PIXELS; ClampScrollPos(); return true; } else if (ev.type == UIEvent.Type_WheelDown) { SetSelectedItem(-1, false); DestScrollPos.X += MOUSE_SCROLL_PIXELS * 0.5; DestScrollPos.Y += MOUSE_SCROLL_PIXELS; ClampScrollPos(); return true; } return MouseEvents(ev); } virtual void SnapTicker() { TransitionTick(); if (GetCurrentMenu() == self && MenuTransition == 0.0 && TransitionSpeed == 0.0 && ClosingMenu == false) { // prevmenu was used instead of a proper close. // This thing doesn't call like ANY of the proper callbacks. // So we can't transition out properly, and we need to put // this in to get us out of the soft-lock state. // It should be OK since pretty much the only thing // that does this is menu_resolution_set_custom. TryTransitionIn(null); } if (ScrollInit == false) { UpdateDestScroll(GetSelectedItem(), true); ScrollPos = DestScrollPos; ScrollInit = true; } Vector2 Diff = (DestScrollPos - ScrollPos); if (Diff.Length() < 1.0) { // Fix floating point silliness ScrollPos = DestScrollPos; } else { ScrollPos += 0.25 * Diff; } } override void Ticker() { let parent = SnapMenuBase(mParentMenu); if (parent != null && parent.MenuTransition > 0.0) { // Wait to finish the parent's transition first. if (parent.MenuTransition >= 1.0) { parent.TryTransitionOut(self); parent.ClosingMenu = false; } parent.Ticker(); return; } super.Ticker(); if (MenuData.Fader.FadeOffset >= 1.0 && LoadAfterFade == true) { LoadAfterFade = false; int s = ConvertSortedToUnsorted(Selected); if (s < 0) { s = 0; } manager.LoadSavegame(s); } SnapTicker(); } virtual void DrawSaveItem(SaveGameNode Node, Vector2 Delta, Vector2 TransitionOffset, bool IsSelected) { Vector2 IconBasePos = Delta + (16, 0); Vector2 IconPos = IconBasePos - (TransitionOffset.X, 0); if (Node != null && SaveIsBad(Node)) { SnapMenuTexture(BadSaveIcon, IconPos); } else { SnapMenuTexture(SaveIcon, IconPos); if (IsSelected == true) { manager.DrawSavePic( int((IconPos.X + VirtualOffset.X + 2) * VirtualScale), int((IconPos.Y + VirtualOffset.Y + 2) * VirtualScale), int(90 * VirtualScale), int(50 * VirtualScale) ); } } Vector2 TitlePos = IconBasePos + (96, 8) + (TransitionOffset.X, 0); String Title = ""; if (Node == null) { Title = StringTable.Localize("$SNAPMENU_LOAD_EMPTY"); } else { Title = Node.SaveTitle; } SnapMenuText(FontBig, Font.CR_UNTRANSLATED, TitlePos, Title); } virtual void SaveDrawer() { Vector2 Offset = (0, 0); int Selected = GetSelectedItem(); int FirstDrawn = -1; int LastDrawn = -1; Vector2 TransitionOffset = VirtualSize; TransitionOffset *= (1.0 - MenuTransition); int h = GetSaveHeight(); uint NumItems = manager.SavegameCount(); if (NumItems == 0) { Vector2 Delta = (h * 0.5, h); if (GetCurrentMenu() == self && MenuTransition >= 0.5) { MenuData.Cursor.DestPos = Delta + (24, h * 0.5); MenuData.Cursor.DestSmall = false; } DrawSaveItem(null, Delta, TransitionOffset, false); } else { for (uint i = 0; i < NumItems; i++) { bool isSelected = (Selected == i); Vector2 Delta = (Offset - ScrollPos); if (isSelected == true && GetCurrentMenu() == self && MenuTransition >= 0.5) { MenuData.Cursor.DestPos = Delta + (24, h * 0.5); MenuData.Cursor.DestSmall = false; } SaveGameNode node = SortedSaves[i]; DrawSaveItem(node, Delta, TransitionOffset, isSelected); if (FirstDrawn == -1) { FirstDrawn = i; } LastDrawn = i; Offset.X += (h * 0.5); Offset.Y += h; } } bool CanScrollUp = (FirstDrawn > FirstSelectable()); bool CanScrollDown = (LastDrawn < LastSelectable()); /* if (CanScrollUp) { DrawOptionText(screen.GetWidth() - 11 * CleanXfac_1, 0.0, OptionMenuSettings.mFontColorSelection, "â–²"); } if (CanScrollDown) { DrawOptionText(screen.GetWidth() - 11 * CleanXfac_1 , Offset - 8*CleanYfac_1, OptionMenuSettings.mFontColorSelection, "â–¼"); } */ } override void Drawer() { let parent = SnapMenuBase(mParentMenu); if (parent != null && parent.MenuTransition > 0.0) { // Finish the parent's transition first. parent.Drawer(); return; } if (FadeHide == true) { // Finish fading first. let parent = SnapMenuBase(mParentMenu); if (parent != null) { parent.Drawer(); } return; } UpdateScaleParameters(); MenuData.DrawBackground(); SaveDrawer(); MouseBackButtonDrawer(); MenuData.DrawCursor(); if (InMenuFade() == true) { SnapFader.DrawFadeOverlay(MenuData.Fader.FadeOffset); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapStaticEventHandler { Map LocalizedTextureHeap; void DeserializeLocalizedTexture( in out Map Dest, String BaseTexture, JsonElement Elem) { if (Elem == null) { Console.Printf("TEXLOCAL parse warning: entry \"%s\" is not an element.", BaseTexture); return; } let LocalizedTexture = JsonString(Elem); if (LocalizedTexture == null) { Console.Printf("TEXLOCAL parse warning: entry \"%s\" is not a string.", BaseTexture); return; } Dest.Insert(BaseTexture, LocalizedTexture.s); } void DeserializeLocalizedTexturesLump(JsonElement Elem) { if (Elem == null) { // Invalid input, ignore. return; } let Obj = JsonObject(Elem); if (Obj == null) { // Not an object, ignore. return; } JsonObjectKeys Keys = Obj.GetKeys(); for (int i = 0; i < Keys.Keys.Size(); i++) { String k = Keys.Keys[i]; DeserializeLocalizedTexture( LocalizedTextureHeap, k, Obj.Get(k) ); } } void ReadTextureLocalizations() { int lump = Wads.FindLump("TEXLOCAL", 0, Wads.ANYNAMESPACE); while (lump != -1) { JsonElementOrError data = JSON.Parse(Wads.ReadLump(lump), false); if (data is "JsonError") { ThrowAbortException("TEXLOCAL fatal error: " .. JsonError(data).what); } else { DeserializeLocalizedTexturesLump(JsonElement(data)); } lump = Wads.FindLump("TEXLOCAL", lump + 1, Wads.ANYNAMESPACE); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapPlayer { const LOCKONANG = 5.625; const MAXTRACE = 4; Actor LockOn; bool LockOnHeld; bool LockOnInit; bool LockOnSound; bool LockOnTargetValid(Actor test) { if (test == null || test.bDestroyed == true) { return false; } if (test.health <= 0) { return false; } if (IsTeammate(test) == true) { return false; } if (test.bShootable == false || test.bNonShootable == true) { return false; } if (test.bCantSeek == true) { return false; } if (test.bIsMonster == true || test is "PlayerPawn") { double dis = 3072.0; if (CheckSight(test) == false) { // If you can't see the target, reduce the distance drastically. dis = 1024.0; } return CheckIfCloser(test, dis, true); } return false; } Actor TraceLockOnTarget(Vector3 TracePos, double TraceAngle, double TracePitch) { FLineTraceData data; bool result = LineTrace( Angle + TraceAngle, 2048.0, Pitch + TracePitch, TRF_ABSPOSITION|TRF_ABSOFFSET|TRF_THRUHITSCAN, TracePos.z, TracePos.x, TracePos.y, data ); if (result == true) { if (data.HitType == TRACE_HitActor && LockOnTargetValid(data.HitActor) == true) { return data.HitActor; } } return null; } Actor FindLockOnTarget() { double MoMidOffset = ViewHeight - FloorClip; Vector3 TracePos = Vec3Offset(0, 0, MoMidOffset); // Check direct center Actor a = TraceLockOnTarget(TracePos, 0.0, 0.0); if (a != null) { return a; } // Look through deviations // TODO: Maybe use a blockmap iterator + SphericalCoords // instead of tons of line traces. for (uint t = 1; t <= MAXTRACE; t++) { for (uint i = 0; i < 8; i++) { double an = 0.0; double pt = 0.0; switch (i) { case 0: an = -LOCKONANG; break; case 1: an = LOCKONANG; break; case 2: pt = LOCKONANG; break; case 3: pt = -LOCKONANG; break; case 4: an = -LOCKONANG; pt = LOCKONANG; break; case 5: an = LOCKONANG; pt = LOCKONANG; break; case 6: an = -LOCKONANG; pt = -LOCKONANG; break; case 7: an = LOCKONANG; pt = -LOCKONANG; break; default: break; } an *= t; pt *= t; // Check for deviation being too large (for diagonals) double dev = abs(an) + abs(pt); if (dev > LOCKONANG * MAXTRACE) { continue; } a = TraceLockOnTarget(TracePos, an, pt); if (a != null) { return a; } } } return null; } void EndLockOn() { if (LockOnSound == true) { A_StartSound("lock/off", CHAN_6); LockOnSound = false; } LockOn = null; } void UpdateLockOnAngle() { if (LockOn != null) { if (LockOnTargetValid(LockOn) == true) { // Aim directly at the target. Vector3 Dir = Vec3To(LockOn); // Adjust the height you aim at the object at based on Z difference. double HThreshold = Height; // Height * 2.0 double HDiff = max(min(Dir.Z, HThreshold), -HThreshold * 0.5); // -HThreshold // When below the object: 0.8 // When level with the object: 0.5 // When above the object: 0.35 double HeightMod = 0.5 + ((HDiff / HThreshold) * 0.3); double MoMidOffset = ViewHeight - FloorClip; let player = self.player; if (player != null) { MoMidOffset += player.crouchviewdelta; } Dir.Z += ((LockOn.Height * HeightMod) - MoMidOffset) * 0.5; double LockAngle = VectorAngle(Dir.X, Dir.Y); double LockPitch = -VectorAngle(Dir.XY.Length(), Dir.Z); A_SetAngle(LockAngle, SPF_INTERPOLATE); A_SetPitch(LockPitch, SPF_INTERPOLATE); } else { // Remove lock on when it's invalid (you killed it, for instance). EndLockOn(); } } } void CheckLockOn() { if (Health <= 0) { // Remove lock on when dead. EndLockOn(); return; } UpdateLockOnAngle(); bool LockOnHoldMode = false; let LockOnHoldCV = CVar.GetCVar("snap_lockonhold", player); if (LockOnHoldCV != null) { LockOnHoldMode = LockOnHoldCV.GetBool(); } // Check lock on inputs if (player.cmd.buttons & BT_USER2) { Actor PrevLock = LockOn; if (LockOn == null && (LockOnHeld == false || LockOnInit == true)) { // Find a target if you don't have one! LockOn = FindLockOnTarget(); LockOnInit = true; if (LockOn != PrevLock) { A_StartSound("lock/on", CHAN_6); LockOnSound = true; } } else if (LockOnInit == false && LockOnHoldMode == false) { EndLockOn(); } LockOnHeld = true; } else { LockOnHeld = LockOnInit = false; if (LockOnHoldMode == true) { EndLockOn(); } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapIntermission { // // Intermission type logic // clearscope virtual int GetMapScore() { // The total score of the map. return 0; } clearscope virtual int GetPlayerScore(int playerID) { // An individual player's score. return 0; } virtual void InitData() { // Allows for editing data before setting MaxScore. } abstract void Start(); // Ran on intermission start, after InitData. abstract void Update(); // Ticker when we want to run intermission code. virtual void End() { // Run to do the transition out. // Virtual just in case I want to add any more to this. HandleFinish = true; } // // Data functions // clearscope bool ValidPlayerNum(int pnum) { if (pnum >= 0 && pnum < MAXPLAYERS) { return true; } return false; } clearscope int GetScoreValue(int count, int weight = 100, int limit = 0) { if (limit > 0) { if (count > limit) { count = limit; } else if (count < -limit) { count = -limit; } } return (count * weight); } clearscope int CalculateGrade(int yourScore) { if (RealParTime == 0) { // No par time set // Probably means grading hasn't been balanced yet // and thus you probably shouldn't be graded! return GRADE_INVALID; } if (yourScore >= MaxScore) { return GRADE__MAX; // S rank } double percentage = (yourScore * 1.0) / (MaxScore * 1.0); for (int i = GRADE_A; i > GRADE_E; i--) { if (percentage >= RankPercents[i]) { return i; } } return GRADE_E; // shouldn't happen, but just in case. } clearscope int GetMapParTime() { int Par = 0; if (MapDef != null) { if (GameDifficulty >= 2) { Par = MapDef.ParTimes[1]; } else { Par = MapDef.ParTimes[0]; } } if (Par <= 0) { // Use MAPINFO par time as a default. Par = Level.ParTime; } if (Par < 0) { Par = 0; } return Par; } // // Logic helpers // void GenericPauseState(int rankDoneState = -1) { // We are pausing for just a moment if (GenericDelay > 0) { GenericDelay--; } if (GenericDelay <= 0) { if (CurState == rankDoneState) { PlaySound("intermission/rankDone"); RequireRelease = true; } CurState++; GenericDelay = TICRATE; } } bool DoSkipLogic() { bool CanSkip = true; for (int i = 0; i < MAXPLAYERS; i++) { PlayerInfo player = players[i]; if (playeringame[i] == false) { continue; } if (multiplayer == true) { if (player.Bot || PlayerData[i].KeyHeld == true) { // Ready up! PlayerData[i].Ready = true; } if (PlayerData[i].Ready == false) { // Can't skip if someone isn't ready. CanSkip = false; } } else { // Skip if pressing any buttons. if (PlayerData[i].KeyHeld == false) { CanSkip = false; } // We switched screens. // Don't skip until buttons are released. if (RequireRelease == true) { if (CanSkip == false) { RequireRelease = false; } else { CanSkip = false; } } } } return CanSkip; } void ResetSkip() { //SkipStage = false; RequireRelease = true; for (uint i = 0; i < MAXPLAYERS; i++) { PlayerData[i].Ready = false; } } int IncrementScore(int cur, int dest, int factor = 80) { int add = (dest - cur) / factor; // Add at least 0.1% of the total grade. int minAdd = int(dest * 0.001); if (add < minAdd) { add = minAdd; } add = (add / 10) * 10; // Round to 10s place // Add at least 100 at a time if it's even lower. if (add < 10) { add = 10; } return add; } int IncrementGradeScore(int cur, int dest, int factor = 80) { int add = (dest - cur) / factor; int g = CalculateGrade(cur); if (g != GRADE_INVALID) { // HACK: Scale depending on the length of the segment, // so that they all look even, despite them not actually being :V if (g >= GRADE__MAX) { g = GRADE__MAX-1; } double percentDiff = abs(RankPercents[g + 1] - RankPercents[g]); double markiplier = percentDiff / BASE_RANK_DIFF; add = int(add * markiplier); } // Add at least 0.1% of the total grade. int minAdd = int(dest * 0.001); if (add < minAdd) { add = minAdd; } add = (add / 10) * 10; // Round to 10s place // Add at least 100 at a time if it's even lower. if (add < 100) { add = 100; } return add; } void PlaySound(Sound snd) { S_StartSound(snd, CHAN_VOICE, CHANF_MAYBE_LOCAL|CHANF_UI, 1, ATTN_NONE); } void ScoreTick() { if (Level.maptime % 6 == 0) { PlaySound("intermission/tick"); } } void PlayRankSound(double progress) { int rankSound = int(progress * NUM_RANK_TICKS); if (rankSound < 0) { rankSound = 0; } if (rankSound >= NUM_RANK_TICKS) { rankSound = NUM_RANK_TICKS-1; } PlaySound(rankTicks[ rankSound ]); } void FadeOutTick() { FadeOutTimer++; if (FadeOutTimer > 50) { End(); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapLookupMenu : OptionMenu { // Dummy menu, which just redirects // to another different menu. virtual Name GetLookupMenu() { return "SnapMainMenu"; } override void Init(Menu parent, OptionMenuDescriptor desc) { super.Init(parent, desc); DontDim = true; } override void Ticker() { Menu.SetMenu(GetLookupMenu()); Destroy(); } override void Drawer() { return; } override bool MenuEvent(int mKey, bool gamepad) { return false; } } class SnapLookupMainMenu : SnapLookupMenu { // Go to SnapPauseMenu when in a game. // Go to SnapMainMenu otherwise. override Name GetLookupMenu() { switch (gamestate) { case GS_TITLELEVEL: case GS_MENUSCREEN: { return "SnapMainMenu"; } default: { return "SnapPauseMenu"; } } } override void Ticker() { Name NewMenu = GetLookupMenu(); bool Unlocks = false; if (NewMenu == "SnapMainMenu") { SnapStaticEventHandler.CheckAchievements(); Unlocks = SnapAchievementMenu.UnlockedNewStuff(); } if (Unlocks == true) { // Emulate the path to the extras menu, // so we can see the unlocking animations! let data = SnapMenuData.Get(); if (data != null) { data.StepThru = true; } Menu.SetMenu(NewMenu); //Menu.SetMenu("SnapExtra"); Menu.SetMenu("SnapChallenge"); if (data != null) { data.StepThru = false; } } else { Menu.SetMenu(NewMenu); } Destroy(); } } class SnapLookupEndGame : SnapLookupMenu { // Go to QuitMenu in netgames. // Go to EndGameMenu otherwise. override Name GetLookupMenu() { if (netgame == true) { return "QuitMenu"; } return "EndGameMenu"; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapMapDef : SnapDefinition { String Title; String Icon; int ParTimes[2]; CVar RecordVar; SnapMapRecord Records[NUM_RECORD_SKILLS]; // Filled out later CVar SecretVar; uint TotalSecrets[SECRET_SAVE_SKILLS]; uint SecretFlags[SECRET_SAVE_SKILLS]; bool InEpisode; bool Locked(uint MenuGameType = GT_CAMPAIGN) { if (InEpisode == false) { return (SnapReward_BonusMap.BonusMapUnlocked(self.ID) == false); } return false; } uint CountSecretsGotten(uint Skill) { if (Skill >= SECRET_SAVE_SKILLS) { return 0; } if (TotalSecrets[Skill] == 0) { return 0; } uint Count = 0; for (uint i = 0; i < TotalSecrets[Skill]; i++) { uint Flag = 1 << i; if (SecretFlags[Skill] & Flag) { Count++; } } return Count; } static void OnCompleted(Name MapLump, int GameDifficulty) { /* let MapDef = SnapMapDef.Get(MapLump); if (MapDef == null) { return; } // TODO: If I do decide I need a separate // map complete variable separate from // records, then it'd go here. let ev = SnapStaticEventHandler.Get(); if (ev == null) { return; } SnapDefinitions AllDefs = ev.SnapDefs; if (AllDefs == null) { return; } MapIterator it; if (it.Init(AllDefs.EpisodeHeap) == false) { return; } while (it.Next() == true) { let def = it.GetValue(); uint MapListLen = def.MapList.Size(); if (MapListLen == 0) { continue; } let LastMap = def.MapList[MapListLen - 1]; if (LastMap != null && LastMap.ID == MapLump) { // If we finished the last map of an episode, // consider the episode completed. CVar BeatenCV = def.BeatenVar; if (BeatenCV != null) { int AlreadyBeaten = BeatenCV.GetInt(); if (GameDifficulty > AlreadyBeaten) { BeatenCV.SetInt(GameDifficulty); } break; } } } */ // DEMO MODE CVar MapFlags = CVar.FindCVar("snap_demo_maps"); if (MapFlags != null) { int flags = MapFlags.GetInt(); let DemoMaps = SnapEpisodeDef.ConstructBonusLevelsEpisode(); for (int i = 0; i < DemoMaps.MapList.Size(); i++) { let Compare = DemoMaps.MapList[i]; if (Compare.ID == MapLump) { flags |= 1 << i; } } MapFlags.SetInt(flags); } } static SnapMapDef Get(Name ID) { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return null; } SnapDefinitions defs = ev.SnapDefs; if (defs == null) { return null; } if (defs.MapHeap.CheckKey(ID) == false) { return null; } return defs.MapHeap.Get(ID); } static String GetMapTitle(Name ID) { String ret = "$SNAPMENU_RECORD_NOTVISITED"; let MapDef = SnapMapDef.Get(ID); if (MapDef != null && MapDef.Title.Length() > 0) { ret = MapDef.Title; } return StringTable.Localize(ret); } static String GetMapTitleOrHidden(Name ID) { String ret = "$SNAPMENU_RECORD_NOTVISITED"; let MapDef = SnapMapDef.Get(ID); if (MapDef != null && MapDef.Title.Length() > 0) { for (uint i = 0; i < NUM_RECORD_SKILLS; i++) { if (MapDef.Records[i] != null) { ret = MapDef.Title; break; } } } return StringTable.Localize(ret); } void ParseParTimes(JsonObject Obj) { JsonElement Elem = Obj.Get("partimes"); if (Elem == null) { return; } let ElemArray = JsonArray(Elem); if (ElemArray == null) { return; } uint n = ElemArray.Size(); if (n != 2) { Console.Printf( "SNAPDEFS parse warning: array \"%s\" is incorrect length (got %d, expected %d).", "partimes", n, 2 ); return; } for (uint i = 0; i < 2; i++) { let ParElem = JsonInt(ElemArray.Get(i)); if (ParElem == null) { Console.Printf( "SNAPDEFS parse warning: array \"%s\" element %d is not an integer.", "partimes", i ); } else { ParTimes[i] = ParElem.i; } } } void ParseNumSecrets(JsonObject Obj) { JsonElement Elem = Obj.Get("numsecrets"); if (Elem == null) { return; } let ElemInt = JsonInt(Elem); if (ElemInt != null) { // Hey, this is pretty easy. // Just treat it like an uint. int integer = ElemInt.i; if (integer < 0 || integer > SECRET_SAVE_MAX) { Console.Printf( "SNAPDEFS parse warning: element \"%s\" only accepts integers between 0 and %d.", "numsecrets", SECRET_SAVE_MAX ); } else { // Set them all the same way. for (uint i = 0; i < SECRET_SAVE_SKILLS; i++) { TotalSecrets[i] = uint(integer); } } return; } let ElemArray = JsonArray(Elem); if (ElemArray != null) { // Alright, time to do it the hard way. uint n = ElemArray.Size(); if (n != SECRET_SAVE_SKILLS) { Console.Printf( "SNAPDEFS parse warning: array \"%s\" is incorrect length (got %d, expected %d).", "numsecrets", n, SECRET_SAVE_SKILLS ); return; } for (uint i = 0; i < SECRET_SAVE_SKILLS; i++) { let SkillElem = JsonInt(ElemArray.Get(i)); if (SkillElem == null) { Console.Printf( "SNAPDEFS parse warning: array \"%s\" element %d is not an integer.", "numsecrets", i ); } else { int integer = SkillElem.i; if (integer < 0 || integer > SECRET_SAVE_MAX) { Console.Printf( "SNAPDEFS parse warning: array \"%s\" element %d only accepts integers between 0 and %d.", "numsecrets", i, SECRET_SAVE_MAX ); } else { // Individual set TotalSecrets[i] = uint(integer); } } } return; } Console.Printf( "SNAPDEFS parse warning: element \"%s\" is an invalid type (expected an integer or array).", "numsecrets" ); } override void InternalDeserialize(JsonObject Obj) { ParseForString(Title, Obj, "title"); ParseForString(Icon, Obj, "icon"); if (Icon.Length() == 0) { Icon = "MI_BOSS"; } ParseParTimes(Obj); RecordVar = ParseForCVar(Obj, "recordvar"); ParseNumSecrets(Obj); SecretVar = ParseForCVar(Obj, "secretvar"); } static void Deserialize( in out Map Dest, Name FindID, JsonElement Elem) { if (Elem == null) { Console.Printf("SNAPDEFS parse warning: entry \"%s\" is not an element.", FindID); return; } let Obj = JsonObject(Elem); if (Obj == null) { Console.Printf("SNAPDEFS parse warning: entry \"%s\" is not an object.", FindID); return; } SnapMapDef EditDef = null; bool Exists = false; [EditDef, Exists] = Dest.CheckValue(FindID); if (Exists == false) { EditDef = new("SnapMapDef"); EditDef.ID = FindID; EditDef.Sort = Dest.CountUsed(); Dest.Insert(FindID, EditDef); } EditDef.InternalDeserialize(Obj); } } extend class SnapDefinitions { Map MapHeap; static void GetSortedBonusMaps(in out Array Sorted) { Sorted.Clear(); let ev = SnapStaticEventHandler.Get(); if (ev == null) { return; } SnapDefinitions defs = ev.SnapDefs; if (defs == null) { return; } MapIterator it; if (it.Init(defs.MapHeap) == false) { return; } while (it.Next() == true) { let MapDef = it.GetValue(); if (MapDef.InEpisode == true) { continue; } uint Index = 0; uint Size = Sorted.Size(); for (Index = 0; Index < Size; Index++) { let other = Sorted[Index]; if (MapDef.Sort < Other.Sort) { break; } } Sorted.Insert(Index, MapDef); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapMapList abstract { bool Looping; uint Length; Array StageLumps; Array StageIcons; void InsertMapInList(String MapLump, String IconLump) { StageLumps.Push(MapLump); StageIcons.Push(IconLump); Length++; } abstract void Init(); static SnapMapList GetMapsList(String MapLump) { SnapStaticEventHandler ev = SnapStaticEventHandler(StaticEventHandler.Find("SnapStaticEventHandler")); if (ev == null) { return null; } uint NumLists = ev.MapLists.Size(); if (NumLists > 0) { // Use the latest one. for (int ListID = NumLists-1; ListID >= 0; ListID--) { SnapMapList List = ev.MapLists[ListID]; if (List != null) { for (uint i = 0; i < List.Length; i++) { if (List.StageLumps[i] == MapLump) { return List; } } } } } return null; } } class SnapEpisode1List : SnapMapList { override void Init() { Looping = false; InsertMapInList("E1M1", "MI_E1M1"); InsertMapInList("E1M2", "MI_E1M2"); InsertMapInList("E1M3", "MI_E1M3"); InsertMapInList("E1M4", "MI_E1M4"); InsertMapInList("E1M5", "MI_E1M5"); InsertMapInList("E1M6", "MI_E1M6"); InsertMapInList("E1M7", "MI_E1M7"); InsertMapInList("E1M8", "MI_E1M8"); InsertMapInList("E1M9", "MI_E1M9"); InsertMapInList("E1M10", "MI_E1M10"); } } class SnapVersusList : SnapMapList { override void Init() { Looping = true; InsertMapInList("VS1", "MI_E1M10"); InsertMapInList("VS2", "MI_E1M1"); InsertMapInList("VS3", "MI_E1M6"); InsertMapInList("VS4", "MI_E1M3"); InsertMapInList("VS5", "MI_E1M9"); } } class SnapInvasionList : SnapMapList { override void Init() { Looping = true; InsertMapInList("INV1", "MI_E1M2"); InsertMapInList("INV2", "MI_E1M8"); } } extend class SnapStaticEventHandler { Array MapLists; void AddNewMapList(class ListClass) { let List = SnapMapList(new(ListClass)); if (List != null) { List.Init(); MapLists.Push(List); } } void InitMapLists() { AddNewMapList("SnapEpisode1List"); AddNewMapList("SnapVersusList"); AddNewMapList("SnapInvasionList"); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- #include "./mapmisc/cactus.zs" #include "./mapmisc/oildrum.zs" #include "./mapmisc/scruffie.zs" #include "./mapmisc/beachflags.zs" #include "./mapmisc/lavaspew.zs" #include "./mapmisc/bombs.zs" #include "./mapmisc/fountain.zs" #include "./mapmisc/volcanotorch.zs" #include "./mapmisc/generator.zs" #include "./mapmisc/cars.zs" #include "./mapmisc/citydecor.zs" #include "./mapmisc/devroom.zs" #include "./mapmisc/titlesnap.zs" #include "./mapmisc/relativeskybox.zs" #include "./mapmisc/landmark.zs" #include "./mapmisc/rbbomb.zs" #include "./mapmisc/factorydecor.zs" #include "./mapmisc/crane.zs" //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- // Core classes #include "./menu/parallax.zs" #include "./menu/cursor.zs" #include "./menu/draw.zs" #include "./menu/data.zs" #include "./menu/core.zs" #include "./menu/base.zs" #include "./menu/items.zs" // Generic types #include "./menu/message.zs" #include "./menu/lookup.zs" #include "./menu/horizontal.zs" // Specialized types #include "./menu/option.zs" #include "./menu/joystick.zs" #include "./menu/record.zs" #include "./menu/episode.zs" #include "./menu/skill.zs" #include "./menu/trial.zs" #include "./menu/load.zs" #include "./menu/challenge.zs" #include "./menu/custom.zs" //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapMenuMessageBox : MessageBoxMenu { mixin SnapMenuDrawing; mixin SnapMenuCore; TextureID BoxTexture; Vector2 BoxSize; TextureID OptBG; String Choices[2]; uint TextWidth; BrokenLines MessageLines; bool QuitGameBox; bool CallHandlerAfterFade; override void Init(Menu parent, String message, int messageMode, bool playSound, Name cmd, voidptr nativeHandler) { parent = LookupParentRedirect(parent); super.Init(parent, message, messageMode, playSound, cmd, nativeHandler); mParentMenu = parent; DontDim = true; PrecacheMenuDrawing(); PrecacheMenuCore(); BoxTexture = TexMan.CheckForTexture("MSGBG", TexMan.Type_MiscPatch); BoxSize = SnapMenuTextureSize(BoxTexture); OptBG = TexMan.CheckForTexture("HUDKEYBG", TexMan.Type_MiscPatch); if (mMessageMode == 0) { String defaultQuitMsg = StringTable.Localize("$SNAP_QUIT_HACK"); QuitGameBox = ( message.Left(defaultQuitMsg.length()) == defaultQuitMsg ); if (QuitGameBox == true) { // TODO: Maybe move quit message definitions to SNAPDEFS? // idk, can't be assed right now Array QuitMessages; uint TestIndex = 0; String TestString = ""; String LocalizedString = ""; while (true) { TestIndex++; TestString = "SNAP_QUIT_MSG"..TestIndex; LocalizedString = StringTable.Localize("$"..TestString); if (LocalizedString == TestString) { // End of quit messages break; } QuitMessages.Push(LocalizedString); } if (QuitMessages.Size() > 0) { int index = random[snap_quit](0, QuitMessages.Size() - 1); message = QuitMessages[index]; } Choices[0] = Stringtable.Localize("$SNAPMENU_QUIT"); Choices[1] = Stringtable.Localize("$SNAP_QUIT_BACK"); } else { Choices[0] = Stringtable.Localize("$TXT_YES"); Choices[1] = Stringtable.Localize("$TXT_NO"); } } else { Choices[0] = Stringtable.Localize("$SNAPMENU_OK"); } TextWidth = uint(BoxSize.X - 48); MessageLines = FontSmall.BreakLines(message, TextWidth); TransitionMode = TM_LINEAR; TryTransitionIn(parent); } virtual void TryTransitionIn(Menu From) { TransitionSpeed = BASE_TRANSITION_SPEED; ClosingMenu = false; } virtual void TryTransitionOut(Menu To) { TransitionSpeed = -BASE_TRANSITION_SPEED; } override void OnReturn() { TryTransitionIn(GetCurrentMenu()); // TODO: ensure this is correct super.OnReturn(); } override void Ticker() { TransitionTick(); super.Ticker(); if (MenuData.Fader.FadeOffset >= 1.0 && CallHandlerAfterFade == true) { CallHandlerAfterFade = false; CallHandler(Handler); } } void FadeConfirm() { CallHandlerAfterFade = true; SnapFader.StartGameFade(true, QuitGameBox ? 0.02 : SnapFader.LEVELFADESPEED); } void MessageClose() { CloseSound(); TryTransitionOut(self); ClosingMenu = true; } override void HandleResult(bool res) { if (Handler != null) { if (res) { FadeConfirm(); } else { MessageClose(); } } else if (mParentMenu != null) { if (mMessageMode == 0) { if (mAction == 'None') { mParentMenu.MenuEvent(res ? MKEY_MBYes : MKEY_MBNo, false); MessageClose(); } else { MessageClose(); if (res) { SetMenu(mAction, -1); } } } } } override bool MenuEvent(int mKey, bool gamepad) { if (InMenuTransition() == true) { return false; } if (mMessageMode == 0) { if (mkey == MKEY_Up || mkey == MKEY_Down) { MenuSound("menu/cursor"); messageSelection = !messageSelection; return true; } else if (mkey == MKEY_Enter) { // 0 is yes, 1 is no HandleResult(!messageSelection); return true; } else if (mkey == MKEY_Back) { HandleResult(false); return true; } return false; } else { MessageClose(); return true; } return false; } override bool MouseEvent(int type, int x, int y) { if (VirtualScale == 0) { // not init yet return false; } x = int(x / VirtualScale); y = int(y / VirtualScale); if (mMessageMode == 0) { int sel = -1; int optHeight = FontMenu.GetHeight(); int optSpace = int((optHeight * 1.5) + 0.5); Vector2 OptionPos = (160, 100) + (optHeight * 2, optSpace + optHeight); Vector4 BoundingBox = ( OptionPos.x - (optHeight * 2.5), OptionPos.y - (optHeight * 1.5), OptionPos.x + (optHeight * 2.5), OptionPos.y + (optHeight * 1.5) ); if (x >= BoundingBox.x && x <= BoundingBox.z && y >= BoundingBox.y && y <= BoundingBox.w) { sel = (y >= BoundingBox.w - ((BoundingBox.w - BoundingBox.y) * 0.5)); } messageSelection = sel; if (type == MOUSE_Release) { return MenuEvent(MKEY_Enter, true); } return true; } else { if (type == MOUSE_Click) { return MenuEvent(MKEY_Enter, true); } return false; } } override void Drawer() { UpdateScaleParameters(); if (mParentMenu) { mParentMenu.Drawer(); } Screen.Dim( Color(0, 0, 0), MenuTransition * 0.75, 0, 0, int(RealSize.X), int(RealSize.Y) ); Vector2 MsgPos = (160, 100); MsgPos.Y -= (1.0 - MenuTransition) * VirtualSize.X; DrawMessageBox(MsgPos); if (InMenuFade() == true) { SnapFader.DrawFadeOverlay(MenuData.Fader.FadeOffset); } } virtual void DrawMessageBox(Vector2 Pos) { int optHeight = FontMenu.GetHeight(); int optSpace = int((optHeight * 1.5) + 0.5); int fHeight = FontSmall.GetHeight(); SnapMenuTexture(BoxTexture, Pos - (BoxSize * 0.5)); int lines = MessageLines.Count(); Vector2 TextPos = Pos - ( 0.0, (fHeight * 0.5 * lines) + optSpace ); for (int i = 0; i < lines; i++) { SnapMenuText( FontSmall, Font.CR_UNTRANSLATED, TextPos - (MessageLines.StringWidth(i) * 0.5, 0), MessageLines.StringAt(i) ); TextPos.Y += fHeight; } Vector2 OptionPos = Pos + (-optHeight, optSpace); if (mMessageMode == 0) { // Yes or No mode for (uint i = 0; i < 2; i++) { SnapMenuTexture( OptBG, OptionPos + (-8, 2) ); SnapMenuText( FontMenu, (messageSelection == i) ? FontHighlightColor : Font.CR_UNTRANSLATED, OptionPos, Choices[i] ); OptionPos.Y += optHeight; } } else { // OK mode OptionPos.Y += (optHeight * 0.5); SnapMenuTexture( OptBG, OptionPos + (-8, 2) ); SnapMenuText( FontMenu, Font.CR_UNTRANSLATED, OptionPos, Choices[0] ); OptionPos.Y += optHeight; } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class MineSnail : SnapMonster { uint RudeSnailFastTime; bool SwapRevPuff; transient bool WasSteppedOn; action state A_MineSnailChaseJump() { double defSpeed = Default.Speed; let snail = MineSnail(self); if (snail) { if (snail.bSpeedUp == true) { // Set Invasion speed up defSpeed *= 2.0; } if (snail.RudeSnailFastTime > 0) { snail.Speed = defSpeed * 2.0; snail.RudeSnailFastTime--; return ResolveState("QuickChase"); } } snail.Speed = defSpeed; return null; } bool SnailForceExplode() { Array TargetList; // Add our target. if (target != null && target.Health > 0) { TargetList.Push(target); } // Add all players. for (uint i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] == false) { continue; } let mo = players[i].mo; if (mo != null && mo.Health > 0 && mo != target) { TargetList.Push(mo); } } // Add everything from our hate TID. if (TIDtoHate != 0) { let it = Level.CreateActorIterator(TIDtoHate); Actor mo; while (mo = it.Next()) { if (mo.Health <= 0 || mo == target) { continue; } TargetList.Push(mo); } } // Now that we have all targets, we'll see if we're close enough to explode on any of them. uint sz = TargetList.Size(); if (sz == 0) { return false; } for (uint i = 0; i < sz; i++) { let mo = TargetList[i]; if (Pos.Z + Height + 24.0 < mo.Pos.Z || mo.Pos.Z + mo.Height < Pos.z) { continue; } double dis = Distance2D(mo); double range = MeleeRange + mo.radius; if (dis > range) { continue; } return true; } return false; } action void A_MineSnailChase() { let snail = MineSnail(self); if (!snail) { A_SnapChase(); return; } // Check if ANYTHING that we want to explode against is on top of us. // If they are, then forcefully explode NOW! if (snail.SnailForceExplode() == true) { if (AttackSound) { S_StartSound(AttackSound, CHAN_WEAPON); } SetState(MeleeState); return; } // Nothing to explode against, just chase your target. if (snail.bVeryRude == true && snail.RudeSnailFastTime == 0) { // Rude, and not sped up yet -- try revving up when far away. A_SnapChase(null, "Missile"); } else { // No missile attack A_SnapChase(null, null); //A_SnapChase("Melee", null); } if (snail.RudeSnailFastTime > 0) { // Spawn trail when you're fast. A_MineSnailTrail(0, 0); } } action void A_MineSnailTrail(double initMom, uint tireMode) { double puffAng = 180.0; if (tireMode == 2) { puffAng = 202.5; } else if (tireMode == 1) { puffAng = 157.5; } Actor puff = Spawn("SnapPuff", Vec3Angle(radius, angle + puffAng), ALLOW_REPLACE); if (puff) { if (tireMode != 0) { puff.VelFromAngle(initMom, angle + puffAng); } puff.Vel.Z += initMom + random[snap_decor](0, 1); } } action void A_MineSnailRev(double initMom) { let snail = MineSnail(self); if (!snail) { return; } A_FaceTarget(22.5); // Spawn particles uint tireMode = 1; if (snail.SwapRevPuff) { tireMode = 2; } A_MineSnailTrail(initMom, tireMode); snail.SwapRevPuff = !snail.SwapRevPuff; } action void A_MineSnailRelease() { let snail = MineSnail(self); A_FaceTarget(22.5); // Enable fast if (snail) { snail.RudeSnailFastTime = 2*TICRATE; } // Play release sound A_StartSound("mineSnail/release"); } Default { Health 60; Radius 28; Height 24; Speed 15; Mass 100; SnapActor.DamageFlash "EnemyDamagedBlue"; SnapMonster.Poise 25; SeeSound "mineSnail/see"; ActiveSound "mineSnail/idle"; PainSound "mineSnail/hurt"; Obituary "$OB_MINESNAIL"; Tag "$TAG_MINESNAIL"; Species "Robot"; +SnapMonster.ROBOTEXPLODES } States { Spawn: MSNL A 1 A_SnapMonsterLook(); MSNL BABABABAB 1; Loop; See: MSNL C 0 A_MineSnailChaseJump(); MSNL C 2 A_MineSnailChase(); MSNL D 2; Loop; QuickChase: MSNL C 1 A_MineSnailChase(); MSNL D 1; Goto See; Pain: MSNL E 2; MSNL E 2 A_SnapMonsterPain(); Goto See; Kicked: MSNL E 2; MSNL E 2 A_SnapMonsterPain(); KickLoop: MSNL E 2 A_EndKick(); Loop; Missile: MSNL C 0 A_StartSound("mineSnail/rev"); MSNL CDCDCD 3 A_MineSnailRev(1.0); MSNL CDCDCD 2 A_MineSnailRev(2.0); MSNL CDCDCD 1 A_MineSnailRev(3.0); MSNL C 0 A_MineSnailRelease(); Goto See; Melee: MSNL E 0 { WasSteppedOn = true; self.DamageMobj(null, null, Health, "None", DMG_FORCED|DMG_THRUSTLESS); } Stop; Death: MSNL E 2 A_StartSound("mineSnail/fuse"); MSNL EEEEE 2; // MSNL EE 2; TNT1 A 35 DoSnapMonsterDie(); Stop; /* GiantDeath: MSNL E 1; MSNL EEEEEEEE 4 DoSnapMonsterExplode(true); TNT1 A 35 DoSnapMonsterDie(true, true); Stop; */ } override bool Slam(Actor victim) { if (Pos.Z > victim.Pos.Z + victim.Height || Pos.Z + Height < victim.Pos.Z) { return false; } if (kickTossed == true && victim.bShootable == true) { KickTossEnd(); Vel.Z = 5; } return false; } override void KickTossThink() { bSkullFly = true; int result = CheckSolidFooting(); if ((result & CSF_FLOORMASK) != 0) { // Bounce off the ground KickTossEnd(); Vel.Z = 5; } else { Vector2 kickedWallBounce = GetWallBounceDir(); if (kickedWallBounce.Length() > 0) { Vel.XY = kickedWallBounce * Vel.XY.Length() * 0.8; } bSkullFly = false; } } override void KickTossEnd() { super.KickTossEnd(); bSkullFly = false; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapMirrorProps : SnapWeaponProps { override void Init() { WeaponName = "Mirror"; NiceName = "$SNAPMENU_WEAPON_MIRROR"; PickupType = "SnapMirrorPowerup"; WeaponIcon = "WP_MIROR"; FireState = "FireMirror"; } } class SnapMirrorCan : SnapItemCan { Default { DropItem "SnapMirrorPowerup"; } States { Spawn: WP_M A 10; WP_M A 10 Bright; Loop; } } class SnapMirrorPowerup : SnapWeaponPowerup { Default { SnapWeaponPowerup.WeaponPower "Mirror"; Inventory.PickupMessage "$POWERUP_MIRROR"; SnapInventory.VoiceSample "voice/mirror"; } States { Spawn: WP_M B 10; WP_M B 10 Bright; Loop; } } class SnapMirrorTrail : SnapActor { Default { RenderStyle "Add"; Alpha 0.5; +NOINTERACTION +NOBLOCKMAP +NOGRAVITY +DONTSPLASH +RANDOMIZE +BRIGHT } States { Spawn: TNT1 A 2; MBUL B 1; TNT1 A 1; MBUL B 1; TNT1 A 1; MBUL B 1; Stop; } } class SnapMirrorDebris : SnapMirrorTrail { Default { -NOGRAVITY } States { Spawn: TNT1 A 2; MBUL B 2; TNT1 A 1; MBUL B 2; TNT1 A 1; MBUL B 1; MBUL B 1; TNT1 A 2; MBUL B 1; TNT1 A 2; MBUL B 1; Stop; } override void Tick() { super.Tick(); if (Level.isFrozen() == true) { return; } A_SetAngle(Angle + 45, SPF_INTERPOLATE); // Update origin with velocity. SetOrigin(Pos + Vel, true); if (bNoGravity == false) { // Apply fake gravity. Vel.Z -= Gravity; } } } class SnapMirrorShot : SnapBasicShot { // Mirror splits off into multiple projectile every time it hits a target. // This is the closest thing to a BFG this game has, although it's not as // extreme. Actor MirrorLastHit; void MirrorTrail() { let trail = SnapActor(Spawn("SnapMirrorTrail", Pos, ALLOW_REPLACE)); if (trail == null) { return; } trail.SetHitstunParent(self); trail.Angle = self.Angle; trail.Pitch = self.Pitch; trail.Roll = self.Roll; trail.bRollSprite = self.bRollSprite; trail.bRollCenter = self.bRollCenter; trail.Scale = self.Scale; trail.SpriteOffset = self.SpriteOffset; } void MirrorExplode() { double a = angle + 135; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { double p = (j * 45); Actor debris = Spawn("SnapMirrorDebris", Pos, ALLOW_REPLACE); if (debris) { debris.Vel = ( 8 * cos(a) * cos(p), 8 * sin(a) * cos(p), 8 * sin(p) ); debris.angle = a; } } a += 90; } } Default { DamageFunction 25; DamageType "Mirror"; Obituary "$OB_MIRROR"; BounceType "Grenade"; BounceCount 4; BounceFactor 1.0; WallBounceFactor 1.0; +BOUNCEONWALLS +BOUNCEONFLOORS +BOUNCEONCEILINGS +BOUNCEONUNRIPPABLES +NODAMAGETHRUST } States { Spawn: MBUL AB 1 Light("MirrorShotLight") A_SpawnItemEx("SnapMirrorTrail"); Loop; Death: MBUL A 1 Light("MirrorShotLight"); TNT1 A 1 MirrorExplode(); Stop; } override int SpecialMissileHit(Actor victim) { if (TryClink(victim) == true) { // No colliding when clinked. return 1; } if (victim == null || victim.bNonShootable == true || victim.bNoInteraction == true || victim.bNoClip == true) { // Don't interact at all. return 1; } if (victim.bShootable == false || victim.bInvulnerable == true || victim.bDontRip == true) { // Default interaction. return -1; } if (target != null) { if (victim == target || victim.isFriend(target) || victim.isTeammate(target)) { // Don't interact with friendlies. return -1; } } if (MirrorLastHit) { if (victim == MirrorLastHit) { // Don't create projectiles on the same guy several times return 1; } } // Offset the existing projectile angle += 22.5; Vel3DFromAngle(Default.Speed, angle, 0); // Update last hit MirrorLastHit = victim; // Reset bounce count, so it can keep going! bouncecount = Default.BounceCount + 1; // Create new projectile bool success; Actor newShot; [success, newShot] = A_SpawnItemEx( "SnapMirrorShot", 0, 0, 0, 0, 0, 0, -45, SXF_TRANSFERPOINTERS ); if (success) { newShot.Vel3DFromAngle(Default.Speed, newShot.angle, 0); let newMirror = SnapMirrorShot(newShot); if (newMirror) { newMirror.MirrorLastHit = victim; } newMirror.A_StartSound("revolver/mirrorsplit"); } DoMissileDamage(victim); return 1; } override void Tick() { super.Tick(); if (TickPaused() == true) { return; } if (MirrorLastHit) { // Unset last hit when outside of its hitbox double dist = MirrorLastHit.radius + self.radius + Vel.Length(); bool stillRipping = CheckIfCloser(MirrorLastHit, dist, false); if (stillRipping == false) { MirrorLastHit = null; } } } } extend class SnapGun { action void A_SnapgunMirror() { if (player == null || player.mo == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } A_SnapgunFlash('MirrorFlash'); A_SnapgunMomentumProjectile("SnapMirrorShot"); A_StartSound("revolver/mirror", CHAN_WEAPON); SoundAlert(self); player.mo.TakeInventory("SnapPowerupAmmo", 1, false, true); } States { FireMirror: SGUN A 1 A_SnapgunMirror(); SGUN BCD 1; SGUN E 6; SGUN A 0 A_SnapGunRefire(); SGUN F 5; Goto GunIdle; MirrorFlash: TNT1 A 1 Bright A_Light(2); SFL5 A 1 Bright A_Light(1); SFL5 B 1 Bright A_Light(0); SFL5 C 1 Bright; SFL5 D 1 Bright; Goto LightDone; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapMissileProps : SnapWeaponProps { override void Init() { WeaponName = "Missile"; NiceName = "$SNAPMENU_WEAPON_MISSILE"; PickupType = "SnapMissilePowerup"; WeaponIcon = "WP_MISSL"; FireState = "FireMissile"; DropFreq = 15; } } class SnapMissileCan : SnapItemCan { Default { DropItem "SnapMissilePowerup"; } States { Spawn: WPHM A 10; WPHM A 10 Bright; Loop; } } class SnapMissilePowerup : SnapWeaponPowerup { Default { SnapWeaponPowerup.WeaponPower "Missile"; Inventory.PickupMessage "$POWERUP_MISSILE"; SnapInventory.VoiceSample "voice/missile"; } States { Spawn: WPHM B 10; WPHM B 10 Bright; Loop; } } class SnapMissileDamageEFX : SnapRadiusDamageEFXRed { States { Spawn: RDER C 3 Light("RadiusExplosionMissileLight") NoDelay A_SetRenderStyle(GetDMGAlpha(), STYLE_Add); RDER DE 3 Light("RadiusExplosionMissileLight"); Stop; } } class SnapMissileShot : SnapBasicShot { // I found Explode is super fun but is a little hard to use. // It's a fun aiming challenge but some maps might just want to give you // its crowd control power with less effort required. // So here are Missiles! // Much slower than Explode but they shoot in a straight line, // and a far smaller direct-hit damage bonus, but in return, // it causes multiple explosions in the area it hit, // and can be used from a much longer range. action void A_SnapMissileExplode() { bNoGravity = true; double a = random[snap_decor](0,7) * 45; double h = 10; double v = 8; Vector2 speed; h = frandom[snap_decor](h * 0.5, h * 2.0); v = frandom[snap_decor](-v, v); A_StartSound("explosion/enemy"); speed = AngleToVector(a, h); A_SpawnItemEx( "SnapMonsterExplodeSmall", 0, 0, 0, speed.x, speed.y, v ); A_SnapExplode(10, 128, XF_THRUSTZ|XF_CIRCULAR|XF_NOSPLASH, "SnapMissileDamageEFX"); } action void A_SnapMissileExplodeLarge() { bNoGravity = true; A_StartSound("explosion/bigEnemy"); for (int i = 0; i < 8; i++) { double a = i * 45; double h = 10; double v = 8; Vector2 speed; if (i & 1) { h = 4; v = 12; } h = frandom[snap_decor](h * 0.5, h * 2.0); v = frandom[snap_decor](v * 0.5, v * 2.0); speed = AngleToVector(a, h); A_SpawnItemEx( "SnapMonsterExplode", 0, 0, 0, speed.x, speed.y, v ); } double starta = random[snap_decor](0,7) * 45; for (int i = 0; i < 2; i++) { double a = starta + (i * 180); double h = 6; double v = 16; Vector2 speed; h = frandom[snap_decor](h * 0.5, h * 2.0); v = frandom[snap_decor](v * 0.5, v * 2.0); speed = AngleToVector(a, h); A_SpawnItemEx( "SnapMonsterShrapnelSpawner", 0, 0, 0, speed.x, speed.y, v ); } A_SnapExplode(20, 192, VisualType: "SnapRadiusDamageEFXRed"); } action void A_SnapMissileSpeedUp() { let us = SnapMissileShot(self); if (!us) { return; } double curSpeed = Vel.Length(); if (curSpeed > 0) { double newSpeed = (curSpeed + Default.Speed); if (newSpeed > 60.0) { newSpeed = 60.0; } Vector3 dir = Vel.Unit(); Vel = dir * newSpeed; } let smoke = Spawn("SnapSmoke", Pos + (0, 0, Height * 0.5)); if (smoke) { smoke.Vel = Vel * -0.5; smoke.Vel += ( random[snap_decor](-2, 2), random[snap_decor](-2, 2), random[snap_decor](-2, 2) ); } } Default { Speed 5; DamageFunction 10; DamageType "Missile"; Obituary "$OB_MISSILE"; ProjectileKickback 1; RenderStyle "Normal"; Alpha 1.0; DeathSound "explosion/enemy"; +DONTBOUNCEONSHOOTABLES } States { Spawn: HVYM D 2; SpawnLoop: HVYM ABCD 2 A_SnapMissileSpeedUp(); Loop; Death: HVYM D 2; HVYM D 0 { bNoHitstun = true; } // Hitlag during the explosion is kinda cool but also kinda not HVYM DDDDD 4 A_SnapMissileExplode(); TNT1 A 4 A_SnapMissileExplodeLarge(); Stop; } } extend class SnapGun { action void A_SnapgunMissile() { if (player == null || player.mo == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } A_SnapgunFlash('MissileFlash'); A_SnapgunMomentumProjectile("SnapMissileShot"); A_StartSound("revolver/missile", CHAN_WEAPON); SoundAlert(self); player.mo.TakeInventory("SnapPowerupAmmo", 1, false, true); } States { FireMissile: SGUN A 1 A_SnapgunMissile; SGUN BCD 1; SGUN E 6; SGUN F 5; SGUN A 8; SGUN A 0 A_SnapGunRefire(); Goto GunIdle; MissileFlash: TNT1 A 1 Bright A_Light(2); SFL4 A 1 Bright A_Light(1); SFL4 B 1 Bright A_Light(0); SFL4 C 1 Bright; SFL4 D 1 Bright; Goto LightDone; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapVictoryMarchParticle : SnapDynamicDecor { default { Radius 24; Height 20; RenderStyle "Add"; +BRIGHT } states { Spawn: INVI MMLKJIHGFEDFEDFEDCBA 1; Stop; } } class SnapVictoryMarchParticle2 : SnapVictoryMarchParticle { default { Radius 24; Height 20; RenderStyle "Add"; +BRIGHT } states { Spawn: INVI FEDFEDFEDCBA 1; Stop; } } extend class SnapMonster { uint BaseHP; // Monster modifiers (for Invasion) uint MonsterModifiers; flagdef Giant: MonsterModifiers, 0; flagdef SpeedUp: MonsterModifiers, 1; flagdef HalfShield: MonsterModifiers, 2; flagdef QuadDamage: MonsterModifiers, 3; flagdef Bossified: MonsterModifiers, 4; uint VictoryMarch; const VICTORY_MARCH_TIME = 20*TICRATE; void SpeedUpEFX() { if (Level.maptime & 1) { return; } Vector3 startPos = Pos; startPos.X += frandom[snap_decor](-Radius, Radius); startPos.Y += frandom[snap_decor](-Radius, Radius); startPos.Z += frandom[snap_decor](0, Height); double VelAngle = angle; if (Vel.Length() > Speed) { VelAngle = atan2(Vel.Y, Vel.X); if (Vel.X < 0) { VelAngle = 360 + VelAngle; } } Actor particleObject = Spawn("SnapSpeedParticle", startPos, ALLOW_REPLACE); if (particleObject) { particleObject.Vel = Vel * 0.5; particleObject.Angle = VelAngle - 90; particleObject.target = self; particleObject.Scale = Scale; } Actor otherParticleObject = Spawn("SnapSpeedParticleOther", startPos, ALLOW_REPLACE); if (otherParticleObject) { otherParticleObject.Vel = Vel * 0.5; otherParticleObject.Angle = VelAngle + 90; otherParticleObject.target = self; otherParticleObject.Scale = Scale; } } void QuadDamageEFX() { if (Level.maptime & 1) { return; } Vector3 startPos = Pos; startPos.X += frandom[snap_decor](-Radius, Radius); startPos.Y += frandom[snap_decor](-Radius, Radius); startPos.Z += frandom[snap_decor](0.0, Height); Actor particleObject = Spawn("SnapDamageParticle", startPos, ALLOW_REPLACE); if (particleObject) { particleObject.Vel = Vel * 0.75; particleObject.Vel.X += frandom[snap_decor](-2.0, 2.0); particleObject.Vel.Y += frandom[snap_decor](-2.0, 2.0); particleObject.Vel.Z += frandom[snap_decor](0.0, 6.0); particleObject.Angle = Angle; particleObject.target = self; particleObject.Scale = Scale; } } void VictoryMarchEFX() { if (random[snap_decor](0, 2) != 0) { return; } Vector3 startPos = Pos; startPos.X += frandom[snap_decor](-Radius, Radius); startPos.Y += frandom[snap_decor](-Radius, Radius); startPos.Z += frandom[snap_decor](0, Height); Actor particleObject = Spawn("SnapVictoryMarchParticle", startPos, ALLOW_REPLACE); if (particleObject) { particleObject.Vel = Vel * 0.25; particleObject.target = self; particleObject.Scale = Scale * 0.5; particleObject.Scale.Y *= 0.25; } } void SetVictoryMarch() { VictoryMarch += VICTORY_MARCH_TIME; } bool RunExtraTick() { if (Tics != -1) { if (Tics > 0) { Tics--; } while (Tics == 0) { if (CurState == null) { Destroy(); return false; } if (SetState(CurState.NextState) == false) { // mobj was removed return false; } } } return true; } state GiantRobotState(StateLabel st) { if (bGiant == true) { return ResolveState(st); } return null; } const HP_SMALL_HP = 70; const HP_BIG_HP = 500; double BossifiedHPMultiplier(int baseHealth, double low, double high) { // What tends to be a good multiplier for // small enemies tends to be awful for large // enemies, and vice versa. So this decides // a decent value from the monster's starting // health. double BigBossified = HP_BIG_HP * low; // Low increase to big enemies double SmallBossified = HP_SMALL_HP * high; // High increase to small enemies. double slope = (BigBossified - SmallBossified) / (HP_BIG_HP - HP_SMALL_HP); double intercept = SmallBossified - (slope * HP_SMALL_HP); double clamped = clamp(baseHealth, HP_SMALL_HP, HP_BIG_HP); return ((slope * clamped) + intercept) / clamped; } void AllowDI() { if (bDontThrust == true) { return; } bCanDI = true; } const GIANTSCALE = 2.0; void UpdateOurMonsterModifiers(bool origin = false) { Scale = Default.Scale; Mass = Default.Mass; MeleeRange = Default.MeleeRange; MaxStepHeight = Default.MaxStepHeight; SnapScore = Default.SnapScore; if (BaseHP == 0) { Health = Default.Health; } else { Health = BaseHP; } StartHealth = BaseHP; PoiseMax = Default.PoiseMax; Speed = Default.Speed; FloatSpeed = Default.FloatSpeed; bBoss = Default.bBoss; bCanDI = Default.bCanDI; double HealthMul = 1.0; if (bGiant == true) { Scale *= GIANTSCALE; Mass = int(Mass * GIANTSCALE); MeleeRange *= GIANTSCALE; MaxStepHeight *= GIANTSCALE; //Speed *= GIANTSCALE; bRobotTough = true; HealthMul *= 3.0; AllowDI(); SnapScore *= 10; } if (bSpeedUp == true) { Speed *= 2.0; FloatSpeed *= 2.0; } if (bHalfShield == true) { Vector3 startPos = Pos; startPos.XY += AngleToVector(Angle + 180, Radius * 2); startPos.Z += 32 + BobSin(Level.maptime); startPos += Vel; let newshield = Spawn("SnapShieldParticle", startPos, ALLOW_REPLACE); if (newshield) { newshield.Angle = Angle + 180; newshield.target = self; newshield.Scale = Scale; } } if (bBossified == true && bBoss == false) { // Turns normal non-boss enemies into bosses. bBoss = true; self.Translation = GetDefaultTranslation(); // Make sure translation is updated if (bNoBossifyHP == false) { // Reminder that boss HP scaling will additionally // multiply this further, on top of being multiplied // on top of Giant status, so probably don't go too crazy. HealthMul *= BossifiedHPMultiplier(Health, 1.2, 7.5); } AllowDI(); SnapScore *= 2; } if (bBoss == true) { // Scale boss HP. HealthMul *= GetBossHPScale(); } SetPhysicalSize(Scale); MultiplyMonsterHP(HealthMul); } virtual void InitMonsterModifiers() { UpdateOurMonsterModifiers(); } } class SnapMonsterModifier : Actor { // This actor exposes the Invasion monster modifiers // to be able to be used in custom SP maps. Default { +NOBLOCKMAP +NOSECTOR +NOGRAVITY +DONTSPLASH } void UpdateMonstersModifiers(SnapMonster monster) { if (monster.Health <= 0) { return; } monster.bGiant = self.bFriendly; monster.bSpeedUp = self.bAmbush; monster.bHalfShield = self.bStandStill; monster.bQuadDamage = self.bDormant; monster.bBossified = self.bShadow; monster.InitMonsterModifiers(); } void UpdateAllMonsterModifiers() { Actor thing; if (tid > 0) { // Find all monsters with the right tag. let it = Level.CreateActorIterator(tid, 'SnapMonster'); while (thing = it.Next()) { let monster = SnapMonster(thing); if (monster != null) { UpdateMonstersModifiers(monster); } } } /* This code freezes for some reason...?? else { // Find all monsters in our sector. for (thing = cursector.thinglist; thing != null; thing = thing.snext) { let monster = SnapMonster(thing); if (monster != null) { UpdateMonstersModifiers(monster); } } } */ } override void PostBeginPlay() { super.PostBeginPlay(); UpdateAllMonsterModifiers(); //Destroy(); } override void Activate(Actor source) { bDormant = false; } override void Deactivate(Actor source) { bDormant = true; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapMonster : SnapShadowActor abstract { uint SnapMonsterFlags; flagdef VeryRude: SnapMonsterFlags, 0; flagdef BossHard: SnapMonsterFlags, 1; flagdef ShowContents: SnapMonsterFlags, 2; flagdef IsContainer: SnapMonsterFlags, 3; flagdef FloatMatchHeight: SnapMonsterFlags, 4; flagdef NoBossifyHP: SnapMonsterFlags, 5; flagdef RobotExplodes: SnapMonsterFlags, 6; flagdef RobotTough: SnapMonsterFlags, 7; Default { // Poise replaces this for Snap's monsters PainChance 0; // 0 == Always use pain state SnapMonster.Poise 0; // How many points this monster gives, when using COUNTKILL SnapActor.Score 100; // Starting missile range. Increases when they attempt // to attack and fail because out of range, making this // an "aggression" value for far away robots. SnapMonster.BaseMissileRange 400; SnapActor.DamageFlash "EnemyDamaged"; DamageFactor "BotPower", 100.0; Monster; +NOBLOOD +ISMONSTER //+DOHARMSPECIES +NOFORWARDFALL +SYNCHRONIZED +FLOORCLIP +WINDTHRUST +NOINFIGHTSPECIES +SnapShadowActor.SHADOWSTAYONDEATH +SnapActor.CANDROPAMMO } action void A_DeathmatchGoAway() { if (deathmatch) { Height = Default.Height; bInvisible = true; bSolid = false; } else { Destroy(); } } override int TakeSpecialDamage(Actor inflictor, Actor source, int damage, Name damagetype) { int result = super.TakeSpecialDamage(inflictor, source, damage, damagetype); if (bHalfShield == true) { result /= 2; } return result; } override int DamageMobj(Actor inflictor, Actor source, int damage, Name mod, int flags, double angle) { source = SetDominoSource(source); int trueDamage = super.DamageMobj(inflictor, source, damage, mod, flags, angle); let srcPlayer = SnapPlayer(source); if (srcPlayer) { // Increase their POW meter a little bit. srcPlayer.AddSnapPOWMeter(trueDamage); if (trueDamage > 0 && bBoss == true) { // If it's a boss fight, then give points for hits in multiplayer! srcPlayer.AddScore(10); } } if (!(flags & DMG_NO_PAIN) && trueDamage > 0) { bool result = ReduceSnapMonsterPoise(trueDamage, mod); if (result == true && srcPlayer) { // POW meter gets a tiny chunk for stun srcPlayer.AddSnapPOWMeter(5); } } if (kickTossed == true) { A_SnapJuggle(inflictor); KickMomentumReduce(); if (srcPlayer) { // POW meter gets a massive chunk! srcPlayer.AddSnapPOWMeter(25); } } return trueDamage; } override void Die(Actor source, Actor inflictor, int dmgflags, Name MeansOfDeath) { if (kickTossed == true) { KickTossEnd(); } source = SetDominoSource(source); super.Die(source, inflictor, dmgflags, MeansOfDeath); if (Default.bDontFall == true && Default.bNoGravity == true) { // Not convinced this flag is working as intended? // So just doing it myself. bNoGravity = true; } if (bGiant == true) { state gDeathState = FindState("GiantDeath"); if (gDeathState != null) { SetState(gDeathState); } } } override double GetDeathHeight() { double metaheight = -1; if (DamageType == 'Fire') { metaheight = BurnHeight; } if (metaheight < 0) { metaheight = DeathHeight; } if (metaheight < 0) { return Height; } else { return max(metaheight, 0); } } override void Tick() { super.Tick(); if (IsContainer() == true) { if (ContainSearched == false) { // Placed in map, rather than spawned in DM. // So we need to initialize some stuff. DoContainerSearch(); ContainSearched = true; } if (ContainPower != null) { ContainerUpdate(); } } if (TickPaused() == true || Health <= 0) { // Don't run the thinker! return; } if (bSpeedUp == true) { // Double state speed!! if (RunExtraTick() == false) { return; } SpeedUpEFX(); } if (bQuadDamage == true) { QuadDamageEFX(); } if (VictoryMarch > 0) { VictoryMarch--; if (VictoryMarch > 0) { if (RunExtraTick() == false) { return; } VictoryMarchEFX(); } } if (bBoss == true && BossMeterWasInit == false) { if (Target != null && Target.Health > 0 && Target != PrevBossTarget) { // Boss started targeting something. // Show the boss meter if it's player-related. if (Target is "PlayerPawn" || Target.bFriendly == true) { InitBossMeter(); BossMeterWasInit = true; } } PrevBossTarget = Target; } if (kickTossed == true) { // Prolong timer in kick state PoiseTimer = POISETIMELEN; } else { if (PoiseTimer > 0) { PoiseTimer--; if (PoiseTimer <= 0) { Poise = PoiseMax; PoiseTimer = 0; } } else { Poise = PoiseMax; } } int smokeHealth = SpawnHealth() / 4; if (health <= smokeHealth) { A_KickedDust("SnapSmoke", true); } if (kickTossed == true) { A_KickedDust(); KickTossThink(); } } override void BeginPlay(void) { super.BeginPlay(); // Simple shortcut when rude is enabled :) bVeryRude = !!G_SkillPropertyInt(SKILLP_FastMonsters); // Same for Hard Mode, for bosses. int skill = G_SkillPropertyInt(SKILLP_ACSReturn); bBossHard = (skill >= 2); // Copy StartHealth, since we'll likely change it with monster modifiers. BaseHP = StartHealth; if (bBoss == true) { // Scale boss HP. MultiplyMonsterHP(GetBossHPScale()); } } override void PostBeginPlay(void) { super.PostBeginPlay(); //InitMonsterModifiers(); } virtual void InvasionExtraValue(int ExtraValue) { return; } /* override int GetDefaultTranslation() { if (bBossified == true && Default.bBoss == false) { return Translate.GetID("Bossified"); } return super.GetDefaultTranslation(); } */ // Anything that inherits from SnapMonster can be activated/deactivated, // even without the IsMonster flag, because that's just annoying :V override void Activate(Actor source) { if (bIsMonster == false && (Health > 0 || bIceCorpse == true)) { if (bDormant == true) { bDormant = false; state st = FindState("Active"); if (st != null) { SetState(st); } else { tics = 1; } } return; } super.Activate(source); } override void Deactivate(Actor source) { if (bIsMonster == false && (Health > 0 || bIceCorpse == true)) { if (bDormant == false) { bDormant = true; state st = FindState("Inactive"); if (st != null) { SetState(st); } else { tics = -1; } } return; } super.Deactivate(source); } override void ApplyKickback(Actor inflictor, Actor source, int damage, double angle, Name mod, int flags) { super.ApplyKickback(inflictor, source, damage, angle, mod, flags); if (bFloat == true && bNoGravity == true) { // Floating monster, they get pushed down by bullets. int kickback; double thrust; if (inflictor && inflictor.projectileKickback) kickback = inflictor.projectileKickback; else if (!source || !source.player || !source.player.ReadyWeapon) kickback = gameinfo.defKickback; else kickback = source.player.ReadyWeapon.Kickback; kickback = int(kickback * G_SkillPropertyFloat(SKILLP_KickbackFactor) * 0.5); if (kickback) { Actor origin = (source && (flags & DMG_INFLICTOR_IS_PUFF)) ? source : inflictor; thrust = mod == 'MDK' ? 10 : 32; if (Mass > 0) { thrust = clamp((damage * 0.125 * kickback) / Mass, 0., thrust); } // Don't apply ultra-small damage thrust if (thrust < 0.01) thrust = 0; Vel.Z = -thrust; } } } } #include "./monsters/chase.zs" #include "./monsters/projectile.zs" #include "./monsters/explode.zs" #include "./monsters/kicked.zs" #include "./monsters/poise.zs" #include "./monsters/boss.zs" #include "./monsters/container.zs" #include "./monsters/modifier.zs" #include "./monsters/types.zs" //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class MosquitoZapTrail : SnapActor { Default { Radius 12; Height 12; RenderStyle "Add"; +RANDOMIZE +BRIGHT +SnapActor.MISSILESPRITEFIX +NOINTERACTION +NOGRAVITY +NOBLOCKMAP } States { Spawn: TNT1 A 2; MSBL ABCD 3; Stop; } } class MosquitoZapTrail2 : MosquitoZapTrail { States { Spawn: TNT1 A 2; MSBL EFGH 3; Stop; } } class MosquitoZapTrail3 : MosquitoZapTrail { States { Spawn: TNT1 A 2; MSBL IJKL 3; Stop; } } class MosquitoZap : SnapMissile { Default { Radius 12; Height 12; Speed 30; Mass 10; DamageFunction 5; Obituary "$OB_MOSQUITO"; RenderStyle "Add"; DeathSound "revolver/death"; BounceSound "revolver/bounce"; +RANDOMIZE +BRIGHT } void SpawnZapTrail(class type) { Actor trail = Spawn(type, Pos, ALLOW_REPLACE); if (trail != null) { trail.Scale = self.Scale; trail.target = self; let sa = SnapActor(trail); if (sa != null) { sa.SetHitstunParent(self); } } } States { Spawn: MSBL A 2 SpawnZapTrail("MosquitoZapTrail"); Loop; Death: MSBL ABACAD 1; Stop; } } class MosquitoRudeZap : MosquitoZap { Default { DamageFunction 10; } States { Spawn: MSBL E 2 SpawnZapTrail("MosquitoZapTrail2"); TNT1 I 2 SpawnZapTrail("MosquitoZapTrail3"); Loop; Death: MSBL EIEJEK 1; Stop; } override int DoSpecialDamage(Actor victim, int damage, name damagetype) { if (target != null) { target.health += damage; int max = target.Default.Health * 5; if (target.health > max) { target.health = max; } } return super.DoSpecialDamage(victim, damage, damagetype); } } class Mosquito : SnapMonster { const NEWPOSTIMER = 16; const BOUNCESPD = 10.0; Vector3 NewPosition; int NewPositionTime; double NewPositionPhase; bool NewPositionZAlt; //Actor BumpedActor; Actor LastTarget; void MosquitoCalcNewPos() { NewPositionTime = NEWPOSTIMER; Actor ChaseObj = null; if (goal != null) { ChaseObj = goal; } else if (target != null) { ChaseObj = target; } if (ChaseObj != null) { // Go to new position around the player. NewPosition = ChaseObj.Pos + ( MeleeRange * cos(NewPositionPhase), MeleeRange * sin(NewPositionPhase), 64.0 ); if (NewPositionZAlt == false) { NewPosition.Z += 64.0; } } else { NewPosition = Pos; } NewPositionPhase += 120.0; NewPositionZAlt = !NewPositionZAlt; } bool CheckMosquitoTarget() { if (threshold) { if (target == null || target.health <= 0) { threshold = 0; } else { threshold--; } } if (target == null || target.bShootable == false) { if (goal != null) { NewPositionPhase = goal.AngleTo(self); MosquitoCalcNewPos(); target = goal; LastTarget = Target; return true; } if (TIDToHate != 0) { // Target Invasion Core above all else! if (LookForTID(true) == true) { NewPositionPhase = target.AngleTo(self); MosquitoCalcNewPos(); LastTarget = Target; return true; } } if (target != null && target.bNonShootable == true) { // Target is only temporarily unshootable, so remember it. lastenemy = target; // Switch targets faster, since we're only changing because we can't // hurt our old one temporarily. threshold = 0; } // look for a new target if (LookForPlayers(true) == true) { NewPositionPhase = Target.AngleTo(self); MosquitoCalcNewPos(); LastTarget = Target; return true; // got a new target } return false; } if (LastTarget != Target) { NewPositionPhase = Target.AngleTo(self); MosquitoCalcNewPos(); LastTarget = Target; } return true; } const MOSQTURN = 16.875; void MosquitoAngle(Vector2 DestDir) { Angle = SnapUtils.AngleTowardsDir(self.Angle, DestDir, MOSQTURN); } action state A_MosquitoChase() { let m = Mosquito(self); if (!m) { A_SnapChase(); return null; } if (m.CheckMosquitoTarget() == false) { return ResolveState("Spawn"); } m.MosquitoAngle(Vel.XY); if (m.NewPositionTime > 0) { // Decrement timer m.NewPositionTime--; } // Move towards the new position. Vector3 PosDiff = (m.NewPosition - Pos); if (SnapUtils.ValidVec3Unit(PosDiff) == true) { double dis = PosDiff.Length(); double spd = Speed * 2.0; double jitterDist = spd * 8.0; if (dis <= jitterDist || m.NewPositionTime <= 0) { m.NewPosition = Pos; m.NewPositionTime = NEWPOSTIMER; ReactionTime = NEWPOSTIMER; return ResolveState("Jitter"); } else { Vector3 AddVelDir = SnapUtils.SafeVec3Unit(PosDiff); Vel += AddVelDir * spd; } } return null; } action state A_MosquitoJitter() { let m = Mosquito(self); if (m == null) { A_SnapChase(); return null; } if (reactiontime > 0) { reactiontime--; } if (m.CheckMosquitoTarget() == false) { return ResolveState("Spawn"); } // Aim at the target m.MosquitoAngle(Vec2To(target)); if (goal == target) { m.MosquitoCalcNewPos(); return ResolveState("See"); } else { // Force out of the state eventually. // If SnapTryMissileAttack fails this many times in a row, // this position is likely bad, and you should just move. if (m.NewPositionTime > 0) { m.NewPositionTime--; } else { m.MosquitoCalcNewPos(); return ResolveState("See"); } if (m.SnapTryMissileAttack() == true) { // Successful missile attack!! m.MosquitoCalcNewPos(); if (CheckSight(target) == false) { return ResolveState("See"); } else { if (m.bVeryRude == true) { return ResolveState("RudeMissile"); } else { return ResolveState("Missile"); } } } } // Move towards the new position. Vector3 PosDiff = (m.NewPosition - Pos); if (SnapUtils.ValidVec3Unit(PosDiff) == true) { double dis = PosDiff.Length(); double spd = Speed; double fastSpd = spd * 4.0; double jitterDist = fastSpd * 4.0; if (dis > jitterDist) { Vector3 AddVelDir = SnapUtils.SafeVec3Unit(PosDiff); if (SnapUtils.ValidVec3Unit(Vel) == true) { if (AddVelDir dot SnapUtils.SafeVec3Unit(Vel) < 0.0) { spd = fastSpd; } } Vel += AddVelDir * spd; } } return null; } action void A_MosquitoSlow() { Vel *= 0.5; A_FaceTarget(22.5); } action void A_MosquitoReset() { let m = Mosquito(self); if (!m) { return; } m.MosquitoCalcNewPos(); } Default { Health 20; Radius 30; Height 40; Speed 1; Mass 100; MeleeRange 192; SnapMonster.Poise 10; SeeSound "pestachio/see"; ActiveSound "pestachio/idle"; PainSound "pestachio/hurt"; Obituary "$OB_MOSQUITO"; Tag "$TAG_MOSQUITO"; Species "Robot"; +FLOAT +NOGRAVITY +BOUNCEONWALLS +BOUNCEONFLOORS +BOUNCEONCEILINGS +ALLOWBOUNCEONACTORS +BOUNCEONACTORS } States { Spawn: MOSQ A 3 A_SnapMonsterLook(); MOSQ BCDEF 3; Loop; See: MOSQ ABCDEF 4 A_MosquitoChase(); Loop; Jitter: MOSQ ABCDEF 4 A_MosquitoJitter(); Loop; Missile: MOSQ GHIJ 4 A_MosquitoSlow(); MOSQ GH 2 A_MosquitoSlow(); MOSQ I 2 A_SnapMonsterProjectile("MosquitoZap"); MOSQ J 2; Goto See; RudeMissile: MOSQ GHIJ 4 A_MosquitoSlow(); MOSQ GH 2 A_MosquitoSlow(); MOSQ I 2 A_SnapMonsterProjectile("MosquitoRudeZap"); MOSQ J 2; Goto See; Pain: MOSQ K 3 A_MosquitoReset(); MOSQ K 3 A_SnapMonsterPain(); Goto See; Kicked: MOSQ K 3 A_MosquitoReset(); MOSQ K 3 A_SnapMonsterPain(); KickLoop: MOSQ K 3 A_EndKick(); Loop; Death: MOSQ K 1; TNT1 A 35 DoSnapMonsterDie(); Stop; GiantDeath: MOSQ K 1; MOSQ KKKKKKKK 4 DoSnapMonsterExplode(); TNT1 A 35 DoSnapMonsterDie(); Stop; } override void Tick() { super.Tick(); if (TickPaused() == true) { return; } if (Health <= 0) { A_StopSound(CHAN_7); return; } if (target != null || goal != null) { A_StartSound("pestachio/engine", CHAN_7, CHANF_LOOPING, 0.1); if (kickTossed == false) { // Always do bouncing for mosquitos Vector2 wallBump = GetWallBounceDir(); if (wallBump != (0, 0)) { Vel.XY = BOUNCESPD * wallBump; } else { int result = CheckSolidFooting(); if (result & CSF_FLOORMASK) { Vel.Z = BOUNCESPD; } else if (result & CSF_CEILINGMASK) { Vel.Z = -BOUNCESPD; } } } } if (goal != null) { double dis = Vec3To(goal).Length(); if (dis <= MeleeRange * 2) { let iterator = Level.CreateActorIterator(goal.args[0], "PatrolPoint"); let specit = Level.CreateActorIterator(goal.TID, "PatrolSpecial"); Actor spec = null; // Execute the specials of any PatrolSpecials with the same TID // as the goal. while (spec = specit.Next()) { A_CallSpecial(spec.special, spec.args[0], spec.args[1], spec.args[2], spec.args[3], spec.args[4]); } goal = iterator.Next(); } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapPlayer { const SnapMugTicks = TICRATE; enum SnapMugTypes { SNAPMUG_NORMAL = 0, SNAPMUG_GOOD, SNAPMUG_BAD, } meta String SnapMugPrefix; property SnapMugPrefix: SnapMugPrefix; meta String SnapMugPrefixSmall; property SnapMugPrefixSmall: SnapMugPrefixSmall; uint SnapMug; uint SnapMugTimer; void SetSnapMugshot(uint id) { SnapMug = id; SnapMugTimer = SnapMugTicks; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapHUD { void SortSmallPlayers(in out Array Sort) { if (multiplayer == false) { // Don't need to do anything for singleplayer. return; } uint Length = 0; Sort.Clear(); for (uint i = 0; i < MaxPlayers; i++) { if (playeringame[i] == false) { // Not playing. continue; } PlayerInfo player = players[i]; if (player == null) { // Doesn't exist? continue; } if (player == CPlayer) { // Don't include us. continue; } // Insert every available player into the table. Sort.Push(i); Length++; } if (Length <= 1) { // Only one other player, no need to sort. return; } // Sort the players. for (uint i = 0; i < Length-1; i++) { for (uint j = i+1; j < Length; j++) { PlayerInfo playerA = players[Sort[i]]; if (playerA == null) { // Try to fix the invalid player... Sort.Delete(i); Length--; i--; continue; } PlayerInfo playerB = players[Sort[j]]; if (playerB == null) { // Try to fix the invalid player... Sort.Delete(j); Length--; j--; continue; } let spA = SnapPlayer(playerA.mo); int fragsA = 0; if (spA != null) { fragsA = spA.GetFragCount(); } let spB = SnapPlayer(playerB.mo); int fragsB = 0; if (spB != null) { fragsB = spB.GetFragCount(); } // Sort by best frags in deathmatch, worst health in Coop. bool sortVal = false; if (deathmatch == true) { sortVal = (fragsA < fragsB); } else { sortVal = (playerA.health > playerB.health); } if (sortVal == true) { int swap = Sort[i]; Sort[i] = Sort[j]; Sort[j] = swap; } } } } void DrawSmallHUD(double TicFrac, int id, SnapPlayer sp, Vector2 offset) { Vector2 basePos = (2, -42) + offset; int t = Translation.MakeID(TRANSLATION_Players, sp.PlayerNumber()); let PInfo = sp.SnapPlayerInfo; let plr = sp.player; // BG DrawImage("SHUDBACK", basePos, DI_SCREEN_LEFT_BOTTOM|DI_ITEM_LEFT_BOTTOM); // Face DrawImage( String.Format("%sFAC%d", sp.SnapMugPrefixSmall, sp.SnapMug + 1), basePos + (5, -6), DI_ITEM_LEFT_BOTTOM|DI_SCREEN_LEFT_BOTTOM|DI_MIRROR, translation: t ); // HP DrawHPNum(SmallHP[id], basePos + (4, -7), DI_SCREEN_LEFT_BOTTOM|DI_ITEM_LEFT_BOTTOM, big: false, jitterScale: 0.5); // Septacrash if (PInfo != null) { DrawSingleStar(sp, PInfo, basePos + (22, -8)); } if (deathmatch == true) { Vector2 ptsPos = basePos + (28, 1); Vector2 ptsTextPos = ptsPos + (-1, -8); uint pts = sp.GetFragCount(); int max = SnapUtils.GetPointLimit(); int cr = Font.CR_UNTRANSLATED; if (max > 0 && int(pts) >= max-1 && ((Level.maptime / 3) & 1)) { cr = Font.FindFontColor('HPLight'); } HUDFont ft = SnapNumFont; if (pts > 9 || pts < 0) { ft = SnapTinyNumFont; } DrawString( ft, String.Format("%d", pts), ptsTextPos, DI_ITEM_LEFT_BOTTOM|DI_SCREEN_LEFT_BOTTOM|DI_TEXT_ALIGN_RIGHT, cr ); DrawImage("VSPTS", ptsPos, DI_ITEM_LEFT_BOTTOM|DI_SCREEN_LEFT_BOTTOM); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- struct TrialSettings { enum CustomGameFlags { CF_ROBOTSEXPLODE = 1, CF_CRASHRATIONS = 1<<1, CF_ROBOTSFAST = 1<<2, CF_ROBOTSRESIST = 1<<3, CF_ROBOTSDAMAGE = 1<<4, } bool Active; bool CustomGame; int CustomWeapon; uint CustomFlags; } extend class SnapEventHandler { TrialSettings Trial; static void ExecuteNewGame() { SnapStaticEventHandler ev = SnapStaticEventHandler(StaticEventHandler.Find("SnapStaticEventHandler")); if (ev == null) { ThrowAbortException("Tried to execute new game without event handler"); return; } // Reset settings to defaults ev.Trial.Active = false; ev.Trial.CustomGame = false; ev.Trial.CustomWeapon = 0; ev.Trial.CustomFlags = 0; SnapEpisodeDef EpisodeDef = SnapMenuData.GetSelectedEpisode(); SnapMapDef MapDef = SnapMenuData.GetSelectedMap(); int skillID = SnapMenuData.GetSelectedSkill(); int characterID = SnapMenuData.GetSelectedCharacter(); // If forcing a map, then we're in a Trial session. if (MapDef != null) { ev.Trial.Active = true; ev.Trial.CustomGame = SnapMenuData.GetCustomGame(); if (ev.Trial.CustomGame == true) { let WeaponCV = CVar.FindCVar("snap_menu_custom_weapon"); if (WeaponCV != null) { ev.Trial.CustomWeapon = WeaponCV.GetInt(); } let ExplodeCV = CVar.FindCVar("snap_menu_custom_robots_explode"); if (ExplodeCV != null && ExplodeCV.GetBool() == true) { ev.Trial.CustomFlags |= ev.Trial.CF_ROBOTSEXPLODE; } let RationsCV = CVar.FindCVar("snap_menu_custom_septacrash_rations"); if (RationsCV != null && RationsCV.GetBool() == true) { ev.Trial.CustomFlags |= ev.Trial.CF_CRASHRATIONS; } let FastCV = CVar.FindCVar("snap_menu_custom_robots_fast"); if (FastCV != null && FastCV.GetBool() == true) { ev.Trial.CustomFlags |= ev.Trial.CF_ROBOTSFAST; } let ResistCV = CVar.FindCVar("snap_menu_custom_robots_resist"); if (ResistCV != null && ResistCV.GetBool() == true) { ev.Trial.CustomFlags |= ev.Trial.CF_ROBOTSRESIST; } let DamageCV = CVar.FindCVar("snap_menu_custom_robots_damage"); if (DamageCV != null && DamageCV.GetBool() == true) { ev.Trial.CustomFlags |= ev.Trial.CF_ROBOTSDAMAGE; } } } else { if (EpisodeDef == null) { ThrowAbortException("Tried to execute new game without episode or map selected"); return; } if (EpisodeDef.MapList.Size() == 0) { // fake episode selected? ThrowAbortException("Tried to execute new game with invalid episode selected"); return; } // Go to first map as a non-trial. MapDef = EpisodeDef.MapList[0]; if (MapDef == null) { ThrowAbortException("Invalid starting map for episode"); return; } } if (skillID < SNAP_SKILL_EASY || skillID >= SNAP_SKILL__MAX) { // Skill out of range, default to normal skillID = SNAP_SKILL_NORMAL; } if (characterID < 0 || characterID >= PlayerClasses.Size()) { characterID = 0; } Level.ChangeLevel( MapDef.ID, 0, CHANGELEVEL_NOINTERMISSION|CHANGELEVEL_RESETINVENTORY|CHANGELEVEL_RESETHEALTH|CHANGELEVEL_CHANGESKILL, skillID ); } void UpdateTrialStatus() { let ev = SnapStaticEventHandler.Get(); if (ev != null) { Trial.Active = ev.Trial.Active; Trial.CustomGame = ev.Trial.CustomGame; Trial.CustomWeapon = ev.Trial.CustomWeapon; Trial.CustomFlags = ev.Trial.CustomFlags; } for (uint i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] == false) { continue; } let sp = SnapPlayer(players[i].mo); let spi = SnapPlayerGlobals.GetForPlayerNum(i); if (sp != null) { PlayerInfiniteGun(sp, spi); } spi.POWRations = ((Trial.CustomFlags & ev.Trial.CF_CRASHRATIONS) != 0); } if (Trial.CustomFlags & ev.Trial.CF_ROBOTSEXPLODE) { ThinkerIterator MonsterFinder = ThinkerIterator.Create("SnapMonster"); SnapMonster mo; while ((mo = SnapMonster(MonsterFinder.Next())) != null) { if (mo.bIsMonster == true && mo.bRobotExplodes == false) { mo.bRobotExplodes = true; if (mo.DamageFlashTranslation ~== "EnemyDamaged") { mo.DamageFlashTranslation = "EnemyDamagedBlue"; } } } } uint Mods = 0; if (Trial.CustomFlags & ev.Trial.CF_ROBOTSFAST) { Mods |= MOD_FAST; } if (Trial.CustomFlags & ev.Trial.CF_ROBOTSRESIST) { Mods |= MOD_RESIST; } if (Trial.CustomFlags & ev.Trial.CF_ROBOTSDAMAGE) { Mods |= MOD_DAMAGE; } if (Mods != 0) { ThinkerIterator MonsterFinder = ThinkerIterator.Create("SnapMonster"); SnapMonster mo; while ((mo = SnapMonster(MonsterFinder.Next())) != null) { if (mo.bIsMonster == true) { if (Mods & MOD_FAST) { mo.bSpeedUp = true; } if (Mods & MOD_RESIST) { mo.bHalfShield = true; } if (Mods & MOD_DAMAGE) { mo.bQuadDamage = true; } mo.InitMonsterModifiers(); } } } } } extend class SnapStaticEventHandler { TrialSettings Trial; bool ReturningFromTrial; static void PlayCredits() { LevelLocals.StartSlideshow( StringTable.Localize("$SNAP_SEQUENCE_CREDITS") ); } static void CheckDemoCredits() { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return; } if (multiplayer == true) { // Don't do credits in multiplayer... return; } // Show credits sequence for the demo after beating all stages CVar creditsVar = CVar.FindCVar("snap_demo_credits"); if (creditsVar != null && creditsVar.GetBool() != true) { CVar mapsVar = CVar.FindCVar("snap_demo_maps"); if (mapsVar != null) { int allFlags = 0; let DemoMaps = SnapEpisodeDef.ConstructBonusLevelsEpisode(); for (int i = 0; i < DemoMaps.MapList.Size(); i++) { allFlags |= 1 << i; } int flags = mapsVar.GetInt(); if ((flags & allFlags) == allFlags) { creditsVar.SetBool(true); PlayCredits(); } } } } static void EndTrial() { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return; } if (multiplayer == true) { // Repeat the selected Trial level. SnapMapDef LastMap = SnapMenuData.GetSelectedMap(); if (LastMap != null) { Level.ChangeLevel( LastMap.ID, 0, CHANGELEVEL_NOINTERMISSION|CHANGELEVEL_RESETINVENTORY|CHANGELEVEL_RESETHEALTH|CHANGELEVEL_CHANGESKILL, -1 ); } return; } ev.ReturningFromTrial = true; Menu.SetMenu("SnapMainMenu"); Menu.SetMenu("SnapPlay"); if (ev.Trial.CustomGame == true) { //Menu.SetMenu("SnapCustom"); // NOT IN DEMO Menu.SetMenu("SnapCustomMap"); } else { //Menu.SetMenu("SnapTrial"); // NOT IN DEMO Menu.SetMenu("SnapTrialMap"); } SnapStaticEventHandler.CheckAchievements(); if (SnapAchievementMenu.UnlockedNewStuff() == true) { Menu.SetMenu("SnapChallenge"); } LevelLocals.ExitLevel(0, false); ev.ReturningFromTrial = false; } static void FixTrialMenuStatus() { // Fix the menu data when reloading save files. let ev = SnapEventHandler.Get(); if (ev == null) { return; } let sev = SnapStaticEventHandler.Get(); if (sev == null) { return; } if (ev.Trial.Active == false) { // doesn't matter for anything other than trial rn return; } CVar MapCV = CVar.FindCVar("snap_menu_map"); if (MapCV != null) { MapCV.SetString(Level.MapName); } CVar EpisodeCV = CVar.FindCVar("snap_menu_episode"); if (EpisodeCV != null) { String epName = ""; SnapDefinitions EpDefs = sev.SnapDefs; if (EpDefs != null) { MapIterator it; if (it.Init(EpDefs.EpisodeHeap) == true) { while (it.Next() == true) { let def = it.GetValue(); uint MapListLen = def.MapList.Size(); if (MapListLen == 0) { continue; } for (uint i = 0; i < MapListLen; i++) { if (def.MapList[i].ID == Level.MapName) { epName = def.ID; break; } } if (epName.Length() > 0) { break; } } } } if (epName.Length() == 0) { epName = SnapEpisodeDef.BONUS_LEVEL_EPISODE_ID; } EpisodeCV.SetString(epName); } CVar SkillCV = CVar.FindCVar("snap_menu_skill"); if (SkillCV != null) { SkillCV.SetInt(G_SkillPropertyInt(SKILLP_ACSReturn)); } CVar CharCV = CVar.FindCVar("snap_menu_character"); if (CharCV != null) { int CharID = 0; PlayerInfo player = players[consoleplayer]; if (player.mo != null) { class CharacterType = player.mo.GetClass(); for (int i = 0; i < PlayerClasses.Size(); i++) { if (CharacterType == PlayerClasses[i].Type) { CharID = i; break; } } } CharCV.SetInt(CharID); } } static void EndCreditsMenu() { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return; } ev.ReturningFromTrial = true; Menu.SetMenu("SnapMainMenu"); Menu.SetMenu("SnapExtra"); LevelLocals.ExitLevel(0, false); ev.ReturningFromTrial = false; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapPlayerGlobals { bool NoGunMode; } extend class SnapPlayer { static void SetSnapsGun(Actor activator, int playerID = 0, bool mode = true) { playerID--; // So that 0 means use activator SnapPlayer sp = null; if (playerID >= 0 && playerID < MAXPLAYERS) { if (playeringame[playerID] == true) { sp = SnapPlayer(players[playerID].mo); } } else if (activator != null && activator.player != null) { sp = SnapPlayer(activator); } if (sp != null && sp.SnapPlayerInfo != null) { if (sp.InfiniteWeapon == true && mode == true) { // Allow infinite weapon to work in kick-only levels return; } sp.SnapPlayerInfo.NoGunMode = mode; } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class BarrelFlameSpawner : OceanFlameSpawner { Default { Obituary "$OB_BARREL"; +HITOWNER } } class SnapBarrelExplodeOverlay : SnapDynamicDecor { Default { +NOBLOCKMAP +NOGRAVITY +NOINTERACTION +BRIGHT } States { Spawn: LASR DEFGHI 1 Light("TerajoltLaserLight"); Stop; } } class SnapBarrel : Cactus { void SnapBarrelExplode() { A_FaceTarget(); DoSnapMonsterDie(); for (int i = 0; i < 8; i++) { double a = i * 45; Actor spawner = Spawn("BarrelFlameSpawner", self.Pos, ALLOW_REPLACE); if (spawner) { spawner.A_StartSound(GetDefaultByType("BarrelFlameSpawner").SeeSound); spawner.target = self.target; spawner.tracer = self.tracer; spawner.angle = self.angle + a; spawner.Vel.XY = AngleToVector(spawner.angle, spawner.Default.Speed); spawner.Vel.Z = self.Vel.Z + 6; } } } Default { Health 40; Radius 24; Height 72; Obituary "$OB_BARREL"; Species "Barrel"; DeathSound "explosion/bigEnemy"; SnapActor.DamageFlash "EnemyDamagedBlue"; +SnapMonster.ROBOTTOUGH +SnapMonster.ROBOTEXPLODES } States { LocalizationSprites: BAPT A 1; Loop; Spawn: BARL A -1; Loop; Death: BARL A 1; BARL A 1 SnapBarrelExplode(); TNT1 A 35; TNT1 A 1015 A_DeathmatchGoAway(); TNT1 A 5 A_Respawn(); Wait; } override void Tick() { super.Tick(); if (Sprite == GetSpriteIndex("BARL")) { Sprite = GetSpriteIndex(Stringtable.Localize("$SNAP_SPRITE_BARL")); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- mixin class SnapOptionBase { void OptionDraw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { UpdateScaleParameters(); Vector2 Pos = ((BASE_VID_WIDTH * 0.5) + xOffset, yOffset); int col = Font.CR_UNTRANSLATED; if (DisplayGrayed() == true) { col = FontGrayColor; } else if (selected == true) { col = FontHighlightColor; } SnapMenuText( FontSmall, col, RightAlignPos(FontSmall, mLabel, Pos - (OPTIONS_MID_SPACE, 0)), mLabel ); int Selection = GetSelection(); String text = StringTable.Localize(OptionValues.GetText(mValues, Selection)); if (text.Length() == 0) { text = "Unknown"; } SnapMenuText( FontSmall, col, Pos + (OPTIONS_MID_SPACE, 0), text ); } } class OptionMenuItemSnapOption : OptionMenuItemOption { mixin SnapMenuDrawing; mixin SnapMenuItemCore; mixin SnapOptionBase; OptionMenuItemSnapOption Init( String label, String tooltip, Name command, Name values, CVar graycheck = null, int center = 0) { super.Init(label, command, values, graycheck, center); mTooltip = tooltip; return self; } virtual int GetLineSpacing() { return FontSmall.GetHeight(); } override void OnMenuCreated() { super.OnMenuCreated(); PrecacheMenuDrawing(); } virtual bool DisplayGrayed() { // I mostly only want to edit the // drawing, so this function exists now. if (Parent != null) { bool InList = Parent.ItemCurrentlyInList(self); if (InList == false) { return true; } } return isGrayed(); } virtual void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.DestPos = Delta + (BASE_VID_WIDTH * 0.5, 0); Cursor.DestPos = RightAlignPos(FontSmall, mLabel, Cursor.DestPos - (OPTIONS_MID_SPACE, 0)); Cursor.DestSmall = true; } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { OptionDraw(desc, yOffset, xOffset, selected); return xOffset; } override bool MenuEvent(int mKey, bool gamepad) { bool ret = super.MenuEvent(mKey, gamepad); if (ret == true) { CursorPlayFire(); } return ret; } } class SnapMenuItemOptionLocked : OptionMenuItemSnapOption { virtual bool Locked() { return false; } override String Tooltip() { if (Locked() == true) { return "???"; } return super.Tooltip(); } override bool DisplayGrayed() { if (Locked() == true) { return true; } return super.DisplayGrayed(); } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { if (Locked() == true) { UpdateScaleParameters(); Vector2 Pos = ((BASE_VID_WIDTH * 0.5) + xOffset, yOffset); String Mystery = MakeSecretString(StringTable.Localize(mLabel)); SnapMenuText( FontSmall, FontGrayColor, RightAlignPos(FontSmall, Mystery, Pos - (OPTIONS_MID_SPACE, 0)), Mystery ); SnapMenuText( FontSmall, FontGrayColor, Pos + (OPTIONS_MID_SPACE, 0), "???" ); return xOffset; } return super.Draw(desc, yOffset, xOffset, selected); } override bool MenuEvent(int mKey, bool gamepad) { if (Locked() == true) { return false; } return super.MenuEvent(mKey, gamepad); } } class OptionMenuItemSnapOptionMultiTooltip : OptionMenuItemSnapOption { Name mTooltipValues; void UpdateTooltip() { int Selection = GetSelection(); String text = OptionValues.GetText(mTooltipValues, Selection); if (text.Length() == 0) { text = "Unknown"; } mTooltip = text; } OptionMenuItemSnapOptionMultiTooltip Init( String label, Name tooltips, Name command, Name values, CVar graycheck = null, int center = 0) { super.Init(label, "", command, values, graycheck, center); mTooltipValues = tooltips; UpdateTooltip(); return self; } override bool MenuEvent(int mKey, bool gamepad) { bool result = super.MenuEvent(mKey, gamepad); if (result == true) { UpdateTooltip(); } return result; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapParallaxLayer ui abstract { mixin SnapMenuDrawing; TextureID Texture; Vector2 Offset; double Depth; double Transparency; enum ParallaxFlags { PLF_LOOPX = 1, PLF_LOOPY = 1<<1, PLF_LOOPMASK = (PLF_LOOPX|PLF_LOOPY), } uint Flags; void DrawTexture(TextureID tex, Vector2 Pos) { Screen.DrawTexture( tex, true, Pos.X, Pos.Y, DTA_Alpha, 1.0 - Transparency, DTA_VirtualWidthF, VirtualSize.X, DTA_VirtualHeightF, VirtualSize.Y, DTA_KeepRatio, true ); } virtual void Draw(Vector2 InterpViewPos, double TicFrac) { UpdateScaleParameters(); Vector2 Delta = (0, 0); if (Depth != 0.0) { Delta = (Offset - InterpViewPos) / Depth; } Delta += VirtualOffset; Vector2 Size = SnapMenuTextureSize(Texture); switch (Flags & PLF_LOOPMASK) { case (PLF_LOOPX|PLF_LOOPY): // Loop both axes while (Delta.X >= 0.0) { Delta.X -= Size.X; } while (Delta.Y >= 0.0) { Delta.Y -= Size.Y; } Vector2 StartDelta = Delta; while (Delta.X <= RealSize.X) { while (Delta.Y <= RealSize.Y) { DrawTexture(Texture, Delta); Delta.Y += Size.Y; } Delta.Y = StartDelta.Y; Delta.X += Size.X; } break; case PLF_LOOPY: // Loop the Y while (Delta.Y >= 0.0) { Delta.Y -= Size.Y; } while (Delta.Y <= RealSize.Y) { DrawTexture(Texture, Delta); Delta.Y += Size.Y; } break; case PLF_LOOPX: // Loop the X while (Delta.X >= 0.0) { Delta.X -= Size.X; } while (Delta.X <= RealSize.X) { DrawTexture(Texture, Delta); Delta.X += Size.X; } break; default: // One single position, no looping. DrawTexture(Texture, Delta); break; } } abstract void Begin(); } class SnapMenuParallax ui abstract { mixin SnapMenuDrawing; Array Layers; Vector2 ViewPos; Vector2 PrevViewPos; Color ClearColor; uint Time; abstract void Construct(); // This is where you would create the layers virtual void DrawLayer(uint ID, Vector2 InterpViewPos, double TicFrac) { Layers[ID].Draw(InterpViewPos, TicFrac); } virtual void DrawClear() { Screen.Dim( ClearColor, 1.0, 0, 0, int(RealSize.X), int(RealSize.Y) ); } virtual void Draw(double TicFrac) { UpdateScaleParameters(); DrawClear(); uint NumLayers = Layers.Size(); if (NumLayers == 0) { return; } Vector2 InterpViewPos = PrevViewPos + ((ViewPos - PrevViewPos) * TicFrac); for (uint i = 0; i < NumLayers; i++) { DrawLayer(i, InterpViewPos, TicFrac); } } virtual void Begin() { Construct(); } virtual void Tick() { PrevViewPos = ViewPos; Time++; } void AddLayer(class layerType, in out Array Dest) { SnapParallaxLayer layer = SnapParallaxLayer( new(layerType) ); if (layer != null) { Dest.Push(layer); layer.Begin(); } } } // // Actual city BG // class SnapCityLayerA : SnapParallaxLayer { override void Begin() { Texture = TexMan.CheckForTexture("CITYBGA0", TexMan.Type_MiscPatch); Depth = 0.0; Flags |= PLF_LOOPX; } } class SnapCityLayerB : SnapParallaxLayer { override void Begin() { Texture = TexMan.CheckForTexture("CITYBGA1", TexMan.Type_MiscPatch); Depth = 5.0; Flags |= PLF_LOOPX; } } class SnapCityLayerC : SnapParallaxLayer { override void Begin() { Texture = TexMan.CheckForTexture("CITYBGA2", TexMan.Type_MiscPatch); Depth = 3.0; Flags |= PLF_LOOPX; } } class SnapCityLayerD : SnapParallaxLayer { override void Begin() { Texture = TexMan.CheckForTexture("CITYBGA3", TexMan.Type_MiscPatch); Depth = 1.5; Flags |= PLF_LOOPX; } } class SnapCityLayerE : SnapParallaxLayer { override void Begin() { Texture = TexMan.CheckForTexture("CITYBGA4", TexMan.Type_MiscPatch); Depth = 1.1; Flags |= PLF_LOOPX; } } class SnapCityLayerF : SnapParallaxLayer { override void Begin() { Texture = TexMan.CheckForTexture("CITYBGA5", TexMan.Type_MiscPatch); Depth = 1.0; Flags |= PLF_LOOPX; } } class SnapCityLayerG : SnapParallaxLayer { override void Begin() { Texture = TexMan.CheckForTexture("CITYBGA6", TexMan.Type_MiscPatch); Depth = 0.9; Flags |= PLF_LOOPX; } } class SnapCityLayerDawnA : SnapCityLayerA { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGB0", TexMan.Type_MiscPatch); } } class SnapCityLayerDawnB : SnapCityLayerB { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGB1", TexMan.Type_MiscPatch); } } class SnapCityLayerDawnC : SnapCityLayerC { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGB2", TexMan.Type_MiscPatch); } } class SnapCityLayerDawnD : SnapCityLayerD { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGB3", TexMan.Type_MiscPatch); } } class SnapCityLayerDawnE : SnapCityLayerE { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGB4", TexMan.Type_MiscPatch); } } class SnapCityLayerDawnF : SnapCityLayerF { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGB5", TexMan.Type_MiscPatch); } } class SnapCityLayerDawnG : SnapCityLayerG { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGB6", TexMan.Type_MiscPatch); } } class SnapCityLayerDayA : SnapCityLayerA { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGC0", TexMan.Type_MiscPatch); } } class SnapCityLayerDayB : SnapCityLayerB { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGC1", TexMan.Type_MiscPatch); } } class SnapCityLayerDayC : SnapCityLayerC { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGC2", TexMan.Type_MiscPatch); } } class SnapCityLayerDayD : SnapCityLayerD { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGC3", TexMan.Type_MiscPatch); } } class SnapCityLayerDayE : SnapCityLayerE { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGC4", TexMan.Type_MiscPatch); } } class SnapCityLayerDayF : SnapCityLayerF { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGC5", TexMan.Type_MiscPatch); } } class SnapCityLayerDayG : SnapCityLayerG { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGC6", TexMan.Type_MiscPatch); } } class SnapCityLayerSunsetA : SnapCityLayerA { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGD0", TexMan.Type_MiscPatch); } } class SnapCityLayerSunsetB : SnapCityLayerB { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGD1", TexMan.Type_MiscPatch); } } class SnapCityLayerSunsetC : SnapCityLayerC { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGD2", TexMan.Type_MiscPatch); } } class SnapCityLayerSunsetD : SnapCityLayerD { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGD3", TexMan.Type_MiscPatch); } } class SnapCityLayerSunsetE : SnapCityLayerE { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGD4", TexMan.Type_MiscPatch); } } class SnapCityLayerSunsetF : SnapCityLayerF { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGD5", TexMan.Type_MiscPatch); } } class SnapCityLayerSunsetG : SnapCityLayerG { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGD6", TexMan.Type_MiscPatch); } } class SnapCityLayerDuskA : SnapCityLayerA { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGE0", TexMan.Type_MiscPatch); } } class SnapCityLayerDuskB : SnapCityLayerB { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGE1", TexMan.Type_MiscPatch); } } class SnapCityLayerDuskC : SnapCityLayerC { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGE2", TexMan.Type_MiscPatch); } } class SnapCityLayerDuskD : SnapCityLayerD { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGE3", TexMan.Type_MiscPatch); } } class SnapCityLayerDuskE : SnapCityLayerE { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGE4", TexMan.Type_MiscPatch); } } class SnapCityLayerDuskF : SnapCityLayerF { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGE5", TexMan.Type_MiscPatch); } } class SnapCityLayerDuskG : SnapCityLayerG { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGE6", TexMan.Type_MiscPatch); } } class SnapCityLayerOvercastA : SnapCityLayerA { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGF0", TexMan.Type_MiscPatch); } } class SnapCityLayerOvercastB : SnapCityLayerB { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGF1", TexMan.Type_MiscPatch); } } class SnapCityLayerOvercastC : SnapCityLayerC { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGF2", TexMan.Type_MiscPatch); } } class SnapCityLayerOvercastD : SnapCityLayerD { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGF3", TexMan.Type_MiscPatch); } } class SnapCityLayerOvercastE : SnapCityLayerE { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGF4", TexMan.Type_MiscPatch); } } class SnapCityLayerOvercastF : SnapCityLayerF { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGF5", TexMan.Type_MiscPatch); } } class SnapCityLayerOvercastG : SnapCityLayerG { override void Begin() { super.Begin(); Texture = TexMan.CheckForTexture("CITYBGF6", TexMan.Type_MiscPatch); } } class SnapCityBG : SnapMenuParallax { const BLEND_SPEED = 0.005; Array BlendLayers; Color BlendClearColor; double BlendAlpha; const TIME_OF_DAY_SWAP = 15*TICRATE; uint TimeOfDay; uint TimeOfDayLeft; enum TimeOfDayTypes { TOD_NIGHT, TOD_DAWN, TOD_OVERCAST, TOD_DAY, TOD_SUNSET, TOD_DUSK, TOD__MAX, } Color TimeColors[TOD__MAX]; void AddCityLayers(uint TimeIndex, in out Array Dest, in out Color Clear) { static const String TimeOfDaySuffix[] = { "", "Dawn", "Overcast", "Day", "Sunset", "Dusk" }; for (uint i = 0; i < 7; i++) { AddLayer( String.Format("SnapCityLayer%s%c", TimeOfDaySuffix[TimeIndex], 0x41 + i), Dest ); } Clear = TimeColors[TimeIndex]; } void StartCityBlend() { BlendAlpha = 0.0; uint NextTimeOfDay = (TimeOfDay + 1) % TOD__MAX; AddCityLayers(NextTimeOfDay, BlendLayers, BlendClearColor); } void NextTimeOfDay() { TimeOfDay = (TimeOfDay + 1) % TOD__MAX; TimeOfDayLeft = TIME_OF_DAY_SWAP; for (int i = 0; i < Layers.Size(); i++) { let layer = Layers[i]; if (layer != null) { layer.Destroy(); } } Layers.Clear(); //BlendLayers.Move(Layers); // it does NOT like move, manually reconstruct... for (int i = 0; i < BlendLayers.Size(); i++) { let layer = BlendLayers[i]; if (layer != null) { layer.Destroy(); } } BlendLayers.Clear(); AddCityLayers(TimeOfDay, Layers, ClearColor); BlendAlpha = 0.0; } override void Construct() { TimeColors[TOD_NIGHT] = Screen.PaletteColor(31); TimeColors[TOD_DAWN] = Screen.PaletteColor(139); TimeColors[TOD_OVERCAST] = Screen.PaletteColor(247); TimeColors[TOD_DAY] = Screen.PaletteColor(119); TimeColors[TOD_SUNSET] = Screen.PaletteColor(132); TimeColors[TOD_DUSK] = Screen.PaletteColor(140); ViewPos = (0.0, 104.0); TimeOfDay = random[snap_menu](0, TOD__MAX-1); TimeOfDayLeft = TIME_OF_DAY_SWAP; AddCityLayers(TimeOfDay, Layers, ClearColor); } override void Tick() { super.Tick(); ViewPos += (4.0, 0.0); if (TimeOfDayLeft > 0) { TimeOfDayLeft--; } if (TimeOfDayLeft <= 0) { if (BlendLayers.Size() == 0) { // Create blend StartCityBlend(); } else { BlendAlpha += BLEND_SPEED; if (BlendAlpha > 1.0) { NextTimeOfDay(); } } } } override void DrawClear() { super.DrawClear(); Screen.Dim( BlendClearColor, BlendAlpha, 0, 0, int(RealSize.X), int(RealSize.Y) ); } override void DrawLayer(uint ID, Vector2 InterpViewPos, double TicFrac) { super.DrawLayer(ID, InterpViewPos, TicFrac); uint s = BlendLayers.Size(); if (ID >= s) { return; } let bl = BlendLayers[ID]; if (bl != null) { BlendLayers[ID].Transparency = max(1.0 - BlendAlpha, 0.0); BlendLayers[ID].Draw(InterpViewPos, TicFrac); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class PetBullet : GuardRoboBullet { Default { Speed 40; Obituary "$OB_PETWALKER"; } } class WalkersPet : SnapMonster { const PET_DIST = 96.0; const PET_HEIGHT = 64.0; uint Offset; Vector3 DestPos; void PetNewPosition() { if (Tracer == null || Tracer.Health <= 0) { return; } DestPos = Tracer.Pos; Vector3 NewPos = Tracer.Pos; NewPos.Z += PET_HEIGHT; double offsetAng = Tracer.Angle - 45.0 + (90.0 * Offset); for (uint i = 0; i < 4; i++) { NewPos.XY = Tracer.Pos.XY + ((cos(offsetAng), sin(offsetAng)) * PET_DIST); if (CheckMove(NewPos.XY) == true) { DestPos = NewPos; break; } offsetAng += 90.0; } Offset++; } state PetPickAttackState() { let PetOwner = PetWalker(Tracer); if (PetOwner != null && PetOwner.TumbleTimer == 0) { // Not in danger, so focus what a boss would // focus on (the Core in Invasion) A_PickBossTarget(); } else { // In danger! Attack the flipper! Target = PetOwner.Target; } /* if (VeryRude == true) { return ResolveState("RudeMissile"); } */ return ResolveState("Missile"); } Default { Health 100; Radius 28; Height 72; Speed 8; Mass 500; Obituary "$OB_PETWALKER"; Tag "$TAG_PETWALKER"; Species "Robot"; +INVULNERABLE -COUNTKILL +FLOAT +NOGRAVITY +AVOIDMELEE +DONTFALL } States { Spawn: PSTP D 35; PSTP D 35 PetNewPosition(); PSTP D 0 PetPickAttackState(); Loop; Missile: PSTP DDDDD 3 A_FaceTarget(22.5); MissileLoop: PSTP DDDDD 3 A_SnapMonsterProjectile("PetBullet"); Goto Spawn; Death: PSTP D 1; TNT1 A 35 DoSnapMonsterDie(); Stop; GiantDeath: PSTP D 1; PSTP DDDDDDDD 4 DoSnapMonsterExplode(); TNT1 A 35 DoSnapMonsterDie(); Stop; } override void Tick() { super.Tick(); if (TickPaused() == true) { return; } if ((Tracer == null || Tracer.Health <= 0) && Health > 0) { Health = 0; Die(null, null); return; } if (Pos ~== DestPos) { if (TestMobjLocation() == true) { bNoClip = false; } } else { Vel = (DestPos - Pos) * 0.1; Vector3 diff = Vec3Offset(DestPos.X, DestPos.Y, DestPos.Z); if (diff.Length() > PET_DIST * 4.0) { bNoClip = true; } } } } class PetWalker : SnapMonster { WalkersPet Pet; const STRUGGLE_TIME = TICRATE; const STRUGGLE_SND_FREQ = 4; const TUMBLE_TIME = 2*TICRATE + STRUGGLE_TIME; uint TumbleTimer; void PetWalkerUpdateInvuln() { if (TumbleTimer == 0) { DamageFactor = 0.0; } else { DamageFactor = 1.0; } } state PetWalkerTumble() { if (kickTossed == true) { return null; } if (TumbleTimer == 0) { // Flip back over. Vel.Z = 5.0; PetWalkerUpdateInvuln(); return ResolveState("See"); } if ((TumbleTimer % STRUGGLE_SND_FREQ) == 0) { A_StartSound("petWalker/struggle"); } TumbleTimer--; if (TumbleTimer < STRUGGLE_TIME) { Tics = 1; } return null; } state PetWalkerFlip() { if (TumbleTimer > 0) { // Unflip TumbleTimer = 0; PetWalkerUpdateInvuln(); return ResolveState("Unflip"); } // Set target so we know who // flipped us over! if (kickInflictor != null) { Target = kickInflictor; } TumbleTimer = TUMBLE_TIME; PetWalkerUpdateInvuln(); return ResolveState("Flip"); } Default { Health 100; Radius 28; Height 32; Speed 8; Mass 100; MeleeRange 512; SeeSound "petWalker/see"; ActiveSound "petWalker/idle"; PainSound "petWalker/hurt"; Obituary "$OB_PETWALKER"; Tag "$TAG_PETWALKER"; Species "Robot"; DamageFactor 0.0; +NOPAIN +AVOIDMELEE } States { Spawn: PSTP A 10 A_SnapMonsterLook(); Loop; See: PSTP A 3 A_SnapChase(); Loop; Tumbled: PSTP B 3 PetWalkerTumble(); Loop; Kicked: PSTP C 3; PSTP C 3 A_SnapMonsterPain(); PSTP C 0 PetWalkerFlip(); UnFlip: PSTP C 3 A_EndKick("See"); Loop; Flip: PSTP C 3 A_EndKick("Tumbled"); Loop; Death: PSTP C 1; TNT1 A 35 DoSnapMonsterDie(); Stop; GiantDeath: PSTP C 1; PSTP CCCCCCCC 4 DoSnapMonsterExplode(); TNT1 A 35 DoSnapMonsterDie(); Stop; } override void InitMonsterModifiers() { super.InitMonsterModifiers(); if (Pet != null) { Pet.MonsterModifiers = self.MonsterModifiers; Pet.UpdateOurMonsterModifiers(); } } override void BeginPlay() { super.BeginPlay(); Pet = WalkersPet(Spawn("WalkersPet", Pos + (0, 0, WalkersPet.PET_HEIGHT), ALLOW_REPLACE)); if (Pet == null) { return; } Pet.Angle = self.Angle; Pet.Tracer = self; Pet.PetNewPosition(); } override void KickTossEnd() { // Ignore any damage from kick toss end. double PrevDamageFactor = DamageFactor; DamageFactor = 0.0; super.KickTossEnd(); DamageFactor = PrevDamageFactor; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- // Include dependencies. #include "./player/globals.zs" #include "./player/projectile.zs" #include "./player/pow.zs" #include "./player/lockon.zs" #include "./player/invuln.zs" #include "./player/resist.zs" #include "./player/mugshot.zs" #include "./player/footstep.zs" #include "./player/roll.zs" #include "./player/sway.zs" #include "./player/voice.zs" #include "./player/combo.zs" #include "./player/ammodrop.zs" #include "./player/frags.zs" #include "./player/pvpkick.zs" #include "./player/roulette.zs" #include "./player/nogun.zs" #include "./player/score.zs" #include "./player/animate.zs" #include "./player/crashpspr.zs" class SnapPlayer : PlayerPawn { mixin SnapHitstunFuncs; mixin SnapGeneralFunctions; mixin SnapShadowCarryover; mixin SnapShadowCode; mixin SnapPlayerResistances; SnapPlayerGlobals SnapPlayerInfo; int WeaponPower; bool InfiniteWeapon; bool PlayerDropsHealth; bool PlayerRanHitstun; uint AmmoDropCycle; bool CoopTeleport; property DamageFlash: DamageFlashTranslation; Default { Radius 16; Height 56; DeathHeight 56; Mass 50; Tag "$TAG_SNAP"; Obituary "$OB_MPDEFAULT"; HitObituary "$OB_KICK"; Player.DisplayName "Snap"; Player.WeaponSlot 1, "SnapGun"; SnapPlayer.AnimatorClass "SnapsAnimator"; Player.Portrait "SNAPFAC1"; //Player.ScoreIcon "SMALFAC1"; //Player.CrouchSprite "PCRH"; SnapPlayer.SnapMugPrefix "SNAP"; SnapPlayer.SnapMugPrefixSmall "SMAL"; Player.ColorRange 1, 15; Player.ColorSet 0, "$SNAP_COLOR_RED", 0x01, 0x0F, 0x08; Player.ColorSet 1, "$SNAP_COLOR_SALMON", 0x20, 0x27, 0x24; Player.ColorSet 2, "$SNAP_COLOR_ORANGE", 0x28, 0x2F, 0x2C; Player.ColorSet 3, "$SNAP_COLOR_GOLD", 0x30, 0x37, 0x34; Player.ColorSet 4, "$SNAP_COLOR_YELLOW", 0x38, 0x3F, 0x3C; Player.ColorSet 5, "$SNAP_COLOR_PEAR", 0x40, 0x47, 0x44; Player.ColorSet 6, "$SNAP_COLOR_THUNDER", 0xC8, 0xCF, 0xCC; Player.ColorSet 7, "$SNAP_COLOR_LIME", 0x48, 0x4F, 0x4C; Player.ColorSet 8, "$SNAP_COLOR_GREEN", 0x50, 0x57, 0x54; Player.ColorSet 9, "$SNAP_COLOR_FOREST", 0x58, 0x5F, 0x5C; Player.ColorSet 10, "$SNAP_COLOR_TURQUOISE", 0x60, 0x67, 0x64; Player.ColorSet 11, "$SNAP_COLOR_CERULEAN", 0x68, 0x6F, 0x6C; Player.ColorSet 12, "$SNAP_COLOR_GHOST", 0x78, 0x7F, 0x7C; Player.ColorSet 13, "$SNAP_COLOR_CYAN", 0x70, 0x77, 0x74; Player.ColorSet 14, "$SNAP_COLOR_BLUE", 0x80, 0x87, 0x84; Player.ColorSet 15, "$SNAP_COLOR_COBALT", 0x88, 0x8F, 0x8C; Player.ColorSet 16, "$SNAP_COLOR_INDIGO", 0xA0, 0xA7, 0xA4; Player.ColorSet 17, "$SNAP_COLOR_PURPLE", 0x90, 0x97, 0x94; Player.ColorSet 18, "$SNAP_COLOR_MAUVE", 0xA8, 0xAF, 0xAC; Player.ColorSet 19, "$SNAP_COLOR_MAGENTA", 0xB0, 0xB7, 0xB4; Player.ColorSet 20, "$SNAP_COLOR_PINK", 0xB8, 0xBF, 0xBC; Player.ColorSet 21, "$SNAP_COLOR_SCARLET", 0xD0, 0xD7, 0xD4; Player.ColorSet 22, "$SNAP_COLOR_PASTEL", 0xC0, 0xC7, 0xC4; Player.ColorSet 23, "$SNAP_COLOR_CARAMEL", 0xD8, 0xDF, 0xDC; Player.ColorSet 24, "$SNAP_COLOR_BROWN", 0xE8, 0xEF, 0xEC; Player.ColorSet 25, "$SNAP_COLOR_BEIGE", 0xE0, 0xE7, 0xE4; Player.ColorSet 26, "$SNAP_COLOR_DUSK", 0x98, 0x9F, 0x9C; Player.ColorSet 27, "$SNAP_COLOR_MECHA", 0xF0, 0xF7, 0xF4; Player.ColorSet 28, "$SNAP_COLOR_PEARL", 0xF8, 0xFF, 0xFC; Player.ColorSet 29, "$SNAP_COLOR_WHITE", 0x10, 0x19, 0x14; Player.ColorSet 30, "$SNAP_COLOR_GRAY", 0x10, 0x1F, 0x17; Player.ColorSet 31, "$SNAP_COLOR_BLACK", 0x16, 0x1F, 0x1B; Player.WeaponSlot 1, "SnapGun"; Player.StartItem "SnapGun"; Player.StartItem "SnapStandardAmmo", 7; Player.MaxHealth 999; Player.AirCapacity 0.0; Player.SpawnClass 1; Player.DamageScreenColor "Red", 0.0; SnapPlayer.DamageFlash "EnemyDamaged"; +NOBLOOD +NOTELEFRAG +SnapPlayer.CANDI } override bool OnGiveSecret(bool printmsg, bool playsound) { AddSnapVoice("voice/secret", 0); // 22 return super.OnGiveSecret(printmsg, playsound); } virtual int GetDefaultTranslation() { return Translate.MakeID(TRANSLATION_Players, PlayerNumber()); } virtual int GetFlashTranslation() { return DefaultFlashing(); } override void BeginPlay() { super.BeginPlay(); HitstunBegin(); ShadowBegin(); Combo.Owner = self; } override void OnDestroy() { super.OnDestroy(); ShadowDestroy(); } override void Tick() { Combo.Owner = self; // Combo is transient, so we have to update this UpdateTouchDamage(); if (CoopTeleport == true && Level.MapTime > 0) { Spawn("TeleportFog", Pos + (0, 0, gameinfo.telefogheight), ALLOW_REPLACE); let telezoom = CVar.FindCVar("telezoom"); if (telezoom != null && telezoom.GetBool() == true) { player.FOV = min(175.0, player.DesiredFOV + 45.0); } CoopTeleport = false; } if (!ShadowActor) { // Shadow is lost when moving between maps without this ShadowBegin(); } ShadowTick(); CalcSnapSway(); Combo.Tick(); bool froze = CheckFrozen(); PlayerRanHitstun = RunHitstun(); if (froze == true || PlayerRanHitstun == true) { ReactionTime = max(ReactionTime, 1); return; } super.Tick(); RunDamageFlash(); DecrementTouchDelay(); // undo crouch bullshit Height = FullHeight; if (!player || !player.mo || player.mo != self) { DamageFlash = 0; // fix corpse flashing UsingPOW = 0; //SnapPlayerInfo = null; return; } if (SnapPlayerInfo == null) { SnapPlayerInfo = SnapPlayerGlobals.GetForPlayerNum(PlayerNumber()); InitPlayerAnimator(); } // If pain state was interrupted, // then don't keep old acculmate values for too long. if (DamageAccumulateDelay > 0) { DamageAccumulateDelay--; } else if (DamageAccumulate > 0) { DamageAccumulate--; } UpdateCrashClap(); if (UsingPOW > 0) { MoveCrashLayers(); POWTick(); return; } DoWaterPushEFX(); DoOverheal(GetDefaultTranslation()); RunSnapVoiceQueue(); if (kickTossed == true) { A_KickedDust(); PushDecay = PushDecayTicks; if (player.onground == true && Vel.Z <= 0) { kickTossed = false; } } else if (PushDecay > 0) { PushDecay--; if (PushDecay <= 0) { PushSource = null; } } if (SnapInvulnTick > 0) { SnapInvulnTick--; if (SnapInvulnTick == 0) { bNoTelefrag = bRespawnInvul = false; TeleportMove(pos, true, false); // Check for telefrag now that we're solid :) } } else { bNoTelefrag = false; } if (SnapMugTimer > 0) { SnapMugTimer--; if (SnapMugTimer <= 0) { SnapMug = SNAPMUG_NORMAL; SnapMugTimer = 0; } } } override bool CheckFrozen() { let player = self.player; if (player == null || player.mo == null) { return false; } if (Hitstun != null && Hitstun.Time > 0) { return true; } SnapEventHandler ev = SnapEventHandler(EventHandler.Find("SnapEventHandler")); if (ev != null && ev.VSCountdown > 0) { // Only allow aiming during level intro UserCmd cmd = player.cmd; cmd.buttons = 0; cmd.forwardmove = 0; cmd.sidemove = 0; cmd.upmove = 0; player.turnticks = 0; return false; } return super.CheckFrozen(); } void UpdatePlayerYaw() { let player = self.player; UserCmd cmd = player.cmd; // [RH] 180-degree turn overrides all other yaws if (player.turnticks) { player.turnticks--; Angle += (180. / TURN180_TICKS); } else { Angle += cmd.yaw * (360./65536.); } } void UpdatePlayerAngles() { // Call this when in a state where we want to // freeze the player but still allow them to move their camera. UpdatePlayerYaw(); CheckPitch(); } override void PlayerThink() { let player = self.player; UserCmd cmd = player.cmd; // No use key please :V cmd.buttons &= ~BT_USE; if (CheckFrozen() == true || PlayerRanHitstun == true) { if (PlayerRanHitstun == true && Hitstun.FromDamage == true) { UpdatePlayerAngles(); } return; } if (UsingPOW > 0) { Vel = (0, 0, 0); player.Vel = (0, 0); if (!(player.cheats & CF_PREDICTING)) { TickPOWPSprites(); } return; } super.PlayerThink(); StrafeRoll(); if (!(player.cheats & CF_PREDICTING)) { let pmo = SnapPlayer(player.mo); if (pmo) { pmo.TryPlayerFootstep(); pmo.CheckPOW(); pmo.CheckLockOn(); pmo.CheckWeaponRoulette(); } } } override void TickPSprites() { UpdateLockOnAngle(); super.TickPSprites(); } override void DeathThink(void) { // Yup, another bruh moment where we have to copy-paste to properly override default behavior. let player = self.player; int dir; double delta; player.Uncrouch(); TickPSprites(); player.onground = (pos.Z <= floorz); if (self is "PlayerChunk") { // Flying bloody skull or flying ice chunk player.viewheight = 6; player.deltaviewheight = 0; if (player.onground) { if (Pitch > -19.) { double lookDelta = (-19. - Pitch) / 8; Pitch += lookDelta; } } } else if (!bIceCorpse) { // Fall to ground (if not frozen) player.deltaviewheight = 0; if (player.viewheight > 6) { player.viewheight -= 1; } if (player.viewheight < 6) { player.viewheight = 6; } if (Pitch < 0) { Pitch += 3; } else if (Pitch > 0) { Pitch -= 3; } if (abs(Pitch) < 3) { Pitch = 0.; } } player.mo.CalcHeight (); if (player.attacker && player.attacker != self) { // Watch killer double diff = deltaangle(angle, AngleTo(player.attacker)); double delta = abs(diff); if (delta < 10) { // Looking at killer, so fade damage and poison counters if (player.damagecount) { player.damagecount--; } if (player.poisoncount) { player.poisoncount--; } } delta /= 8; Angle += clamp(diff, -5., 5.); } else { if (player.damagecount) { player.damagecount--; } if (player.poisoncount) { player.poisoncount--; } } if (!sv_norespawn) { if ((PlayerNumber() == consoleplayer) && (Level.maptime == (player.respawn_time + (TICRATE/2)))) { SnapFader.StartGameFade(true, 0.02); } if (Level.maptime >= (player.respawn_time + (2*TICRATE))) { player.cls = NULL; // Force a new class if the player is using a random class. player.playerstate = (multiplayer || level.AllowRespawn || G_SkillPropertyInt(SKILLP_PlayerRespawn)) ? PST_REBORN : PST_ENTER; if (special1 > 2) { special1 = 0; } } } // Now for the actual SNAP THE SENTINEL code :V SnapMug = SNAPMUG_BAD; // ded, always use the bad one SnapMugTimer = 0; kickTossed = false; SnapInvulnTick = 0; bRespawnInvul = false; } override int TakeSpecialDamage(Actor inflictor, Actor source, int damage, Name damagetype) { int result = super.TakeSpecialDamage(inflictor, source, damage, damagetype); let srcMonster = SnapMonster(source); if (srcMonster != null) { if (srcMonster.bQuadDamage == true) { result *= 4; } if (srcMonster.VictoryMarch > 0) { result = int(ceil(result * 1.5)); } } if (Hitstun != null && Hitstun.Burst > 0) { // Reduced damage during burst. result = int(ceil(result * SnapHitstun.BURST_DMG_FACTOR)); } DamageAccumulate += result; DamageAccumulateDelay = DMGACCDELAY; if (result < TELEFRAG_DAMAGE) { if (SnapInvulnTick > 0) { result = 0; //flags |= DMG_NO_PAIN; } else if (Health > 1 && result >= Health) { // Lucky day! // You don't go below 1 health unless if you're already at 1 health, allowing for more close calls. // (Trying to set buddha on the player didn't work for some reason.) result = Health - 1; } } return result; } override int DamageMobj(Actor inflictor, Actor source, int damage, Name mod, int flags, double angle) { if (SnapInvulnTick > 0 && damage < TELEFRAG_DAMAGE) { return 0; } SnapVoiceInterrupt(); source = SetDominoSource(source); int trueDamage = super.DamageMobj(inflictor, source, damage, mod, flags, angle); HandleDamageHitstun(trueDamage, inflictor); SetDamageFlash(trueDamage); if (!(flags & DMG_NO_PAIN) && (trueDamage > 0)) { SetSnapMugshot(SNAPMUG_BAD); } let srcPlayer = SnapPlayer(source); if (srcPlayer) { // Increase their POW meter a little bit. srcPlayer.AddSnapPOWMeter(trueDamage); } if (kickTossed == true) { A_SnapJuggle(inflictor); KickMomentumReduce(); // POW meter gets a massive chunk! if (srcPlayer) { srcPlayer.AddSnapPOWMeter(25); } } // Increase your own POW meter by a lot. AddSnapPOWMeter(trueDamage * 2.5); // Reduce time on the combo. //Combo.TimeDecrease( min(trueDamage * 2, SnapCombo.MAX_DAMAGE) ); return trueDamage; } override void ApplyKickback(Actor inflictor, Actor source, int damage, double angle, Name mod, int flags) { super.ApplyKickback(inflictor, source, damage, angle, mod, flags); PushSource = source; } override void Die(Actor source, Actor inflictor, int dmgflags, Name MeansOfDeath) { SnapVoiceInterrupt(); source = SetDominoSource(source); if (inflictor == null && source == null && PushSource != null) { // Environment kill, but you were pushed into it. inflictor = source = PushSource; MeansOfDeath = "Pushed"; if (PushSource is "PlayerPawn") { dmgflags |= DMG_PLAYERATTACK; } } if (source != null && source != self && multiplayer == true) { // Allow dropping health later in the death animation PlayerDropsHealth = true; // Add a bonus to your power meter. AddSnapPOWMeter(250); } super.Die(source, inflictor, dmgflags, MeansOfDeath); if (multiplayer == true) { // Lose a small bit of score in Coop AddScore(-3000); let sb = SnapBot(source); if (sb != null) { // Give the bot their crash. sb.GivePOW(); } let inv = InvasionThinker.Find(); if (inv != null) { inv.ApplyVictoryMarch(); } } if (deathmatch == true) { UpdateFrags(SnapPlayer(source)); } } override void OnRespawn() { super.OnRespawn(); // Ensure no powerup ammo remaining... SetInventory("SnapPowerupAmmo", 0); SetInventory("SnapStandardAmmo", 7); FootstepTick = 0; PlayerDropsHealth = false; // Ignore sv_respawnprotect and just always do this if (deathmatch) { SetRespawnInvul(); } } override bool PreTeleport(Vector3 destpos, double destangle, int flags) { SetRespawnInvul(); return super.PreTeleport(destpos, destangle, flags); } override bool CanCollideWith(Actor other, bool passive) { let otherp = SnapPlayer(other); if (otherp) { if (bNoTelefrag == true || otherp.bNoTelefrag == true) { return false; } } return super.CanCollideWith(other, passive); } override void Travelled() { // Reset ammo drop cycle. AmmoDropCycle = 0; // Init new player animator InitPlayerAnimator(); } override Vector2 BobWeapon(double ticfrac) { let player = self.player; if (!player) { return (0, 0); } let weapon = player.ReadyWeapon; if (weapon == null || weapon.bDontBob == true) { return (0, 0); } return ((PrevSwayOffset * (1. - ticfrac)) + (SwayOffset * ticfrac)); } override void CheatGive(String n, int amount) { if (n ~== "SnapPOWMeter") { AddSnapPOWMeter(amount, false, false); return; } super.CheatGive(n, amount); } override void CheatTake(String n, int amount) { if (n ~== "SpillTest") { SpillPowerups(); return; } if (n ~== "SnapPOWMeter") { TakeSnapPOWMeter(amount); return; } super.CheatTake(n, amount); } override void CheatSetInv(String n, int amount, bool beyond) { if (n ~== "SnapPOWMeter") { SetSnapPOWMeter(amount, beyond); return; } super.CheatSetInv(n, amount, beyond); } override int DoSpecialDamage(Actor target, int dmg, name dmgtype) { if (dmgtype == "ScreenClear") { if (SnapUtils.PlayerOrBot(target)) { dmg *= 2; } /* else if (target.bIsMonster == false) { dmg = 1; } */ else { /* if (target.bBoss == true) { // Bosses take reduced damage. dmg *= 0.8; } */ if (Distance3D(target) > 512.0 && CheckSight(target) == false) { // Damage is reduced against anything that cannot be seen and is too far away. // Helps maintain the balance of small contained maps. (E1M7) dmg = int(dmg * 0.8); } } } return super.DoSpecialDamage(target, dmg, dmgtype); } void SpillPowerups() { // NEW: Drop ALL OF YOUR POWERUPS! // MUAHAHAHHAHAH!! uint NUMPOWERS = 4; // todo: proper way to add new powerups class PowerupTypes[4]; PowerupTypes[0] = "SnapSpeedPower"; PowerupTypes[1] = "SnapShieldPower"; PowerupTypes[2] = "SnapDamagePower"; PowerupTypes[3] = "SnapDogPower"; class PowerupDrops[4]; PowerupDrops[0] = "SnapSpeedPowerup"; PowerupDrops[1] = "SnapShieldPowerup"; PowerupDrops[2] = "SnapDamagePowerup"; PowerupDrops[3] = "SnapDogPowerup"; uint TotalDrops = 0; // First count the number of drops. for (uint i = 0; i < NUMPOWERS; i++) { let power = Powerup(FindInventory(PowerupTypes[i], true)); if (power != null) { TotalDrops++; } } // Now drop them all. double a = -666; for (uint i = 0; i < NUMPOWERS; i++) { let power = Powerup(FindInventory(PowerupTypes[i], true)); if (power != null) { a = SnapDropItems(PowerupDrops[i], 1, TotalDrops, a, -1, power.EffectTics); SetInventory(PowerupTypes[i], 0); } } } override string GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack) { if (mod == "ScreenClear") { return StringTable.Localize("$OB_CRASH"); } return super.GetObituary(victim, inflictor, mod, playerattack); } virtual Actor CreateShiftDIGhost(Vector3 SpawnPos) { Actor ghost = DefaultShiftDIGhost("SnapsGhost", SpawnPos, Pos, false); if (ghost == null) { return null; } if (self == players[consoleplayer].camera && !(self.player.cheats & CF_CHASECAM)) { ghost.bInvisible = true; } let player = self.player; if (player) { ghost.SetShade(player.GetDisplayColor()); } return ghost; } override void PreTravelled() { Combo.End(); Score = 0; super.PreTravelled(); } override void CrouchMove(int direction) { // Removed physical height changes. // Creates a lot of boring to fix bugs and let player = self.player; double crouchspeed = direction * CROUCHSPEED; double oldheight = player.viewheight; player.crouchdir = direction; player.crouchfactor += crouchspeed; player.crouchfactor = clamp(player.crouchfactor, 0.65, 1.0); player.viewheight = ViewHeight * player.crouchfactor; player.crouchviewdelta = player.viewheight - ViewHeight; // Check for eyes going above/below fake floor due to crouching motion. CheckFakeFloorTriggers(pos.Z + oldheight, true); } override void MovePlayer() { let player = self.player; UserCmd cmd = player.cmd; // [RH] 180-degree turn overrides all other yaws if (player.turnticks) { player.turnticks--; Angle += (180. / TURN180_TICKS); } else { Angle += cmd.yaw * (360./65536.); } player.onground = (pos.z <= floorz) || bOnMobj || bMBFBouncer || (player.cheats & CF_NOCLIP2); double destSpeed = Default.Speed; double destSpeedDot = -1.0; // killough 10/98: // // We must apply thrust to the player and bobbing separately, to avoid // anomalies. The thrust applied to bobbing is always the same strength on // ice, because the player still "works just as hard" to move, while the // thrust applied to the movement varies with 'movefactor'. if (cmd.forwardmove | cmd.sidemove) { Vector2 moveVec; double bobfactor; double friction, movefactor; [friction, movefactor] = GetFriction(); bobfactor = friction < ORIG_FRICTION ? movefactor : ORIG_FRICTION_FACTOR; if (!player.onground && !bNoGravity && !waterlevel) { // [RH] allow very limited movement if not on ground. movefactor *= level.aircontrol; bobfactor *= level.aircontrol; } double fm, sm; fm = cmd.forwardmove; sm = cmd.sidemove; [fm, sm] = TweakSpeeds(fm, sm); fm *= Speed / 256; sm *= Speed / 256; // When crouching, speed and bobbing have to be reduced if (CanCrouch() && player.crouchfactor != 1.0) { fm *= player.crouchfactor; sm *= player.crouchfactor; bobfactor *= player.crouchfactor; } moveVec.X = fm * movefactor * (35 / TICRATE); moveVec.Y = sm * movefactor * (35 / TICRATE); if (moveVec.X) { Bob(Angle, cmd.forwardmove * bobfactor / 256., true); ForwardThrust(moveVec.X, Angle); } if (moveVec.Y) { let a = Angle - 90; Bob(a, cmd.sidemove * bobfactor / 256., false); Thrust(moveVec.Y, a); } if (!(player.cheats & CF_PREDICTING) && (moveVec.X != 0 || moveVec.Y != 0)) { PlayRunning (); } if (player.cheats & CF_REVERTPLEASE) { player.cheats &= ~CF_REVERTPLEASE; player.camera = player.mo; } // Maintains extra speed from external sources, like // explosions or boosters. double diagonalHack = 1.0; if (moveVec.X && moveVec.Y) { diagonalHack = clamp(abs(moveVec.X) / abs(moveVec.Y), -1.0, 1.0) + clamp(abs(moveVec.Y) / abs(moveVec.X), -1.0, 1.0); } double topOrig = (16.0 * 16.0 * diagonalHack) * (35.0 / TICRATE); double top = topOrig; double _unused = 0.0; [top, _unused] = TweakSpeeds(top, _unused); double currentSpeed = Vel.XY.LengthSquared(); if (top != topOrig) { currentSpeed /= (top / topOrig); } currentSpeed *= friction; if (currentSpeed > top) { destSpeed = sqrt(currentSpeed / top); Vector2 pushDir = SnapUtils.SafeVec2Unit(( (moveVec.X * cos(Angle)) + (moveVec.Y * cos(Angle - 90)), (moveVec.X * sin(Angle)) + (moveVec.Y * sin(Angle - 90)) )); Vector2 velDir = SnapUtils.SafeVec2Unit(Vel.XY); destSpeedDot = pushDir dot velDir; } } if (destSpeed < Default.Speed) { destSpeed = Default.Speed; } if (Speed > destSpeed) { //Speed *= 0.99; Speed *= (destSpeedDot + 1.0) * 0.5; } if (Speed < destSpeed) { Speed = destSpeed; } } } class SnapsGhost : SnapDIGhostBase { States { Spawn: PPAN A 8; Stop; } } // Add RoboSnap character #include "./player/characters/snapbot.zs" //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class PlushSentrySeg : SnapMonster { Default { Health TELEFRAG_DAMAGE; Radius 16; Height 16; Mass 100; SnapActor.TouchDamage 10; Obituary "$OB_PLUSHSENTRY"; Tag "$TAG_PLUSHSENTRY"; Species "Robot"; -COUNTKILL +INVULNERABLE +NOINTERACTION +NOBLOCKMAP +NOGRAVITY +DONTSPLASH +NOTELEPORT +SLIDESONWALLS +DONTTHRUST -SnapActor.CANDROPAMMO } States { Spawn: PLSH G -1; Stop; Death: PLSH G 1; TNT1 A 35 DoSnapSegDie(); Stop; } override void Tick() { super.Tick(); if (TickPaused() == true) { return; } if (Tracer != null) { FloorClip = Tracer.FloorClip; } } } class PlushSentryShield : SnapMonster { Vector3 Home; const NUM_SEGS = 30; Array Segs; const TURN_SPD = 22.5; double LastMoveAngle; double LastMovePitch; const CLOSE_DIST = (384.0 * 384.0); bool Antsy; default { Health TELEFRAG_DAMAGE; Radius 30; Height 40; Speed 32; FloatSpeed 32; Mass 100; MeleeRange 72.0; SeeSound "plush/see"; ActiveSound "plush/idle"; PainSound "plush/hurt"; Obituary "$OB_PLUSHSENTRY"; Tag "$TAG_PLUSHSENTRY"; Species "Robot"; +NOGRAVITY +INVULNERABLE +DONTFALL +DONTTHRUST -COUNTKILL +DROPOFF +NOTELEPORT +SnapMonster.FLOATMATCHHEIGHT } states { Spawn: PLSH C 3 A_SnapMonsterLook(); Loop; See: PLSH C 30; PLSH C 50 ShieldReady(); Extending: PLSH DE 1 ShieldChase(); Loop; Melee: PLSH C 35 ShieldAttack(); Retracting: PLSH C 3 ShieldUnChase(); Loop; Death: PLSH F 1; PLSH F 1 KillSeg(); Loop; DeathEnd: PLSH F 1; TNT1 A 35 DoSnapMonsterDie(); Stop; } override Vector2 GetMonsterMoveDir() { double DestAngle = Angle; double DestPitch = Pitch; if (Target != null) { Vector3 Dir = Vec3To(Target); DestAngle = VectorAngle(Dir.X, Dir.Y); DestPitch = VectorAngle(Dir.XY.Length(), -Dir.Z); } DestAngle = floor(DestAngle * 8.0) / 8.0; DestPitch = floor(DestPitch * 8.0) / 8.0; LastMoveAngle = SnapUtils.AngleTowardsAngle(Angle, DestAngle, TURN_SPD); LastMovePitch = SnapUtils.AngleTowardsAngle(Pitch, DestPitch, TURN_SPD); return AngleToVector(LastMoveAngle); } override void ChaseUpdateAngle() { Angle = LastMoveAngle; Pitch = LastMovePitch; } override bool HandleMonsterMove(Vector2 TryMoveDir, int dropoff, in out FCheckPosition tm) { Vector3 NewPos = Vec3Offset( Speed * cos(Angle) * cos(-Pitch), Speed * sin(Angle) * cos(-Pitch), Speed * sin(-Pitch) ); bool ret = TryMove(NewPos.XY, dropoff, false, tm); if (ret == true) { SetZ(NewPos.Z); } return ret; } override bool HandleMonsterFloat(int FloatDir) { return true; } void ShieldReady() { Antsy = true; A_StartSound("plush/ready"); } void ResetShieldAngle() { Antsy = false; SetOrigin(Home, false); if (Tracer != null) { Angle = LastMoveAngle = Tracer.Angle - 67.5; Pitch = LastMovePitch = 0.0; } } void ShieldAttack() { Antsy = false; if (CheckMeleeRange() == true) { A_StartSound("plush/slam"); Target.DamageMobj(self, self, 10, "Melee"); } } state ShieldChase() { Antsy = false; Vector3 OldPos = Pos; Vector3 OldAng = (Angle, Pitch, Roll); A_SnapChase(); if (Pos ~== OldPos) { A_StartSound("plush/yanked"); return ResolveState("Melee"); } // We moved! Spawn a segment let NewSeg = Spawn("PlushSentrySeg", OldPos, ALLOW_REPLACE); NewSeg.Tracer = self.Tracer; NewSeg.Angle = OldAng.X; NewSeg.Pitch = OldAng.Y; NewSeg.Roll = OldAng.Z; Segs.Push(NewSeg); if (Segs.Size() >= NUM_SEGS) { // Yanked our chain A_StartSound("plush/yanked"); return ResolveState("Melee"); } A_StartSound("plush/extend"); return null; } state ShieldUnChase() { Antsy = false; uint NumSegs = Segs.Size(); if (NumSegs == 0) { // End sequence ResetShieldAngle(); return ResolveState("See"); } uint LastSeg = NumSegs-1; if (Segs[LastSeg] != null) { Vector3 NewPos = Segs[LastSeg].Pos; Vector3 NewAng = (Segs[LastSeg].Angle, Segs[LastSeg].Pitch, Segs[LastSeg].Roll); Segs[LastSeg].Destroy(); SetOrigin(NewPos, true); Angle = NewAng.X; Pitch = NewAng.Y; Roll = NewAng.Z; } Segs.Pop(); A_StartSound("plush/retract"); return null; } state KillSeg() { Antsy = true; uint NumSegs = Segs.Size(); if (NumSegs == 0) { // End sequence return ResolveState("DeathEnd"); } if (Segs[0] != null && Segs[0].Health > 0) { Segs[0].Health = 0; Segs[0].Die(self, self); } Segs.Delete(0); return null; // Continue } override void PostBeginPlay() { super.PostBeginPlay(); Home = Pos; ResetShieldAngle(); } override void Tick() { super.Tick(); if (TickPaused() == true) { return; } if (Tracer != null) { FloorClip = Tracer.FloorClip; } if (Antsy == true) { WorldOffset = ( frandom[snap_decor](-4.0, 4.0), frandom[snap_decor](-4.0, 4.0), frandom[snap_decor](-3.0, 3.0) ); } else { WorldOffset = (0.0, 0.0, 0.0); } } override bool CanCollideWith(Actor other, bool passive) { if (other is "PlushSentry") { return false; } return super.CanCollideWith(other, passive); } } class PlushSentry : SnapMonster { default { Health 250; Radius 30; Height 40; Mass 100; Obituary "$OB_PLUSHSENTRY"; Tag "$TAG_PLUSHSENTRY"; Species "Robot"; +NOPAIN +DONTTHRUST +NOTARGETSWITCH } states { Spawn: See: Pain: PLSH A -1; Stop; Death: PLSH A 1; PLSH AAAAAAAA 4 DoSnapMonsterExplode(); PLSH B -1 DoSnapMonsterDie(); Stop; GiantDeath: PLSH A 1; PLSH AAAAA 4 DoSnapBossExplode(); PLSH A 4 DoSnapBossBigExplode(); PLSH AAAAA 4 DoSnapBossExplode(); PLSH A 4 DoSnapBossBigExplode(); PLSH AAAAA 4 DoSnapBossExplode(); PLSH A 4 DoSnapBossBigExplode(); PLSH AAAAA 4 DoSnapBossExplode(); PLSH A 4 DoSnapBossBigExplode(); PLSH AAAAA 4 DoSnapBossExplode(); PLSH B -1 DoSnapBossDie(); Stop; } override void PostBeginPlay() { super.PostBeginPlay(); double offset = Radius + (GetDefaultByType("PlushSentryShield").Radius * Scale.X); double spAngle = Angle - 67.5; Tracer = Spawn( "PlushSentryShield", Vec3Offset( cos(spAngle) * offset, sin(spAngle) * offset, 0.0 ), ALLOW_REPLACE ); if (Tracer != null) { Tracer.Tracer = self; Tracer.Angle = Angle - 67.5; let sm = SnapMonster(Tracer); if (sm != null) { sm.MonsterModifiers = self.MonsterModifiers; sm.UpdateOurMonsterModifiers(); } } } override int DamageMobj(Actor inflictor, Actor source, int damage, Name mod, int dmgFlags, double angle) { int ret = super.DamageMobj(inflictor, source, damage, mod, dmgFlags, angle); if (Tracer != null && ret > 0) { Tracer.A_Pain(); if ((Tracer.Target == null || Tracer.Target.Health <= 0) && (Source != null && Source is "PlayerPawn" && Source.Health > 0)) { Tracer.Target = Source; Tracer.SetStateLabel("See"); // call look } } return ret; } override void Die(Actor source, Actor inflictor, int dmgFlags, Name mod) { if (Tracer != null && Tracer.Health > 0) { Tracer.Health = 0; Tracer.Die(self, self); } super.Die(source, inflictor, dmgFlags, mod); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapDizzy : SnapDynamicDecor { action void A_DizzyBlink() { bInvisible = !bInvisible; Vel.XY *= 0.5; if (Vel.Z < 0.0) { Vel.Z = 0.0; } else if (Vel.Z > 0.0) { double decel = 1.0; if (Vel.Z <= decel) { Vel.Z = 0.0; } else { Vel.Z -= decel; } } } Default { Radius 7; Height 12; +BRIGHT +RANDOMIZE +NOCLIP +NOINTERACTION +SnapStaticDecor.MISSILESPRITEFIX } States { Spawn: DIZY A 8; DIZY AAAAAAAA 1 A_DizzyBlink; Stop; } } class SnapJuggle : SnapDynamicDecor { action void A_JuggleBlink() { bInvisible = !bInvisible; } Default { Radius 14; Height 24; +BRIGHT +RANDOMIZE -NOGRAVITY } States { Spawn: DIZY BCDE 1; DIZY FGHI 1; DIZY JKLM 1; DIZY JJKKLLMM 1 A_JuggleBlink; Stop; } } extend class SnapMonster { const POISETIMELEN = 50; int Poise; uint PoiseTimer; uint PoiseMax; property Poise: PoiseMax; bool ReduceSnapMonsterPoise(uint amount, Name mod) { let monster = SnapMonster(self); if (!monster) { return false; } if (bNoPain == true) { return false; } if (mod == 'Melee') { // No poise reduce from melee attacks. amount = 0; } if (monster.kickTossed == true) { // Double poise reduce from guns when in kick state. monster.Poise -= amount * 2; // Wait for when you hit the ground, though. return false; } monster.Poise -= amount; if (monster.Poise <= 0) { bool result = TriggerPainChance(mod, true); if (result == true) { A_SnapStun(); monster.Poise = monster.PoiseMax; monster.PoiseTimer = 0; } return result; } else { monster.PoiseTimer = POISETIMELEN; return false; } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class PowerRefill : SnapInventory { Default { /* Inventory.PickupMessage "$POWERUP_POWMETER"; SnapInventory.VoiceSample "voice/powrefill"; */ +INVENTORY.QUIET // Sounds + message are now handled by AddSnapPOWMeter. } States { Spawn: PW_7 A 10; PW_7 A 10 Bright; Loop; } override bool TryPickup (in out Actor other) { let sp = SnapPlayer(other); if (sp && sp.SnapPlayerInfo.POWMeter < sp.SnapPOWMax) { sp.AddSnapPOWMeter(sp.SnapPOWMax, false, false); ItemExtendCombo(sp); GoAwayAndDie(); return true; } return false; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- mixin class SnapPickupCode { Sound VoiceSample; property VoiceSample: VoiceSample; const DESPAWNLEN = 10*TICRATE; uint DespawnTime; uint SnapPickupFlags; flagdef PickupDespawns: SnapPickupFlags, 0; flagdef TossedHitGround: SnapPickupFlags, 1; void PlayVoiceSample(Actor a) { let pawn = SnapPlayer(a); if (pawn == null) { return; } pawn.AddSnapVoice(VoiceSample); } void RunItemDespawn() { if (bPickupDespawns == false || bTossed == false) { DespawnTime = 0; return; } DespawnTime++; if (DespawnTime > DESPAWNLEN) { Destroy(); return; } else if (DespawnTime >= (DESPAWNLEN / 2)) { bInvisible = !bInvisible; } } void CheckTossedHitGround() { if (bTossed == false) { return; } if (Pos.Z <= FloorZ && Vel.Z <= 0) { bTossedHitGround = true; } } void DoShareEffects(PlayerInfo player) { // Does pickup flashes + messages + sounds for shared items. if (player == null || player.mo == null) { return; } if (PickupFlash != null) { Spawn(PickupFlash, player.mo.Pos, ALLOW_REPLACE); } if (bQuiet == false) { PrintPickupMessage(player.mo.CheckLocalView(), PickupMessage()); PlayPickupSound(player.mo); if (bNoScreenFlash == false && player.playerstate != PST_DEAD) { player.bonuscount = BONUSADD; } } } void ItemExtendCombo(Actor Toucher, bool Full = false) { let sp = SnapPlayer(Toucher); if (sp == null) { return; } if (Full == true) { sp.Combo.TimeReset(); } else { sp.Combo.TimeIncrease(SnapCombo.SMALL_ITEM_EXTENSION); } } } mixin class SnapPowerupFix { bool NewPowerupLogic(Inventory item) { if (item.GetClass() == GetClass()) { let power = Powerup(item); if (power.EffectTics == 0) { power.bPickupGood = true; return true; } // Color gets transferred if the new item has an effect. if (power.bAdditiveTime) { // Increase the effect's duration directly. EffectTics += power.EffectTics; BlendColor = power.BlendColor; } else if (EffectTics > power.EffectTics) { // If you have more than enough, then we don't want to give you the powerup. // Snap does this instead of the arbritrary BLINKTHRESHOLD shit :V return true; } else { if (EffectTics > 0) { // Snap: Combine two powerups into one big powerup, // kind of like additive time, but capped at the regular amount. int MaxTics = power.Default.EffectTics; EffectTics += power.EffectTics; if (EffectTics > MaxTics) { EffectTics = MaxTics; } } else { // Set instantly. EffectTics = power.EffectTics; } BlendColor = power.BlendColor; } power.bPickupGood = true; return true; } return false; } } class SnapInventory : Inventory abstract { mixin SnapShadowCarryover; mixin SnapShadowCode; mixin SnapPickupCode; override void BeginPlay() { super.BeginPlay(); ShadowBegin(); } override void Tick() { super.Tick(); ShadowTick(); RunItemDespawn(); CheckTossedHitGround(); } override void OnDestroy() { super.OnDestroy(); ShadowDestroy(); } override void DoPickupSpecial(Actor toucher) { PlayVoiceSample(toucher); if (bTossed == false) { ItemExtendCombo(toucher); } super.DoPickupSpecial(toucher); } Default { Radius 20; Height 24; Inventory.PickupSound "powerup/pickup"; SnapInventory.ShadowSize 16; //+INVENTORY.NOSCREENFLASH +FLOORCLIP } } class SnapBigPowerup : PowerupGiver abstract { mixin SnapShadowCarryover; mixin SnapShadowCode; mixin SnapPickupCode; override void BeginPlay() { super.BeginPlay(); ShadowBegin(); if (deathmatch == true) { // Halve duration in Versus. EffectTics /= 2; } } override void Tick() { super.Tick(); ShadowTick(); RunItemDespawn(); CheckTossedHitGround(); } override void OnDestroy() { super.OnDestroy(); ShadowDestroy(); } Default { Radius 30; Height 36; Inventory.MaxAmount 0; Inventory.PickupSound "powerup/passive"; Powerup.Duration -60; SnapBigPowerup.ShadowSize 16; +INVENTORY.AUTOACTIVATE +INVENTORY.BIGPOWERUP //+INVENTORY.NOSCREENFLASH +FLOORCLIP } override bool Use(bool pickup) { if (pickup == true && bTossed == true && bTossedHitGround == false) { // If this powerup was kicked out of you in Versus, // then prevent picking it up until it lands. return false; } return super.Use(pickup); } override void DoPickupSpecial(Actor toucher) { PlayVoiceSample(toucher); let pmo = SnapPlayer(toucher); if (pmo) { pmo.SetSnapMugshot(pmo.SNAPMUG_GOOD); ItemExtendCombo(pmo, true); } super.DoPickupSpecial(toucher); } } class SnapItemCanDebris : SnapDynamicDecor { Default { -NOGRAVITY } States { Spawn: COPN A 32; Stop; COPN B 32; Stop; } override void Tick() { super.Tick(); bInvisible = !bInvisible; } } class SnapItemCanDust : SnapDynamicDecor { Default { +BRIGHT } States { Spawn: COPN CCDEF 2; TNT1 A 35; Stop; } } class SnapItemCan : SnapMonster abstract { Default { Health 1; Radius 24; Height 36; Species "ItemCan"; SnapShadowActor.ShadowSize 16; DamageFactor 0.0; DamageFactor "Melee", 1.0; -SOLID // Square hitbox feels kinda clunky for this, lets write our own. +SPECIAL +NONSHOOTABLE +NOBLOOD +DONTGIB +NOICEDEATH +DONTTHRUST +DOHARMSPECIES +CANTSEEK -COUNTKILL -CANPUSHWALLS -CANUSEWALLS -ACTIVATEMCROSS -ISMONSTER -SnapActor.CANDROPAMMO +WEAPONSPAWN // Cans were designed for weapons, so remove this flag if you use it for something else. } void ItemCanDust() { Actor Particle = Spawn("SnapItemCanDust", Pos, ALLOW_REPLACE); if (Particle != null) { Particle.A_StartSound("powerup/open"); } } void ItemCanDestroy() { A_SnapNoBlocking(); double a = 0.0; double ab = 0.0; double addSpeed = 0.0; if (target != null) { a = target.Angle; addSpeed = target.Vel.XY.Length(); } else { a = frandom[snap_decor](-180, 180); } ab = a + 90; for (uint i = 0; i < 2; i++) { Actor Debris = Spawn("SnapItemCanDebris", Pos, ALLOW_REPLACE); if (Debris != null) { int sign = 1; if (i & 1) { sign = -1; } Debris.Angle = ab; Debris.Vel.XY = (4.0 + (addSpeed * 0.25)) * ( cos(ab), sin(ab) ); Debris.Vel.XY += (4.0 + (addSpeed * 1.5)) * ( cos(a), sin(a) ); Debris.Vel.Z = 12.0; Debris.SetState(Debris.SpawnState + i); Debris.bXFlip = random[snap_decor](0, 1); } ab += 180; } } States { Spawn: ICAN A 10; ICAN A 10 Bright; Loop; Death: ICAN B 1 Bright ItemCanDust(); ICAN B 0 ItemCanDestroy(); Stop; } override void WasKicked( Actor source, Actor hitPuff, uint KickDamage, Vector3 KickSpeed, int HitlagFrames, bool FromFriendly) { if (Health <= 0) { // Already dead. return; } if (bShootable == false || bDormant == true) { // Non-interactable. return; } Die(source, source, 0, "Melee"); AddHitstun(HitlagFrames, false); let sp = SnapPlayer(source); let sa = SnapActor(source); if (sp) { sp.AddHitstun(HitlagFrames, false); } else if (sa) { sa.AddHitstun(HitlagFrames, false); } target = source; } override void Touch(Actor toucher) { if (Health <= 0 || bKilled == true) { // We've been removed return; } if (toucher == null || toucher.Health <= 0) { // Toucher invalid return; } // Push player out of the hitbox. // (SOLID was a little TOO soild :p) Vector2 v = Vec2To(toucher); Vector2 dir = SnapUtils.SafeVec2Unit(v); double dist = v.Length(); double rad = radius; //(radius + toucher.radius); toucher.Vel.XY += dir * ((dist - rad) * 0.5); } } #include "zscript/snap/powerup/health.zs" #include "zscript/snap/powerup/speed.zs" #include "zscript/snap/powerup/shield.zs" #include "zscript/snap/powerup/damage.zs" #include "zscript/snap/powerup/dog.zs" #include "zscript/snap/powerup/pow.zs" #include "zscript/snap/powerup/ammo.zs" #include "zscript/snap/powerup/gun.zs" #include "zscript/snap/powerup/secret.zs" #include "zscript/snap/powerup/robotcore.zs" //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapHUD { virtual String GetSnapPowerupImage(Powerup power) { if (power is "SnapSpeedPower") { return "POW_SPD"; } else if (power is "SnapDamagePower") { return "POW_DMG"; } else if (power is "SnapShieldPower") { return "POW_RES"; } else if (power is "SnapDogPower") { return "POW_DOG"; } return ""; } void DrawPowerupDisplay(SnapPlayer sp, Vector2 PowerPos) { Inventory inv; for (inv = sp.Inv; inv; inv = inv.Inv) { let power = Powerup(inv); if (power) { int time = (power.EffectTics + (TICRATE-1)) / TICRATE; String img = GetSnapPowerupImage(power); DrawImage("HUDPWRBG", PowerPos, DI_ITEM_RIGHT_BOTTOM|DI_SCREEN_RIGHT_BOTTOM); DrawImage(img, PowerPos + (-18, 3), DI_ITEM_RIGHT_BOTTOM|DI_SCREEN_RIGHT_BOTTOM); DrawSnapNum(time, 2, PowerPos + (-18, -9), DI_ITEM_RIGHT_BOTTOM|DI_SCREEN_RIGHT_BOTTOM); PowerPos.Y -= 15; } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapPlayer { Actor SnapPlayerProjectile(class type, double SpreadOffset = 0.0, double SpreadPitch = 0.0) { double MoMidOffset = ViewHeight - FloorClip; let player = self.player; if (player != null) { MoMidOffset += player.crouchviewdelta; } Vector3 offset = (0, 0, MoMidOffset); double MissileRad = GetDefaultByType(type).Radius; double XYFix = Radius + MissileRad * 0.5; offset += RotateVector3((XYFix, 0, 0), Angle, Pitch); Vector3 TraceOffset = offset; double PMidOffset = GetDefaultByType(type).Height * 0.5; offset -= RotateVector3((0, 0, PMidOffset), Angle, Pitch); Vector2 weapOffset = (-12.0, -3.0); offset += RotateVector3((0, weapOffset.X, weapOffset.Y), Angle, Pitch); Vector3 FinalPos = Vec3Offset(offset.x, offset.y, offset.z); Actor projectile = Spawn(type, FinalPos, ALLOW_REPLACE); if (projectile) { PlaySpawnSound(projectile); projectile.target = self; projectile.angle = Angle; // temp Vector3 FinalDir = ( cos(Angle) * cos(-Pitch), sin(Angle) * cos(-Pitch), sin(-Pitch) ); Vector3 TracePos = Vec3Offset(TraceOffset.x, TraceOffset.y, TraceOffset.z); FLineTraceData data; bool result = LineTrace( Angle, 2048.0, Pitch, TRF_ABSPOSITION|TRF_ABSOFFSET|TRF_THRUHITSCAN|TRF_SOLIDACTORS, TracePos.z, TracePos.x, TracePos.y, data ); if (result == true) { if (data.HitType != TRACE_HitNone && data.NumPortals == 0) { Vector3 towards = Level.Vec3Diff(projectile.Pos, data.HitLocation - (0, 0, PMidOffset)); // Adjust by missile radius so that it appears more centered. // Without this, it's slightly offset to the right, since // its outer radius actually touches the part we aimed at // before the center does double dis = min(data.Distance, MissileRad); if (dis > 0.0) { towards -= data.HitDir * dis; } FinalDir = SnapUtils.SafeVec3Unit(towards); } } if (projectile.bFloorHugger == true || projectile.bCeilingHugger == true) { FinalDir.Z = 0.0; } if (SpreadOffset != 0.0) { FinalDir += sin(SpreadOffset) * ( cos(angle + 90), sin(angle + 90), 0.0 ); } if (SpreadPitch != 0.0) { FinalDir += RotateVector3((0, 0, sin(SpreadPitch)), Angle, Pitch); } FinalDir = SnapUtils.SafeVec3Unit(FinalDir); double FinalAngle = VectorAngle(FinalDir.X, FinalDir.Y); double FinalPitch = -VectorAngle(FinalDir.XY.Length(), FinalDir.Z); projectile.angle = FinalAngle; projectile.pitch = FinalPitch; projectile.Vel = RotateVector3((GetDefaultSpeed(type), 0, 0), FinalAngle, FinalPitch); Vector3 addSpeed = (0, 0, 0); double moSpeed = Vel.Length(); if (moSpeed > 0.0) { Vector3 pvu = SnapUtils.SafeVec3Unit(projectile.Vel); double mul = pvu dot SnapUtils.SafeVec3Unit(Vel); if (mul > 0.0) { addSpeed = pvu * moSpeed * mul; } } projectile.Vel += addSpeed; if (projectile.bSeekerMissile == true) { projectile.tracer = FindHomingTarget(1024, FinalAngle, self); } if (projectile.bSpectral == true) { projectile.SetFriendPlayer(player); } if (projectile.CheckMissileSpawn(projectile.radius) == true) { return projectile; } } return null; } void TossCurrentWeapon() { // I don't like how this came out. // I'll polish it later. return; if (CountInv("SnapPowerupAmmo") <= 0) { // No weapon return; } let WeapProps = SnapWeaponProps.GetWeaponPropsByID(WeaponPower); if (WeapProps == null) { // Invalid weapon. return; } class item = WeapProps.PickupType; if (item == null) { // Invalid item to toss. return; } double spawnZ = Height * 0.5; double spreadOut = 4.0; Actor mo = Spawn(item, Pos + (0, 0, spawnZ), ALLOW_REPLACE); if (mo) { mo.bDropped = true; mo.bNoGravity = false; mo.Vel = ( spreadOut * cos(angle + 180), spreadOut * sin(angle + 180), 8.0 ); let inv = Inventory(mo); if (inv) { //inv.ModifyDropAmount(amountPerDrop); inv.bTossed = true; if (inv.SpecialDropAction(self)) { inv.Destroy(); } } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapPlayer { // Kicked dust trail flag bool kickTossed; // Was recently pushed by an external force. // Used to properly award frags in cases of environment kills. const PushDecayTicks = 3*TICRATE; Actor PushSource; uint PushDecay; const KICKDMG = 70; // Player's base kick damage const KICKTHRUST = 16.0; // Player's base kick thrust void SetPushSource(Actor src) { if (src == null) { return; } PushSource = src; PushDecay = PushDecayTicks; } virtual void WasKicked( Actor source, Actor hitPuff, uint KickDamage, Vector3 KickSpeed, int HitstunFrames, bool FromFriendly) { if (Health <= 0) { // Already dead. return; } if (bShootable == false || bDormant == true) { // Non-interactable. return; } let srcPMobj = SnapPlayer(source); if (srcPMobj != null) { bool teammate = isTeammate(srcPMobj); if (teammate == true) { // Just give a light playful shove :) Vel.XY += KickSpeed.XY; if (Vel.Z < 0.0) { // Set speed when falling. Vel.Z = KickSpeed.Z; } else { // Add speed when rising. Vel.Z += KickSpeed.Z; } AddHitstun(HitstunFrames, true); srcPMobj.AddHitstun(HitstunFrames, false); } else { // Sorta emulate the monster kicks in PvP Vel = KickSpeed; int dr = DamageMobj(srcPMobj, srcPMobj, KickDamage, 'Melee'); if (dr > 0) { srcPMobj.AddHitstun(HitstunFrames, false); } // For players, kickTossed handles the dust trail // and persists push source for longer. kickTossed = true; SetPushSource(srcPMobj); SpillPowerups(); } } else { Vel = KickSpeed; int dr = DamageMobj(source, source, KickDamage, 'Melee'); if (dr > 0) { let sa = SnapActor(source); if (sa != null) { sa.AddHitstun(HitstunFrames, false); } } kickTossed = true; SetPushSource(source); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapRapidProps : SnapWeaponProps { override void Init() { WeaponName = "Rapid"; NiceName = "$SNAPMENU_WEAPON_RAPID"; PickupType = "SnapRapidPowerup"; WeaponIcon = "WP_RAPID"; FireState = "FireRapid"; DropFreq = 5; } } class SnapRapidCan : SnapItemCan { Default { DropItem "SnapRapidPowerup"; } States { Spawn: WP_R A 10; WP_R A 10 Bright; Loop; } } class SnapRapidPowerup : SnapWeaponPowerup { Default { SnapWeaponPowerup.WeaponPower "Rapid"; Inventory.PickupMessage "$POWERUP_RAPID"; SnapInventory.VoiceSample "voice/rapid"; } States { Spawn: WP_R B 10; WP_R B 10 Bright; Loop; } } class SnapRapidShot : SnapBasicShot { // Rapid was the first powerup to be made. // It is the most simplistic, and it was used as the // measuring stick to balance out the rest. Default { DamageFunction 10; DamageType "Rapid"; Obituary "$OB_RAPID"; Speed 60; } States { Spawn: RBUL A 3 Light("RapidShotLight"); RBUL B 2 Light("RapidShotLight"); Loop; Death: RBUL CCCDDEF 1 Light("RapidShotLight"); Stop; } } extend class SnapGun { action void A_SnapgunRapid(bool takeAmmo) { if (player == null || player.mo == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } A_SnapgunFlash('RapidFlash'); A_SnapgunMomentumProjectile("SnapRapidShot"); A_StartSound("revolver/rapid", CHAN_WEAPON); SoundAlert(self); if (takeAmmo == true) { player.mo.TakeInventory("SnapPowerupAmmo", 1, false, true); } } States { FireRapid: SGUN A 1 A_SnapgunRapid(true); SGUN BC 1; SGUN A 1 A_SnapgunRapid(false); SGUN BC 1; SGUN A 1 A_SnapgunRapid(false); SGUN BC 1; SGUN A 0 A_SnapGunRefire(); SGUN D 1; SGUN E 6; SGUN F 5; Goto GunIdle; RapidFlash: TNT1 A 1 Bright A_Light(2); SFL1 A 1 Bright A_Light(1); SFL1 B 1 Bright A_Light(0); SFL1 C 1 Bright; SFL1 D 1 Bright; Goto LightDone; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapRadiusDamageEFXRootBeer : SnapRadiusDamageEFX { States { Spawn: RDRB A 2 NoDelay A_SetRenderStyle(GetDMGAlpha(), STYLE_Translucent); RDRB B 1 Light("RadiusExplosionLight") A_SetRenderStyle(GetDMGAlpha(), STYLE_Add); RDRB C 2 Light("RadiusExplosionLightRootBeer1"); RDRB D 2 Light("RadiusExplosionLightRootBeer2"); RDRB E 2 Light("RadiusExplosionLightRootBeer3"); Stop; } } class RootBeerBombUnderlay : SnapActor { Default { Radius 24; Height 72; Health 1000; +NOINTERACTION +NOBLOCKMAP +NOGRAVITY } States { Spawn: RBBM ABCDEFGH 1; Loop; } override void Tick() { if (Target == null) { Destroy(); return; } super.Tick(); Vector2 offset = SnapShadow.ShadowAdjust(-10000.0); SetOrigin(( Target.Pos.X + offset.X, Target.Pos.Y + offset.Y, Target.Pos.Z ), true); FloorClip = Target.FloorClip; } } class RootBeerBomb : SnapMonster { Actor Underlay; Default { Health 70; Radius 24; Height 72; Obituary "$OB_ROOTBEERBOMB"; DeathSound "explosion/enemy"; Species "RootBeerBomb"; SnapShadowActor.ShadowSize 32; DamageFactor 0.0; DamageFactor "Melee", 1.0; +NOBLOOD +DONTGIB +NOICEDEATH +DOHARMSPECIES +CANTSEEK -COUNTKILL -CANPUSHWALLS -CANUSEWALLS -ACTIVATEMCROSS -ISMONSTER +ACTIVATEIMPACT +ACTIVATEPCROSS -SnapActor.CANDROPAMMO } void RootBeerExplode() { A_SnapNoBlocking(); A_Scream(); if (Underlay != null) { Underlay.Destroy(); } A_SnapExplode(300, 384, XF_THRUSTZ|XF_CIRCULAR|XF_NOTMISSILE, VisualType: "SnapRadiusDamageEFXRootBeer", dmgType: "RootBeerExplode"); let sp = SnapPlayer(Target); if (sp != null) { int index = sp.Combo.Items.Find(self); if (index != sp.Combo.Items.Size()) { sp.Combo.Items.Delete(index); } } } States { Spawn: RBBM I -1; Loop; Kicked: RBBM IJKLMNOP 5; Loop; Death: RBBM M 1; TNT1 A 35 RootBeerExplode(); Stop; } override void WasKicked( Actor source, Actor hitPuff, uint KickDamage, Vector3 KickSpeed, int HitlagFrames, bool FromFriendly) { if (Health <= 0) { // Already dead. return; } if (bShootable == false || bDormant == true) { // Non-interactable. return; } let oldPlayer = SnapPlayer(Target); let newPlayer = SnapPlayer(Source); if (oldPlayer != newPlayer) { if (oldPlayer != null) { int index = oldPlayer.Combo.Items.Find(self); if (index != oldPlayer.Combo.Items.Size()) { oldPlayer.Combo.Items.Delete(index); } } if (newPlayer != null) { newPlayer.Combo.Items.Push(self); } } if (kickTossed == false) { SetStateLabel("Kicked"); } Target = Source; Vel = KickSpeed; kickTossed = true; bSkullFly = true; } override void KickTossEnd() { kickTossed = false; bNoGravity = Default.bNoGravity; A_Die("Melee"); } bool BombFromFriend(Actor victim) { if (victim == null) { return false; } if (Target != null) { if (victim == Target) { return true; } if (victim.IsTeammate(Target) == true) { return true; } } return false; } override int DoSpecialDamage(Actor victim, int damage, name mod) { int value = super.DoSpecialDamage(victim, damage, mod); if (mod == "RootBeerExplode") { if (BombFromFriend(victim) == true) { // Reduce friendly fire significantly. value = 5; } else if (victim is "PlayerPawn") { // Deal a good chunk of damage. value = 20; } } return value; } override bool Slam(Actor victim) { if (Pos.Z > victim.Pos.Z + victim.Height || Pos.Z + Height < victim.Pos.Z) { return true; } if (kickTossed == true && victim.bShootable == true) { KickTossEnd(); } return true; } override void KickTossThink() { Angle = VectorAngle(Vel.X, Vel.Y); if (Tics > 1) { int AnimSpeed = 5 - (int)(Vel.Length() / 4.0); Tics = min(Tics, max(1, AnimSpeed)); } int result = CheckSolidFooting(); if ((result & CSF_FLOORMASK) != 0) { KickTossEnd(); } else { Vector2 kickedWallBounce = GetWallBounceDir(); if (kickedWallBounce.Length() > 0) { Vel.XY = kickedWallBounce * Vel.XY.Length() * 0.1; } } } override void OnDestroy() { if (Underlay != null) { Underlay.Destroy(); } super.OnDestroy(); } override void BeginPlay() { super.BeginPlay(); Actor a = Spawn("RootBeerBombUnderlay", Pos, ALLOW_REPLACE); if (a != null) { Underlay = a; a.Target = self; let sa = SnapActor(a); if (sa != null) { sa.SetHitstunParent(self); } } } } class RootBeerBombSpawner : SnapStaticDecor { const NEW_BOMB_TIME = TICRATE; uint BombSpawnTimer; Default { Radius 24; Height 72; DeathSound "rbbomb/spawn"; } override void Tick() { super.Tick(); if (Target == null) { BombSpawnTimer++; if (BombSpawnTimer >= NEW_BOMB_TIME) { Target = Spawn("RootBeerBomb", Pos, ALLOW_REPLACE); BombSpawnTimer = 0; A_Scream(); } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapRecordItem : SnapMenuItemBase { mixin SnapIntermissionDrawing; SnapMapRecord mRecords[NUM_RECORD_SKILLS]; String mStage; String mLump; TextureID GradeSelector; TextureID TitleBG; uint StarOffset; SnapRecordItem Init() { super.Init("", 'None', true); IntermissionPrecache(); GradeSelector = TexMan.CheckForTexture("GSELECT", TexMan.Type_MiscPatch); TitleBG = TexMan.CheckForTexture("STAT_TTL", TexMan.Type_MiscPatch); StarOffset = 0; return self; } override int GetLineSpacing() { return 34; } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { UpdateScaleParameters(); Vector2 BasePos = (BASE_VID_WIDTH * 0.5 + xOffset, yOffset); Vector2 TitlePos = BasePos + (-20, 14); if (Parent != null) { TitlePos.X -= (1.0 - Parent.MenuTransition) * VirtualSize.X; } Vector2 LumpPos = TitlePos + (-21, -12); int LumpLength = FontSmall.StringWidth(mLump); DrawSticker(LumpPos + (0, 2), 36, STICKER_TYPE_TEXT); SnapMenuText( FontSmall, Font.CR_UNTRANSLATED, CenterAlignPos(FontSmall, mLump, LumpPos), mLump ); SnapMenuTexture(TitleBG, TitlePos + (-136, 1)); SnapMenuText( FontBig, Font.CR_UNTRANSLATED, RightAlignPos(FontBig, mStage, TitlePos), mStage ); Vector2 GradePos = BasePos + (-8, 2); if (Parent != null) { GradePos.X += (1.0 - Parent.MenuTransition) * VirtualSize.X; } for (uint i = 0; i < NUM_RECORD_SKILLS; i++) { int Grade = GRADE_INVALID; if (mRecords[i] != null) { Grade = mRecords[i].Grade; } DrawGrade(Grade, GradePos, Menu.MenuTime() + (256 * (StarOffset + i))); if (selected == true) { let p = SnapRecordMenu(Parent); if (p != null && p.SkillSelected == i) { SnapMenuTexture(GradeSelector, GradePos); } } GradePos.X += 36; } return xOffset; } override bool MenuEvent(int mKey, bool gamepad) { let p = SnapRecordMenu(Parent); if (p != null) { if (mkey == Menu.MKEY_Enter && p.SkillSelected >= 0 && p.SkillSelected < NUM_RECORD_SKILLS) { let record = mRecords[p.SkillSelected]; if (record == null) { Menu.MenuSound("menu/nope"); return true; } let NewMenu = SnapIntermissionMenu( new("SnapIntermissionMenu") ); NewMenu.Init(p, "", 1, true, 'None', null); NewMenu.record = record; NewMenu.MapName = mStage; NewMenu.ActivateMenu(); return true; } else if (mkey == Menu.MKEY_Left && p.SkillSelected > 0) { p.SetRecordSkill(p.SkillSelected - 1); } else if (mkey == Menu.MKEY_Right && p.SkillSelected < NUM_RECORD_SKILLS - 1) { p.SetRecordSkill(p.SkillSelected + 1); } else { return false; } Menu.MenuSound("menu/change"); return true; } return false; } const RECORD_BOX_SIZE = 36; const RECORD_BOX_START = (BASE_VID_WIDTH * 0.5) - 8; override bool MouseEvent(int type, int x, int y) { let p = SnapRecordMenu(Parent); if (p != null) { int newSkill = (x - (RECORD_BOX_START + VirtualOffset.X)) / RECORD_BOX_SIZE; newSkill = clamp(newSkill, 0, NUM_RECORD_SKILLS-1); p.SetRecordSkill(newSkill); } return super.MouseEvent(type, x, y); } override void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.Offscreen(); } } class SnapRecordMenu : SnapMenuBase { uint SkillSelected; SnapEpisodeDef EpisodeDef; void CreateRecordItem(SnapMapDef MapDef, uint Index) { if (MapDef.RecordVar == null) { // Map doesn't save records, don't show. return; } let item = SnapRecordItem( new("SnapRecordItem") ); item.Init(); mDesc.mItems.Push(item); item.OnMenuCreated(); item.Parent = self; item.mLump = MapDef.ID; item.StarOffset = Index; bool HasAnyRecord = false; for (uint i = 0; i < NUM_RECORD_SKILLS; i++) { item.mRecords[i] = SnapMapRecord.Get(MapDef.ID, i + FIRST_GRADED_SKILL); if (item.mRecords[i] != null) { HasAnyRecord = true; } } if (HasAnyRecord == true) { item.mStage = MapDef.Title; } else { item.mStage = "$SNAPMENU_RECORD_NOTVISITED"; } } override void Init(Menu parent, OptionMenuDescriptor desc) { super.Init(parent, desc); EpisodeDef = SnapMenuData.GetSelectedEpisode(); if (EpisodeDef == null) { ThrowAbortException("SnapRecordMenu accessed without episode selected."); return; } uint NumItems = mDesc.mItems.Size(); for (uint i = 0; i < NumItems; i++) { let item = mDesc.mItems[i]; if (item is "SnapRecordItem") { item.Destroy(); mDesc.mItems.Delete(i); i--; NumItems--; continue; } } uint NumMaps = EpisodeDef.MapList.Size(); for (uint i = 0; i < NumMaps; i++) { SnapMapDef MapDef = EpisodeDef.MapList[i]; if (MapDef != null) { CreateRecordItem(MapDef, i); } } SetRecordSkill(1); SetSelectedItem(0); } void SetRecordSkill(int value) { if (value < 0 || value >= NUM_RECORD_SKILLS) { return; } SkillSelected = value; } override void ItemsDrawer() { super.ItemsDrawer(); Vector2 SkillPos = (BASE_VID_WIDTH * 0.5, 0) + (-8, 2) + (72, 28); SkillPos.Y -= (1.0 - MenuTransition) * (VirtualSize.Y * 0.5); DrawSticker(SkillPos + (0, 2), 138, STICKER_TYPE_TEXT); Vector2 SkillText = SkillPos - (54, 0); for (uint i = 0; i < NUM_RECORD_SKILLS; i++) { String disp = "X"; int col = FontGrayColor; switch (i) { case 0: disp = Stringtable.Localize("$SNAPMENU_SKILL_EASY_ACRONYM"); col = Font.FindFontColor("HPGreen"); break; case 1: disp = Stringtable.Localize("$SNAPMENU_SKILL_NORMAL_ACRONYM"); col = Font.FindFontColor("HPYellow"); break; case 2: disp = Stringtable.Localize("$SNAPMENU_SKILL_HARD_ACRONYM"); col = Font.FindFontColor("HPOrange"); break; case 3: disp = Stringtable.Localize("$SNAPMENU_SKILL_RUDE_ACRONYM"); col = Font.FindFontColor("HPRed"); break; } SnapMenuText( FontSmall, col, CenterAlignPos(FontSmall, disp, SkillText), disp ); SkillText.X += 36; } Vector2 HeaderPos = (BASE_VID_WIDTH * 0.5, 8); HeaderPos.Y -= (1.0 - MenuTransition) * (VirtualSize.Y * 0.5); String LabelText = Stringtable.Localize("$SNAPMENU_RECORD"); DrawMenuHeader( LabelText, CenterAlignPos(FontHeader, LabelText, HeaderPos) ); } } class SnapIntermissionMenu : SnapMenuMessageBox { // Replicate the intermission screen. // Thought about trying to do more of this with a mixin, // but these two screens are just so annoyingly different. mixin SnapIntermissionDrawing; SnapMapRecord record; String MapName; override void Init(Menu parent, String message, int messageMode, bool playSound, Name cmd, voidptr nativeHandler) { super.Init(parent, message, messageMode, playSound, cmd, nativeHandler); IntermissionPrecache(); } int GetScore() { return (record.RobotScore + record.SecretScore + record.ComboScore + record.TimeScore); } void DrawTitle() { Vector2 TitleOffset = ((1.0 - MenuTransition) * VirtualSize.X, 0); if (TransitionSpeed < 0.0) { TitleOffset = -TitleOffset; } DrawTexture(TitleStrip, (0, 10) + TitleOffset); DrawText(standardFont, standardColor, (32, 8) + TitleOffset, MapName); DrawTextRightAligned(headerFont, headerColor, (288, 8) + TitleOffset, "$INTER_RESULT"); } override void Drawer() { UpdateScaleParameters(); if (mParentMenu) { mParentMenu.Drawer(); } Screen.Dim( Color(0, 0, 0), MenuTransition * 0.75, 0, 0, int(RealSize.X), int(RealSize.Y) ); Vector2 StatsOffset = (0, (1.0 - MenuTransition) * VirtualSize.Y); DrawTexture(StatsBG, (48, 28) - StatsOffset); DrawText(standardFont, standardColor, (60, 36) - StatsOffset, "$INTER_KILLS"); DrawTotal(standardFont, standardColor, (207, 36) - StatsOffset, record.Robots, record.TotalRobots); drawNum(bonusFont, (260, 38) - StatsOffset, record.RobotScore, 0, true, (record.Robots >= record.TotalRobots) ? bonusColor : standardColor ); DrawText(standardFont, standardColor, (60, 55) - StatsOffset, "$INTER_SECRET"); DrawTotal(standardFont, standardColor, (207, 55) - StatsOffset, record.Secrets, record.TotalSecrets); drawNum(bonusFont, (260, 57) - StatsOffset, record.SecretScore, 0, true, (record.Secrets >= record.TotalSecrets) ? bonusColor : standardColor ); DrawText(standardFont, standardColor, (60, 74) - StatsOffset, "$INTER_COMBO"); DrawTotal(standardFont, standardColor, (207, 74) - StatsOffset, record.Combos, record.TotalCombos); drawNum(bonusFont, (260, 76) - StatsOffset, record.ComboScore, 0, true, (record.Combos >= record.TotalCombos) ? bonusColor : standardColor ); int timeColor = standardColor; if (record.TimeScore < 0) { timeColor = headerColor; } else if (record.Time <= record.ParTime) { timeColor = bonusColor; } DrawText(standardFont, standardColor, (60, 93) - StatsOffset, "$INTER_TIME"); DrawTimeCompare(standardFont, standardColor, (207, 93) - StatsOffset, record.Time, record.ParTime); drawNum(bonusFont, (260, 95) - StatsOffset, record.TimeScore, 0, true, timeColor ); DrawText(headerFont, headerColor, (60, 114) - StatsOffset, "$INTER_TOTAL"); drawNum(standardFont, (260, 114) - StatsOffset, record.RobotScore + record.SecretScore + record.ComboScore + record.TimeScore, 0, true, headerColor ); // Rankometer DrawText(rankFont, rankColor, CenterAlignPos(rankFont, "$INTER_RANK", (159.5, 139)) + StatsOffset, "$INTER_RANK"); DrawGrade( record.Grade, (142, 148) + StatsOffset, Menu.MenuTime() ); DrawRankometer( GetScore(), record.MapScore, (60, 180) + StatsOffset, Menu.MenuTime() ); DrawTitle(); if (StringTable.Localize("$SNAPVERSION") != record.VerStr) { DrawText(rankFont, rankColor, (1, 189) + StatsOffset, record.VerStr); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- // These aren't great, but they are a little better // than nothing at all... class SnapRelativeSkyOrigin : SnapStaticDecor { Default { +NOSECTOR } } class SnapRelativeSky : SkyViewPoint { Vector3 OurOrigin; Vector3 LevelOrigin; Default { +NOINTERACTION } override void PostBeginPlay() { super.PostBeginPlay(); OurOrigin = Pos; Actor mo = null; if (tid != 0) { // Find a matching level origin. ActorIterator it = Level.CreateActorIterator(tid); mo = it.Next(); while (mo) { if (mo is "SnapRelativeSkyOrigin") { break; } mo = it.Next(); } } if (mo == null) { ThinkerIterator it = ThinkerIterator.Create("SnapRelativeSkyOrigin"); mo = Actor(it.Next()); if (mo == null) { A_Log("Could not find a relative skybox level origin."); LevelOrigin = OurOrigin; return; } } LevelOrigin = mo.Pos; } override void Tick() { Vector3 CameraPos = LevelOrigin; PlayerInfo player = players[consoleplayer]; if (player != null && player.camera != null) { CameraPos = player.camera.Pos; // Can potentially not be themselves. PlayerInfo camPlayer = player.camera.player; if (camPlayer != null) { CameraPos.Z = camPlayer.viewz; } else { CameraPos.Z += player.camera.GetCameraHeight(); } } Vector3 Offset = CameraPos - LevelOrigin; Vector3 NewPos = OurOrigin + ( Offset.X * Scale.X, Offset.Y * Scale.X, Offset.Z * Scale.Y ); SetOrigin(NewPos, true); super.Tick(); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapEventHandler { class GetCarReplacement(bool moving) { int carRNG = random[snap_decor](0, 5); switch (carRNG) { default: return (moving ? "SnapCarMoving" : "SnapCar"); case 3: return (moving ? "SnapTruckMoving" : "SnapTruck"); case 4: return (moving ? "SnapBuggyMoving" : "SnapBuggy"); case 5: return (moving ? "SnapSportzMoving" : "SnapSportz"); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- mixin class SnapPlayerResistances { Default { //SelfDamageFactor 0.0; // Versus damage modifiers //DamageFactor "Basic", 1.2; DamageFactor "Mirror", 1.4; DamageFactor "Boomerang", 0.5; DamageFactor "Charge", 0.5; //DamageFactor "Fire", 2.0; // This one is handled by SnapFlameShot, to not affect other instances of fire damage. // Cars only deal lots of damage so that robots get torn up by them. DamageFactor "Roadkill", 0.3; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapAchievementReward abstract { bool IsCustomGameOption; // If true, this also unlocks the Custom Game mode. abstract String GetTexture(); abstract String RewardString(); virtual void Initialize() { // NOP } virtual void DeserializeArgs(JsonObject Obj) { // NOP } static bool AllCustomGameOptionsLocked() { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return true; } SnapDefinitions defs = ev.SnapDefs; if (defs == null) { return true; } MapIterator it; if (it.Init(defs.AchievementMap) == false) { return true; } while (it.Next() == true) { let Achievement = it.GetValue(); if (Achievement == null) { continue; } let Reward = Achievement.Reward; if (Reward == null) { continue; } if (Reward.IsCustomGameOption == false) { continue; } if (Achievement.RewardUnlocked() == true) { // We got something! return false; } } return true; } } class SnapReward_FreeSpace : SnapAchievementReward { override String GetTexture() { return "A_FREE"; } override String RewardString() { return String.Format( "%s %s", StringTable.Localize("$SNAPMENU_REWARD_CHALLENGE"), StringTable.Localize("$SNAPMENU_REWARD_FREE") ); } static uint CountFreeSpaces() { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return 0; } SnapDefinitions defs = ev.SnapDefs; if (defs == null) { return 0; } MapIterator it; if (it.Init(defs.AchievementMap) == false) { return 0; } int UnlockedFreeSpaces = 0; int UsedFreeSpaces = 0; while (it.Next() == true) { let Achievement = it.GetValue(); if (Achievement == null) { continue; } if (Achievement.StatusVar != null) { int Status = Achievement.StatusVar.GetInt(); if (Status & Achievement.STATUS_FLAG_SKIPPED) { UsedFreeSpaces++; } } let Reward = SnapReward_FreeSpace(Achievement.Reward); if (Reward == null) { continue; } if (Achievement.RewardUnlocked() == true) { UnlockedFreeSpaces++; } } int diff = (UnlockedFreeSpaces - UsedFreeSpaces); if (diff < 0) { return 0; } return diff; } } class SnapReward_CustomGameOption : SnapAchievementReward { enum CustomOptionMode { TYPE_UNDEFINED, TYPE_SINGLEWEAPON, TYPE_ROBOTSEXPLODE, TYPE_CRASHRATIONS, TYPE_ROBOTSFAST, TYPE_ROBOTSRESIST, TYPE_ROBOTSDAMAGE, } uint Type; override void Initialize() { IsCustomGameOption = true; } override String GetTexture() { return "A_CUSTOM"; } override String RewardString() { String TypeStr = "???"; switch (Type) { case TYPE_SINGLEWEAPON: { TypeStr = "$SNAPMENU_CUSTOM_WEAPON"; break; } case TYPE_ROBOTSEXPLODE: { TypeStr = "$SNAPMENU_CUSTOM_ROBOTS_EXPLODE"; break; } case TYPE_CRASHRATIONS: { TypeStr = "$SNAPMENU_CUSTOM_SEPTACRASH_RATIONS"; break; } case TYPE_ROBOTSFAST: { TypeStr = "$SNAPMENU_CUSTOM_ROBOTS_FAST"; break; } case TYPE_ROBOTSRESIST: { TypeStr = "$SNAPMENU_CUSTOM_ROBOTS_RESIST"; break; } case TYPE_ROBOTSDAMAGE: { TypeStr = "$SNAPMENU_CUSTOM_ROBOTS_DAMAGE"; break; } default: { break; } } return String.Format("%s %s", StringTable.Localize("$SNAPMENU_REWARD_OPTION"), StringTable.Localize(TypeStr)); } override void DeserializeArgs(JsonObject Obj) { String TypeStr = ""; SnapDefinition.ParseForString(TypeStr, Obj, "type"); if (TypeStr ~== "SingleWeapon") { Type = TYPE_SINGLEWEAPON; } else if (TypeStr ~== "RobotsExplode") { Type = TYPE_ROBOTSEXPLODE; } else if (TypeStr ~== "SeptacrashRations") { Type = TYPE_CRASHRATIONS; } else if (TypeStr ~== "RobotsFast") { Type = TYPE_ROBOTSFAST; } else if (TypeStr ~== "RobotsResist") { Type = TYPE_ROBOTSRESIST; } else if (TypeStr ~== "RobotsDamage") { Type = TYPE_ROBOTSDAMAGE; } } static bool CustomOptionUnlocked(uint LookForType) { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return false; } SnapDefinitions defs = ev.SnapDefs; if (defs == null) { return false; } MapIterator it; if (it.Init(defs.AchievementMap) == false) { return false; } while (it.Next() == true) { let Achievement = it.GetValue(); if (Achievement == null) { continue; } let Reward = SnapReward_CustomGameOption(Achievement.Reward); if (Reward == null) { continue; } if (Reward.Type != LookForType) { continue; } if (Achievement.RewardUnlocked() == true) { return true; } } return false; } } class SnapReward_BonusMap : SnapAchievementReward { String MapLump; override String GetTexture() { return "A_MAP"; } override String RewardString() { return String.Format("%s %s", StringTable.Localize("$SNAPMENU_REWARD_MAP"), SnapMapDef.GetMapTitle(MapLump)); } override void DeserializeArgs(JsonObject Obj) { SnapDefinition.ParseForString(MapLump, Obj, "map"); } static bool BonusMapUnlocked(Name MapLump) { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return false; } SnapDefinitions defs = ev.SnapDefs; if (defs == null) { return false; } MapIterator it; if (it.Init(defs.AchievementMap) == false) { return false; } while (it.Next() == true) { let Achievement = it.GetValue(); if (Achievement == null) { continue; } let Reward = SnapReward_BonusMap(Achievement.Reward); if (Reward == null) { continue; } if (Reward.MapLump == MapLump) { return Achievement.RewardUnlocked(); } } return true; } } class SnapReward_BonusCharacter : SnapAchievementReward { String ClassName; override void Initialize() { IsCustomGameOption = true; } override String GetTexture() { return "A_CHAR"; } override String RewardString() { return String.Format( "%s %s", StringTable.Localize("$SNAPMENU_REWARD_OPTION"), PlayerPawn.GetPrintableDisplayName(ClassName) ); } override void DeserializeArgs(JsonObject Obj) { SnapDefinition.ParseForString(ClassName, Obj, "class"); } static bool BonusCharacterUnlocked(int ID) { if (ID < 0 || ID >= PlayerClasses.Size()) { // Out of range return false; } if (ID == 0) { // Always allow our base character. return true; } let ev = SnapStaticEventHandler.Get(); if (ev == null) { return false; } SnapDefinitions defs = ev.SnapDefs; if (defs == null) { return false; } MapIterator it; if (it.Init(defs.AchievementMap) == false) { return false; } while (it.Next() == true) { let Achievement = it.GetValue(); if (Achievement == null) { continue; } let Reward = SnapReward_BonusCharacter(Achievement.Reward); if (Reward == null) { continue; } PlayerClass ClassData = PlayerClasses[ID]; if (ClassData.Type != Reward.ClassName) { continue; } return Achievement.RewardUnlocked(); } return true; } } class SnapReward_Custom : SnapAchievementReward { Name ID; String Label; override String GetTexture() { return "A_STAR"; } override String RewardString() { return String.Format( "%s %s", StringTable.Localize("$SNAPMENU_REWARD_CHALLENGE"), StringTable.Localize(Label) ); } override void DeserializeArgs(JsonObject Obj) { SnapDefinition.ParseForName(ID, Obj, "id"); SnapDefinition.ParseForString(Label, Obj, "label"); } static bool CustomUnlocked(Name ID) { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return false; } SnapDefinitions defs = ev.SnapDefs; if (defs == null) { return false; } MapIterator it; if (it.Init(defs.AchievementMap) == false) { return false; } while (it.Next() == true) { let Achievement = it.GetValue(); if (Achievement == null) { continue; } let Reward = SnapReward_Custom(Achievement.Reward); if (Reward == null) { continue; } if (ID != Reward.ID) { continue; } if (Achievement.RewardUnlocked() == false) { return false; } } return true; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class RiotRoboBullet : SnapMissile { Default { Radius 16; Height 32; Speed 10; DamageFunction 5; Scale 2.0; RenderStyle "Add"; SeeSound "riotRobo/shoot"; DeathSound "revolver/death"; Obituary "$OB_RIOTROBO"; +RANDOMIZE +BRIGHT } States { Spawn: PMMS ABACAD 2 Light("RiotRoboBulletLight"); Loop; Death: PMMS GGGHHIJ 1 Light("RiotRoboBulletLight"); Stop; } } class RiotRobo : SnapMonster { const RIOTATKANG = 22.5; int RiotAtkSign; void RiotAttackSetup() { if (target == NULL) { return; } if (SnapUtils.SafeVec2Unit(target.Vel.XY) dot AngleToVector(angle + 90) < 0.0) { RiotAtkSign = -1; } else { RiotAtkSign = 1; } } void RiotAttackAim(int phase = 0) { if (target == null || target.Health <= 0) { return; } double a = AngleTo(target) + (RIOTATKANG * RiotAtkSign * phase); Angle = SnapUtils.AngleTowardsAngle(Angle, a); } void RiotAttack(int phase = 0) { if (Target == null) { return; } double AimPitch = 0.0; if ((Target.Pos.Z > Pos.Z + Height) || (Target.Pos.Z + Target.Height < Pos.Z)) { Vector2 XYDiff = Vec2To(Target); double OurCenter = Pos.Z + (Height * 0.5); double TheirCenter = Target.Pos.Z + (Target.Height * 0.5); double ZDiff = TheirCenter - OurCenter - FloorClip; AimPitch = VectorAngle(XYDiff.Length(), ZDiff); } A_SnapMonsterProjectile( "RiotRoboBullet", (0, 0, 12), Angle, AimPitch, SMP_ABSOLUTEANGLE|SMP_ABSOLUTEPITCH|SMP_DONTAIM ); } void RiotBackup() { if (target != NULL) { double a = AngleTo(target); Angle = SnapUtils.AngleTowardsAngle(Angle, a, 2.0); } Vel.XY = -SnapUtils.SafeVec2Unit( (cos(Angle), sin(Angle)) ) * Speed * 2.0; } const JUMP_IN_SPEED_H = 12.0; const JUMP_IN_SPEED_V = 12.0; void DoJumpIn() { A_SetRenderStyle(1.0, STYLE_Normal); bShootable = true; bNoGravity = false; Vel = ( cos(Angle) * JUMP_IN_SPEED_H, sin(Angle) * JUMP_IN_SPEED_H, JUMP_IN_SPEED_V ); } state EndJumpIn() { // Some air friction Vel.XY *= 0.95; if (Vel.Z > 0.0) { return null; } int result = CheckSolidFooting(); if ((result & CSF_FLOORMASK) != 0) { return ResolveState("See"); } return null; } Default { Health 70; Radius 28; Height 72; Speed 8; Mass 200; MeleeRange 256; SnapMonster.Poise 35; SeeSound "riotRobo/see"; ActiveSound "riotRobo/idle"; PainSound "riotRobo/hurt"; Obituary "$OB_RIOTROBO"; Tag "$TAG_RIOTROBO"; Species "Robot"; +CROSSLINECHECK } States { Spawn: POMC M 10 A_SnapMonsterLook(JumpState: "JumpIn"); Loop; JumpIn: POMC M 0 DoJumpIn(); JumpLoop: POMC M 3 EndJumpIn(); Loop; Idle: POMC A 10 A_SnapMonsterLook(); Loop; See: POMC GHIJ 3 A_SnapChase(); Loop; Missile: POMC A 0 RiotAttackSetup(); POMC BC 4 RiotAttackAim(1); POMC A 0 RiotAttack(1); POMC DEDEDE 1; POMC F 6; POMC A 0 A_MonsterRefire(0, "See"); POMC BC 4 RiotAttackAim(-1); POMC A 0 RiotAttack(-1); POMC DEDEDE 1; POMC F 6; POMC A 0 A_MonsterRefire(0, "See"); POMC BC 4 RiotAttackAim(0); POMC A 0 RiotAttack(0); POMC DEDEDE 1; POMC F 6; Goto See; Melee: POMC A 0 A_StartSound("riotRobo/dodge"); POMC KLKLKLKLKLKLKLKLKL 1 RiotBackup(); POMC A 12; Goto Missile; Pain: POMC S 3; POMC S 3 A_SnapMonsterPain(); Goto See; Kicked: POMC S 3; POMC S 3 A_SnapMonsterPain(); KickLoop: POMC S 3 A_EndKick(); Loop; Death: POMC S 1; TNT1 A 35 DoSnapMonsterDie(); Stop; GiantDeath: POMC S 1; POMC SSSSSSSS 4 DoSnapMonsterExplode(); TNT1 A 35 DoSnapMonsterDie(); Stop; } override void PostBeginPlay() { super.PostBeginPlay(); if (bAmbush == true && GetRenderStyle() == STYLE_None) { // Amazing Jumping Riot Robo!! bShootable = false; bNoGravity = true; } else { // Not using jump-in. SetStateLabel("Idle"); } } override bool CanCrossLine(Line ld, Vector3 next) { if (InStateSequence(CurState, ResolveState("Melee")) == true) { double NewFloorZ = GetZAt(next.X, next.Y, 0.0, GZF_ABSOLUTEPOS); if (FloorZ - NewFloorZ > 24.0) { // Don't allow drop off while reversing return false; } } return super.CanCrossLine(ld, next); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapRobotCoreShard : SnapDynamicDecor { Default { Radius 10; Height 10; RenderStyle "Add"; +RANDOMIZE +ROLLSPRITE +ROLLCENTER -NOGRAVITY } States { Spawn: RCSH ABCDEDCB 2; RCSH ABCDEDCB 2; Stop; AltSpawn: RCSH FGHIJIHG 2; RCSH FGHIJIHG 2; Stop; } override void BeginPlay() { super.BeginPlay(); if (random[snap_decor](0, 1)) { SetStateLabel("AltSpawn"); } } override void Tick() { super.Tick(); if (isFrozen() == true) { return; } A_SetRoll(Roll + 11.25, SPF_INTERPOLATE); Actor trail = Spawn("SnapLavaDropTrail", Pos, ALLOW_REPLACE); if (trail) { trail.Vel = -Vel * 0.1; } } } class SnapRobotCorePiece : SnapShadowActor { uint CorePieceTimeout; bool CorePieceDone; Default { Health 1; Radius 20; Height 32; Species "RobotCore"; SnapShadowActor.ShadowSize 16; XScale 0.8; YScale 0.65; -SOLID -SHOOTABLE +DONTTHRUST +ROLLSPRITE +BOUNCEONWALLS +BOUNCEONFLOORS +USEBOUNCESTATE +MISSILE +ROLLCENTER } States { Spawn: RCRD B -1; Loop; Bounce.Floor: RCRD B 0 RobotCorePiecePause(); RCRD B 2; Stop; } void RobotCorePiecePause() { CorePieceDone = true; A_SnapNoBlocking(); HandleDamageHitstun(30, null, Target); A_DamageSound(30, null, Target); } void ResetPlayersCombo() { let sp = SnapPlayer(Target); if (sp != null) { sp.Combo.TimeReset(); int index = sp.Combo.Items.Find(self); if (index != sp.Combo.Items.Size()) { sp.Combo.Items.Delete(index); } } } const GLASS_SPD = 16.0; void RobotCorePieceExplode() { // Glass shards for (uint i = 0; i < 16; i++) { Actor shard = Spawn("SnapRobotCoreShard", Pos + (0, 0, 24), ALLOW_REPLACE); if (i == 0) { double attn = ATTN_NORM; if (target != null) { let player = target.player; if (player != null && player == players[consoleplayer]) { attn = ATTN_NONE; } } shard.A_StartSound("powerup/robotcoreShatter", 9, attenuation: attn); } shard.Roll = frandom[snap_decor](-180.0, 180.0); shard.Vel = ( frandom[snap_decor](-GLASS_SPD, GLASS_SPD), frandom[snap_decor](-GLASS_SPD, GLASS_SPD), frandom[snap_decor](0.0, GLASS_SPD) ); } // Small explosions for (int i = 0; i < 3; i++) { double a = i * 120.0; double h = 10.0; double v = 8.0; class type = "SnapMonsterExplodeSmall"; Vector2 speed; speed = AngleToVector(a, h); double zh = 8 - (GetDefaultByType(type).Height * 0.5); Actor particle = Spawn(type, Pos + (0, 0, zh), ALLOW_REPLACE); particle.Vel = (Vel * 0.5) + ((speed.x, speed.y, v) * 0.5); } // Explosion shrapnel class shrapnelType = "SnapMonsterShrapnelSpawner"; double shrapnelAngle = random[snap_decor](0, 7) * 45.0; double shrapnelH = 6.0; double shrapnelV = 16.0; Vector2 shrapnelVel = (0.0, 0.0); Actor shrapnel = Spawn( shrapnelType, Vec3Offset(0, 0, 8.0 - (GetDefaultByType(shrapnelType).Height * 0.5)), ALLOW_REPLACE ); shrapnelVel = AngleToVector(shrapnelAngle, shrapnelH); shrapnel.Vel = (Vel * 0.5) + ((shrapnelVel.X, shrapnelVel.Y, shrapnelV) * 0.5); } override void Tick() { super.Tick(); if (TickPaused() == true || CorePieceDone == true) { return; } CorePieceTimeout++; if (CorePieceTimeout > 3*TICRATE) { SetStateLabel("Bounce.Floor"); return; } double ang = 5.0 + (Vel.Length() * 0.5); A_SetRoll(Roll + ang, SPF_INTERPOLATE); } override void OnDestroy() { ResetPlayersCombo(); RobotCorePieceExplode(); super.OnDestroy(); } } class SnapRobotCore : SnapActor { Default { Health 1; Radius 20; Height 32; Species "RobotCore"; DamageFactor 0.0; DamageFactor "Melee", 1.0; XScale 0.8; YScale 0.65; -SOLID -SHOOTABLE +SPECIAL +DONTTHRUST } void RobotCoreDestroy(SnapPlayer Source) { Die(Source, Source, 0, "Melee"); Target = Source; A_SnapNoBlocking(); double a = 0.0; double ab = 0.0; double addSpeed = 0.0; if (Source != null) { a = Source.Angle; addSpeed = Source.Vel.XY.Length(); } else { a = frandom[snap_decor](-180, 180); } ab = a + 90.0; Actor Debris = Spawn("SnapRobotCorePiece", Pos, ALLOW_REPLACE); A_StartSound("powerup/robotcoreTouch", 9); if (Debris != null) { Debris.Angle = a; Debris.Vel.XY = (4.0 + (addSpeed * 1.5)) * ( cos(a), sin(a) ); Debris.Vel.Z = 12.0; Debris.bXFlip = random[snap_decor](0, 1); Debris.Target = Source; Source.Combo.Items.Push(Debris); } } States { Spawn: RCRE ABACABAC 1 Bright; RCRE DEDF 1 Bright; RCRE GHIHGHIH 1 Bright; RCRE DEDF 1 Bright; Loop; Death: RCRD A -1; Stop; } override void Touch(Actor toucher) { if (Health <= 0 || bKilled == true) { // We've been removed return; } if (toucher == null || toucher.Health <= 0) { // Toucher invalid return; } let sp = SnapPlayer(toucher); if (sp != null) { RobotCoreDestroy(sp); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapPlayer { double SnapStrafeRoll; void StrafeRoll(void) { CVar tiltcvar = CVar.GetCVar('snap_screentilt', players[consoleplayer]); if (tiltcvar && tiltcvar.GetBool() == false) { SnapStrafeRoll = 0; } else { int strafe = GetPlayerInput(MODINPUT_SIDEMOVE); double maxStrafe = 10240.0; double sideSpeed = Vel.XY.Length(); double maxSideSpeed = 40.0; int sideSign = 0; if (sideSpeed) { double mul = 1.0 - abs(AngleToVector(angle) dot Vel.XY.Unit()); sideSpeed *= mul; double velAngle = VectorAngle(Vel.X, Vel.Y); double sideDiff = DeltaAngle(Normalize180(angle), velAngle); if (sideDiff > 0) { sideSign = 1; } else { sideSign = -1; } } double rollAngle = -15; SnapStrafeRoll = rollAngle * ((sideSpeed / maxSideSpeed) * sideSign); } A_SetRoll((self.Roll + SnapStrafeRoll) / 2, SPF_INTERPOLATE); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapPlayer { bool WeaponRoulette; // Active? uint WRTicSpeed; // Tick speed of the roulette. WeaponPattern WRPattern; // Pattern ID to use. uint WRPos; // Current position in weapon pattern. uint WRTics; // Tics before changing position. uint WRDelay; // Ticks before allowing confirmation. bool WRHeld; // Holding the confirm button. uint WROffset; // How many roulettes we started, changes starting position void CheckWeaponRoulette() { if (Health <= 0) { // Cancel if dead. WeaponRoulette = false; } if (WRPattern == null) { // Cancel if pattern is invalid. WeaponRoulette = false; } if (player.cmd.buttons & BT_ATTACK) { if (WeaponRoulette == true) { WRHeld = true; } } else { WRHeld = false; } if (WeaponRoulette == false) { WRPos = 0; WRTics = 0; WRTicSpeed = 1; WRPattern = null; WRDelay = 0; return; } if (WRDelay > 0) { WRDelay--; } if (WRTics > 0) { WRTics--; } else { WRPos++; if (WRPos >= uint(WRPattern.List.Size())) { WRPos = 0; } WRTics = WRTicSpeed; A_StartSound("powerup/roulette", CHAN_ITEM, CHANF_UI|CHANF_LOCAL); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- // Keep track of a score value for Cooperative mode extend class SnapPlayerGlobals { uint Score; void AddScore(int add) { if (add < 0 && uint(abs(add)) >= Score) { Score = 0; return; } Score += add; } } extend class SnapPlayer { void AddScore(int add) { if (SnapPlayerInfo == null) { return; } SnapPlayerInfo.AddScore(add); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class Scruffie : SnapMonster { void DogWander() { bool close = false; Actor targetPlayer = null; if (bFriendly == true) { PlayerInfo player; if (FriendPlayer != 0) { player = Players[FriendPlayer - 1]; } else { int newPlayer = 0; if (multiplayer) { for ( newPlayer = random[snap_gameplay](0, MAXPLAYERS-1); !playeringame[newPlayer]; newPlayer = (newPlayer + 1) & (MAXPLAYERS-1) ); } player = Players[newPlayer]; } targetPlayer = player.mo; } if (targetPlayer != null) { double dist = (Pos - targetPlayer.Pos).Length(); close = (dist <= MeleeRange * 2.0); } if (targetPlayer != null && close == false) { Actor oldTarget = target; target = targetPlayer; SnapNewChaseDir(); target = oldTarget; } else { movedir = (movedir + 1) & 7; } FaceMovementDirection(); SnapMonsterMove(); } void DogStartAway() { A_SnapNoBlocking(); bNoGravity = true; bNoInteraction = true; Vel = (0, 0, 0); } void DogAway() { Angle += 45.0; Vel.Z += 0.5; Actor Circle = Spawn("SnapTeleportPadCircle", Pos + (0, 0, Height * 0.5), ALLOW_REPLACE); if (Circle != null) { Circle.Vel.Z = Vel.Z * 0.75; } } Default { Health (TELEFRAG_DAMAGE-1); Radius 12; Height 28; PainChance 0; DamageFactor 0.0; Mass 100; Monster; Speed 15; Damage 10; // NOT DamageFunction because it breaks PvP for some reason?! SeeSound "scruffie/see"; ActiveSound "scruffie/idle"; AttackSound "scruffie/attack"; Obituary "$OB_DOG"; Species "Dog"; SnapActor.DamageFlash ""; SnapShadowActor.ShadowSize 16; +NOBLOOD +NOPAIN +FRIENDLY +PUSHABLE //+NODAMAGE +INVULNERABLE +DROPOFF +CANTSEEK -COUNTKILL +SnapActor.NOFOOTSTEPS } States { Spawn: DOGS A 2 DogWander(); DOGS A 2 A_Look; DOGS B 2 DogWander(); DOGS B 2 A_Look; DOGS C 2 DogWander(); DOGS C 2 A_Look; DOGS D 2 DogWander(); DOGS D 2 A_Look; Loop; See: DOGS AABBCCDD 2 A_SnapChase(); Loop; Melee: DOGS A 2 A_CustomMeleeAttack(Default.Damage); DOGS BCD 2; Goto See; Pain: Goto See; Kicked: DOGS ABCD 1 A_EndKick(); Loop; Death: // Scruffie's in danger! // Whisk her to safety. DOGS A 1 DogStartAway(); DOGS ABCDABCD 5 DogAway(); DOGS ABCDABCD 4 DogAway(); DOGS ABCDABCD 3 DogAway(); DOGS ABCDABCD 2 DogAway(); DOGS ABCDABCD 1 DogAway(); DOGS ABCDABCDA 1 A_SetRenderStyle(Alpha - 0.1, STYLE_Translucent); Stop; } override bool CanCollideWith(Actor other, bool passive) { if (other is "Scruffie") { return true; } if (isFriend(other)) { return false; } return super.CanCollideWith(other, passive); } override bool OkayToSwitchTarget(Actor other) { if (other.bNoDamage == true || other.bNonShootable == true) { return false; } return super.OkayToSwitchTarget(other); } } class PowerupScruffie : Scruffie { Default { Damage 25; +BRIGHT -SnapActor.NOFOOTSTEPS } States { Spawn: DOGM A 1 DogWander(); DOGM A 1 A_Look; DOGM B 1 DogWander(); DOGM B 1 A_Look; DOGM C 1 DogWander(); DOGM C 1 A_Look; DOGM D 1 DogWander(); DOGM D 1 A_Look; Loop; See: DOGM AABBCCDD 1 A_SnapChase(); Loop; Melee: DOGM A 1 A_CustomMeleeAttack(Default.Damage); DOGM BCD 1; Goto See; Pain: Goto See; Kicked: DOGM ABCD 1 A_EndKick(); Loop; Death: DOGM A 1 DogStartAway(); DOGM ABCD 5 DogAway(); DOGM ABCD 4 DogAway(); DOGM ABCD 3 DogAway(); DOGM ABCD 2 DogAway(); DOGM ABCD 1 DogAway(); DOGM ABCDABCDA 1 A_SetRenderStyle(Alpha - 0.1, STYLE_Translucent); Stop; } override int GetDefaultTranslation() { let sp = SnapPlayer(tracer); if (sp != null) { return sp.GetDefaultTranslation(); } return super.GetDefaultTranslation(); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapSecretItem : SnapInventory { uint SecretID; void SetSecretID(int Value) { let MapDef = SnapMapDef.Get(Level.MapName); if (MapDef == null) { Console.Printf( "Bad secret item: Map does not have definition" ); Destroy(); return; } int MaxValue = MapDef.TotalSecrets[ SnapEventHandler.GetSecretSkill() ]; if (MaxValue > SECRET_SAVE_MAX) { // Should never happen, but just in case MaxValue = SECRET_SAVE_MAX; } if (MaxValue <= 0) { Console.Printf( "Bad secret item: Map does not define secrets" ); Destroy(); return; } if (Value <= 0 || Value > MaxValue) { Console.Printf( "Bad secret item: invalid ID %d (only values between 1 and %d are allowed)", Value, MaxValue ); Destroy(); return; } // Make it 0-based SecretID = uint(Value - 1); } default { Radius 32; Height 64; Inventory.PickupSound "powerup/secret"; Inventory.PickupMessage ""; +FLOATBOB +NOGRAVITY +COUNTSECRET } states { Spawn: SEC1 A 0 NoDelay PickSecretItemState(); FloppyA: SEC1 A 10; SEC1 A 10 Bright; Loop; FloppyB: SEC2 A 10; SEC2 A 10 Bright; Loop; Laserdisk: SEC3 A 10; SEC3 A 10 Bright; Loop; Record: SEC4 A 10; SEC4 A 10 Bright; Loop; CD: SEC5 A 10; SEC5 A 10 Bright; Loop; VHS: SEC6 A 10; SEC6 A 10 Bright; Loop; Cassette: SEC7 A 10; SEC7 A 10 Bright; Loop; EightTrack: SEC8 A 10; SEC8 A 10 Bright; Loop; GameCard: SEC9 A 10; SEC9 A 10 Bright; Loop; Film: SECA A 10; SECA A 10 Bright; Loop; } state PickSecretItemState() { static const StateLabel StateList[] = { "FloppyA", "FloppyB", "Laserdisk", "Record", "CD", "VHS", "Cassette", "EightTrack", "GameCard", "Film" }; return ResolveState( StateList[ random[snap_decor](0, 9) ] ); } override bool TryPickup(in out Actor Toucher) { if (Toucher != null) { let cp = players[consoleplayer]; if (cp != null && cp.mo != null && cp.mo == Toucher) { SnapEventHandler.QueueSecretID( SecretID ); } ItemExtendCombo(Toucher, true); } GoAwayAndDie(); return true; } override void PostBeginPlay() { super.PostBeginPlay(); SetSecretID( int(floor(Angle) + 0.5) ); if (Pos.Z == FloorZ) { SetOrigin(Pos + (0, 0, 8), false); } } override void Tick() { super.Tick(); A_SetAngle(Angle + 5.0, SPF_INTERPOLATE); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- mixin class SnapShadowCarryover { // Shared properties between the shadow caster // and the shadow itself double ShadowSize; uint ShadowFlags; flagdef ShadowStayOnHit: ShadowFlags, 0; flagdef ShadowStayOnDeath: ShadowFlags, 1; flagdef DisableShadow: ShadowFlags, 2; } mixin class SnapShadowCode { // Properties only belonging to the original actor. SnapShadow ShadowActor; property ShadowSize: ShadowSize; void ShadowBegin() { if (bDisableShadow == true) { return; } if (ShadowActor == null) { ShadowActor = SnapShadow(Spawn("SnapShadow", Pos, NO_REPLACE)); if (ShadowActor == null) { return; } ShadowActor.Master = self; ShadowActor.bInvisible = true; // Use additive for bright objects. if (Default.bBright) { ShadowActor.A_SetRenderStyle(ShadowActor.Alpha, STYLE_Add); //ShadowActor.SetStateLabel("Strong"); } } } void ShadowTick() { if (ShadowActor) { ShadowActor.ShadowSize = self.ShadowSize; ShadowActor.ShadowFlags = self.ShadowFlags; } } void ShadowDestroy() { if (ShadowActor) { ShadowActor.Destroy(); } } void ShadowNewSize(double newSize = 0.0) { ShadowSize = newSize; } } class SnapShadow : SnapDynamicDecor { // The drop shadow itself. mixin SnapShadowCarryover; const ShadowSpriteRadius = 32.0; const ShadowSmidgeValue = 0.001; bool ShadowPrevMissile; Default { RenderStyle "Subtract"; DistanceCheck "snap_shadowdrawdist"; +NOBLOCKMAP +NOGRAVITY +NOINTERACTION +BRIGHT +ROLLSPRITE +FLATSPRITE +INVISIBLE // Updated in shadow code //+MASTERNOSEE } States { Spawn: SHAD A -1; Stop; /* Weak: SHAD B -1; Stop; Strong: SHAD C -1; Stop; */ } static Vector2 ShadowAdjust(double ObjZ) { // Offsets the shadow slightly based on the camera // to account for Doom's silly sprite sorting. PlayerInfo p = players[consoleplayer]; if (p && p.camera) { Vector2 Adjust = p.camera.AngleToVector(p.camera.Angle, ShadowSmidgeValue); double CameraZ = p.camera.Pos.Z; // Can potentially not be themselves. PlayerInfo camPlayer = p.camera.player; if (camPlayer != null) { CameraZ = camPlayer.viewz; } else { CameraZ += p.camera.GetCameraHeight(); } if (CameraZ < ObjZ) { Adjust = -Adjust; } return Adjust; } return ( 0, 0 ); } void ShadowTick() { let us = self.master; if (!us) { Destroy(); return; } if ((ShadowPrevMissile == true) && (us.bMissile == false) && (bShadowStayOnHit == false)) { // Missile exploded Destroy(); return; } ShadowPrevMissile = us.bMissile; bInvisible = us.bInvisible; if (us.CurState.Sprite == us.GetSpriteIndex("TNT1")) { bInvisible = true; } if (bInvisible == true) { // If invisible, we don't need to update it any further. return; } // Copy render properties bShadow = us.bShadow; bGhost = us.bGhost; Alpha = us.Alpha; // Set scale double newSize = ShadowSize * us.Scale.X; if (newSize <= 0.0) { // Adjust to the object's radius newSize = us.Radius; } double newScale = newSize / ShadowSpriteRadius; Scale = ( newScale, newScale ); double cDist; Sector cSector; F3DFloor c3DFloor; [cDist, cSector, c3DFloor] = us.CurSector.NextLowestFloorAt( us.Pos.X, us.Pos.Y, us.Pos.Z, 0, us.MaxStepHeight ); SecPlane shadowFloor = null; if (c3DFloor) { shadowFloor = c3DFloor.Top; } else if (cSector) { shadowFloor = cSector.FloorPlane; } else { // Bail early since there's no valid sector?! bInvisible = true; return; } // Update position to below the object Vector2 ShadowXY = us.Pos.XY; double zHeight = shadowFloor.ZAtPoint(ShadowXY); if (zHeight > us.Pos.Z) { // We're below the floor bInvisible = true; return; } ShadowXY += ShadowAdjust(zHeight); Vector3 ShadowPos = (ShadowXY.X, ShadowXY.Y, zHeight); SetOrigin(ShadowPos, true); //Vel.XY = us.Vel.XY; if (shadowFloor.isSlope()) { Vector3 n = shadowFloor.Normal; Vector2 dist = ( n.X, n.Y ); Pitch = VectorAngle(n.Z, dist.Length()); Angle = VectorAngle(n.X, n.Y); // Hack to try and prevent the shadow from going into slopes when moving too fast. /* double xySpeed = ourselves.Vel.XY.Length(); if (xySpeed) { double adjustFactor = 0.5; double d = min(ourselves.Vel.XY.Unit() dot n.XY.Unit(), 0); Vel.Z = (xySpeed * n.Z) * -d * adjustFactor; } else { Vel.Z = 0; } */ } else { Pitch = Angle = 0; //Vel.Z = 0; } } override void BeginPlay() { super.BeginPlay(); ChangeStatNum(STAT_SHADOW); } override void Tick() { super.Tick(); ShadowTick(); } } class SnapShadowActor : SnapActor abstract { // An actor that has a drop shadow. mixin SnapShadowCarryover; mixin SnapShadowCode; override void BeginPlay() { super.BeginPlay(); ShadowBegin(); } override void Tick() { super.Tick(); ShadowTick(); } override void OnDestroy() { super.OnDestroy(); ShadowDestroy(); } override void Die(Actor source, Actor inflictor, int dmgflags, Name MeansOfDeath) { if (bShadowStayOnDeath == false) { ShadowDestroy(); } super.Die(source, inflictor, dmgflags, MeansOfDeath); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapShieldParticle : SnapDynamicDecor { Default { RenderStyle "Add"; +BRIGHT +WALLSPRITE } States { Spawn: PWPR A 20; PWPR BCDEC 2; Loop; } override void Tick() { super.Tick(); if (isFrozen() == true) { return; } if (target == null || target.health <= 0) { Destroy(); return; } double a = angle + 5.625; double zpos = 32 * (target.Height / 56.0); Vector3 newPos = target.Pos; newPos.XY += AngleToVector(a, target.Radius * 2); newPos.Z += zpos + BobSin(Level.maptime); newPos += target.Vel; SetOrigin(newPos, true); A_SetAngle(a, SPF_INTERPOLATE); } } class SnapShieldPower : PowerProtection { mixin SnapPowerupFix; Actor ShieldParticle; Default { DamageFactor "Normal", 0.5; Powerup.Duration -30; } override bool HandlePickup(Inventory item) { return NewPowerupLogic(item); } override void InitEffect() { Super.InitEffect(); if (Owner == NULL || Owner.player == NULL) return; for (Inventory item = Inv; item != NULL; item = item.Inv) { let sitem = SnapShieldPower(item); if (sitem != null) { return; } } Vector3 startPos = Owner.Pos; startPos.XY += AngleToVector(Owner.Angle + 180, Owner.Radius * 2); startPos.Z += 32 + BobSin(Level.maptime); startPos += Owner.Vel; let newshield = Spawn("SnapShieldParticle", startPos, ALLOW_REPLACE); if (newshield) { newshield.Angle = Owner.Angle + 180; newshield.target = Owner; newshield.Scale = Owner.Scale; if (Owner == players[consoleplayer].camera && !(Owner.player.cheats & CF_CHASECAM)) { newshield.bInvisible = true; } ShieldParticle = newshield; } } override void DoEffect() { Super.DoEffect(); if (!ShieldParticle) { return; } if (Owner == NULL || Owner.player == NULL) { ShieldParticle.Destroy(); return; } if (Owner == players[consoleplayer].camera && !(Owner.player.cheats & CF_CHASECAM)) { ShieldParticle.bInvisible = true; } else { ShieldParticle.bInvisible = false; } } override void EndEffect() { super.EndEffect(); if (ShieldParticle) { ShieldParticle.Destroy(); } } override void ModifyDamage(int damage, Name damageType, out int newdamage, bool passive, Actor inflictor, Actor source, int flags) { if (passive && damage > 0) { newdamage = max(0, ApplyDamageFactors(GetClass(), damageType, damage, damage / 4)); if (Owner != null && newdamage < damage) { Owner.A_StartSound(ActiveSound, CHAN_AUTO, CHANF_DEFAULT, 1.0, ATTN_NONE); } if (newdamage <= 0) { // Always ensure damage newdamage = 1; } } } } class SnapShieldPowerup : SnapBigPowerup { Default { Inventory.PickupMessage "$POWERUP_SHIELD"; SnapBigPowerup.VoiceSample "voice/shell"; Powerup.Type "SnapShieldPower"; } States { Spawn: PW_R A 10; PW_R A 10 Bright; Loop; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapIntermissionSingle : SnapIntermission { enum GradingStates { STATS_START, COUNT_MONSTERS, STATS_PAUSE1, COUNT_SECRETS, STATS_PAUSE2, COUNT_COMBOS, STATS_PAUSE3, COUNT_TIME, STATS_PAUSE4, COUNT_GRADE, STATS_PAUSE5, WAIT_INPUT, SP_FADEOUT, }; int Robots; int Secrets; int Combos; int RobotScore; int SecretScore; int ComboScore; int CountedRobots; int CountedSecrets; int CountedCombos; int CountedTime; int CountedRobotScore; int CountedSecretScore; int CountedComboScore; int CountedTimeScore; int CountedScore; int OldRankSegs; bool IsGraded; bool DidSave; override int GetMapScore() { return (MaxRobotScore + MaxSecretScore + MaxComboScore + MaxTimeScore); } override int GetPlayerScore(int playerID) { return max(0, RobotScore + SecretScore + ComboScore + FinalTimeScore); } override void Start() { // Use the actual full total in singleplayer Robots = Level.Killed_Monsters; Combos = PlayerData[consoleplayer].Combos; Secrets = Level.Found_Secrets; RobotScore = GetScoreValue(Robots, WEIGHT_MONSTER); ComboScore = GetScoreValue(Combos, WEIGHT_COMBO); SecretScore = GetScoreValue(Secrets, WEIGHT_SECRET); // Count each of these individually. CountedRobots = CountedCombos = CountedSecrets = CountedTime = 0; CountedRobotScore = CountedComboScore = CountedSecretScore = CountedScore = 0; CountedTimeScore = MaxTimeScore; GenericDelay = TICRATE; DidSave = false; if (SnapMapRecord.AllowGrading() == true) { IsGraded = true; // Save our record data. let record = SnapMapRecord( new("SnapMapRecord") ); record.Lump = MapLump; record.Skill = GameDifficulty; int FinalScore = GetPlayerScore(0); record.Grade = CalculateGrade(FinalScore); record.Robots = Robots; record.TotalRobots = TotalRobots; record.RobotScore = RobotScore; record.Secrets = Secrets; record.TotalSecrets = TotalSecrets; record.SecretScore = SecretScore; record.Combos = Combos; record.TotalCombos = TotalCombos; record.ComboScore = ComboScore; record.Time = FinalTime; record.ParTime = RealParTime; record.TimeScore = FinalTimeScore; record.MapScore = MaxScore; DidSave = record.Save(); } } override void Update() { switch (CurState) { case STATS_START: case STATS_PAUSE1: case STATS_PAUSE2: case STATS_PAUSE3: case STATS_PAUSE4: case STATS_PAUSE5: if (SkipStage == true && GenericDelay > SKIP_PAUSE_LEN) { GenericDelay = SKIP_PAUSE_LEN; } GenericPauseState(STATS_PAUSE5); break; case COUNT_MONSTERS: if ((CountedRobots >= Robots && CountedRobotScore >= RobotScore) || (SkipStage == true)) { CountedRobots = Robots; CountedRobotScore = RobotScore; PlaySound("intermission/nextstage"); SkipStage = false; CurState++; } else { ScoreTick(); int Dest = RobotScore; if (CountedRobots < Robots) { CountedRobots += 2; if (CountedRobots > Robots) { CountedRobots = Robots; } Dest = GetScoreValue(CountedRobots, WEIGHT_MONSTER); } if (CountedRobotScore < Dest) { CountedRobotScore += SCORE_TALLY_SPEED; if (CountedRobotScore > Dest) { CountedRobotScore = Dest; } } } break; case COUNT_SECRETS: if ((CountedSecrets >= Secrets && CountedSecretScore >= SecretScore) || (SkipStage == true)) { CountedSecrets = Secrets; CountedSecretScore = SecretScore; PlaySound("intermission/nextstage"); SkipStage = false; CurState++; } else { ScoreTick(); int Dest = SecretScore; if (CountedSecrets < Secrets) { CountedSecrets++; if (CountedSecrets > Secrets) { CountedSecrets = Secrets; } Dest = GetScoreValue(CountedSecrets, WEIGHT_SECRET); } if (CountedSecretScore < Dest) { CountedSecretScore += SCORE_TALLY_SPEED; if (CountedSecretScore > Dest) { CountedSecretScore = Dest; } } } break; case COUNT_COMBOS: if ((CountedCombos >= Combos && CountedComboScore >= ComboScore) || (SkipStage == true)) { CountedCombos = Combos; CountedComboScore = ComboScore; PlaySound("intermission/nextstage"); SkipStage = false; CurState++; } else { ScoreTick(); int Dest = ComboScore; if (CountedCombos < Combos) { CountedCombos += 5; if (CountedCombos > Combos) { CountedCombos = Combos; } Dest = GetScoreValue(CountedCombos, WEIGHT_COMBO); } if (CountedComboScore < Dest) { CountedComboScore += SCORE_TALLY_SPEED; if (CountedComboScore > Dest) { CountedComboScore = Dest; } } } break; case COUNT_TIME: if ((CountedTime >= FinalTime && CountedTimeScore <= FinalTimeScore) || (SkipStage == true)) { CountedTime = FinalTime; CountedTimeScore = FinalTimeScore; PlaySound("intermission/nextstage"); SkipStage = false; CurState++; } else { ScoreTick(); int Dest = FinalTimeScore; if (CountedTime < FinalTime) { CountedTime += 5; if (CountedTime > FinalTime) { CountedTime = FinalTime; } int Counted = (RealParTime + TIME_BONUS_CUTOFF) - CountedTime; if (Counted > TIME_BONUS_CUTOFF) { Counted = TIME_BONUS_CUTOFF; } else if (Counted < -TIME_BONUS_CUTOFF) { Counted = -TIME_BONUS_CUTOFF; } Dest = GetScoreValue(Counted, WEIGHT_TIME, TIME_BONUS_CUTOFF); } if (CountedTimeScore > Dest) { CountedTimeScore -= SCORE_TALLY_SPEED; if (CountedTimeScore < Dest) { CountedTimeScore = Dest; } } } break; case COUNT_GRADE: int FinalScore = GetPlayerScore(0); if (IsGraded == true) { int RankSegs = RankometerSegs(CountedScore, MaxScore); bool RankTicked = (RankSegs > OldRankSegs); OldRankSegs = RankSegs; if (RankTicked == true && SkipStage == false) { double progress = (CountedScore * 1.0) / (MaxScore * 1.0); PlayRankSound(progress); } if ((CountedScore >= FinalScore) || (SkipStage == true)) { CountedScore = FinalScore; PlaySound("intermission/nextstage"); SkipStage = false; CurState++; } else { ScoreTick(); CountedScore += IncrementGradeScore(CountedScore, FinalScore, 80); } } else { // Increment like any other stage. if (CountedScore >= FinalScore || SkipStage == true) { CountedScore = FinalScore; PlaySound("intermission/nextstage"); SkipStage = false; CurState++; } else { ScoreTick(); if (CountedScore < FinalScore) { CountedScore += SCORE_TALLY_SPEED * 2; if (CountedScore > FinalScore) { CountedScore = FinalScore; } } } } break; case WAIT_INPUT: if (SkipStage == true) { PlaySound("intermission/paststats"); let ev = SnapEventHandler.Get(); if (ev != null && ev.Trial.Active == true) { SnapFader.StartGameFade(true, 0.02); CurState++; } else { End(); } } break; case SP_FADEOUT: FadeOutTick(); break; } // Allow skipping in all states SkipStage = DoSkipLogic(); } override void End() { let ev = SnapEventHandler.Get(); if (ev != null && ev.Trial.Active == true) { Level.ChangeLevel("TRIALEND", 0, CHANGELEVEL_NOINTERMISSION); Destroy(); return; } super.End(); } override void Drawer() { super.Drawer(); int yourGrade = CalculateGrade(CountedScore); if (yourGrade == GRADE_INVALID) { DrawText(headerFont, headerColor, (60, 36), "$INTER_INVALID"); DrawText(standardFont, standardColor, (60, 62), "$INTER_TIME"); DrawTime(standardFont, standardColor, (260, 62), FinalTime); DrawTitle(); return; } Vector2 StatsOffset = (0, (1.0 - Transition) * TRANSITION_DIST); DrawTexture(StatsBG, (48, 28) - StatsOffset); DrawText(standardFont, standardColor, (60, 36) - StatsOffset, "$INTER_KILLS"); DrawTotal(standardFont, standardColor, (207, 36) - StatsOffset, CountedRobots, TotalRobots); drawNum(bonusFont, (260, 38) - StatsOffset, CountedRobotScore, 0, true, (CountedRobots >= TotalRobots) ? bonusColor : standardColor ); DrawText(standardFont, standardColor, (60, 55) - StatsOffset, "$INTER_SECRET"); DrawTotal(standardFont, standardColor, (207, 55) - StatsOffset, CountedSecrets, TotalSecrets); drawNum(bonusFont, (260, 57) - StatsOffset, CountedSecretScore, 0, true, (CountedSecrets >= TotalSecrets) ? bonusColor : standardColor ); DrawText(standardFont, standardColor, (60, 74) - StatsOffset, "$INTER_COMBO"); DrawTotal(standardFont, standardColor, (207, 74) - StatsOffset, CountedCombos, TotalCombos); drawNum(bonusFont, (260, 76) - StatsOffset, CountedComboScore, 0, true, (CountedCombos >= TotalCombos) ? bonusColor : standardColor ); int timeColor = standardColor; if (CountedTimeScore < 0) { timeColor = headerColor; } else if (CountedTime <= RealParTime && CurState > COUNT_TIME) { timeColor = bonusColor; } DrawText(standardFont, standardColor, (60, 93) - StatsOffset, "$INTER_TIME"); DrawTimeCompare(standardFont, standardColor, (207, 93) - StatsOffset, CountedTime, RealParTime); drawNum(bonusFont, (260, 95) - StatsOffset, CountedTimeScore, 0, true, timeColor ); DrawText(headerFont, headerColor, (60, 114) - StatsOffset, "$INTER_TOTAL"); drawNum(standardFont, (260, 114) - StatsOffset, CountedScore, 0, true, headerColor ); if (IsGraded == true) { bool suspense = (CurState <= COUNT_GRADE); // Don't show S rank until the very very end // Rankometer DrawText(rankFont, rankColor, CenterAlignPos(rankFont, "$INTER_RANK", (159.5, 139)) + StatsOffset, "$INTER_RANK"); DrawGrade( (CurState < COUNT_GRADE) ? GRADE_INVALID : yourGrade, (142, 148) + StatsOffset, InterTicks, suspense, (CurState == STATS_PAUSE5) ? GenericDelay+1 : 0 ); DrawRankometer( CountedScore, MaxScore, (60, 180) + StatsOffset, InterTicks, suspense, (CurState == STATS_PAUSE5) ? GenericDelay+1 : 0 ); if (CurState >= WAIT_INPUT && DidSave == true) { DrawText( rankFont, Font.FindFontColor("HPYellow"), CenterAlignPos(rankFont, "$INTER_NEWRECORD", (160, 176)) + StatsOffset, "$INTER_NEWRECORD" ); } } DrawTitle(); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapSkillItem : SnapMenuItemSubmenuLocked { SnapEpisodeDef mEpisode; SnapMapDef mMap; uint mSkill; TextureID HeaderArrow[2]; TextureID mLocked; TextureID mDarken; TextureID mBG[2]; TextureID mSnapStand; TextureID mSnapWalk; TextureID mAmmo; TextureID mShield; TextureID mComputurret; TextureID mGuardRobo; TextureID mRudeRobo; uint SkillAnimTimer; SnapSkillItem Init() { super.Init("", "", 'None', 0); mEpisode = SnapMenuData.GetSelectedEpisode(); if (mEpisode != null && mEpisode.Special == true) { mMap = SnapMenuData.GetSelectedMap(); } HeaderArrow[0] = TexMan.CheckForTexture("MENUAL", TexMan.Type_MiscPatch); HeaderArrow[1] = TexMan.CheckForTexture("MENUAR", TexMan.Type_MiscPatch); mLocked = TexMan.CheckForTexture("SKLOCK", TexMan.Type_MiscPatch); mDarken = TexMan.CheckForTexture("SKDARKEN", TexMan.Type_MiscPatch); mBG[0] = TexMan.CheckForTexture("SKBG1", TexMan.Type_MiscPatch); mBG[1] = TexMan.CheckForTexture("SKBG2", TexMan.Type_MiscPatch); mSnapStand = TexMan.CheckForTexture("SKSNAPA0", TexMan.Type_MiscPatch); mSnapWalk = TexMan.CheckForTexture("SKSNAPB1", TexMan.Type_MiscPatch); mAmmo = TexMan.CheckForTexture("SKAMMO", TexMan.Type_MiscPatch); mShield = TexMan.CheckForTexture("SKSH1", TexMan.Type_MiscPatch); mComputurret = TexMan.CheckForTexture("SKTURR1", TexMan.Type_MiscPatch); mGuardRobo = TexMan.CheckForTexture("SKROBOA0", TexMan.Type_MiscPatch); mRudeRobo = TexMan.CheckForTexture("SKROBOB1", TexMan.Type_MiscPatch); SkillAnimTimer = 0; return self; } override int GetLineSpacing() { return 268; } override bool Locked() { if (mEpisode == null) { // Invalid episode. return true; } uint NumMaps = mEpisode.MapList.Size(); if (NumMaps == 0) { // Fake episode, always grayed out. return true; } int Beaten = -1; int Requirement = -1; if (mMap != null) { // Bonus Level conditions. for (int i = NUM_RECORD_SKILLS-1; i >= 0; i--) { if (SnapMapRecord.Get(mMap.ID, i + FIRST_GRADED_SKILL) != null) { Beaten = i + FIRST_GRADED_SKILL; break; } } // Easy & Normal are always available. // Hard modes need you to have already beaten // the previous skill level. if (mSkill >= SNAP_SKILL_HARD) { Requirement = mSkill - 1; } } else { CVar BeatenVar = mEpisode.BeatenVar; if (BeatenVar != null) { Beaten = BeatenVar.GetInt(); } let p = SnapSkillMenu(Parent); if (p != null) { switch (p.SkillType) { case GT_TRIAL: case GT_CUSTOM: // Need to have already beaten this skill, // or any of the harder ones. Requirement = mSkill; break; default: // Easy & Normal are always available. // Hard modes need you to have already beaten // the previous skill level. if (mSkill >= SNAP_SKILL_HARD) { Requirement = mSkill - 1; } break; } } } return (Beaten < Requirement); } override bool Activate() { if (Locked() == true) { Menu.MenuSound("menu/cant"); return true; } let p = SnapSkillMenu(Parent); if (p != null) { SnapMenuData.SetSelectedSkill(mSkill); Menu.MenuSound("menu/advance"); // Update character // Doesn't work fully unless if we do it well // in advance, like right here. int CharacterID = SnapMenuData.GetSelectedCharacter(); let m = NewPlayerMenu(Menu.GetCurrentMenu()); m.PickPlayerClass(CharacterID); PlayerMenu.ClassChanged(CharacterID, m.mPlayerClass); p.NewGameAfterFade = true; SnapFader.StartGameFade(true, 0.02); return true; } return false; } const OPTION_HEADER_HEIGHT = 36; override bool MouseEvent(int type, int x, int y) { let p = SnapSkillMenu(Parent); if (p != null) { p.ArrowMouseSelect = -1; if (y - VirtualOffset.Y <= OPTION_HEADER_HEIGHT) { int HalfPos = (BASE_VID_WIDTH * 0.5) + VirtualOffset.X; p.ArrowMouseSelect = ((x - HalfPos) > 0); int Selected = p.GetSelectedItem(); if (type == Menu.MOUSE_Release) { if (p.ArrowMouseSelect == 0 && Selected > p.FirstSelectable()) // lazy { p.SetSelectedItem(Selected - 1); } else if (p.ArrowMouseSelect == 1 && Selected < p.LastSelectable()) { p.SetSelectedItem(Selected + 1); } else { return false; } Menu.MenuSound("menu/change"); return true; } //p.SetSelectedItem(-1, false); return true; } if (type == Menu.MOUSE_Release) { int Selected = p.GetSelectedItem(); int ItemPos = p.GetItemPos(Selected); double NewPos = ItemPos - (BASE_VID_WIDTH * 0.5); if (abs(p.ScrollPos.X - NewPos) >= 1.0) { Menu.MenuSound("menu/change"); p.UpdateDestScroll(Selected, false); if (m_use_mouse == 2) { return true; } } } } return super.MouseEvent(type, x, y); } override void Ticker() { super.Ticker(); SkillAnimTimer++; } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool Selected) { UpdateScaleParameters(); Vector2 Pos = ((GetLineSpacing() * 0.5) + xOffset, yOffset); String LabelText = Stringtable.Localize(mLabel); Vector2 HeaderPos = Pos + (0, 8); SnapMenuText( FontHeader, Selected ? FontHighlightColor : Font.CR_UNTRANSLATED, CenterAlignPos(FontHeader, LabelText, HeaderPos), LabelText ); if (Selected == true) { double ArrowDist = FontHeader.StringWidth(LabelText) * 0.5; Vector2 ArrowOffset = (ArrowDist + 12.0, 0); ArrowOffset.X += 3.0 * sin(Menu.MenuTime() * 8.0); Vector2 ArrowSize = SnapMenuTextureSize(HeaderArrow[0]); int HighlightTrans = Translate.GetID("BackButtonHighlight"); int ArrowSelect = -1; let p = SnapSkillMenu(Parent); if (p != null) { ArrowSelect = p.ArrowMouseSelect; } if (mSkill > SNAP_SKILL_EASY) { SnapMenuTextureTranslated( HeaderArrow[0], HeaderPos - ArrowOffset - (ArrowSize.X, 0), (ArrowSelect == 0) ? HighlightTrans : 0 ); } if (mSkill < SNAP_SKILL_VERYRUDE) { SnapMenuTextureTranslated( HeaderArrow[1], HeaderPos + ArrowOffset, (ArrowSelect == 1) ? HighlightTrans : 0 ); } } /* if (Parent != null) { Pos.X += (1.0 - Parent.MenuTransition) * VirtualSize.X; } */ Vector2 IconPos = Pos + (-112, 55); if (Locked() == true) { SnapMenuTexture(mLocked, IconPos); } else { SnapMenuTexture(mBG[0], IconPos); if (mSkill <= SNAP_SKILL_NORMAL) { SnapMenuTexture(mBG[1], IconPos); } if (selected == false) { SnapMenuTexture(mSnapStand, IconPos + (38, 42)); } else { SnapMenuTexture(mSnapWalk, IconPos + (38, 42)); } if (mSkill <= SNAP_SKILL_EASY) { int bob = 1; if ((SkillAnimTimer / 5) & 1) { bob = -bob; } Vector2 AmmoOffset = (82, 82); for (uint i = 0; i < 3; i++) { SnapMenuTexture(mAmmo, IconPos + AmmoOffset + (0, 0.5 + (bob * 0.5))); AmmoOffset.X += 10; bob = -bob; } if (SkillAnimTimer & 1) { double sine = sin(SkillAnimTimer * 4.0) * 4.0; SnapMenuTexture(mShield, IconPos + (38, 58 + sine)); } } if (mSkill <= SNAP_SKILL_NORMAL) { SnapMenuTexture(mComputurret, IconPos + (146, 53)); } else { int bob = -1; if ((SkillAnimTimer / 5) & 1) { bob = -bob; } Vector2 RoboOffset = (100, 42); for (uint i = 0; i < 2; i++) { if (mSkill >= SNAP_SKILL_VERYRUDE) { double sine = sin((SkillAnimTimer * 4.0) + (i * 90)) * 16.0; SnapMenuTexture(mRudeRobo, IconPos + RoboOffset + (0, sine + (0.5 + (bob * 0.5) - 16))); } else { SnapMenuTexture(mGuardRobo, IconPos + RoboOffset + (0, 0.5 + (bob * 0.5))); } RoboOffset.X += 36; bob = -bob; } } } if (selected == false) { SnapMenuTextureAlpha(mDarken, IconPos, 0.5); } return xOffset; } override void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.Offscreen(); } } class SnapSkillMenu : SnapHorizontalMenu { uint SkillType; bool NewGameAfterFade; int ArrowMouseSelect; SnapSkillItem CreateSkillItem(uint SkillID) { let item = SnapSkillItem( new("SnapSkillItem") ); item.Init(); mDesc.mItems.Push(item); item.OnMenuCreated(); item.Parent = self; item.mSkill = SkillID; switch (SkillID) { case SNAP_SKILL_EASY: item.mLabel = "$SNAPMENU_SKILL_EASY"; item.mTooltip = "$SNAPMENU_SKILL_DESCRIPTOR_EASY"; break; case SNAP_SKILL_NORMAL: item.mLabel = "$SNAPMENU_SKILL_NORMAL"; item.mTooltip = "$SNAPMENU_SKILL_DESCRIPTOR_NORMAL"; break; case SNAP_SKILL_HARD: item.mLabel = "$SNAPMENU_SKILL_HARD"; item.mTooltip = "$SNAPMENU_SKILL_DESCRIPTOR_HARD"; break; case SNAP_SKILL_VERYRUDE: item.mLabel = "$SNAPMENU_SKILL_RUDE"; item.mTooltip = "$SNAPMENU_SKILL_DESCRIPTOR_RUDE"; break; } if (item.Locked() == true) { if (item.mMap != null) { item.mTooltip = "$SNAPMENU_SKILL_LOCKED_BONUS"; } else { switch (SkillType) { case GT_CAMPAIGN: item.mTooltip = "$SNAPMENU_SKILL_LOCKED_CAMPAIGN"; break; case GT_TRIAL: case GT_CUSTOM: item.mTooltip = "$SNAPMENU_SKILL_LOCKED_TRIAL"; break; default: item.mTooltip = "$SNAPMENU_SKILL_LOCKED"; break; } } } return item; } override void Init(Menu parent, OptionMenuDescriptor desc) { super.Init(parent, desc); uint NumItems = mDesc.mItems.Size(); for (uint i = 0; i < NumItems; i++) { let item = mDesc.mItems[i]; let n = OptionMenuItemSnapGameType(item); if (n != null) { SkillType = n.mGameType; } if (item is "SnapSkillItem") { item.Destroy(); mDesc.mItems.Delete(i); i--; NumItems--; continue; } } for (uint i = SNAP_SKILL_EASY; i < SNAP_SKILL__MAX; i++) { CreateSkillItem(i); } NumItems = mDesc.mItems.Size(); int LastSkillID = SnapMenuData.GetSelectedSkill(); if (LastSkillID != -1) { for (uint i = 0; i < NumItems; i++) { let item = mDesc.mItems[i]; let n = SnapSkillItem(item); if (n != null) { if (n.mSkill == LastSkillID) { SetSelectedItem(i); return; } } } } // Default to normal SetSelectedItem(FirstSelectable() + 1); ArrowMouseSelect = -1; } override void SnapTicker() { super.SnapTicker(); if (MenuData.Fader.FadeOffset >= 1.0 && NewGameAfterFade == true) { StartNewGame(); } } void StartNewGame() { Menu.SetMenu("EpisodeMenu", SnapMenuData.GetSelectedCharacter()); // Param sets player class ID Menu.SetMenu("SkillMenu", 0); // Param sets episode ID Menu.SetMenu("StartGame", SnapMenuData.GetSelectedSkill()); // Param sets skill ID } override void ClampScrollPos() { int FirstPos = GetItemPos(FirstSelectable()); int LastPos = GetItemPos(LastSelectable()); DestScrollPos.X = clamp(DestScrollPos.X, FirstPos - (BASE_VID_WIDTH * 0.5), LastPos - (BASE_VID_WIDTH * 0.5)); } override void UpdateDestScroll(int Selected, bool force) { int ItemPos = GetItemPos(Selected); DestScrollPos.X = ItemPos - (BASE_VID_WIDTH * 0.5); if (force == true) { ScrollPos = DestScrollPos; } } override void ItemsDrawer() { Vector2 HeaderPos = (BASE_VID_WIDTH * 0.5, 8); HeaderPos.Y -= (1.0 - MenuTransition) * (VirtualSize.Y * 0.5); DrawSticker(HeaderPos + (0, 2), 0); super.ItemsDrawer(); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- mixin class SnapSliderBase { String DefaultSliderString(double Value, double Percent) { if (mShowValue >= 0) { String formatter = String.Format("%%.%df", mShowValue); return String.Format(formatter, Value); } else if (mShowValue == 0) { return String.Format("%d", int(round(Value))); } // Special cases from here on out. switch (mShowValue) { case -1: default: // -1: No text return ""; case -2: // -2: As percentage return String.Format("%d%%", int(Percent * 100)); } } void SliderDraw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { UpdateScaleParameters(); Vector2 Pos = ((BASE_VID_WIDTH * 0.5) + xOffset, yOffset); int col = Font.CR_UNTRANSLATED; if (DisplayGrayed() == true) { col = FontGrayColor; } else if (selected == true) { col = FontHighlightColor; } SnapMenuText( FontSmall, col, RightAlignPos(FontSmall, mLabel, Pos - (OPTIONS_MID_SPACE, 0)), mLabel ); double CurValue = GetSliderValue(); double Range = mMax - mMin; double Percent = clamp((CurValue - mMin) / Range, 0.0, 1.0); Vector2 BarPos = Pos + (OPTIONS_MID_SPACE, 0); if (CurValue > mMin) { SnapMenuTexture(Sliders[SLIDER_ARROWL], BarPos); } Vector2 ArrowSize = SnapMenuTextureSize(Sliders[SLIDER_ARROWL]); BarPos.X += ArrowSize.X; Vector2 BarOffset = (0, 2); Vector2 BarSize = SnapMenuTextureSize(Sliders[SLIDER_EMPTY]); SnapMenuTexture(Sliders[SLIDER_EMPTY], BarPos + BarOffset); Screen.SetClipRect( int((BarPos.X + BarOffset.X + VirtualOffset.X) * VirtualScale), int((BarPos.Y + BarOffset.Y + VirtualOffset.Y) * VirtualScale), int((BarSize.X * VirtualScale) * Percent), int(BarSize.Y * VirtualScale) ); SnapMenuTexture(Sliders[SLIDER_FULL], BarPos + BarOffset); Screen.ClearClipRect(); String SliderText = GetSliderString(CurValue, Percent); // Save for later Vector2 SliderTextPos = CenterAlignPos(FontSmall, SliderText, BarPos + (BarSize.X * 0.5, 0)); BarPos.X += BarSize.X; if (CurValue < mMax) { SnapMenuTexture(Sliders[SLIDER_ARROWR], BarPos); } SnapMenuText( FontSmall, col, SliderTextPos, SliderText ); } } class OptionMenuItemSnapSlider : OptionMenuItemSlider { mixin SnapMenuDrawing; mixin SnapMenuItemCore; mixin SnapSliderBase; OptionMenuItemSnapSlider Init( String label, String tooltip, Name command, double min, double max, double step, int showval = 1, CVar graycheck = null) { super.Init(label, command, min, max, step, showval, graycheck); mTooltip = tooltip; return self; } virtual int GetLineSpacing() { return FontSmall.GetHeight(); } override void OnMenuCreated() { super.OnMenuCreated(); PrecacheMenuDrawing(); } virtual bool DisplayGrayed() { // I mostly only want to edit the // drawing, so this function exists now. if (Parent != null) { bool InList = Parent.ItemCurrentlyInList(self); if (InList == false) { return true; } } return isGrayed(); } virtual void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.DestPos = Delta + (BASE_VID_WIDTH * 0.5, 0); Cursor.DestPos = RightAlignPos(FontSmall, mLabel, Cursor.DestPos - (OPTIONS_MID_SPACE, 0)); Cursor.DestSmall = true; } virtual String GetSliderString(double Value, double Percent) { return DefaultSliderString(Value, Percent); } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { SliderDraw(desc, yOffset, xOffset, selected); return xOffset; } override bool MenuEvent(int mKey, bool gamepad) { double value = GetSliderValue(); bool ret = super.MenuEvent(mKey, gamepad); if (GetSliderValue() != value) { CursorPlayFire(); } return ret; } } class OptionMenuItemSnapScaleSlider : OptionMenuItemScaleSlider { mixin SnapMenuDrawing; mixin SnapMenuItemCore; mixin SnapSliderBase; OptionMenuItemSnapScaleSlider Init( String label, String tooltip, Name command, double min, double max, double step, String zero, String negone = "") { super.Init(label, command, min, max, step, zero, negone); mTooltip = tooltip; return self; } virtual int GetLineSpacing() { return FontSmall.GetHeight(); } override void OnMenuCreated() { super.OnMenuCreated(); PrecacheMenuDrawing(); } virtual bool DisplayGrayed() { // I mostly only want to edit the // drawing, so this function exists now. if (Parent != null) { bool InList = Parent.ItemCurrentlyInList(self); if (InList == false) { return true; } } return isGrayed(); } virtual void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.DestPos = Delta + (BASE_VID_WIDTH * 0.5, 0); Cursor.DestPos = RightAlignPos(FontSmall, mLabel, Cursor.DestPos - (OPTIONS_MID_SPACE, 0)); Cursor.DestSmall = true; } virtual String GetSliderString(double Value, double Percent) { int v = int(Value); switch (v) { case 0: return TextZero; case -1: return TextNegOne; default: return DefaultSliderString(Value, Percent); } } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { SliderDraw(desc, yOffset, xOffset, selected); return xOffset; } override bool MenuEvent(int mKey, bool gamepad) { double value = GetSliderValue(); bool ret = super.MenuEvent(mKey, gamepad); if (GetSliderValue() != value) { CursorPlayFire(); } return ret; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapPlayerRobo : SnapPlayer { Default { Tag "$TAG_SNAPBOT"; Player.DisplayName "Robo Snap"; SnapPlayer.AnimatorClass "SnapBotsAnimator"; Player.Portrait "ROBOFAC1"; //Player.ScoreIcon "ROBSFAC1"; SnapPlayer.SnapMugPrefix "ROBO"; SnapPlayer.SnapMugPrefixSmall "SROB"; // Snap Bot is a glass cannon. DamageFactor 1.65; DamageMultiply 1.65; } override Actor CreateShiftDIGhost(Vector3 SpawnPos) { Actor ghost = DefaultShiftDIGhost("SnapBotsGhost", SpawnPos, Pos, false); if (ghost == null) { return null; } if (self == players[consoleplayer].camera && !(self.player.cheats & CF_CHASECAM)) { ghost.bInvisible = true; } let player = self.player; if (player) { ghost.SetShade(player.GetDisplayColor()); } return ghost; } const BOT_POWER_TIME = 30 * TICRATE; const BOT_POWER_DRAIN = SnapPOWMax / BOT_POWER_TIME; const BOT_POWER_DRAIN_VS = BOT_POWER_DRAIN * 3.0; double BotPower; uint BotPowerFreeze; override bool AllowPOWGain() { if (BotPower > 0.0) { return false; } return super.AllowPOWGain(); } override void PlayerUseSuperPower() { SetRespawnInvul(); SnapInvulnTick = 12; A_StartSound("septacrash/use", CHAN_BODY); double seg = POWSegment(); BotPower = seg; BotPowerFreeze = TICRATE/2; } override void PlayerThink() { let player = self.player; UserCmd cmd = player.cmd; // No use key please :V cmd.buttons &= ~BT_USE; if (CheckFrozen() == true || PlayerRanHitstun == true) { if (PlayerRanHitstun == true && Hitstun.FromDamage == true) { UpdatePlayerAngles(); } return; } if (BotPowerFreeze > 0) { Vel = (0, 0, 0); player.Vel = (0, 0); if (!(player.cheats & CF_PREDICTING)) { TickPOWPSprites(); BotPowerFreeze--; } return; } super.PlayerThink(); if (!(player.cheats & CF_PREDICTING)) { if (BotPower > 0.0) { SetRespawnInvul(); SnapInvulnTick = 12; double Drain = BOT_POWER_DRAIN; if (deathmatch == true) { Drain = BOT_POWER_DRAIN_VS; } BotPower -= Drain; } else if (BotPower < 0.0) { BotPower = 0.0; } } } const NUM_POWER_FLASH_COLORS = 12; override int GetFlashTranslation() { if (BotPower > 0 && (Level.MapTime & 1)) { static const String PowerFlashColors[] = { "BotPowerFlashA", "BotPowerFlashB", "BotPowerFlashC", "BotPowerFlashD", "BotPowerFlashE", "BotPowerFlashF", "BotPowerFlashG", "BotPowerFlashH", "BotPowerFlashI", "BotPowerFlashJ", "BotPowerFlashK", "BotPowerFlashL" }; return Translate.GetID(PowerFlashColors[ (Level.MapTime / 2) % NUM_POWER_FLASH_COLORS ]); } return super.GetFlashTranslation(); } void SnapBotPlayerDeathExplode() { double a = random[snap_decor](0,7) * 45; double h = 10; double v = 8; Vector2 speed; class type = "SnapMonsterExplodeSmall"; A_StartSound("explosion/enemy", 9); speed = AngleToVector(a, h); double zh = 8 - (GetDefaultByType(type).Height * 0.5); Actor particle = Spawn(type, Pos + (0, 0, zh), ALLOW_REPLACE); particle.Vel = (speed.x, speed.y, v); } void SnapBotPlayerDeath() { A_DeathmatchHealthDrop(); A_StartSound("explosion/boss", 9, CHANF_OVERLAP); for (int i = 0; i < 8; i++) { double a = i * 45; double h = 10; double v = 8; Vector2 speed; if (i & 1) { h = 4; v = 12; } speed = AngleToVector(a, h); class type = "SnapMonsterExplode"; double zh = 8 - (GetDefaultByType(type).Height * 0.5); Actor particle = Spawn(type, Pos + (0, 0, zh), ALLOW_REPLACE); particle.Vel = (speed.x, speed.y, v); } for (int i = 0; i < 8; i++) { double a = (i * 45) + 22.5; double h = 4; double v = 12; Vector2 speed; if (i & 1) { h = 16; v = 16; } speed = AngleToVector(a, h); class type = "SnapMonsterExplode"; double zh = 8 - (GetDefaultByType(type).Height * 0.5); Actor particle = Spawn(type, Pos + (0, 0, zh), ALLOW_REPLACE); particle.Vel = (speed.x, speed.y, v); } double starta = random[snap_decor](0,7) * 45; for (int i = 0; i < 4; i++) { double a = starta + (i * 90); double h = 12; double v = 16; Vector2 speed; speed = AngleToVector(a, h); class type = "SnapMonsterShrapnelSpawner"; double zh = 8 - (GetDefaultByType(type).Height * 0.5); Actor particle = Spawn(type, Pos + (0, 0, zh), ALLOW_REPLACE); particle.Vel = (speed.x, speed.y, v); } A_SnapScreenShake(1280, 1536, 9.0, 1.0); } States { Spawn: ANIM A -1; Loop; Pain: PPAN A 4; PPAN A 4 SnapHurtScream(); Goto Spawn; Death: PPAN A 1; PPAN AAA 2 SnapBotPlayerDeathExplode(); PPAN A 0 A_PlayerScream; PPAN AAA 2 SnapBotPlayerDeathExplode(); TNT1 A 0 SnapBotPlayerDeath(); DeathCheck: TNT1 A 1 PlayerCorpseCheck(); Loop; DeathDone: TNT1 A -1; Stop; Power: Goto Spawn; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapDefinition abstract { Name ID; uint Sort; static void ParseForInt(in out int Dest, JsonObject Obj, String ObjKey) { JsonElement Elem = Obj.Get(ObjKey); if (Elem != null) { let ElemInt = JsonInt(Elem); if (ElemInt == null) { Console.Printf( "SNAPDEFS parse warning: element \"%s\" is not an integer.", ObjKey ); } else { Dest = ElemInt.i; } } } static void ParseForUInt(in out uint Dest, JsonObject Obj, String ObjKey) { JsonElement Elem = Obj.Get(ObjKey); if (Elem != null) { let ElemInt = JsonInt(Elem); if (ElemInt == null) { Console.Printf( "SNAPDEFS parse warning: element \"%s\" is not an integer.", ObjKey ); } else { int integer = ElemInt.i; if (integer < 0) { Console.Printf( "SNAPDEFS parse warning: element \"%s\" is < 0 for a field that only accepts positive integers.", ObjKey ); } else { Dest = uint(integer); } } } } static void ParseForName(in out Name Dest, JsonObject Obj, String ObjKey) { JsonElement Elem = Obj.Get(ObjKey); if (Elem != null) { let ElemStr = JsonString(Elem); if (ElemStr == null) { Console.Printf( "SNAPDEFS parse warning: element \"%s\" is not a string.", ObjKey ); } else { Dest = ElemStr.s; } } } static void ParseForString(in out String Dest, JsonObject Obj, String ObjKey) { JsonElement Elem = Obj.Get(ObjKey); if (Elem != null) { let ElemStr = JsonString(Elem); if (ElemStr == null) { Console.Printf( "SNAPDEFS parse warning: element \"%s\" is not a string.", ObjKey ); } else { Dest = ElemStr.s; } } } static CVar ParseForCVar(JsonObject Obj, String ObjKey) { JsonElement Elem = Obj.Get(ObjKey); if (Elem != null) { let ElemStr = JsonString(Elem); if (ElemStr == null) { Console.Printf( "SNAPDEFS parse warning: element \"%s\" is not a string.", ObjKey ); } else { return CVar.FindCVar(ElemStr.s); } } return null; } abstract void InternalDeserialize(JsonObject Obj); } class SnapDefinitions { void Deserialize(JsonElement Elem) { if (Elem == null) { // Invalid input, ignore. return; } let Obj = JsonObject(Elem); if (Obj == null) { // Not an object, ignore. return; } JsonElement ClearElem = Obj.Get("clear"); if (ClearElem != null) { let ClearValue = JsonBool(ClearElem); if (ClearValue == null) { Console.Printf("SNAPDEFS parse warning: element \"clear\" is not a bool."); } else { if (ClearValue.b == true) { MapHeap.Clear(); EpisodeHeap.Clear(); AchievementMap.Clear(); } } } JsonElement MapElem = Obj.Get("maps"); if (MapElem != null) { let MapObj = JsonObject(MapElem); if (MapObj == null) { Console.Printf("SNAPDEFS parse warning: element \"maps\" is not an object."); } else { JsonObjectKeys MapKeys = MapObj.GetKeys(); for (int i = 0; i < MapKeys.Keys.Size(); i++) { String MapKey = MapKeys.Keys[i]; SnapMapDef.Deserialize( MapHeap, MapKey, MapObj.Get(MapKey) ); } } } JsonElement EpisodeElem = Obj.Get("episodes"); if (EpisodeElem != null) { let EpisodeObj = JsonObject(EpisodeElem); if (EpisodeObj == null) { Console.Printf("SNAPDEFS parse warning: element \"episodes\" is not an object."); } else { JsonObjectKeys EpisodeKeys = EpisodeObj.GetKeys(); for (int i = 0; i < EpisodeKeys.Keys.Size(); i++) { String EpisodeKey = EpisodeKeys.Keys[i]; SnapEpisodeDef.Deserialize( EpisodeHeap, EpisodeKey, EpisodeObj.Get(EpisodeKey) ); } } } JsonElement AchievementElem = Obj.Get("achievements"); if (AchievementElem != null) { let AchievementObj = JsonObject(AchievementElem); if (AchievementObj == null) { Console.Printf( "SNAPDEFS parse warning: element \"%s\" is not an object.", "achievements" ); } else { JsonObjectKeys AchievementKeys = AchievementObj.GetKeys(); for (int i = 0; i < AchievementKeys.Keys.Size(); i++) { String AchievementKey = AchievementKeys.Keys[i]; SnapAchievementDef.Deserialize( AchievementMap, AchievementKey, AchievementObj.Get(AchievementKey) ); } } } } } #include "./snapdefs/map.zs" #include "./snapdefs/episode.zs" #include "./snapdefs/conditions.zs" #include "./snapdefs/rewards.zs" #include "./snapdefs/achievements.zs" extend class SnapStaticEventHandler { SnapDefinitions SnapDefs; void ReadSnapDefs() { SnapDefs = new("SnapDefinitions"); int lump = Wads.FindLump("SNAPDEFS", 0, Wads.NS_GLOBAL); while (lump != -1) { JsonElementOrError data = JSON.Parse(Wads.ReadLump(lump), false); if (data is "JsonError") { ThrowAbortException("SNAPDEFS (@ %s) recieved fatal error '%s', ignoring...", Wads.GetLumpFullName(lump), JsonError(data).what); } else { SnapDefs.Deserialize(JsonElement(data)); } lump = Wads.FindLump("SNAPDEFS", lump + 1, Wads.NS_GLOBAL); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapSpeedParticle : SnapDynamicDecor { Default { RenderStyle "Add"; VisibleAngles -90, 90; VisiblePitch -180, 180; +MASKROTATION +BRIGHT +WALLSPRITE } States { Spawn: PWPS ABCDEFGHIJ 1; Stop; } } class SnapSpeedParticleOther : SnapSpeedParticle { States { Spawn: PWS2 ABCDEFGHIJ 1; Stop; } } class SnapSpeedPower : PowerSpeed { mixin SnapPowerupFix; Default { Speed 1.5; Powerup.Duration -30; PowerSpeed.NoTrail 1; } override bool HandlePickup(Inventory item) { return NewPowerupLogic(item); } override void DoEffect() { if (Owner == NULL || Owner.player == NULL) return; if (Owner.player.cheats & CF_PREDICTING) return; if (Level.maptime & 1) return; if (Owner.Vel.Length() < 4) return; for (Inventory item = Inv; item != NULL; item = item.Inv) { let sitem = SnapSpeedPower(item); if (sitem != null) { return; } } Vector3 startPos = Owner.Pos; startPos.X += frandom[snap_decor](-Owner.Radius, Owner.Radius); startPos.Y += frandom[snap_decor](-Owner.Radius, Owner.Radius); startPos.Z += frandom[snap_decor](0.0, Owner.Height); double VelAngle = atan2(Owner.Vel.Y, Owner.Vel.X); if (Owner.Vel.X < 0) { VelAngle = 360 + VelAngle; } Actor particleObject = Spawn("SnapSpeedParticle", startPos, ALLOW_REPLACE); if (particleObject) { particleObject.Vel = Owner.Vel * 0.5; particleObject.Angle = VelAngle - 90; particleObject.target = Owner; particleObject.Scale = Owner.Scale; if (Owner == players[consoleplayer].camera && !(Owner.player.cheats & CF_CHASECAM)) { particleObject.bInvisible = true; } } Actor otherParticleObject = Spawn("SnapSpeedParticleOther", startPos, ALLOW_REPLACE); if (otherParticleObject) { otherParticleObject.Vel = Owner.Vel * 0.5; otherParticleObject.Angle = VelAngle + 90; otherParticleObject.target = Owner; otherParticleObject.Scale = Owner.Scale; if (Owner == players[consoleplayer].camera && !(Owner.player.cheats & CF_CHASECAM)) { otherParticleObject.bInvisible = true; } } } } class SnapSpeedPowerup : SnapBigPowerup { Default { Inventory.PickupMessage "$POWERUP_SPEED"; SnapBigPowerup.VoiceSample "voice/speed"; Powerup.Type "SnapSpeedPower"; } States { Spawn: PW_S A 10; PW_S A 10 Bright; Loop; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapSplashBase : SnapDynamicDecor abstract { Default { +NOGRAVITY } action void A_SpawnRadiusDrops( class type, uint numParticles, double hMom, double vMom, double angleOffset = 0.0) { if (numParticles == 0) { return; } double angleAdd = 360.0 / numParticles; double baseAngle = angle; if (Target != null) { baseAngle = Target.angle; } else { baseAngle += frandom[snap_splash](-angleAdd * 0.5, angleAdd * 0.5); } double a = baseAngle + angleOffset; hMom += (hMom * 0.1) * frandom[snap_splash](-2.0, 4.0); vMom += (vMom * 0.1) * frandom[snap_splash](-2.0, 4.0); for (uint i = 0; i < numParticles; i++) { Actor Droplet = Spawn(type, Vec3Offset(cos(a) * 4.0, sin(a) * 4.0, 0.0), ALLOW_REPLACE); if (Droplet) { Droplet.Vel.XY = ( hMom * cos(a), hMom * sin(a) ); Droplet.Vel.Z = vMom; Droplet.Scale = Scale; Droplet.Target = Target; if (Target != null) { Droplet.Vel.XY += Target.Vel.XY; } } a += angleAdd; } } States { Spawn: TNT1 A 1; Stop; } } class SnapWaterImpact : SnapSplashBase { States { Spawn: SPLB ABCDEF 2; Stop; } } class SnapWaterDrops : SnapSplashBase { Default { VSpeed 4.0; -NOGRAVITY } States { Spawn: SPLD ABCDE 3; Stop; } } class SnapWaterDropsShort : SnapWaterDrops { States { Spawn: SPLD A 1; SPLD BCDE 3; Stop; } } class SnapWaterImpactWithDrops : SnapWaterImpact { override void PostBeginPlay() { A_SpawnRadiusDrops( "SnapWaterDrops", 4, 6.0, 8.0, 0.0 ); A_SpawnRadiusDrops( "SnapWaterDropsShort", 4, 12.0, 6.0, 45.0 ); } } class SnapLavaImpact : SnapSplashBase { Default { +BRIGHT } States { Spawn: LSPB ABCDEF 3; Stop; } } class SnapLavaDrops : SnapSplashBase { Default { VSpeed 3.0; +BRIGHT -NOGRAVITY } States { Spawn: LSPD ABCDE 3; Stop; } override void Tick() { super.Tick(); if (Level.isFrozen()) { return; } Actor trail = Spawn("SnapLavaDropTrail", Pos, ALLOW_REPLACE); if (trail) { trail.Vel = -Vel * 0.1; } } } class SnapLavaDropsShort : SnapLavaDrops { States { Spawn: LSPD ABCDE 1; Stop; } } class SnapLavaImpactWithDrops : SnapLavaImpact { override void PostBeginPlay() { A_SpawnRadiusDrops( "SnapLavaDrops", 4, 6.0, 8.0, 0.0 ); A_SpawnRadiusDrops( "SnapLavaDropsShort", 4, 12.0, 6.0, 45.0 ); } } class SnapLavaDropTrail : SnapSplashBase { Default { +BRIGHT } States { Spawn: TNT1 A 1; Trail1: LSPT A 7; Stop; Trail2: LSPT B 7; Stop; Trail3: LSPT C 7; Stop; Trail4: LSPT D 7; Stop; Trail5: LSPT E 7; Stop; Trail6: LSPT F 7; Stop; } override void Tick() { super.Tick(); if (Level.isFrozen()) { return; } bInvisible = !bInvisible; } override void BeginPlay() { super.BeginPlay(); statelabel labels[6]; labels[0] = "Trail1"; labels[1] = "Trail2"; labels[2] = "Trail3"; labels[3] = "Trail4"; labels[4] = "Trail5"; labels[5] = "Trail6"; SetStateLabel(labels[random[snap_decor](0, 5)]); } } class SnapMuckImpact : SnapSplashBase { Default { +BRIGHT } States { Spawn: MSPB ABCDEF 2; Stop; } } class SnapMuckDrops : SnapSplashBase { Default { VSpeed 2.0; -NOGRAVITY +BRIGHT } States { Spawn: MSPD ABCDE 3; Stop; } } class SnapMuckDropsShort : SnapMuckDrops { States { Spawn: MSPD A 1; MSPD BCDE 3; Stop; } } class SnapMuckImpactWithDrops : SnapMuckImpact { override void PostBeginPlay() { A_SpawnRadiusDrops( "SnapMuckDrops", 4, 6.0, 6.0, 0.0 ); A_SpawnRadiusDrops( "SnapMuckDropsShort", 4, 8.0, 4.0, 45.0 ); } } class SnapGroundDust : SnapSplashBase { Default { VSpeed 2.0; //RenderStyle "Add"; //Alpha 0.5; +SnapStaticDecor.MISSILESPRITEFIX } States { Spawn: //FPUF ABCD 2; PUFF CDEFGH 1; Stop; } } class SnapGroundImpact : SnapSplashBase { override void PostBeginPlay() { A_SpawnRadiusDrops( "SnapGroundDust", 5, 12.0, 2.0, 0.0 ); } } class SnapOilImpact : SnapWaterImpact { States { Spawn: SPOB ABCDEF 2; Stop; } } class SnapOilDrops : SnapWaterDrops { States { Spawn: SPOD ABCDE 3; Stop; } } class SnapOilDropsShort : SnapOilDrops { States { Spawn: SPOD A 1; SPOD BCDE 3; Stop; } } class SnapOilImpactWithDrops : SnapOilImpact { override void PostBeginPlay() { A_SpawnRadiusDrops( "SnapOilDrops", 4, 6.0, 8.0, 0.0 ); A_SpawnRadiusDrops( "SnapOilDropsShort", 4, 12.0, 6.0, 45.0 ); } } class SnapSplashSpot : SnapDynamicDecor abstract { meta class SplashType; property SplashType: SplashType; action void A_SpawnWaterfallSplashes(class type = null) { double SplashAngle = random[snap_splash](0, 359); double SplashDist = random[snap_splash](0, int(Radius)); Vector3 NewPos = Pos; NewPos.XY += ( SplashDist * cos(SplashAngle), SplashDist * sin(SplashAngle) ); if (type == null) { let sp = SnapSplashSpot(self); if (sp) { type = sp.SplashType; } if (type == null) { return; } } Actor Splash = Spawn(type, NewPos, ALLOW_REPLACE); if (Splash) { Splash.Scale *= 2.0; } } Default { Radius 40; Height 1; +INVISIBLE -SOLID } States { Spawn: TNT1 A random(1, 10); SpawnLoop: TNT1 A 8 A_SpawnWaterfallSplashes(); Loop; } } class SnapWaterfallSpot : SnapSplashSpot { Default { SnapSplashSpot.SplashType "SnapWaterImpactWithDrops"; } } class SnapLavafallSpot : SnapSplashSpot { Default { SnapSplashSpot.SplashType "SnapLavaImpactWithDrops"; } } class SnapMuckfallSpot : SnapSplashSpot { Default { SnapSplashSpot.SplashType "SnapMuckImpactWithDrops"; } } class SnapOilfallSpot : SnapSplashSpot { Default { SnapSplashSpot.SplashType "SnapOilImpactWithDrops"; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapSpreadProps : SnapWeaponProps { override void Init() { WeaponName = "Spread"; NiceName = "$SNAPMENU_WEAPON_SPREAD"; PickupType = "SnapSpreadPowerup"; WeaponIcon = "WP_SPRED"; FireState = "FireSpread"; DropFreq = 5; } } class SnapSpreadCan : SnapItemCan { Default { DropItem "SnapSpreadPowerup"; } States { Spawn: WP_S A 10; WP_S A 10 Bright; Loop; } } class SnapSpreadPowerup : SnapWeaponPowerup { Default { SnapWeaponPowerup.WeaponPower "Spread"; Inventory.PickupMessage "$POWERUP_SPREAD"; SnapInventory.VoiceSample "voice/spread"; } States { Spawn: WP_S B 10; WP_S B 10 Bright; Loop; } } class SnapSpreadShot : SnapBasicShot { // Rapid has 10 damage per shot, and fires 3 // Spread has 7 damage per shot, and fires 7 // This evens out to make Rapid and Spread roughly the same power. // The main deciding factors between them are DPS, // spread vs precision, the distance of the encounter, // and just plain user preference. Default { DamageFunction 6; DamageType "Spread"; Obituary "$OB_SPREAD"; Mass 5; ProjectileKickback 1000; } States { Spawn: SBUL ABCDEFGH 1 Light("SpreadShotLight"); SpawnLoop: SBUL IJKL 1 Light("SpreadShotLight"); Loop; Death: SBUL MMMNNOP 1 Light("SpreadShotLight"); Stop; } } extend class SnapGun { action void A_SnapgunSpread() { if (player == null || player.mo == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } A_SnapgunFlash('SpreadFlash'); int numProjectiles = 7; // We keep changing it :V double startOffset = 15.0; double offsetAmt = (startOffset * 2) / (numProjectiles-1); double angleOffset = startOffset; //double originalPitch = BulletSlope(); for (int i = 0; i < numProjectiles; i++) { A_SnapgunMomentumProjectile("SnapSpreadShot", angleOffset); angleOffset -= offsetAmt; } A_StartSound("revolver/spread", CHAN_WEAPON); SoundAlert(self); player.mo.TakeInventory("SnapPowerupAmmo", 1, false, true); } States { FireSpread: SGUN A 1 A_SnapgunSpread; SGUN BCD 1; SGUN E 3; SGUN A 0 A_SnapGunRefire(); SGUN E 3; SGUN F 5; Goto GunIdle; SpreadFlash: TNT1 A 1 Bright A_Light(2); SFL2 A 1 Bright A_Light(1); SFL2 B 1 Bright A_Light(0); SFL2 C 1 Bright; SFL2 D 1 Bright; Goto LightDone; } } // // ======== // Static elements // ======== // // StaticLabel: // Centered, moves with options. class OptionMenuItemSnapStaticLabel : SnapMenuItemBase { Font mFont; OptionMenuItemSnapStaticLabel Init(String Label, Name FontName = "SmallFont") { super.Init(Label, 'None', true); mFont = Font.GetFont(FontName); return self; } override bool Selectable() { return false; } override int GetLineSpacing() { return mFont.GetHeight(); } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { UpdateScaleParameters(); Vector2 Pos = (160 + xOffset, yOffset); int col = Font.CR_UNTRANSLATED; if (DisplayGrayed() == true) { col = FontGrayColor; } SnapMenuText( mFont, col, CenterAlignPos(mFont, mLabel, Pos), mLabel ); return xOffset; } } // StaticHeader: // Centered, moves with options. class OptionMenuItemSnapStaticHeader : OptionMenuItemSnapStaticLabel { TextureID mBigStrip; OptionMenuItemSnapStaticHeader Init(String Label) { super.Init(Label, "MenuFont"); mBigStrip = TexMan.CheckForTexture("BIGSTRIP", TexMan.Type_MiscPatch); return self; } override int GetLineSpacing() { return mFont.GetHeight() * 3; } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { if (mLabel.Length() == 0) { // invisible headers, to fix // the scrolling between headered // and headerless options submenus return xOffset; } UpdateScaleParameters(); int h = mFont.GetHeight(); Vector2 Pos = (160 + xOffset, yOffset + h); Vector2 TexSize = SnapMenuTextureSize(mBigStrip); SnapMenuTexture( mBigStrip, Pos + (-TexSize.X * 0.5, 1) ); int col = FontHeaderColor; if (DisplayGrayed() == true) { col = FontGrayColor; } SnapMenuText( mFont, col, CenterAlignPos(mFont, mLabel, Pos), mLabel ); return xOffset; } } // StaticText: // Exact X/Y coordinates, always on-screen. class OptionMenuItemSnapStaticText : OptionMenuItemSnapStaticLabel { Vector2 mTextPos; OptionMenuItemSnapStaticText Init(String Label, int x, int y, String FontName = "SmallFont") { super.Init(Label, FontName); mTextPos = (x, y); return self; } override int GetLineSpacing() { return 0; } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { UpdateScaleParameters(); Vector2 Pos = mTextPos; if (Parent != null) { Pos.X -= (1.0 - Parent.MenuTransition) * VirtualSize.X; } SnapMenuText( mFont, Font.CR_UNTRANSLATED, Pos, mLabel ); return xOffset; } } // StaticPatch: // Centered, moves with options. class OptionMenuItemSnapStaticPatch : SnapMenuItemBase { TextureID mTexture; OptionMenuItemSnapStaticPatch Init(String TextureName) { super.Init("", 'None', true); mTexture = TexMan.CheckForTexture(TextureName, TexMan.Type_MiscPatch); return self; } override bool Selectable() { return false; } override int GetLineSpacing() { Vector2 TexSize = SnapMenuTextureSize(mTexture); return int(TexSize.Y); } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { UpdateScaleParameters(); Vector2 TexSize = SnapMenuTextureSize(mTexture); Vector2 Pos = (160 + xOffset, yOffset); SnapMenuTexture( mTexture, Pos - (TexSize.X * 0.5, 0.0) ); return xOffset; } } // StaticLogo: // Exact X/Y coordinates, always on-screen. class OptionMenuItemSnapStaticLogo : OptionMenuItemSnapStaticPatch { Vector2 mLogoPos; OptionMenuItemSnapStaticLogo Init(String TextureName, int x, int y) { super.Init(TextureName); mLogoPos = (x, y); return self; } override int GetLineSpacing() { return 0; } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { UpdateScaleParameters(); Vector2 Pos = mLogoPos; if (Parent != null) { Pos.X -= (1.0 - Parent.MenuTransition) * VirtualSize.X; } SnapMenuTexture( mTexture, Pos ); return xOffset; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapStaticEventHandler { CVar StatVar_Robots; CVar StatVar_PlayTime; CVar StatVar_Matches; CVar StatVar_RobotsKicked; CVar StatVar_RobotsJuggled; CVar StatVar_RobotsMineSnailCollateral; CVar StatVar_RobotsTrafficCollateral; CVar StatVar_RobotsSeptacrash; CVar StatVar_RobotsMineSnailStepOn; CVar StatVar_VitalityBest; CVar StatVar_KickCombo; CVar StatVar_RobotsLockOn; CVar StatVar_ComboBest; void AddStatRobotsNormal() { if (StatVar_Robots == null) { StatVar_Robots = CVar.FindCVar("snap_stats_robots"); if (StatVar_Robots == null) { return; } } StatVar_Robots.SetInt( StatVar_Robots.GetInt() + 1 ); } void AddStatRobotsMineSnailCollateral() { if (StatVar_RobotsMineSnailCollateral == null) { StatVar_RobotsMineSnailCollateral = CVar.FindCVar("snap_stats_robots_minesnail_collateral"); if (StatVar_RobotsMineSnailCollateral == null) { return; } } StatVar_RobotsMineSnailCollateral.SetInt( StatVar_RobotsMineSnailCollateral.GetInt() + 1 ); } void AddStatRobotsTrafficCollateral() { if (StatVar_RobotsTrafficCollateral == null) { StatVar_RobotsTrafficCollateral = CVar.FindCVar("snap_stats_robots_traffic_collateral"); if (StatVar_RobotsTrafficCollateral == null) { return; } } StatVar_RobotsTrafficCollateral.SetInt( StatVar_RobotsTrafficCollateral.GetInt() + 1 ); } void AddStatRobotsSeptacrash() { if (StatVar_RobotsSeptacrash == null) { StatVar_RobotsSeptacrash = CVar.FindCVar("snap_stats_robots_septacrash"); if (StatVar_RobotsSeptacrash == null) { return; } } StatVar_RobotsSeptacrash.SetInt( StatVar_RobotsSeptacrash.GetInt() + 1 ); } void AddStatRobotsMineSnailStepOn() { if (StatVar_RobotsMineSnailStepOn == null) { StatVar_RobotsMineSnailStepOn = CVar.FindCVar("snap_stats_robots_minesnail_stepon"); if (StatVar_RobotsMineSnailStepOn == null) { return; } } StatVar_RobotsMineSnailStepOn.SetInt( StatVar_RobotsMineSnailStepOn.GetInt() + 1 ); } void AddStatRobotsLockOn() { if (StatVar_RobotsLockOn == null) { StatVar_RobotsLockOn = CVar.FindCVar("snap_stats_robots_lockon"); if (StatVar_RobotsLockOn == null) { return; } } StatVar_RobotsLockOn.SetInt( StatVar_RobotsLockOn.GetInt() + 1 ); } void AddStatRobots(Actor Victim, Actor Inflictor, Actor Source, Name mod) { if (Victim == null || Victim.bCountKill == false) { return; } if (Victim.Target == null && !(Inflictor != null && Inflictor is "PlayerPawn") && !(Source != null && Source is "PlayerPawn")) { // Do not count if it was an "idle" hit that // a player was not involved with return; } if (multiplayer == true) { PlayerInfo Player = null; if (Source != null) { Player = Source.Player; } if (Player != players[consoleplayer]) { return; } } AddStatRobotsNormal(); if (Inflictor != null && Victim != Inflictor && Inflictor is "MineSnail") { AddStatRobotsMineSnailCollateral(); } let ms = MineSnail(Victim); if (ms != null) { if (ms.WasSteppedOn == true) { AddStatRobotsMineSnailStepOn(); } } if (mod == "Roadkill") { AddStatRobotsTrafficCollateral(); } if (mod == "ScreenClear" || mod == "BotPower") { AddStatRobotsSeptacrash(); } let sp = SnapPlayer(Source); if (sp != null) { if (Victim == sp.LockOn) { AddStatRobotsLockOn(); } } } void AddStatRobotsKicked() { if (StatVar_RobotsKicked == null) { StatVar_RobotsKicked = CVar.FindCVar("snap_stats_robots_kicked"); if (StatVar_RobotsKicked == null) { return; } } StatVar_RobotsKicked.SetInt( StatVar_RobotsKicked.GetInt() + 1 ); } void AddStatRobotsJuggled() { if (StatVar_RobotsJuggled == null) { StatVar_RobotsJuggled = CVar.FindCVar("snap_stats_robots_juggled"); if (StatVar_RobotsJuggled == null) { return; } } StatVar_RobotsJuggled.SetInt( StatVar_RobotsJuggled.GetInt() + 1 ); } void SetStatKickCombo(PlayerInfo player, int NewCombo) { PlayerInfo con = players[consoleplayer]; if (player != con) { return; } if (StatVar_KickCombo == null) { StatVar_KickCombo = CVar.FindCVar("snap_stats_kick_combo"); if (StatVar_KickCombo == null) { return; } } if (NewCombo <= StatVar_KickCombo.GetInt()) { return; } StatVar_KickCombo.SetInt( NewCombo ); } void AddStatRobotOnDamage(Actor Victim, Actor Inflictor, Actor Source, int Damage, Name mod) { if (Victim == null || Victim.bCountKill == false) { return; } if (multiplayer == true) { PlayerInfo Player = null; if (Source != null) { Player = Source.Player; } if (Player != players[consoleplayer]) { return; } } let sm = SnapMonster(Victim); //AddStatRobotsDamaged(Damage); if (mod == "Melee") { AddStatRobotsKicked(); } if (sm != null) { if (sm.kickTossed == true && sm.WasJuggled == false && mod != "Melee") { AddStatRobotsJuggled(); sm.WasJuggled = true; } } } void AddStatPlayTime(int Seconds) { if (Seconds <= 0) { return; } if (StatVar_PlayTime == null) { StatVar_PlayTime = CVar.FindCVar("snap_stats_playtime"); if (StatVar_PlayTime == null) { return; } } StatVar_PlayTime.SetInt( StatVar_PlayTime.GetInt() + Seconds ); } void AddStatMatches(void) { if (StatVar_Matches == null) { StatVar_Matches = CVar.FindCVar("snap_stats_matches"); if (StatVar_Matches == null) { return; } } StatVar_Matches.SetInt( StatVar_Matches.GetInt() + 1 ); } void SetStatVitalityBest(PlayerInfo player, int NewHealth) { PlayerInfo con = players[consoleplayer]; if (player != con) { return; } if (StatVar_VitalityBest == null) { StatVar_VitalityBest = CVar.FindCVar("snap_stats_vitality_best"); if (StatVar_VitalityBest == null) { return; } } if (NewHealth <= StatVar_VitalityBest.GetInt()) { return; } StatVar_VitalityBest.SetInt( NewHealth ); } void SetStatComboBest(PlayerInfo player, int NewCombo) { PlayerInfo con = players[consoleplayer]; if (player != con) { return; } if (StatVar_ComboBest == null) { StatVar_ComboBest = CVar.FindCVar("snap_stats_combo_best"); if (StatVar_ComboBest == null) { return; } } if (NewCombo <= StatVar_ComboBest.GetInt()) { return; } StatVar_ComboBest.SetInt( NewCombo ); } static clearscope void CheckAchievements() { let ev = SnapStaticEventHandler.Get(); if (ev == null) { return; } SnapDefinitions defs = ev.SnapDefs; if (defs == null) { return; } MapIterator it; if (it.Init(defs.AchievementMap) == false) { return; } while (it.Next() == true) { SnapAchievementDef Achievement = it.GetValue(); if (Achievement == null) { continue; } if (Achievement.StatusVar == null) { continue; } int Status = Achievement.StatusVar.GetInt(); int StatusMode = (Status & Achievement.STATUS_MASK); if (StatusMode == SnapAchievementDef.STATUS_UNFINISHED) { bool WasAchieved = Achievement.ConditionAchieved(); if (WasAchieved == false) { continue; } // Tell the achievements menu to do the cool // explosion animation. Achievement.StatusVar.SetInt( SnapAchievementDef.STATUS_NEWLY_UNLOCKED | (Status & Achievement.STATUS_FLAG_MASK) ); } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- // // Base for new submenu types // class SnapMenuItemSubmenu : OptionMenuItemSubmenu abstract { mixin SnapMenuDrawing; mixin SnapMenuItemCore; SnapMenuItemSubmenu Init( String label, String tooltip, Name command, int param = 0) { super.Init(label, command, param, false); mTooltip = tooltip; return self; } virtual int GetLineSpacing() { return 0; } override void OnMenuCreated() { super.OnMenuCreated(); PrecacheMenuDrawing(); } virtual bool isGrayed() { return false; } virtual bool DisplayGrayed() { // I mostly only want to edit the // drawing, so this function exists now. if (Parent != null) { bool InList = Parent.ItemCurrentlyInList(self); if (InList == false) { return true; } } return isGrayed(); } virtual void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.Offscreen(); } override bool Activate() { bool ret = super.Activate(); if (ret == true) { CursorPlayFire(); } return ret; } } // // Locked submenus with taglines, for episode / skill selects. // class SnapMenuItemSubmenuLocked : SnapMenuItemSubmenu abstract { virtual bool Locked() { return false; } override bool isGrayed() { if (Locked() == true) { return true; } return super.isGrayed(); } override bool Activate() { if (Locked() == true) { Menu.MenuSound("menu/cant"); return true; } return super.Activate(); } } // // Regular options submenu // class OptionMenuItemSnapSubmenu : SnapMenuItemSubmenu { override int GetLineSpacing() { return FontSmall.GetHeight(); } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { UpdateScaleParameters(); Vector2 Pos = ((BASE_VID_WIDTH * 0.5) + xOffset + OPTIONS_SUBMENU_SPACE, yOffset); int col = Font.CR_UNTRANSLATED; if (DisplayGrayed() == true) { col = FontGrayColor; } else if (selected == true) { col = FontHighlightColor; } String text = String.Format("%s...", StringTable.Localize(mLabel)); SnapMenuText( FontSmall, col, RightAlignPos(FontSmall, text, Pos), text ); return xOffset; } override void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.DestPos = Delta + (BASE_VID_WIDTH * 0.5, 0); String text = String.Format("%s...", StringTable.Localize(mLabel)); Cursor.DestPos = RightAlignPos(FontSmall, text, Cursor.DestPos - (OPTIONS_MID_SPACE, 0)); Cursor.DestSmall = true; } } // // Top menu header submenu // class OptionMenuItemSnapHeaderSubmenu : SnapMenuItemSubmenuLocked { override int GetLineSpacing() { return 24; } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { UpdateScaleParameters(); Vector2 Pos = (300 + xOffset, 2 + yOffset); int col = Font.CR_UNTRANSLATED; if (DisplayGrayed() == true) { col = FontGrayColor; } else if (selected == true) { col = FontHighlightColor; } DrawMenuHeader( mLabel, RightAlignPos(FontHeader, mLabel, Pos), col ); return xOffset; } override void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.DestPos = Delta + (300, 0); Cursor.DestPos = RightAlignPos(FontHeader, mLabel, Cursor.DestPos); Cursor.DestSmall = false; } } class OptionMenuItemSnapHeaderNotInDemo : OptionMenuItemSnapHeaderSubmenu { OptionMenuItemSnapHeaderNotInDemo Init(String label) { super.Init(label, "$SNAPMENU_NOT_IN_DEMO", 'None', 0); return self; } override bool Locked() { return true; } } // // Big font submenu // class OptionMenuItemSnapBigSubmenu : SnapMenuItemSubmenuLocked { override int GetLineSpacing() { return FontBig.GetHeight() + 4; } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { UpdateScaleParameters(); Vector2 Pos = (OPTIONS_SUBMENU_SPACE + xOffset, 2 + yOffset); int col = Font.CR_UNTRANSLATED; if (DisplayGrayed() == true) { col = FontGrayColor; } else if (selected == true) { col = FontHighlightColor; } SnapMenuText(FontBig, col, Pos, mLabel); return xOffset; } override void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.DestPos = Delta + (OPTIONS_SUBMENU_SPACE, 0); Cursor.DestSmall = false; } } // // Trial Mode menu // class OptionMenuItemSnapSubmenuTrial : OptionMenuItemSnapHeaderSubmenu { override bool Locked() { return SnapEpisodeDef.AllLocked(GT_TRIAL); } override String Tooltip() { if (Locked() == true) { return "$SNAPMENU_TRIAL_LOCKED"; } return super.Tooltip(); } } // // Custom Mode menu // class OptionMenuItemSnapSubmenuCustom : OptionMenuItemSnapHeaderSubmenu { override bool Locked() { if (SnapAchievementReward.AllCustomGameOptionsLocked() == true) { return true; } return SnapEpisodeDef.AllLocked(GT_CUSTOM); } override String Tooltip() { if (SnapAchievementReward.AllCustomGameOptionsLocked() == true) { return "$SNAPMENU_CUSTOM_LOCKED"; } if (SnapEpisodeDef.AllLocked(GT_CUSTOM) == true) { return "$SNAPMENU_TRIAL_LOCKED"; } return super.Tooltip(); } } // // Resume button // class OptionMenuItemSnapResume : OptionMenuItemSnapHeaderSubmenu { OptionMenuItemSnapResume Init(String label) { super.Init(label, "", "", 0); return self; } override bool Activate() { Menu.GetCurrentMenu().MenuEvent(Menu.MKEY_Back, true); CursorPlayFire(); return true; } } // // Retry button // class OptionMenuItemSnapRetry : OptionMenuItemSnapHeaderSubmenu { override bool Locked() { return (netgame || gamestate != GS_LEVEL); } } // // Credits button // class OptionMenuItemSnapCredits : OptionMenuItemSnapHeaderSubmenu { OptionMenuItemSnapCredits Init(String label, String tooltip) { super.Init(label, tooltip, "", 0); return self; } override bool Activate() { let m = SnapMenuBase(Menu.GetCurrentMenu()); if (m != null) { CursorPlayFire(); m.SetFocus(self); Menu.MenuSound("menu/advance"); SnapFader.StartGameFade(true, 0.02); } return true; } override void Ticker() { super.Ticker(); let m = SnapMenuBase(Menu.GetCurrentMenu()); if (m != null) { if (m.CheckFocus(self) && m.MenuData.Fader.FadeOffset >= 1.0) { Menu.SetMenu("EpisodeMenu", 0); // Param sets player class ID Menu.SetMenu("SkillMenu", 1); // Param sets episode ID Menu.SetMenu("StartGame", 0); // Param sets skill ID m.ReleaseFocus(); } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class InvasionSubwave play abstract { // Called when we first change to a subwave virtual void Init(InvasionThinker Inv) { // NOP } // Called every tic while the // Returning true ends execution. abstract bool Execute(InvasionThinker Inv, bool FastForward); // Once Execute has returned true, // this is the pause before executing the next command. uint Delay; } class InvasionSubwaveDelay : InvasionSubwave { enum SubwaveWaitFor { WAIT_FOR_TICK = 0, WAIT_FOR_MONSTERS, } uint WaitFor; override bool Execute(InvasionThinker Inv, bool FastForward) { if (FastForward == true) { return true; } switch (WaitFor) { case WAIT_FOR_MONSTERS: { ActorIterator MonsterFinder = Level.CreateActorIterator(InvasionThinker.INVASION_MONSTER_TID); Actor Monster = MonsterFinder.Next(); return (Monster == null); } default: { return true; } } } static void Create( int WaitFor = WAIT_FOR_TICK, int Delay = 0) { let inv = InvasionThinker.Get(); if (inv == null) { return; } InvasionSubwaveDelay Subwave = new("InvasionSubwaveDelay"); Subwave.WaitFor = WaitFor; Subwave.Delay = inv.ScaleDelay(Delay); inv.InsertSubwave(Subwave); } } class InvasionSubwaveMonsters : InvasionSubwave { class Type; int Amount; int Freq; int EntranceID; int Modifiers; int ExtraValue; override bool Execute(InvasionThinker Inv, bool FastForward) { if (FastForward == true) { return true; } Inv.QueueInvasionMonster(Type, EntranceID, Modifiers, ExtraValue); Amount--; Inv.SubwaveDelay = Freq; return (Amount <= 0); } static void Create( String TypeStr, int Modifiers, int ExtraValue, int Amount, int EntranceID, int Freq = 0, int Delay = 0) { let inv = InvasionThinker.Get(); if (inv == null) { return; } class NewType = TypeStr; if (NewType == null) { Console.Printf("Unknown monster type '%s'", TypeStr); return; } // Bosses already scale their health, so don't scale their amount!! bool isBoss = ((Modifiers & MOD_BOSSIFY) != 0 || GetDefaultByType(NewType).bBoss == true); InvasionSubwaveMonsters Subwave = new("InvasionSubwaveMonsters"); Subwave.Type = NewType; Subwave.Amount = (isBoss == true) ? Amount : inv.ScaleAmount(Amount); Subwave.EntranceID = EntranceID; Subwave.Modifiers = (Modifiers & MOD_MASK); Subwave.ExtraValue = ExtraValue; Subwave.Freq = inv.ScaleDelay(Freq); Subwave.Delay = inv.ScaleDelay(Delay); inv.InsertSubwave(Subwave); } } class InvasionSubwaveItems : InvasionSubwave { class Type; uint Amount; uint Freq; override bool Execute(InvasionThinker Inv, bool FastForward) { if (FastForward == true) { return true; } Inv.QueueInvasionItem(Type); Amount--; Inv.SubwaveDelay = Freq; return (Amount <= 0); } static void Create( String TypeStr, int Amount, int Freq = 0, int Delay = 0) { let inv = InvasionThinker.Get(); if (inv == null) { return; } class NewType = TypeStr; if (NewType == null) { Console.Printf("Unknown item type '%s'", TypeStr); return; } InvasionSubwaveItems Subwave = new("InvasionSubwaveItems"); Subwave.Type = NewType; Subwave.Amount = Amount; Subwave.Freq = inv.ScaleDelay(Freq); Subwave.Delay = inv.ScaleDelay(Delay); inv.InsertSubwave(Subwave); } } class InvasionSubwaveScript : InvasionSubwave { int ScriptID; int Args[4]; override bool Execute(InvasionThinker Inv, bool FastForward) { ACS_ExecuteWithResult(ScriptID, Args[0], Args[1], Args[2], Args[3]); return true; } static void Create( Name ScriptName, int Arg1 = 0, int Arg2 = 0, int Arg3 = 0, int Arg4 = 0, int Delay = 0) { CreateDirect( -int(ScriptName), Arg1, Arg2, Arg3, Arg4, Delay ); } static void CreateDirect( int ScriptID, int Arg1 = 0, int Arg2 = 0, int Arg3 = 0, int Arg4 = 0, int Delay = 0) { let inv = InvasionThinker.Get(); if (inv == null) { return; } InvasionSubwaveScript Subwave = new("InvasionSubwaveScript"); Subwave.ScriptID = ScriptID; Subwave.Args[0] = Arg1; Subwave.Args[1] = Arg2; Subwave.Args[2] = Arg3; Subwave.Args[3] = Arg4; Subwave.Delay = inv.ScaleDelay(Delay); inv.InsertSubwave(Subwave); } } class InvasionSubwaveWarning : InvasionSubwave { uint Timer; override bool Execute(InvasionThinker Inv, bool FastForward) { if (FastForward == true) { return true; } SnapEventHandler.StartBossWarning(); Inv.Delay = SnapEventHandler.BOSSWARNTIME; // Prevents fast-forward before the WARNING can finish return true; } static void Create() { let inv = InvasionThinker.Get(); if (inv == null) { return; } InvasionSubwaveWarning Subwave = new("InvasionSubwaveWarning"); inv.InsertSubwave(Subwave); } } extend class InvasionThinker { Array Subwaves; uint SubwaveDelay; void ResetSubwaves() { for (int i = 0; i < Subwaves.Size(); i++) { if (Subwaves[i] != null) { Subwaves[i].Destroy(); } } Subwaves.Clear(); SubwaveDelay = 0; for (int i = 0; i < Subwaves.Size(); i++) { if (Subwaves[i] != null) { Subwaves[i].Destroy(); } } FirstMonsterWasSpawned = false; WaveExtraTicks = 0; } void InsertSubwave(InvasionSubwave Subwave) { Subwaves.Push(Subwave); } void ExecuteSubwave(bool FastForward = false) { if (Subwaves.Size() == 0) { // No subwaves left to execute! return; } InvasionSubwave Subwave = Subwaves[0]; bool done = Subwave.Execute(self, FastForward); if (done == true) { if (FastForward == false) { // Delay by its delay value SubwaveDelay = Subwave.Delay; } Subwaves.Delete(0); Subwave.Destroy(); if (Subwaves.Size() >= 1) { Subwave = Subwaves[0]; Subwave.Init(self); } } } void SubwaveTick() { if (SubwaveDelay > 0) { SubwaveDelay--; } else { ExecuteSubwave(); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SuddenDeathFlameSpawner : OceanFlameSpawner { Default { Obituary "$OB_SDBOMB"; } } class SuddenDeathBomb : OceanBomb { Default { Obituary "$OB_SDBOMB"; +NOINTERACTION } override void Tick() { super.Tick(); if (bNoInteraction == true) { if (Pos.Z + Height <= CeilingZ || Pos.Z <= FloorZ) { // Make solid once it enters the level. bNoInteraction = false; } if (TickPaused() == true) { return; } // NoInteraction typically has no gravity Vel.Z -= Gravity; } } } extend class SnapEventHandler { const SDBOMB_START = 20*TICRATE; const SDBOMB_HEIGHT = 1024.0; const SDBOMB_START_FREQ = 3*TICRATE/2; const SDBOMB_END_FREQ = 7; const SDBOMB_FREQ_SCALE = 7; uint VSSuddenDeath; int VSSDBombFreq; int VSSDBombDelay; uint HurryUp; void ResetSuddenDeath() { VSSuddenDeath = 0; VSSDBombDelay = 0; VSSDBombFreq = SDBOMB_START_FREQ; } bool CheckSuddenDeath() { int Best = 0; int BestTeam = Team.NoTeam; bool Tied = false; for (uint i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] == false) { continue; } let mo = SnapPlayer(players[i].mo); if (mo == null) { continue; } int frags = mo.GetFragCount(); int teamID = Team.NoTeam; if (teamplay == true) { teamID = players[i].GetTeam(); } if (frags > Best) { Best = frags; BestTeam = teamID; Tied = false; } else if (frags == Best && (BestTeam != teamID || BestTeam == Team.NoTeam)) { Tied = true; } } if (Best <= 0) { // Not even a single point has been scored yet. return true; } // If there is no clear winner yet, // then go into OVERTIME. return Tied; } void TickSuddenDeath() { if (HurryUp > 0) { HurryUp--; } if (VSSuddenDeath == 0) { // Init Sudden Death HurryUp = VS_GAME_TIME; WordScale = 1.0; PlayAnnouncerLine("announcer/hurry"); } VSSuddenDeath++; bool DoBombs = false; // Spawn trails of bombs behind each player. // Frequency based on how long Sudden Death has been active. if (VSSuddenDeath > SDBOMB_START) { if (VSSDBombDelay <= 0) { int numPlayers = 0; int add = 0; for (uint i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] == false) { continue; } numPlayers++; } add = max(0, (numPlayers-2) * SDBOMB_FREQ_SCALE); DoBombs = true; VSSDBombDelay = VSSDBombFreq + add; if (VSSDBombFreq > SDBOMB_END_FREQ) { VSSDBombFreq--; } } else { VSSDBombDelay--; } } for (uint i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] == false) { continue; } let mo = players[i].mo; if (mo == null) { continue; } // Gradually reduce everyone's health down to 1. if (players[i].Health > 1) { players[i].Health--; } if (mo.Health > 1) { mo.Health--; let sp = SnapPlayer(mo); if (sp != null) { sp.A_DamageSound(1); } } if (DoBombs == true) { let bomb = mo.Spawn("SuddenDeathBomb", mo.Pos + (0, 0, SDBOMB_HEIGHT), ALLOW_REPLACE); if (bomb != null) { bomb.Vel.XY = mo.Vel.XY * 0.35; } } } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapPlayer { double SwayAngle; double SwayPitch; Vector2 SwayOffset; Vector2 PrevSwayOffset; Vector2 AngleSway; void CalcSnapSway() { let player = self.player; if (player == null || player.mo == null) { return; } PrevSwayOffset = SwayOffset; Vector2 DestSwayOffset = (0, 0); if (CheckFrozen() == false) { double XMul = 1.0; double YMul = 0.5; double aDelta = DeltaAngle(SwayAngle, Angle); // yes, intentionally flipped double pDelta = DeltaAngle(Pitch, SwayPitch) * 2.0; double spd = player.Vel.Length(); double FDot = 0.0; double SDot = 0.0; if (spd > 0.0) { FDot = AngleToVector(Angle) dot player.Vel; SDot = AngleToVector(Angle + 90) dot player.Vel; } double MoveSwayAmt = spd * 0.1; double AngleSwayAmt = 2.0; Vector2 DestAngleSway = ( aDelta * AngleSwayAmt, pDelta * AngleSwayAmt ); DestSwayOffset = AngleSway + ( SDot * MoveSwayAmt * XMul, FDot * MoveSwayAmt * YMul ); AngleSway += (DestAngleSway - AngleSway) * 0.2; // Let's add in our own bobbing, too. if (GetCVar("snap_screenbob") == true) { double BobV = 0; double BobH = 0; double BobAmt = 0; double BobAngle = 0; double TickMul = TICRATE / 35; double spdVal = 16.0; if (spd > 0.0) { BobAngle = Level.maptime / (22.5 * TickMul) * 360; BobAmt = player.bob * (spd / spdVal); if (waterlevel > 1) { BobAmt *= 0.5; } BobH = BobAmt * cos(BobAngle + 90); BobV = BobAmt * sin(-BobAngle * 2.0) * 2.0; } else if (player.health > 0) { BobAngle = Level.maptime / (120 * TickMul) * 360; BobAmt = player.GetStillBob(); BobV = BobAmt * sin(BobAngle) * 2.0; } DestSwayOffset.X += BobH; DestSwayOffset.Y += BobV; } // When landing, your gun reacts too. if (player.DeltaViewHeight < 0.0) { DestSwayOffset.Y -= player.DeltaViewHeight * 16.0; } } // Don't show the gun cut-off. if (DestSwayOffset.Y < -2.0) { DestSwayOffset.Y = -2.0; } if (CheckFrozen() == false) { SwayOffset += (DestSwayOffset - SwayOffset) * 0.25; } SwayAngle = Angle; SwayPitch = Pitch; } override void CalcHeight() { if (GetCVar("snap_screenbob") == false) { ViewBob = 0.0; FlyBob = 0.0; } else { ViewBob = Default.ViewBob; FlyBob = Default.FlyBob; } super.CalcHeight(); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapTeleportFog : SnapDynamicDecor replaces TeleportFog { Default { RenderStyle "Add"; +BRIGHT } States { Spawn: TELE ABCDEFGHIGHIGHIGHIGHI 1; TNT1 A 1; TELE G 1; TNT1 A 1; TELE H 1; TNT1 A 1; TELE I 1; TNT1 A 2; TELE G 1; TNT1 A 2; TELE H 1; TNT1 A 2; TELE I 1; Stop; } override void PostBeginPlay() { if (Level.MapTime == 0) { // Suppress first tick Coop teleport effect Destroy(); return; } super.PostBeginPlay(); A_StartSound("misc/teleport", CHAN_BODY); } } class SnapItemFog : SnapDynamicDecor replaces ItemFog { Default { RenderStyle "Add"; +BRIGHT } States { Spawn: TELI ABCDEFG 1; Stop; } override void PostBeginPlay() { super.PostBeginPlay(); A_StartSound("misc/spawn", CHAN_BODY); } } class SnapTeleportPadCircle : SnapDynamicDecor { Default { Radius 32; Height 24; RenderStyle "Add"; +BRIGHT +FLATSPRITE +NOINTERACTION +NOBLOCKMAP +NOGRAVITY +DONTSPLASH -SOLID } States { Spawn: TNT1 A 1; TPAD ABCDE 3; Stop; } } class SnapTeleportPadSparkle : SnapDynamicDecor { Default { Radius 8; Height 16; RenderStyle "Add"; +BRIGHT +NOINTERACTION +NOBLOCKMAP +NOGRAVITY +DONTSPLASH -SOLID } States { Spawn: TNT1 A 1; TPAD IGHIJK 2; //FGHIJK Stop; } } class SnapTeleportPadEFX : SnapDynamicDecor { void SpawnTeleportCircle() { Actor Circle = Spawn("SnapTeleportPadCircle", Pos, ALLOW_REPLACE); if (Circle != null) { Circle.Vel.Z = 4.0; } } void SpawnTeleportSparkle(int time) { double SpAngle = frandom[snap_decor](-180, 180); //45.0 * (time % 8); double SpDis = frandom[snap_decor](0.0, 24.0); //24.0; Vector3 NewPos = Vec3Offset( SpDis * cos(SpAngle), SpDis * sin(SpAngle), 4.0 ); Actor Sparkle = Spawn("SnapTeleportPadSparkle", NewPos, ALLOW_REPLACE); if (Sparkle != null) { Sparkle.Vel.Z = frandom[snap_decor](2.0, 8.0); } } Default { Radius 32; Height 24; +NOINTERACTION +NOBLOCKMAP +NOGRAVITY +DONTSPLASH +INVISIBLE -SOLID +RANDOMIZE +MOVEWITHSECTOR +RELATIVETOFLOOR } const TICFREQ = 3; //3 override void Tick() { super.Tick(); if (isFrozen() == true) { return; } if (Level.maptime % TICFREQ != 0) { return; } int time = Level.maptime / TICFREQ; if (time & 1) { SpawnTeleportSparkle(time / 2); } else { SpawnTeleportCircle(); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class TerajoltLaser : SnapMissile { Default { Radius 36; Height 32; Speed 50; DamageFunction 5; RenderStyle "Add"; +RIPPER +BRIGHT } States { Spawn: LASR ABC 1 Light("TerajoltLaserLight"); Loop; Death: LASR D random(0,2) Light("TerajoltLaserLight"); LASR EFGHI 1 Light("TerajoltLaserLight"); LASR DEFGHI 1 Light("TerajoltLaserLight"); Stop; } override void PostBeginPlay() { super.PostBeginPlay(); SetHitstunParent(Target); } } class TerajoltTeleportEFX : SnapActor { Default { RenderStyle "Add"; +NOBLOCKMAP +NOGRAVITY +NOINTERACTION +BRIGHT } States { Spawn: TNT1 A 1; TJTL ABCDEF 1; Stop; Reverse: TNT1 A 1; TJTL FEDBCA 1; Stop; } override void PostBeginPlay() { super.PostBeginPlay(); SetHitstunParent(Target); } } class TerajoltShield : SnapMonster { action void A_TerajoltShieldCheck() { let ourselves = TerajoltShield(self); if (!ourselves) { // this is so stupid return; } let t = Terajolt(ourselves.master); if (t == null || t.Health <= 0) { // no owner A_Die(); } } Default { Health 150; Radius 36; Height 64; Mass 1000; SnapShadowActor.ShadowSize 16; Species "Robot"; -COUNTKILL -CANPUSHWALLS -CANUSEWALLS -ACTIVATEMCROSS -ISMONSTER +NOPAIN +DONTTHRUST +NOGRAVITY +NOTARGETSWITCH -SnapActor.CANDROPAMMO +CANTSEEK +DONTFALL +NOTELEPORT } States { Spawn: PRSS ABCDEF 2 A_TerajoltShieldCheck(); Loop; Death: PRSS A 1; TNT1 A 35 DoSnapMonsterDie(); Stop; } override bool CanCollideWith(Actor other, bool passive) { if (self.master == other) { // Don't collide with your owner return false; } else if (other.bIsMonster) { // Don't collide with monsters return false; } else if (other is "TerajoltShield") { // Don't collide with other shields return false; } else if (other.bMissile && other.target == self.master) { // Don't collide with your own Terajolt's laser return false; } // Yeah, you can go ahead and collide. return super.CanCollideWith(other, passive); } override void InitBossMeter() { return; } override int GetFlashTranslation() { let tj = Terajolt(master); if (tj != null && tj.Teleporting == true) { return tj.TeleportFlash(); } return super.GetFlashTranslation(); } } class Terajolt : SnapMonster { TerajoltShield TerajoltShields[4]; int TerajoltRotateDir; uint TerajoltRotateTick; uint TerajoltLaserTick; double LaserPitch; bool Teleporting; uint TeleportStep; Vector2 TeleportScale; Vector2 TeleportDir; uint TeleportCall; const TELESPEED = 36; const TELECLEARANCE = 72; const TerajoltLaserMax = 70; const TerajoltTeleTick = 35; action state A_TerajoltCharge() { let ourselves = Terajolt(self); if (!ourselves) { // this is so stupid return null; } A_FaceTarget(22.5); if (target) { Vector2 XYDiff = Vec2To(target); double OurCenter = Pos.Z + (Height * 0.5); double TheirCenter = target.Pos.Z + (target.Height * 0.5); double ZDiff = TheirCenter - OurCenter - FloorClip; ourselves.LaserPitch = VectorAngle(XYDiff.Length(), ZDiff); } ourselves.TerajoltLaserTick++; if ((ourselves.bVeryRude == true) && (ourselves.TerajoltLaserTick == ourselves.TerajoltTeleTick)) { return ResolveState("Teleport"); } if (ourselves.TerajoltLaserTick >= ourselves.TerajoltLaserMax) { A_StartSound("prism/fire"); ourselves.TerajoltLaserTick = 0; return ResolveState("Fire"); } if (!(ourselves.TerajoltLaserTick & 2)) { static const String chargingSounds[] = { "prism/charge1", "prism/charge2", "prism/charge3", "prism/charge4", "prism/charge5", "prism/charge6" }; int numChargeSounds = 6; // uses numChargeSounds+2 to hold on the last sound a bit longer than the others int chargeProgress = (ourselves.TerajoltLaserTick * (numChargeSounds+2)) / ourselves.TerajoltLaserMax; if (chargeProgress < 0) { chargeProgress = 0; } if (chargeProgress >= numChargeSounds) { chargeProgress = numChargeSounds-1; } A_StartSound(chargingSounds[chargeProgress]); } return null; } action void A_TerajoltResetCharge() { let ourselves = Terajolt(self); if (!ourselves) { // this is so stupid return; } ourselves.TerajoltLaserTick = 0; } action void A_TerajoltLaser() { let ourselves = Terajolt(self); if (!ourselves) { // this is so stupid return; } A_SnapMonsterProjectile( "TerajoltLaser", (0, 0, 0), angle, ourselves.LaserPitch, SMP_ABSOLUTEANGLE|SMP_ABSOLUTEPITCH|SMP_DONTAIM ); } action void A_TerajoltTeleportBookend(bool Invert) { let t = Terajolt(self); if (!t) { // this is so stupid return; } bNoPain = !Invert; bInvulnerable = !Invert; bDontThrust = !Invert; if (Invert == true) { Scale = t.TeleportScale; t.Teleporting = false; } else { t.TeleportScale = Scale; t.TeleportStep = 0; t.Teleporting = true; } } action void A_TerajoltTeleportScale(bool Invert) { let t = Terajolt(self); if (!t) { // this is so stupid return; } if (Invert == true) { t.TeleportStep--; } else { t.TeleportStep++; } double mul = 1.0 + (t.TeleportStep * 0.75); Scale.X = t.TeleportScale.X * mul; Scale.Y = t.TeleportScale.Y / mul; } action void A_TerajoltTeleportFlags(bool Invert) { let t = Terajolt(self); if (!t) { // this is so stupid return; } bInvisible = !Invert; bNonShootable = !Invert; bCantSeek = !Invert; bSolid = Invert; bSlidesOnWalls = !Invert; if (Invert == true) { t.TeleportDir = (0, 0); A_ChangeLinkFlags(0, 0); t.TeleportStep = 5; A_FaceTarget(); } else { double TeleAngle = angle; if (target != null) { Vector2 vec = Vec2To(target); TeleAngle = VectorAngle(vec.x, vec.y); } if (t.TeleportCall & 1) { TeleAngle -= 90; } else { TeleAngle += 90; } t.TeleportCall++; t.TeleportDir = (cos(TeleAngle), sin(TeleAngle)); A_ChangeLinkFlags(1, 1); } } action state A_TerajoltValidTeleport() { BlockThingsIterator it = BlockThingsIterator.Create(self, TELECLEARANCE); double OurCenter = Pos.Z + (Height * 0.5); while (it.Next()) { if (it.thing != null && it.thing.bSolid == true && it.thing.master != self) // Terajolt shield { double TheirCenter = it.thing.Pos.Z + (it.thing.Height * 0.5); Vector3 dis = ( abs(it.thing.Pos.x - self.Pos.x), abs(it.thing.Pos.y - self.Pos.y), abs(TheirCenter - OurCenter) ); double XYDisCheck = TELECLEARANCE + it.thing.radius; double ZDisCheck = TELECLEARANCE + (it.thing.height * 0.5); if (dis.x < XYDisCheck || dis.y < XYDisCheck || dis.Z < ZDisCheck) { continue; } // You'll be inside another object, continue teleporting return null; } } // We can end the teleport. return ResolveState("TeleportEnd"); } void TerajoltTeleportEFX(bool reverse = false) { Actor efx = Spawn("TerajoltTeleportEFX", Pos, ALLOW_REPLACE); if (efx != null) { if (reverse == true) { TeleportDir = (0, 0); efx.SetStateLabel("Reverse"); } } } override bool HandleMonsterMove(Vector2 TryMoveDir, int dropoff, in out FCheckPosition tm) { double CurSpeed = Vel.XY.Length(); double AddSpeed = Speed / 3.0; Vector2 NewVel = Vel.XY + (AddSpeed * TryMoveDir); double NewSpeed = NewVel.Length(); if (NewSpeed >= Speed) { Vel.XY = SnapUtils.SafeVec2Unit(NewVel) * Speed; } else { Vel.XY = NewVel; } tm.FromPMove = true; tm.floorz = FloorZ; tm.floatok = true; return (GetWallBounceDir() == (0, 0)); } override bool HandleMonsterFloat(int FloatDir) { if (FloatDir == 0) { return false; } double FS = (FloatDir * FloatSpeed); double CurSpeed = abs(Vel.Z); double AddSpeed = FS / 3.0; double NewVel = Vel.Z + AddSpeed; double NewSpeed = abs(NewVel); if (NewSpeed >= abs(FS)) { if (FloatDir < 0) { Vel.Z = -FloatSpeed; } else { Vel.Z = FloatSpeed; } } else { Vel.Z = NewVel; } return false; } Default { Health 100; Radius 36; Height 64; Speed 8; Mass 1000; SnapMonster.Poise 80; SnapShadowActor.ShadowSize 24; SnapActor.Score 1000; SeeSound "prism/see"; ActiveSound "prism/idle"; PainSound "prism/hurt"; Obituary "$OB_TERAJOLT"; Tag "$TAG_TERAJOLT"; Species "Robot"; +FLOAT +AVOIDMELEE +NOGRAVITY +DONTFALL +SnapMonster.ROBOTTOUGH } States { Spawn: PRSM A 10 A_SnapMonsterLook(); Loop; See: PRSM A 3 A_SnapChase(); Loop; Missile: PRSM FGH 2; MissileLoop: PRSM BBBCCCDDDEEE 1 A_TerajoltCharge(); Loop; Fire: PRSM BBBBBBBBBBBBBBBBBBBB 1 A_TerajoltLaser(); PRSM HGF 2; Goto See; Teleport: PRSM B 0 A_StartSound("prism/teleport", CHAN_AUTO); PRSM B 0 A_TerajoltTeleportBookend(false); PRSM BBBB 1 A_TerajoltTeleportScale(false); PRSM B 0 A_TerajoltTeleportFlags(false); PRSM B 6 TerajoltTeleportEFX(); PRSM B 30; TeleportLoop: PRSM B 10 A_TerajoltValidTeleport(); Loop; TeleportEnd: PRSM B 0 A_StartSound("prism/teleport", CHAN_AUTO); PRSM B 6 TerajoltTeleportEFX(true); PRSM B 0 A_TerajoltTeleportFlags(true); PRSM BBBB 1 A_TerajoltTeleportScale(true); PRSM B 0 A_TerajoltTeleportBookend(true); Goto MissileLoop; Pain: PRSM J 2 A_TerajoltResetCharge(); PRSM K 2 A_SnapMonsterPain(); PRSM L 2; Goto See; Kicked: PRSM J 2 A_TerajoltResetCharge(); PRSM K 2 A_SnapMonsterPain(); PRSM L 2; KickLoop: PRSM J 2 A_EndKick(); PRSM K 1; PRSM K 1 A_EndKick(); PRSM L 2; Loop; Death: PRSM J 1; PRSM BJKLBJKL 4 DoSnapMonsterExplode(); TNT1 A 35 DoSnapMonsterDie(); Stop; GiantDeath: PRSM J 1; PRSM BJKLB 4 DoSnapBossExplode(); PRSM J 4 DoSnapBossBigExplode(); PRSM KLBJK 4 DoSnapBossExplode(); PRSM L 4 DoSnapBossBigExplode(); PRSM BJKLB 4 DoSnapBossExplode(); PRSM J 4 DoSnapBossBigExplode(); PRSM KLBJK 4 DoSnapBossExplode(); PRSM L 4 DoSnapBossBigExplode(); PRSM BJKLB 4 DoSnapBossExplode(); TNT1 A 35 DoSnapBossDie(); Stop; } override void BeginPlay() { super.BeginPlay(); let ourselves = Terajolt(self); if (!ourselves) { // this is so stupid return; } TerajoltRotateDir = 1; if (int(self.Pos.x / 128) & 1) { TerajoltRotateDir = -TerajoltRotateDir; } if (int(self.Pos.y / 128) & 1) { TerajoltRotateDir = -TerajoltRotateDir; } TerajoltLaserTick = 0; for (int i = 0; i < 4; i++) { double a = (i * 90); double dist = (ourselves.radius * 2) + 2; Vector2 Offset = AngleToVector(a, dist); Actor act = Spawn("TerajoltShield", (Pos.X + Offset.x, Pos.Y + Offset.y, Pos.Z), ALLOW_REPLACE); let newShield = TerajoltShield(act); if (newShield) { newShield.master = ourselves; newShield.SetHitstunParent(ourselves); ourselves.TerajoltShields[i] = newShield; } } } const TJSROTSPEED = 0.5; override void Tick() { super.Tick(); if (Health <= 0) { return; } bool pause = TickPaused(); if (pause == false) { TerajoltRotateTick++; if (Teleporting == true) { Vel.Z = 0; if (TeleportDir != (0, 0)) { Vector2 wallBump = GetWallBounceDir(); if (wallBump != (0, 0)) { TeleportDir = wallBump; } Vel.XY = TeleportDir * TELESPEED; } else { Vel.XY = (0, 0); } } } for (uint i = 0; i < 4; i++) { let Shield = TerajoltShield(TerajoltShields[i]); if (Shield == null) { continue; } double a = (TerajoltRotateTick * TJSROTSPEED) + (i * 90); double dist = 48.0 * Scale.X; Vector2 Offset = AngleToVector(a, dist); Vector3 NewPos = Pos; NewPos.xy += Offset; Shield.SetOrigin(NewPos, false); Shield.Angle = a + 90; Shield.Vel = Vel; if (Teleporting == true) { // Only update sprite size. Shield.Scale = Scale; Shield.A_SetSize( (Shield.Default.Radius / Shield.Default.Scale.X) * TeleportScale.X, (Default.Height / Default.Scale.Y) * TeleportScale.Y ); } else { if (Shield.Scale != Scale) { Shield.SetPhysicalSize(Scale); } } Shield.bInvisible = bInvisible; Shield.bInvulnerable = bInvulnerable; Shield.bNonShootable = bNonShootable; Shield.bSolid = bSolid; } } override void InitBossMeter() { super.InitBossMeter(); for (uint i = 0; i < 4; i++) { let Shield = SnapMonster(TerajoltShields[i]); if (Shield != null) { AddActorToBossMeter(Shield); } } } /* On second thought, we don't need to health buff both the Terajolt AND its shields. override void InitMonsterModifiers() { super.InitMonsterModifiers(); for (uint i = 0; i < 4; i++) { let Shield = SnapMonster(TerajoltShields[i]); if (Shield != null) { Shield.MonsterModifiers = self.MonsterModifiers; Shield.UpdateOurMonsterModifiers(); } } } */ int TeleportFlash() { static const Name tr[] = { "TeleportBrightA", "TeleportBrightB", "TeleportBrightC", "TeleportBrightD" }; int trid = max(0, min(3, TeleportStep-1)); return Translate.GetID(tr[trid]); } override int GetFlashTranslation() { if (Teleporting == true) { return TeleportFlash(); } return super.GetFlashTranslation(); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- extend class SnapEventHandler { uint LevelTimer; bool TimerPaused; const TIMER_STAT_UPDATE_FREQ = 1; // 5 void UpdateLevelTimer() { if (Level.isFrozen() == false && TimerPaused == false) { LevelTimer++; if (deathmatch == true) { CheckVersusWinConditions(); } if ((LevelTimer % (TICRATE * TIMER_STAT_UPDATE_FREQ)) == 0) { let sev = SnapStaticEventHandler.Get(); if (sev != null) { sev.AddStatPlayTime(TIMER_STAT_UPDATE_FREQ); } } } } void ResetLevelTimer() { LevelTimer = 0; TimerPaused = false; } static void SetTimerPause(bool newPause) { // Function for setting arbitrary timer pause, for ACS scripts. let ev = SnapEventHandler.Get(); if (ev == null) { return; } ev.TimerPaused = newPause; } static clearscope bool GetTimerPause() { let ev = SnapEventHandler.Get(); if (ev == null) { return false; } return ev.TimerPaused; } } extend class SnapStaticEventHandler { bool MadeSave; uint LastSaveTime; void ResetLastSaveTimer() { LastSaveTime = 0; } void UpdateLastSaveTimer() { SnapEventHandler ev = SnapEventHandler.Get(); if (ev == null) { return; } if (Level.isFrozen() == false && ev.TimerPaused == false) { LastSaveTime++; } } void SaveLoaded() { SnapEventHandler ev = SnapEventHandler.Get(); if (ev == null) { ResetLastSaveTimer(); return; } if (multiplayer == true) { // This is absolutely NOT going to be network safe, // and this doesn't matter for multiplayer anyway since // there isn't any grading, so don't even bother. ResetLastSaveTimer(); return; } if (ev.LevelTimer < TICRATE) { // Start of level save point, don't do this. ResetLastSaveTimer(); return; } // Add engine run-time to the actual level timer, // so that par-time is more reasonable. ev.LevelTimer += LastSaveTime; } static void DoSnapSave() { SnapStaticEventHandler ev = SnapStaticEventHandler.Get(); if (ev == null) { return; } LevelLocals.MakeAutoSave(); ev.ResetLastSaveTimer(); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class TitleSnap : SnapShadowActor { Default { Radius 16; Height 56; +SOLID } States { Spawn: PLAY ABCDEF 7; Loop; } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapMapItem : SnapMenuItemSubmenuLocked { SnapMapDef mMap; uint mStageNum; TextureID mIcon; TextureID mMapDarken; SnapMapRecord mRecords[NUM_RECORD_SKILLS]; bool MapLocked; SnapMapItem Init() { super.Init("", "", 'None', 0); mMapDarken = TexMan.CheckForTexture("MIDARKEN", TexMan.Type_MiscPatch); return self; } override int GetLineSpacing() { return 140; } override bool Locked() { return MapLocked; } override bool Activate() { if (Locked() == true) { Menu.MenuSound("menu/cant"); return true; } let p = SnapTrialMenu(Parent); if (p != null) { SnapMenuData.SetSelectedMap(mMap.ID); //SnapMenuData.SetSelectedSkill(-1); Name NextMenu = 'None'; switch (p.TrialType) { case GT_TRIAL: NextMenu = "SnapTrialSkill"; break; case GT_CUSTOM: NextMenu = "SnapCustomOptions"; break; default: // bad menu setup return false; } Menu.MenuSound("menu/advance"); Menu.SetMenu(NextMenu); return true; } return false; } override bool MouseEvent(int type, int x, int y) { if (type == Menu.MOUSE_Release) { let p = SnapHorizontalMenu(Parent); if (p != null) { int Selected = p.GetSelectedItem(); int ItemPos = p.GetItemPos(Selected); double NewPos = ItemPos - (BASE_VID_WIDTH * 0.5); if (abs(p.ScrollPos.X - NewPos) >= 1.0) { Menu.MenuSound("menu/change"); p.UpdateDestScroll(Selected, false); if (m_use_mouse == 2) { return true; } } } } return super.MouseEvent(type, x, y); } override int Draw(OptionMenuDescriptor desc, int yOffset, int xOffset, bool selected) { UpdateScaleParameters(); Vector2 Pos = ((GetLineSpacing() * 0.5) + xOffset, 70 + yOffset); /* if (Parent != null) { Pos.X += (1.0 - Parent.MenuTransition) * VirtualSize.X; } */ Vector2 IconPos = Pos - (40, 0); SnapMenuTexture(mIcon, IconPos); if (selected == false) { SnapMenuTextureAlpha(mMapDarken, IconPos, 0.5); } return xOffset; } override void UpdateCursor(Vector2 Delta, SnapMenuCursor Cursor) { Cursor.Offscreen(); } } class SnapTrialMenu : SnapHorizontalMenu { mixin SnapIntermissionDrawing; SnapEpisodeDef CurEpisode; TextureID SecretTextures[2]; uint TrialType; SnapMapItem CreateMapItem(SnapMapDef MapDef, uint Index) { let item = SnapMapItem( new("SnapMapItem") ); item.Init(); mDesc.mItems.Push(item); item.OnMenuCreated(); item.Parent = self; item.mMap = MapDef; item.mLabel = MapDef.Title; item.mStageNum = Index + 1; item.mIcon = TexMan.CheckForTexture(MapDef.Icon, TexMan.Type_MiscPatch); for (uint i = 0; i < NUM_RECORD_SKILLS; i++) { item.mRecords[i] = SnapMapRecord.Get(MapDef.ID, i + FIRST_GRADED_SKILL); } item.MapLocked = MapDef.Locked(TrialType); if (item.MapLocked == true) { item.mIcon = TexMan.CheckForTexture("MI_LOCK", TexMan.Type_MiscPatch); item.mLabel = "$SNAPMENU_RECORD_NOTVISITED"; } return item; } override void Init(Menu parent, OptionMenuDescriptor desc) { super.Init(parent, desc); IntermissionPrecache(); SecretTextures[0] = TexMan.CheckForTexture("SECR_NOT", TexMan.Type_MiscPatch); SecretTextures[1] = TexMan.CheckForTexture("SECR_GOT", TexMan.Type_MiscPatch); uint NumItems = mDesc.mItems.Size(); for (uint i = 0; i < NumItems; i++) { let item = mDesc.mItems[i]; let n = OptionMenuItemSnapGameType(item); if (n != null) { TrialType = n.mGameType; } if (item is "SnapMapItem") { item.Destroy(); mDesc.mItems.Delete(i); i--; NumItems--; continue; } } if (TrialType != GT_TRIAL && TrialType != GT_CUSTOM) { ThrowAbortException("Unsupported gametype for Trial menu"); return; } SnapMenuData.SetCustomGame( (TrialType == GT_CUSTOM) ); CurEpisode = SnapMenuData.GetSelectedEpisode(); if (CurEpisode == null) { ThrowAbortException("SnapTrialMenu reached without episode selected"); return; } uint NumMaps = CurEpisode.MapList.Size(); for (uint i = 0; i < NumMaps; i++) { SnapMapDef m = CurEpisode.MapList[i]; if (m != null) { CreateMapItem(m, i); } } if (StepThru() == true) { TryTransitionIn(null); } NumItems = mDesc.mItems.Size(); SnapMapDef LastMap = SnapMenuData.GetSelectedMap(); if (LastMap != null) { for (uint i = 0; i < NumItems; i++) { let item = mDesc.mItems[i]; let n = SnapMapItem(item); if (n != null) { if (n.mMap.ID == LastMap.ID) { SetSelectedItem(i); return; } } } } // Default to first one SetSelectedItem(FirstSelectable()); } override void ClampScrollPos() { int FirstPos = GetItemPos(FirstSelectable()); int LastPos = GetItemPos(LastSelectable()); DestScrollPos.X = clamp(DestScrollPos.X, FirstPos - (BASE_VID_WIDTH * 0.5), LastPos - (BASE_VID_WIDTH * 0.5)); } override void UpdateDestScroll(int Selected, bool force) { int ItemPos = GetItemPos(Selected); DestScrollPos.X = ItemPos - (BASE_VID_WIDTH * 0.5); if (force == true) { ScrollPos = DestScrollPos; } } override void ItemsDrawer() { super.ItemsDrawer(); int sel = GetSelectedItem(); if (sel >= 0 && sel < mDesc.mItems.Size()) { let item = SnapMapItem(mDesc.mItems[sel]); if (item != null) { Vector2 BaseTextPos = (BASE_VID_WIDTH * 0.5, 70); Vector2 TextPos = BaseTextPos; TextPos.Y -= (1.0 - MenuTransition) * (VirtualSize.Y * 0.5); SnapMenuText( FontSmall, Font.CR_UNTRANSLATED, CenterAlignPos(FontSmall, item.mLabel, TextPos - (0, 16)), item.mLabel ); String StageText = Stringtable.Localize("$INTER_STAGE") .. " " .. item.mStageNum; SnapMenuText( FontBig, Font.CR_UNTRANSLATED, CenterAlignPos(FontBig, StageText, TextPos - (0, 32)), StageText ); Vector2 GradePos = BaseTextPos + (0, 70); GradePos -= (72, 0); GradePos.Y += (1.0 - MenuTransition) * (VirtualSize.Y * 0.5); if (TrialType != GT_CUSTOM) { for (uint i = 0; i < NUM_RECORD_SKILLS; i++) { int Grade = GRADE_INVALID; if (item.mRecords[i] != null) { Grade = item.mRecords[i].Grade; } DrawGrade(Grade, GradePos, Menu.MenuTime() + (256 * i)); GradePos.X += 36; } Vector2 SkillPos = (BASE_VID_WIDTH * 0.5, 170); SkillPos.Y += (1.0 - MenuTransition) * (VirtualSize.Y * 0.5); DrawSticker(SkillPos + (0, 2), 138, STICKER_TYPE_TEXT); Vector2 SkillText = SkillPos - (54, 0); for (uint i = 0; i < NUM_RECORD_SKILLS; i++) { String disp = "X"; int col = FontGrayColor; switch (i) { case 0: disp = Stringtable.Localize("$SNAPMENU_SKILL_EASY_ACRONYM"); col = Font.FindFontColor("HPGreen"); break; case 1: disp = Stringtable.Localize("$SNAPMENU_SKILL_NORMAL_ACRONYM"); col = Font.FindFontColor("HPYellow"); break; case 2: disp = Stringtable.Localize("$SNAPMENU_SKILL_HARD_ACRONYM"); col = Font.FindFontColor("HPOrange"); break; case 3: disp = Stringtable.Localize("$SNAPMENU_SKILL_RUDE_ACRONYM"); col = Font.FindFontColor("HPRed"); break; } SnapMenuText( FontSmall, col, CenterAlignPos(FontSmall, disp, SkillText), disp ); SkillText.X += 36; } } Vector2 SecretBasePos = (BASE_VID_WIDTH * 0.5, 128); SecretBasePos.Y += (1.0 - MenuTransition) * (VirtualSize.Y * 0.5); if (item.mMap != null) { for (uint sk = 0; sk < SECRET_SAVE_SKILLS; sk++) { uint Total = item.mMap.TotalSecrets[sk]; if (Total == 0) { continue; } Vector2 SecretPos = SecretBasePos; SecretPos.X += (sk == 0) ? -36 : 36; SecretPos.X -= 9 * Total; for (uint i = 0; i < Total; i++) { bool Gotten = ((item.mMap.SecretFlags[sk] & (1 << i)) != 0); SnapMenuTexture(SecretTextures[Gotten ? 1 : 0], SecretPos); SecretPos.X += 18; } } } } } Vector2 HeaderPos = (BASE_VID_WIDTH * 0.5, 8); HeaderPos.Y -= (1.0 - MenuTransition) * (VirtualSize.Y * 0.5); String LabelText = ""; switch (TrialType) { case GT_CUSTOM: { LabelText = Stringtable.Localize("$SNAPMENU_CUSTOM"); break; } default: { LabelText = Stringtable.Localize("$SNAPMENU_TRIAL"); break; } } DrawMenuHeader( LabelText, CenterAlignPos(FontHeader, LabelText, HeaderPos) ); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapTurretShot : SnapMissile { Default { Radius 12; Height 20; Speed 15; DamageFunction 10; RenderStyle "Add"; SeeSound "turret/shoot"; DeathSound "revolver/death"; Obituary "$OB_TURRET"; SnapShadowActor.ShadowSize 16; +RANDOMIZE +BRIGHT } States { Spawn: TBUL ABCDEFGH 1 Light("TurretShotLight"); Loop; Death: TBUL IJIJKLKL 1 Light("TurretShotLight"); Stop; } } class SnapTurretRudeShot : SnapChargeShot { override void SpawnChargeHitConfirm(Actor victim, Actor source) { return; } action void A_RudeShotTrail() { if (Level.maptime & 1) { return; } uint timer = Level.maptime / 2; double ha = angle + 90; double va = (timer % 8) * 45; double dist = radius; Vector3 offset = ( dist * cos(ha) * cos(va), dist * sin(ha) * cos(va), (dist * 0.8) * sin(va) ); offset.Z += Height * 0.5; Actor particle = Spawn("SnapTurretRudeShotTrailA", Pos + offset, ALLOW_REPLACE); va += 180.0; offset = ( dist * cos(ha) * cos(va), dist * sin(ha) * cos(va), (dist * 0.8) * sin(va) ); offset.Z += Height * 0.5; particle = Spawn("SnapTurretRudeShotTrailB", Pos + offset, ALLOW_REPLACE); } action void A_RudeShotExplode() { double ha = angle + 90; for (int i = 0; i < 8; i++) { double va = i * 45; double spd = 16.0; Actor particle = null; Vector3 spawnPos = Pos; spawnPos.Z += Height * 0.5; if (i & 1) { particle = Spawn("SnapTurretRudeShotTrailB", spawnPos, ALLOW_REPLACE); } else { particle = Spawn("SnapTurretRudeShotTrailA", spawnPos, ALLOW_REPLACE); spd *= 0.5; } if (particle) { particle.Vel = ( spd * cos(ha) * cos(va), spd * sin(ha) * cos(va), spd * sin(va) ); } } } Default { SeeSound "revolver/chargeFire3"; Obituary "$OB_TURRET"; Radius 12; Height 20; Speed 20; SnapChargeShot.ChargeDamage 30; SnapChargeShot.ChargeSwerve 0.0; SnapChargeShot.ChargeRadius 30.0; } States { Spawn: TBLC GHIGHJ 1 Light("RudeTurretShotLight") A_RudeShotTrail(); Loop; Death: TBLC G 1 Light("RudeTurretShotLight"); TNT1 A 1 A_RudeShotExplode(); Stop; } } class SnapTurretRudeShotTrailA : SnapActor { Default { RenderStyle "Add"; +NOINTERACTION +NOGRAVITY +NOBLOCKMAP +RANDOMIZE +BRIGHT } States { Spawn: TBLC A 3; TBLC BABAB 1; Stop; } } class SnapTurretRudeShotTrailB : SnapTurretRudeShotTrailA { States { Spawn: TBLC C 3; TBLC DECDF 1; TBLC ABAB 1; Stop; } } class SnapTurretBase : SnapStaticDecor { States { Spawn: TURR A -1; Stop; } } class SnapTurret : SnapMonster { action void A_DestroyTurretBase(void) { if (tracer && tracer is "SnapTurretBase") { tracer.Destroy(); } } action state A_SnapTurretMissile(void) { let us = SnapTurret(self); if (!us) { return ResolveState("Missile"); } // No target, so don't do anything. // Just try and find a new target for next time. if (target == null || target.bShootable == false || CheckSight(target) == false) { if (target != null && target.bNonShootable == true) { // Target is only temporarily unshootable, so remember it. lastenemy = target; // Switch targets faster, since we're only changing because we can't // hurt our old one temporarily. threshold = 0; } // look for a new target if (LookForPlayers(true) == true && target != goal) { return null; // got a new target } if (target == null) { SetIdle(); return null; } return null; } if (us.bVeryRude == true) { // Rude, use the new missile state. return ResolveState("RudeMissile"); } return ResolveState("Missile"); } action void A_TurretCharge(void) { A_FaceTarget(22.5); double dist = 32.0; double ha = angle + 90; double va = (Level.maptime & 7) * 45; Vector3 offset = ( dist * cos(angle), dist * sin(angle), (height * 0.5) ); offset += ( dist * cos(va), dist * sin(va), 0.0 ); offset += ( dist * cos(va), dist * cos(va), dist * sin(va) ); Actor particle = Spawn("SnapTurretRudeShotTrailA", Pos + offset, ALLOW_REPLACE); if (particle) { particle.Vel = -Vec3To(particle) * 0.25; } } Default { Health 40; Radius 26; Height 36; Mass 100; SnapMonster.Poise 10; SeeSound "turret/see"; Obituary "$OB_TURRET"; Tag "$TAG_TURRET"; Species "Robot"; +DONTTHRUST -FLOORCLIP -WINDTHRUST } States { Spawn: TNT1 A 10 A_SnapMonsterLook(0, 0, 0, 0, 0, "WakeUp"); Loop; Idle: TURR J 10 A_SnapMonsterLook(0, 0, 0, 0, 0, "See"); Loop; WakeUp: TURR DEFGHI 2; See: TURR J 35; TURR J 0 A_SnapTurretMissile(); Loop; Missile: TURR JJJJJ 1 A_FaceTarget(22.5); TURR B 2 Light("TurretMuzzleLight") A_SnapMonsterProjectile("SnapTurretShot", (12, 0, 8)); TURR C 2 Light("TurretMuzzleLight"); TURR J 0 A_MonsterRefire(0, "Idle"); Goto See; RudeMissile: TURR JJJJJ 1 A_FaceTarget(22.5); TURR B 2 Light("TurretMuzzleLight") A_SnapMonsterProjectile("SnapTurretShot", (12, 0, 8)); TURR C 2 Light("TurretMuzzleLight"); TURR JJJJJ 1 A_FaceTarget(22.5); TURR B 2 Light("TurretMuzzleLight") A_SnapMonsterProjectile("SnapTurretShot", (12, 0, 8)); TURR C 2 Light("TurretMuzzleLight"); TURR JJJJJ 1 A_FaceTarget(22.5); TURR B 2 Light("TurretMuzzleLight") A_SnapMonsterProjectile("SnapTurretShot", (12, 0, 8)); TURR C 2 Light("TurretMuzzleLight"); TURR JJJJJJJJ 1 A_TurretCharge(); TURR JJJJJJJJ 1 A_TurretCharge(); TURR JJJJJJJJ 1 A_TurretCharge(); TURR B 2 Light("TurretMuzzleLight") A_SnapMonsterProjectile("SnapTurretRudeShot", (12, 0, 8)); TURR C 2 Light("TurretMuzzleLight"); Goto See; Pain: TURR J 3; TURR J 3 A_SnapMonsterPain(); Goto Idle; Death: TURR J 1; TNT1 A 0 A_DestroyTurretBase(); TNT1 A 35 DoSnapMonsterDie(); Stop; GiantDeath: TURR J 1; TURR JJJJJJJJ 4 DoSnapMonsterExplode(); TNT1 A 0 A_DestroyTurretBase(); TNT1 A 35 DoSnapMonsterDie(); Stop; } override void BeginPlay() { super.BeginPlay(); bool success; Actor act; [success, act] = A_SpawnItemEx("SnapTurretBase"); if (success) { tracer = act; } } override void Tick() { super.Tick(); if (tracer && tracer is "SnapTurretBase") { // Copy a buncha properties to the base tracer.SetOrigin(Pos, true); tracer.Vel = self.Vel; tracer.Scale = self.Scale; tracer.Translation = self.Translation; tracer.bBright = self.bBright; tracer.WorldOffset = self.WorldOffset; } } override void OnDestroy(void) { A_DestroyTurretBase(); super.OnDestroy(); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- // Episode 1 #include "./types/turret.zs" #include "./types/guardrobo.zs" #include "./types/minesnail.zs" #include "./types/cybrass.zs" #include "./types/arsontop.zs" #include "./types/terajolt.zs" #include "./types/dummyocean.zs" #include "./types/mosquito.zs" #include "./types/auger.zs" #include "./types/worm.zs" // Episode 2 #include "./types/snapbot.zs" #include "./types/riotrobo.zs" #include "./types/petwalker.zs" #include "./types/copterbomber.zs" #include "./types/plushsentry.zs" //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapUtils { // Basic utility functions. // Most of everything in here should be static so they can be called by anything. // Vector Units output NaN when given a length < epsilon. // This is very annoying, so I've created simple functions to give an empty vector instead. static bool ValidVec2Unit(Vector2 input) { return !(input ~== (0, 0)); } static bool ValidVec3Unit(Vector3 input) { return !(input ~== (0, 0, 0)); } static Vector2 SafeVec2Unit(Vector2 input) { if (ValidVec2Unit(input) == false) { return (0, 0); } return input.Unit(); } static Vector3 SafeVec3Unit(Vector3 input) { if (ValidVec3Unit(input) == false) { return (0, 0, 0); } return input.Unit(); } static Vector2 ReflectVector2(Vector2 d, Vector2 normal) { Vector2 n = SafeVec2Unit(normal); return d - (2 * (d dot n)) * n; } static Vector2 ProjectVector2(Vector2 input, Vector2 against) { Vector2 n = SafeVec2Unit(input); double t = (against dot n); return t * n; } static Vector2 SlideVector2(Vector2 input, Vector2 normal) { Vector2 n = SafeVec2Unit(normal); return input - n * (input dot n); } /* // TODO: non-actor dependent version of this static Vector3 RotateVector3(Vector3 vec, double angle, double pitch) { // Rotate by pitch Vector2 rotXZ = RotateVector((vec.x, vec.z), -pitch); vec.x = rotXZ.x; vec.z = rotXZ.y; // Rotate by angle vec.xy = RotateVector(vec.xy, angle); return vec; } */ static class GetStepSplashType(TerrainDef Terrain) { if (Terrain != null) { switch (Terrain.TerrainName) { case 'SnapWater': return "SnapWaterDropsShort"; case 'SnapLava': return "SnapLavaDropsShort"; case 'SnapMuck': return "SnapMuckDropsShort"; case 'SnapOil': return "SnapOilDropsShort"; } } return "SnapGroundDust"; } static bool ShouldReduceFlashing() { // CAREFUL! This function will cause desyncs if // you try to use this for game logic. let FlashCV = CVar.FindCVar("gl_weaponlight"); if (FlashCV != null) { return (FlashCV.GetInt() < 8); } return false; } static double AngleTowardsAngle(double Angle, double DestAngle, double MaxTurn = 22.5) { double Delta = -Actor.DeltaAngle(Angle, DestAngle); if (MaxTurn < abs(Delta)) { if (Delta > 0) { Angle -= MaxTurn; } else { Angle += MaxTurn; } } else { Angle = DestAngle; } return Angle; } static double AngleTowardsDir(double Angle, Vector2 DestDir, double MaxTurn = 22.5) { if (SnapUtils.ValidVec2Unit(DestDir) == false) { return Angle; } return AngleTowardsAngle(Angle, VectorAngle(DestDir.X, DestDir.Y), MaxTurn); } static clearscope int GetPointLimit() { let FragLimitCV = CVar.FindCVar("snap_pointlimit"); if (FragLimitCV) { int value = FragLimitCV.GetInt(); if (value < 0) { int numPlayers = 0; for (uint i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] == false) { continue; } numPlayers++; } // Starts at 10, every player above 1v1 adds 2.5 points. // This gives a float value at odd player counts. // 3P doesn't need as big of a jump as 4P, so we round down. double min = 10.0; double limit = min + ((numPlayers - 2) * 2.5); if (limit < min) { limit = min; } return (int)(floor(limit)); } return value; } return 0; } static clearscope int GetTimeLimit() { let TimeLimitCV = CVar.FindCVar("snap_timelimit"); if (TimeLimitCV) { double limit = TimeLimitCV.GetFloat(); if (limit > 0.0) { return (int)(limit * 60.0 * TICRATE); } } return 0; } static bool PlayerOrBot(Actor input) { if (input == null) { return false; } return (input is "PlayerPawn" || input is "SnapBot"); } static play void TryKick( Actor victim, Actor source, Actor hitPuff, uint KickDamage, Vector3 KickSpeed, int HitlagFrames, bool FromFriendly) { let tsp = SnapPlayer(victim); if (tsp != null) { tsp.WasKicked(source, hitPuff, KickDamage, KickSpeed, HitlagFrames, FromFriendly); return; } let sa = SnapActor(victim); if (sa != null) { sa.WasKicked(source, hitPuff, KickDamage, KickSpeed, HitlagFrames, FromFriendly); return; } // USE GENERIC FUNCTION IF IT'S NOT A SNAPACTOR SnapActor.GenericKick(victim, source, hitPuff, KickDamage, KickSpeed, HitlagFrames, FromFriendly); } const AREA_PER_PARTICLE = 768.0; const PARTICLE_SPEED = 16.0; const EXTRA_PARTICLES = 16; static play void GlassShatter(Actor Activator, int LineTag) { LineIdIterator it = Level.CreateLineIdIterator(LineTag); int lineIndex = -1; while ((lineIndex = it.Next()) >= 0) { Line li = Level.Lines[lineIndex]; Sector sec = li.frontsector; Vector3 lineCenter; lineCenter.XY = li.v1.p + (li.Delta * 0.5); double SecFloor = sec.FloorPlane.ZatPoint(lineCenter.XY); double SecCeil = sec.CeilingPlane.ZatPoint(lineCenter.XY); double Width = li.Delta.Length(); double Height = SecCeil - SecFloor; lineCenter.Z = SecFloor + (Height * 0.5); double LineAngle = VectorAngle(li.Delta.X, li.Delta.Y); double PushAngle = LineAngle - 90.0; double Area = Width * Height; int NumParticles = int(floor(Area / AREA_PER_PARTICLE)); for (int i = 0; i < NumParticles; i++) { double OffsetPushAngle = PushAngle + frandom[snap_decor](-45.0, 45.0); Vector3 Push = (cos(OffsetPushAngle), sin(OffsetPushAngle), -1.0); Vector2 Offset = ( frandom[snap_decor](-Width * 0.5, Width * 0.5), frandom[snap_decor](-Height * 0.5, Height * 0.5) ); Actor shard = Actor.Spawn( "FactoryGlassShard", lineCenter + ( cos(LineAngle) * Offset.X, sin(LineAngle) * Offset.X, Offset.Y ), ALLOW_REPLACE ); if (shard != null) { shard.Roll = frandom[snap_decor](-180.0, 180.0); shard.Vel = ( frandom[snap_decor](0.0, PARTICLE_SPEED) * Push.X, frandom[snap_decor](0.0, PARTICLE_SPEED) * Push.Y, frandom[snap_decor](0.0, PARTICLE_SPEED) * Push.Z ); } } } /* if (Activator != null) { double Width = Activator.Radius * 2.0; double Height = Activator.Height; double PushAngle = VectorAngle(Activator.Vel.X, Activator.Vel.Y); double LineAngle = PushAngle + 90.0; for (int i = 0; i < EXTRA_PARTICLES; i++) { double OffsetPushAngle = PushAngle + frandom[snap_decor](-45.0, 45.0); Vector3 Push = (cos(OffsetPushAngle), sin(OffsetPushAngle), -1.0); Vector2 Offset = ( frandom[snap_decor](-Width * 0.5, Width * 0.5), frandom[snap_decor](-Height * 0.5, Height * 0.5) ); Actor shard = Actor.Spawn( "FactoryGlassShard", Activator.Vec3Offset( cos(LineAngle) * Offset.X, sin(LineAngle) * Offset.X, Offset.Y + (Activator.Height * 0.5) ), ALLOW_REPLACE ); if (shard != null) { shard.Roll = frandom[snap_decor](-180.0, 180.0); shard.Vel = ( frandom[snap_decor](0.0, PARTICLE_SPEED * 2.0) * Push.X, frandom[snap_decor](0.0, PARTICLE_SPEED * 2.0) * Push.Y, 0.0 ); } } } */ S_StartSound("glass/break", CHAN_AUTO); } static double GetCameraDistance(Actor Origin) { if (playeringame[consoleplayer] == false) { return 0.0; } double result = 0.0; PlayerInfo player = players[consoleplayer]; if (player != null) { if (player.camera != null) { result = Origin.Distance3D(player.camera); } else if (player.mo != null) { result = Origin.Distance3D(player.mo); } } return result; } static double GetFarawayScale(Actor Origin) { double camDist = SnapUtils.GetCameraDistance(Origin); return 1.0 + (camDist / 2048.0); } static play void SetFreeze(bool value) { // Freeze / unfreeze gameplay. Level.setFrozen(value); for (uint i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i]) { continue; } PlayerInfo player = players[i]; if (player == null) { continue; } if (value) { player.cheats |= (CF_FROZEN|CF_TOTALLYFROZEN); } else { player.cheats &= ~(CF_FROZEN|CF_TOTALLYFROZEN); } } } } // // Other utility classes. // class BounceTrace : LineTracer { Actor master; Vector2 BounceNormal; bool ActorCollideTest(Actor a, Actor t) { if (a.bThruActors == true || t.bThruActors == true) { return false; } if ((a.ThruBits & t.ThruBits) && (a.bAllowThruBits == true || t.bAllowThruBits == true)) { return false; } if (t.bSolid == false) { return false; } if (t.bSpecial == true || t.bNoClip == true) { return false; } if (t.bCorpse == true && t.bIceCorpse == false) { return false; } if (t.bActLikeBridge == false && a.bSpecial == true) { return false; } if (t == a) { return false; } if (a.bMissile == true && t == a.target) { return false; } if (a.Pos.Z > t.Pos.Z + t.Height) { return false; } else if (a.Pos.Z + a.Height <= t.Pos.Z) { return false; } return true; } override ETraceStatus TraceCallback() { if (master == null) { return TRACE_Abort; } if (master.bNoClip == true) { return TRACE_Abort; } if (results.HitType == TRACE_HitWall && results.HitLine != null) { BounceNormal = (-results.HitLine.Delta.Y, results.HitLine.Delta.X); if (results.Side == Line.back) { BounceNormal = -BounceNormal; } return TRACE_Stop; } if (results.HitType == TRACE_HitActor && results.HitActor != null && master != null) { if (ActorCollideTest(master, results.HitActor) == false) { return TRACE_Skip; } BounceNormal = results.HitActor.Vec2To(master); return TRACE_Stop; } return TRACE_Skip; } } class ProjectileTest : SnapStaticDecor { // A dot object to test where projectiles spawn from enemies. Default { Radius 4; Height 6; +NOGRAVITY +BRIGHT +SnapStaticDecor.MISSILESPRITEFIX } States { Spawn: BULL C -1; Stop; } override void PostBeginPlay() { Vel = (0, 0, 0); super.PostBeginPlay(); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapIntermissionVersus : SnapIntermissionCoop { enum VersusStates { VS_START, VS_COUNT, VS_PAUSE, VS_READYUP, VS_FADEOUT }; int Casualties; int CountedCasualties; override int GetMapScore() { int best = 0; for (uint i = 0; i < MAXPLAYERS; i++) { if (PlayerData[i].Frags > best) { best = PlayerData[i].Frags; } } return best; } override int GetPlayerScore(int playerID) { return PlayerData[playerID].Frags; } ui void DrawVersusRankometer(Vector2 Pos, int pnum, int trans) { PlayerInfo thisPlayer = null; int score = 0; if (ValidPlayerNum(pnum) == false) { return; } thisPlayer = players[pnum]; score = CountedPlayerScores[pnum]; uint SegmentsDrawn = 0; DrawTexture(RankometerEnd, Pos); Pos.x++; int SegsToDraw = MPRankometerSegs(score); if (SegsToDraw > 0) { for (int j = 0; j < SegsToDraw; j++) { if (trans >= 0) { DrawTextureTranslated(RankometerImages[GRADE_B], Pos, trans); } else { DrawTexture(RankometerImages[GRADE_E], Pos); } SegmentsDrawn++; Pos.x += 4; } } int SegmentsLeft = RANK_ALL_SEGS - SegmentsDrawn; if (SegmentsLeft > 0) { for (int i = 0; i < SegmentsLeft; i++) { DrawTexture(RankometerEmpty, Pos); SegmentsDrawn++; Pos.x += 4; } } Pos.x--; DrawTexture(RankometerEnd, Pos); } override void DrawAllMPRanking() { Array sortedPlayers; // initialize for (int i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i]) { continue; } sortedPlayers.Push(i); } int s = sortedPlayers.Size(); if (s > 1) { // Sort by best score before drawing! for (int i = 0; i < s; i++) { for (int j = s-1; j > i; j--) { int iPNum = sortedPlayers[j-1]; int iScore = CountedPlayerScores[iPNum]; int jPNum = sortedPlayers[j]; int jScore = CountedPlayerScores[jPNum]; if (jScore > iScore) { sortedPlayers[j-1] = jPNum; sortedPlayers[j] = iPNum; } } } } if (s <= 0) { return; } Vector2 Pos = (48, 40); // Account for ties by recording best/worst score int bestScore = CountedPlayerScores[sortedPlayers[0]]; int worstScore = CountedPlayerScores[sortedPlayers[s-1]]; for (int i = 0; i < s; i++) { int playerNumber = sortedPlayers[i]; PlayerInfo p = players[playerNumber]; int score = CountedPlayerScores[playerNumber]; int trans = Translation.MakeID(TRANSLATION_Players, playerNumber); uint faceID = 0; if ((CurState >= VS_READYUP) && (bestScore != worstScore)) { if (score >= bestScore) { faceID = 1; } else if (score <= worstScore) { faceID = 2; } } Vector2 TransitionOffset = ((1.0 - Transition) * TRANSITION_DIST, 0); double Stagger = ((s - (i+1)) * 32); if (HandleFinish == true) { TransitionOffset = -TransitionOffset; Stagger = ((i+1) * 32); TransitionOffset.X += Stagger; if (TransitionOffset.X > 0) { TransitionOffset.X = 0; } } else { TransitionOffset.X -= Stagger; if (TransitionOffset.X < 0) { TransitionOffset.X = 0; } } DrawTexture(CoopBar, Pos + (-48, 1) + TransitionOffset); if (trans != -1) { DrawTextureTranslated(MPFaces[faceID], Pos - (17, 0) + TransitionOffset, trans); } else { DrawTexture(MPFaces[faceID], Pos - (17, 0) + TransitionOffset); } DrawVersusRankometer(Pos + TransitionOffset, playerNumber, trans); drawNum( bonusFont, Pos + (242, 2) + TransitionOffset, max(0, score), 0, true, bonusColor ); if (ValidPlayerNum(playerNumber) && p != null && (PlayerData[playerNumber].Ready || p.Bot != null) && ((Level.MapTime / 8) & 1)) { DrawTextCenterAligned( rankFont, rankColor, Pos + (100, 1) + TransitionOffset, "$INTER_READY" ); } Pos.y += 16; } } override void Start() { CountedCasualties = 0; Casualties = 0; for (uint i = 0; i < MAXPLAYERS; i++) { if (playeringame[i]) { CountedPlayerScores[i] = 0; FinalScores[i] = GetPlayerScore(i); Casualties += PlayerData[i].Deaths; } } GenericDelay = TICRATE; } override void Update() { switch (CurState) { case VS_START: case VS_PAUSE: GenericPauseState(VS_PAUSE); break; case VS_COUNT: bool allDone = true; int HighCountedScore = 0; int HighRankSegs = 0; for (uint i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i]) { continue; } int FinalScore = GetPlayerScore(i); if (CountedPlayerScores[i] < FinalScore && Level.MapTime % 8 == 0) { CountedPlayerScores[i]++; if (CountedPlayerScores[i] >= FinalScore) { PlaySound("intermission/nextstage"); } } if (CountedPlayerScores[i] > FinalScore) { CountedPlayerScores[i] = FinalScore; } else if (CountedPlayerScores[i] < FinalScore) { allDone = false; } if (CountedPlayerScores[i] > HighCountedScore) { HighCountedScore = CountedPlayerScores[i]; HighRankSegs = MPRankometerSegs(HighCountedScore); } } bool RankTicked = (HighRankSegs > OldRankSegs); OldRankSegs = HighRankSegs; if (RankTicked == true) { double progress = (HighCountedScore * 1.0) / (MaxScore * 1.0); PlayRankSound(progress); } if (CountedCasualties < Casualties) { CountedCasualties += max(1, (Casualties - CountedCasualties) >> 3); if (CountedCasualties > Casualties) { CountedCasualties = Casualties; } else if (CountedCasualties < Casualties) { allDone = false; } } if (allDone == true) { CurState++; } break; case VS_READYUP: // Only do ready-up logic at last stage SkipStage = DoSkipLogic(); if (SkipStage == true) { PlaySound("intermission/paststats"); SnapFader.StartGameFade(true, 0.02); CurState++; } break; case VS_FADEOUT: FadeOutTick(); break; } } override void End() { Level.ChangeLevel(Level.NextMap, 0, CHANGELEVEL_NOINTERMISSION); Destroy(); } override void DrawBottomData(Vector2 Pos) { DrawTextRightAligned( standardFont, standardColor, Pos, Stringtable.Localize("$INTER_DEATH")..": "..CountedCasualties ); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapHPNumData ui { uint Value; // Current value being drawn uint Prev; // Previous value uint Blink; // Blink timer double Jitter; // Jittering void HPTicker(uint NewValue, uint JitterThreshold = 1) { Prev = Value; Value = NewValue; int Diff = Value - Prev; if (Diff > 0) { Blink = 15; } else if (Diff < 0) { Blink = 15; Jitter = max(Jitter, abs(Diff)); } else { Jitter *= 0.5; if (Blink > 0) { Blink--; } } if (Value > 0 && Value <= JitterThreshold) { Jitter = max(Jitter, 0.5); } if (Level.maptime <= 2) { // Reset these on map load. Jitter = 0.0; Blink = 0; } } } extend class SnapHUD { SnapHPNumData OurHP; SnapHPNumData CoreHP; int CoreTrans; Array SmallHP; const MAXHPDIGITS = 5; void DrawHPNum(SnapHPNumData HPData, Vector2 pos, int flags = 0, uint digits = 3, bool big = true, uint BadHealth = 50, uint GoodHealth = 100, double jitterScale = 1.0) { if (digits == 0) { return; } if (digits > MAXHPDIGITS) { digits = MAXHPDIGITS; } HUDFont fn = SnapHPFont; double spacing = 6.0; if (big == false) { fn = SnapTinyNumFont; spacing = 4.0; } uint nums[MAXHPDIGITS]; uint div = 1; for (int i = digits-1; i >= 0; i--) { nums[i] = (HPData.Value / div) % 10; div *= 10; } bool drewNonZero = false; int cr = Font.CR_UNTRANSLATED; if (HPData.Blink > 0 && (Level.maptime & 1)) { cr = Font.FindFontColor('HPLight'); drewNonZero = true; // don't use dark num } else { if (BadHealth > 0 && HPData.Value <= BadHealth) { cr = Font.FindFontColor('HPRed'); } else if (GoodHealth > 0 && HPData.Value > GoodHealth) { cr = Font.FindFontColor('HPYellow'); } } for (uint i = 0; i < digits; i++) { if (nums[i] != 0) { drewNonZero = true; } int ncr = cr; if (drewNonZero == false) { ncr = Font.FindFontColor('HPDark'); } Vector2 npos = pos; if (HPData.Jitter > 0.0) { double a = random[snap_hud](0,359); npos += ( cos(a), sin(a) ) * HPData.Jitter * jitterScale; } DrawString(fn, String.Format("%01d", nums[i]), npos, flags, ncr); pos.X += spacing; } } void InitHP() { OurHP = new("SnapHPNumData"); CoreHP = new("SnapHPNumData"); for (uint i = 0; i < MAXPLAYERS; i++) { SmallHP.Push(new("SnapHPNumData")); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapVoice play { Sound VoiceSample; uint Delay; bool Init; static void PlayVoiceSample(Actor activator, String vc, uint delay = 0, uint priority = 0) { let pawn = SnapPlayer(activator); if (pawn != null) { pawn.AddSnapVoice(vc, delay, priority); } } } extend class SnapPlayer { Array VoiceQueue; uint VoicePriority; uint VoiceDelay; void SnapVoiceInterrupt() { VoicePriority = 0; VoiceDelay = 0; VoiceQueue.Clear(); A_StopSound(CHAN_VOICE); } void AddSnapVoice(Sound vc, uint delay = 22, uint priority = 0) { if (Health <= 0) { // Don't talk while you're dead. return; } SnapVoice v = new("SnapVoice"); if (v == null) { return; } v.VoiceSample = vc; v.Delay = 5; //delay; if (priority >= VoicePriority) { VoiceDelay = delay; if (priority > VoicePriority) { VoicePriority = priority; SnapVoiceInterrupt(); } } VoiceQueue.Push(v); } void RunSnapVoiceQueue() { SnapVoice v = null; uint size = VoiceQueue.Size(); if (size == 0) { VoiceDelay = 0; VoicePriority = 0; return; } if (VoiceDelay > 0) { VoiceDelay--; return; } v = VoiceQueue[0]; if (v == null) { VoiceQueue.Delete(0); return; } if (v.Delay > 0) { v.Delay--; return; } Sound voice = v.VoiceSample; if (v.Init == false) { A_StartSound(voice, CHAN_VOICE, CHANF_UI); v.Init = true; return; } else if (IsActorPlayingSound(CHAN_VOICE, voice) == false) { // Done playing. VoiceQueue.Delete(0); return; } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapVolcanoTorch : SnapDynamicDecor { const SPAWNFREQ = 3; uint SpawnTick; Default { Health 1000; Radius 12; Height 32; +NOBLOCKMAP +NOGRAVITY +NOINTERACTION +DONTSPLASH } action void A_CreateTorchFlame() { Vector3 SpawnPos = Pos + (0, 0, Height); double a = frandom[snap_decor](0.0, 180.0); SpawnPos.XY += frandom[snap_decor](-8.0, 8.0) * ( cos(a), sin(a) ); Actor flame = Spawn("SnapFlameParticle", SpawnPos, ALLOW_REPLACE); if (flame != null) { flame.Vel.X = frandom[snap_decor](-3.0, 3.0); flame.Vel.Y = frandom[snap_decor](-3.0, 3.0); flame.Vel.Z = 1.0 + frandom[snap_decor](0.0, 3.0); } } States { Spawn: VTRC A random(3, 6) Light("VolcanoTorchLight"); VTRC B 6 Light("VolcanoTorchLight"); Loop; } override void BeginPlay() { super.BeginPlay(); SpawnTick = random[snap_decor](0, SPAWNFREQ-1); } override void Tick() { super.Tick(); if (isFrozen() == true) { return; } if (Level.maptime % SPAWNFREQ == SpawnTick) { A_CreateTorchFlame(); } } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class InvasionWaveData play { int UploadScript; } extend class InvasionThinker { Array Waves; uint CurWave; uint WaveExtraTicks; static void AddWaveScript(Name ScriptName) { InvasionThinker.AddWaveScriptNum( -int(ScriptName) ); } static void AddWaveScriptNum(int ScriptNum) { let inv = InvasionThinker.Get(); if (inv == null) { return; } InvasionWaveData Wave = new("InvasionWaveData"); Wave.UploadScript = ScriptNum; inv.Waves.Push(Wave); } void InitNewWave() { // If we interrupted a wave in-progress, // then reset the subwave events. ResetSubwaves(); // Update coop scaling Scalar = InvasionThinker.PlayerScalar(); uint Debug = SnapEventHandler.CoopScalingDebug(); NumPlayers = (Debug > 0) ? Debug : SnapEventHandler.CoopScalingPlayers(); // Call the ACS script which uploads data // for the Invasion thinker to use. ACS_ExecuteWithResult( Waves[CurWave].UploadScript ); // Count number of monsters in this wave. //MonstersLeftToSpawn = CountMonstersToSpawn(); MonstersLeftToSpawn = 0; InitMonsterCount = true; if (Subwaves.Size() > 0) { Subwaves[0].Init(self); } } bool StartNextWave() { CurWave++; if (CurWave >= uint(Waves.Size())) { // All clear!! return true; } InitNewWave(); return false; } bool SetWaveDirectly(uint NewWave) { if (NewWave >= uint(Waves.Size())) { // Out of range. return false; } while (CurWave < NewWave) { // Ensure important events (like scripts) // are executed from the earlier waves. while (Subwaves.Size() > 0) { ExecuteSubwave(FastForward: true); } if (StartNextWave() == true) { // This shouldn't be possible. CurWave = 0; InitNewWave(); return false; } } if (CurWave != NewWave) { // Reaching this means that we need to // rewind instead of fast-forward. CurWave = NewWave; InitNewWave(); } return true; } void WaveTick() { if (InitMonsterCount == true) { MonstersLeftToSpawn = CountMonstersToSpawn(); InitMonsterCount = false; } bool HaveStuffToShoot = MonstersAlive(); if (Subwaves.Size() == 0 && HaveStuffToShoot == false) { // We have finished executing all of our events, // and all of the enemies have been defeated. bool exit = StartNextWave(); if (exit == true) { Console.MidPrint(null, "$INVASION_WIN"); ACS_NamedExecuteWithResult("InvasionWin"); Started = false; } else { Console.MidPrint(null, "$INVASION_NEXT"); HealCores(); SetCheckpoint(); Delay = 3*TICRATE; } return; } if (HaveStuffToShoot == false && FirstMonsterWasSpawned == true) { // For every tic without an enemy to shoot, // go through the events much faster!! WaveExtraTicks += NumPlayers; } else if (WaveExtraTicks > 0) { // Slow back down over time. WaveExtraTicks--; } for (uint i = 0; i <= WaveExtraTicks; i++) { SubwaveTick(); } } void ForceWaveCheat(int Num) { if (Num <= 0) { return; } Thing_Remove(INVASION_MONSTER_TID); MonstersLeftToSpawn = 0; SetWaveDirectly(Num - 1); } } //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class SnapPowerupAmmo : Ammo { Default { Inventory.MaxAmount 99; } } class SnapWeaponPowerup : SnapInventory abstract { transient bool OnlyGotAmmo; Name SetWeaponPower; property WeaponPower: SetWeaponPower; /* override bool CanPickup(Actor toucher) { if (bTossed == true && Vel.Z > 0) { return false; } return super.CanPickup(toucher); } */ void PlayerNewWeapon(SnapPlayer pmo, SnapWeaponProps props, bool shared = false) { if (pmo.InfiniteWeapon == true) { // Give meter instead of weapons. pmo.AddSnapPOWMeter(250, false); return; } /* if (shared == false && pmo.CountInv("SnapPowerupAmmo") > 0) { pmo.TossCurrentWeapon(); } */ if (shared == false || pmo.CountInv("SnapPowerupAmmo") <= 0) { pmo.WeaponPower = props.WeaponID; OnlyGotAmmo = false; } else { OnlyGotAmmo = true; } pmo.GiveAmmo("SnapPowerupAmmo", 50); pmo.SetSnapMugshot(pmo.SNAPMUG_GOOD); // Ensure your gun's reloaded if you switched to a powerup pmo.SetInventory("SnapStandardAmmo", 7); } override void DoPickupSpecial(Actor toucher) { super.DoPickupSpecial(toucher); let props = SnapWeaponProps.GetWeaponPropsByName(SetWeaponPower); if (props == null) { return; } ItemExtendCombo(toucher, false); let pmo = SnapPlayer(toucher); if (pmo) { PlayerNewWeapon(pmo, props); } if (multiplayer == true && deathmatch == false) { // In Coop: share weapons! // If you don't have a weapon, you get this weapon type too. // If you do, then you just get some ammo for your existing weapon. for (int i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i]) { continue; } let mpmo = SnapPlayer(players[i].mo); if (mpmo) { if (mpmo == pmo) { continue; } PlayerNewWeapon(mpmo, props, true); DoShareEffects(mpmo.player); } } } OnlyGotAmmo = false; GoAwayAndDie(); } override String PickupMessage() { if (OnlyGotAmmo == true) { return "$POWERUP_AMMO"; } return super.PickupMessage(); } Default { Inventory.MaxAmount 0; +WEAPONSPAWN +SnapInventory.PICKUPDESPAWNS } } class SnapGun : Weapon { uint ChargeLevel; Vector3 LaserPoint; bool KickHeld; bool BufferKick; bool NoGun; const GoodCharge = 12; const GreatCharge = 32; const PerfectCharge = 70; Array WeaponLayers; Array CrashLayers; const CRASHLAYER_A = 100; const CRASHLAYER_B = 101; const CRASHBOLTL_A = 102; const CRASHBOLTR_A = 103; const CRASHBOLTL_B = 104; const CRASHBOLTR_B = 105; const CRASHBOLTL_C = 106; const CRASHBOLTR_C = 107; const CHARGEWRAPLAYER_C = 8; const CHARGEWRAPLAYER_B = 7; const CHARGEWRAPLAYER_A = 6; const CHARGELEVELLAYER = 5; const CHARGESTREAKLAYER = 4; const RELOADLAYER = 3; const GUNLAYER = 2; const FLASHLAYER = -2; const KICKLAYER = -3; const CRASHSHIFT = 128.0; const NO_GUN_OFFSET = WEAPONBOTTOM; const RAISE_SPD = 12; override void BeginPlay() { super.BeginPlay(); WeaponLayers.Push(PSP_WEAPON); WeaponLayers.Push(GUNLAYER); WeaponLayers.Push(KICKLAYER); WeaponLayers.Push(FLASHLAYER); WeaponLayers.Push(RELOADLAYER); WeaponLayers.Push(CHARGEWRAPLAYER_A); WeaponLayers.Push(CHARGEWRAPLAYER_B); WeaponLayers.Push(CHARGEWRAPLAYER_C); WeaponLayers.Push(CHARGESTREAKLAYER); WeaponLayers.Push(CHARGELEVELLAYER); CrashLayers.Push(CRASHLAYER_A); CrashLayers.Push(CRASHLAYER_B); CrashLayers.Push(CRASHBOLTL_A); CrashLayers.Push(CRASHBOLTR_A); CrashLayers.Push(CRASHBOLTL_B); CrashLayers.Push(CRASHBOLTR_B); CrashLayers.Push(CRASHBOLTL_C); CrashLayers.Push(CRASHBOLTR_C); } action void A_SetSnapGunState(int layer, statelabel newSt) { // Set a specific layer, instead of PSP_WEAPON. // This allows for us to shoot/reload & kick at the same time. let player = player; if (player == null || player.ReadyWeapon == null) { return; } Weapon weapon = player.ReadyWeapon; player.SetPsprite(layer, weapon.FindState(newSt)); } action bool A_OutOfAmmo() { if (player == null || player.mo == null) { return false; } let sp = SnapPlayer(player.mo); if (sp.InfiniteWeapon == true) { // Infinite ammo mode return false; } return (player.mo.CountInv("SnapPowerupAmmo") <= 0); } action state A_SnapgunJumpToPower() { if (player == null || player.mo == null) { return null; } let pmo = SnapPlayer(player.mo); if (pmo == null) { return null; } let weap = SnapGun(player.ReadyWeapon); if (weap == null) { return null; } weap.ChargeLevel = 0; let robo = SnapPlayerRobo(player.mo); if (robo != null && robo.BotPower > 0) { return ResolveState("FireBotPower"); } if ((pmo.WeaponPower < 0 && pmo.InfiniteWeapon == true) // Forced basic gun || A_OutOfAmmo() == true) { return null; } let power = pmo.WeaponPower; let props = SnapWeaponProps.GetWeaponPropsByID(pmo.WeaponPower); return ResolveState(props.FireState); } action void A_SnapgunFlash(statelabel flashlabel = 'Flash', int flags = 0) { let player = player; if (player == null || player.ReadyWeapon == null) { return; } if (!(flags & GFF_NOEXTCHANGE)) { let pmo = SnapPlayer(player.mo); if (pmo) { pmo.PlayFire(); } } A_SetSnapGunState(FLASHLAYER, flashlabel); } action Actor A_SnapgunMomentumProjectile(class type, double SpreadOffset = 0.0, double SpreadPitch = 0.0) { if (player == null || player.mo == null) { return null; } let smo = SnapPlayer(player.mo); if (smo) { return smo.SnapPlayerProjectile(type, SpreadOffset, SpreadPitch); } return null; } action void A_SnapKickAnim() { if (player == null || player.mo == null) { return; } let smo = SnapPlayer(player.mo); if (smo) { smo.PlayKick(); } } action Actor A_CreateKickPuff(Vector3 HitPos, Vector3 HitDir) { A_StartSound("kick/hit", CHAN_WEAPON); return Spawn( "SnapPuff", HitPos - (HitDir * GetDefaultByType("SnapPuff").Radius), ALLOW_REPLACE ); } action void A_SnapKickTarget(Actor target, Actor hitPuff) { if (target == null) { return; } let source = SnapPlayer(player.mo); if (source == null) { return; } int hitstunFrames = int(SnapHitstun.DamageToHitstun(SnapPlayer.KICKDMG) * 0.667); bool friendly = target.isFriend(source); double AddSpeed = 0.0; double moVel = source.Vel.Length(); if (moVel) { Vector2 facingDir = AngleToVector(angle, 1.0); double mul = min(1.0, max(0.0, (SnapUtils.SafeVec2Unit(facingDir) dot SnapUtils.SafeVec2Unit(source.Vel.XY)))); AddSpeed += moVel * mul; } /* Precise double ThrustLen = SnapPlayer.KICKTHRUST * SnapPlayer.KICKTHRUST; double BoostedThrust = sqrt(ThrustLen + ThrustLen); */ // Approximate double BoostedThrust = SnapPlayer.KICKTHRUST * 1.414213562373095; double AimedSpeed = BoostedThrust + AddSpeed; Vector3 KickVec3 = ( AimedSpeed * cos(Angle) * cos(-Pitch), AimedSpeed * sin(Angle) * cos(-Pitch), (BoostedThrust * sin(-Pitch + 45.0)) + source.Vel.Z ); SnapUtils.TryKick(target, source, hitPuff, SnapPlayer.KICKDMG, KickVec3, hitstunFrames, friendly); } action bool A_SnapTryKick(double a, double p = 0.0, double MoMidOffset = 0.0) { double range = DEFMELEERANGE * 1.75; FLineTraceData data; bool valid = LineTrace(a, range, p, TRF_NOSKY|TRF_BLOCKSELF, MoMidOffset, 0, 0, data); if (valid == true && data.HitType == TRACE_HitActor && data.HitActor != null) { Actor puff = A_CreateKickPuff(data.HitLocation, data.HitDir); A_SnapKickTarget(data.HitActor, puff); //AdjustPlayerAngle(t); return true; } return false; } action bool A_SnapTryKickCone(double MoMidOffset = 0.0) { int hIterate = 16; double hCone = 45.0; int vIterate = 4; double vCone = 22.5; for (int i = 0; i < hIterate; i++) { for (int j = 0; j < vIterate; j++) { if (i == 0 && j == 0) { if (A_SnapTryKick(angle, pitch, MoMidOffset) == true) { return true; } } double angleOffset = i * (hCone / hIterate); double pitchOffset = j * (vCone / vIterate); for (int k = 0; k < 4; k++) { int hSign = 0, vSign = 0; if (k & 1) { hSign = -1; } else { hSign = 1; } if (k > 1) { vSign = 1; } else { vSign = -1; } if (A_SnapTryKick( angle + (angleOffset * hSign), pitch + (pitchOffset * vSign), MoMidOffset) == true) { return true; } } } } return false; } action void A_SnapKick() { if (player == null || player.mo == null) { return; } Weapon weap = player.ReadyWeapon; if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } double MoMidOffset = player.mo.ViewHeight - player.mo.FloorClip; if (player != null) { MoMidOffset += player.crouchviewdelta; } bool hitMonster = A_SnapTryKickCone(MoMidOffset); if (hitMonster == false) { // Check if we hit a wall instead. // If so, spawn a puff, and activate it. FLineTraceData WallTrace; LineTrace( angle, DEFMELEERANGE, pitch, TRF_THRUACTORS|TRF_BLOCKUSE, MoMidOffset, 0, 0, WallTrace ); Actor puff; if (WallTrace.HitType == TRACE_HitWall || WallTrace.HitType == TRACE_HitFloor || WallTrace.HitType == TRACE_HitCeiling) { // hit something Actor puff = A_CreateKickPuff(WallTrace.HitLocation, WallTrace.HitDir); if (WallTrace.HitLine != null) { WallTrace.HitLine.Activate(self, 0, SPAC_Use); if (WallTrace.HitLine.GetHealth() > 0) { Destructible.DamageLinedef( WallTrace.HitLine, self, SnapPlayer.KICKDMG, 'Melee', WallTrace.LineSide, WallTrace.HitLocation, false ); } } if (WallTrace.Hit3DFloor != null) { if (WallTrace.Hit3DFloor.Model.GetHealth(SECPART_3D) > 0) { Destructible.DamageSector( WallTrace.Hit3DFloor.Model, self, SnapPlayer.KICKDMG, 'Melee', SECPART_3D, WallTrace.HitLocation, false ); } } else if (WallTrace.HitSector != null) { int Part = SECPART_Floor; if (WallTrace.SectorPlane == Sector.Ceiling) { Part = SECPART_Ceiling; } if (WallTrace.HitSector.GetHealth(Part) > 0) { Destructible.DamageSector( WallTrace.HitSector, self, SnapPlayer.KICKDMG, 'Melee', Part, WallTrace.HitLocation, false ); } } } else { // Whiffed entirely A_StartSound("kick/miss", CHAN_WEAPON); } } } action void A_SnapGunReady() { if (player == null || player.mo == null) { return; } let pmo = SnapPlayer(player.mo); if (!pmo) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { return; } let pspGun = player.GetPSprite(GUNLAYER); let pspKick = player.GetPSprite(KICKLAYER); let pspFlash = player.GetPSprite(FLASHLAYER); let pspReload = player.GetPSprite(RELOADLAYER); let pspChargeWrapA = player.GetPSprite(CHARGEWRAPLAYER_A); let pspChargeWrapB = player.GetPSprite(CHARGEWRAPLAYER_B); let pspChargeWrapC = player.GetPSprite(CHARGEWRAPLAYER_C); let pspChargeStreak = player.GetPSprite(CHARGESTREAKLAYER); let pspChargeLevel = player.GetPSprite(CHARGELEVELLAYER); A_WeaponReady(WRF_NOFIRE); if (pspGun) { pspGun.bPlayerTranslated = true; // Because it won't stay on for some reason if (pmo.WeaponRoulette == true) { if (pmo.WRDelay == 0 && pmo.WRHeld == false && (player.cmd.buttons & BT_ATTACK)) { let obj = Spawn(pmo.WRPattern.List[pmo.WRPos], pmo.Pos, ALLOW_REPLACE); if (obj != null) { obj.bDropped = true; let inv = Inventory(obj); if (inv != null) { inv.DoPickupSpecial(pmo); pmo.A_StartSound(inv.PickupSound, CHAN_ITEM); } } pmo.WRPos = 0; pmo.WRTics = 0; pmo.WRTicSpeed = 1; pmo.WRPattern = null; pmo.WRDelay = 0; pmo.WeaponRoulette = false; pmo.WRHeld = true; } } else if (pmo.SnapPlayerInfo != null && pmo.SnapPlayerInfo.NoGunMode == true) { // Flag that we were just lowering our gun. weap.NoGun = true; // Lower just the gun. if (player.morphTics || player.cheats & CF_INSTANTWEAPSWITCH) { // Set instantly pspGun.y = NO_GUN_OFFSET; } else if (pspGun.y < NO_GUN_OFFSET) { pspGun.y += RAISE_SPD; } // Prevent any other lingering states. A_SetSnapGunState(GUNLAYER, 'GunIdle'); } else if (weap.NoGun == true) { // Raise the gun before letting you shoot again. if (player.morphTics || player.cheats & CF_INSTANTWEAPSWITCH) { // Set instantly pspGun.y = 0; } else if (pspGun.y > 0) { pspGun.y -= RAISE_SPD; } if (pspGun.y <= 0) { // You are good to go. weap.NoGun = false; } } else { if (pspGun.curState == weap.FindState('GunIdle') && (player.cmd.buttons & BT_ATTACK) && pmo.WRHeld == false) { A_SetSnapGunState(GUNLAYER, 'Fire'); } } /* if (pspGun.curState == weap.FindState('Reload')) { pmo.PlayFireNoFlash(); } */ if (pspFlash) { pspFlash.x = pspGun.x; pspFlash.y = pspGun.y; A_OverlayFlags(FLASHLAYER, PSPF_ALPHA|PSPF_RENDERSTYLE, true); if (pmo.GetCVar("gl_weaponlight") ~== 0) { A_OverlayRenderstyle(FLASHLAYER, STYLE_Add); A_OverlayAlpha(FLASHLAYER, 0.5); } else { A_OverlayRenderstyle(FLASHLAYER, STYLE_Normal); A_OverlayAlpha(FLASHLAYER, 1.0); } } if (pspReload) { // No remap is intentional, as it's meant to match the bullet graphic. //pspReload.bPlayerTranslated = true; pspReload.x = pspGun.x; pspReload.y = pspGun.y; } if (pspChargeWrapA) { pspChargeWrapA.x = pspGun.x; pspChargeWrapA.y = pspGun.y; } if (pspChargeWrapB) { pspChargeWrapB.x = pspGun.x; pspChargeWrapB.y = pspGun.y; } if (pspChargeWrapC) { pspChargeWrapC.x = pspGun.x; pspChargeWrapC.y = pspGun.y; } if (pspChargeStreak) { pspChargeStreak.x = pspGun.x; pspChargeStreak.y = pspGun.y; } if (pspChargeLevel) { pspChargeLevel.x = pspGun.x; pspChargeLevel.y = pspGun.y; } } if (pspKick) { pspKick.bPlayerTranslated = true; if (player.cmd.buttons & BT_ALTATTACK) { // Kick is tap fire now, since I don't want the new strategy to be taping down the button if (weap.KickHeld == false) { weap.BufferKick = true; // Allow inputting a kick even when it's not ready. } weap.KickHeld = true; } else { weap.KickHeld = false; } if (pspKick.curState == weap.FindState('KickIdle') && weap.BufferKick == true) { A_SetSnapGunState(KICKLAYER, 'AltFire'); weap.BufferKick = false; } } let parentpsp = player.GetPSprite(weap.CrashLayers[0]); for (uint i = 0; i < uint(weap.CrashLayers.Size()); i++) { let psp = player.GetPSprite(weap.CrashLayers[i]); if (psp != null) { psp.bPlayerTranslated = true; if (i != 0 && parentpsp != null) { psp.y = parentpsp.y; } } } } action void A_UnsetSnapGun() { if (player == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { return; } for (uint i = 0; i < uint(weap.WeaponLayers.Size()); i++) { A_SetSnapGunState(weap.WeaponLayers[i], 'Dead'); } for (uint i = 0; i < uint(weap.CrashLayers.Size()); i++) { A_SetSnapGunState(weap.CrashLayers[i], 'Dead'); } } action void A_SnapGunRefire(int layer = GUNLAYER, statelabel newSt = 'Fire', uint bt = BT_ATTACK) { if (player == null || player.mo == null || player.health <= 0) { return; } if (player.cmd.buttons & bt) { A_SetSnapGunState(layer, newSt); } } action void A_SnapGunInitOverlays() { if (player == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { return; } for (uint i = 0; i < uint(weap.WeaponLayers.Size()); i++) { A_OverlayFlags(weap.WeaponLayers[i], PSPF_ADDWEAPON|PSPF_ADDBOB|PSPF_POWDOUBLE|PSPF_CVARFAST, true); } for (uint i = 0; i < uint(weap.CrashLayers.Size()); i++) { A_OverlayFlags(weap.CrashLayers[i], PSPF_ADDWEAPON|PSPF_ADDBOB|PSPF_POWDOUBLE|PSPF_CVARFAST, true); let pspr = player.GetPSprite(weap.CrashLayers[i]); pspr.y += CRASHSHIFT; } A_SetSnapGunState(GUNLAYER, 'GunIdle'); A_SetSnapGunState(KICKLAYER, 'KickIdle'); } action void A_ResetCrashLayers() { if (player == null) { return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { return; } for (uint i = 0; i < uint(weap.CrashLayers.Size()); i++) { let pspr = player.GetPSprite(weap.CrashLayers[i]); pspr.x = 0; pspr.y = WEAPONBOTTOM; } } action void A_PlayCrashYell() { if (player == null || player.mo == null || player.health <= 0) { return; } let sp = SnapPlayer(player.mo); if (sp != null) { sp.SnapVoiceInterrupt(); sp.A_StartSound("voice/crashUsed", CHAN_VOICE); } } action void A_DoCrashClap() { if (player == null || player.mo == null || player.health <= 0) { return; } let sp = SnapPlayer(player.mo); if (sp != null) { sp.StartCrashClap(); //sp.A_StartSound("septacrash/clap", CHAN_WEAPON); } } action void A_SnapGunRaise() { if (player == null || player.mo == null) { A_Raise(RAISE_SPD); return; } let pmo = SnapPlayer(player.mo); if (pmo == null) { A_Raise(RAISE_SPD); return; } let weap = SnapGun(player.ReadyWeapon); if (invoker != weap || stateinfo == null || stateinfo.mStateType != STATE_Psprite) { weap = null; } if (weap == null) { A_Raise(RAISE_SPD); return; } let pspGun = player.GetPSprite(GUNLAYER); if (pmo.SnapPlayerInfo != null && pmo.SnapPlayerInfo.NoGunMode == true) { // Flag that we were just lowering our gun. weap.NoGun = true; // Set instantly pspGun.y = NO_GUN_OFFSET; } A_Raise(RAISE_SPD); } Default { Weapon.BobStyle "InverseSmooth"; Weapon.BobSpeed 3.0; Weapon.BobRangeX 0.75; Weapon.BobRangeY 1.0; Tag "$TAG_SNAPGUN"; Obituary "$OB_KICK"; HitObituary "$OB_KICK"; +WEAPON.NODEATHINPUT } States { Select: TNT1 A 0 A_SnapGunInitOverlays(); SelectLoop: TNT1 A 1 A_SnapGunRaise(); Loop; Deselect: TNT1 A 0 A_UnsetSnapGun(); DeselectLoop: TNT1 A 1 A_Lower(RAISE_SPD); Loop; Ready: TNT1 A 0 A_SnapGunInitOverlays(); ReadyLoop: TNT1 A 1 A_SnapGunReady(); Loop; GunIdle: SGUN A -1; Loop; KickIdle: TNT1 A -1; Loop; Dead: TNT1 A 1; Stop; Fire: SGUN A 0 A_SnapgunJumpToPower; Goto FireBasic; OpenSesame: TNT1 A 1; SREB A 1; TNT1 A 1; SREB B 1; TNT1 A 1; SREB C 1; Goto LightDone; PutInDaBullets: SREF ABC 3; SREF DHEH 1; SREF FHGH 1; Goto LightDone; AltFire: TNT1 AAA 1 A_OverlayOffset(GUNLAYER, 32, 16, WOF_ADD); SKIK A 1 A_OverlayOffset(KICKLAYER, -160, 32 + (32 * 3), 0); SKIK A 1 A_OverlayOffset(KICKLAYER, -140, 88, WOF_INTERPOLATE); SKIK A 0 A_SnapKickAnim(); SKIK A 1 A_OverlayOffset(KICKLAYER, -120, 48, WOF_INTERPOLATE); SKIK A 1 A_OverlayOffset(KICKLAYER, -60, 40, WOF_INTERPOLATE); SKIK A 0 A_SnapKick(); SKIK A 1 A_OverlayOffset(KICKLAYER, 0, 32, WOF_INTERPOLATE); SKIK A 1 A_OverlayOffset(KICKLAYER, 60, 40, WOF_INTERPOLATE); SKIK A 1 A_OverlayOffset(KICKLAYER, 120, 48, WOF_INTERPOLATE); SKIK A 1 A_OverlayOffset(KICKLAYER, 140, 88, WOF_INTERPOLATE); SKIK A 1 A_OverlayOffset(KICKLAYER, 160, 32 + (32 * 3), WOF_INTERPOLATE); TNT1 AAA 1 A_OverlayOffset(GUNLAYER, -32, -16, WOF_ADD); //TNT1 A 0 A_SnapGunRefire(KICKLAYER, 'AltFire', BT_ALTATTACK); Goto KickIdle; UseCrash: TNT1 A 0 A_ResetCrashLayers(); TNT1 A 7; TNT1 A 0 A_SetSnapGunState(CRASHBOLTL_A, 'CrashBoltLeftA'); TNT1 A 0 A_SetSnapGunState(CRASHBOLTR_A, 'CrashBoltRightA'); TNT1 A 0 A_SetSnapGunState(CRASHBOLTL_B, 'CrashBoltLeftB'); TNT1 A 0 A_SetSnapGunState(CRASHBOLTR_B, 'CrashBoltRightB'); TNT1 A 0 A_SetSnapGunState(CRASHBOLTL_C, 'CrashBoltLeftC'); TNT1 A 0 A_SetSnapGunState(CRASHBOLTR_C, 'CrashBoltRightC'); SCRS ABCDEFGHIJ 1; SCRS K 1; SCRS K 0 A_DoCrashClap(); SCRS LMNO 1; SCRS PQPQPQPQ 1; SCRS RSRS 1; SCRS TUTUTUTUTUTU 1; SCRS RSRS 1; SCR2 A 1 A_PlayCrashYell(); SCR2 BCBCBCBCBCBC 1; SCR2 DEDE 1; TNT1 A 0 A_SetSnapGunState(CRASHLAYER_B, 'CrashSplitRight'); Goto CrashSplitLeft; CrashSplitLeft: SCR2 FGFG 1; SCR2 FG 1 A_OverlayOffset(CRASHLAYER_A, -2, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 FG 1 A_OverlayOffset(CRASHLAYER_A, -4, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 FG 1 A_OverlayOffset(CRASHLAYER_A, -6, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 FG 1 A_OverlayOffset(CRASHLAYER_A, -8, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -10, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -12, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -14, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -16, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -18, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -20, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -22, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -24, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -26, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -28, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -30, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -32, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -34, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -36, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -38, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -40, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -42, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 HI 1 A_OverlayOffset(CRASHLAYER_A, -44, 0, WOF_ADD|WOF_INTERPOLATE); TNT1 A -1; Stop; CrashSplitRight: SCR2 JKJK 1; SCR2 JK 1 A_OverlayOffset(CRASHLAYER_B, 2, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 JK 1 A_OverlayOffset(CRASHLAYER_B, 4, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 JK 1 A_OverlayOffset(CRASHLAYER_B, 6, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 JK 1 A_OverlayOffset(CRASHLAYER_B, 8, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 10, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 12, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 14, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 16, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 18, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 20, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 22, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 24, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 26, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 28, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 30, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 32, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 34, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 36, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 38, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 40, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 42, 0, WOF_ADD|WOF_INTERPOLATE); SCR2 LM 1 A_OverlayOffset(CRASHLAYER_B, 44, 0, WOF_ADD|WOF_INTERPOLATE); TNT1 A -1; Stop; CrashBoltLeftA: SBL1 A 1 Bright; SBL1 G 1; SBL1 B 1 Bright; SBL1 H 1; SBL1 C 1 Bright; SBL1 I 1; SBL1 D 1 Bright; SBL1 J 1; SBL1 E 1 Bright; SBL1 K 1; SBL1 F 1 Bright; SBL1 L 1; SBL1 A 1 Bright; SBL1 G 1; SBL1 B 1 Bright; SBL1 H 1; SBL1 C 1 Bright; SBL1 I 1; SBL1 D 1 Bright; SBL1 J 1; SBL1 E 1 Bright; SBL1 K 1; SBL1 F 1 Bright; SBL1 L 1; SBL1 A 1 Bright; SBL1 G 1; SBL1 B 1 Bright; SBL1 H 1; SBL1 C 1 Bright; SBL1 I 1; SBL1 D 1 Bright; SBL1 J 1; SBL1 E 1 Bright; SBL1 K 1; SBL1 F 1 Bright; SBL1 L 1; TNT1 A -1; Stop; CrashBoltLeftB: TNT1 A 4+1; SBL2 A 1 Bright; SBL2 G 1; SBL2 B 1 Bright; SBL2 H 1; SBL2 C 1 Bright; SBL2 I 1; SBL2 D 1 Bright; SBL2 J 1; SBL2 E 1 Bright; SBL2 K 1; SBL2 F 1 Bright; SBL2 L 1; SBL2 A 1 Bright; SBL2 G 1; SBL2 B 1 Bright; SBL2 H 1; SBL2 C 1 Bright; SBL2 I 1; SBL2 D 1 Bright; SBL2 J 1; SBL2 E 1 Bright; SBL2 K 1; SBL2 F 1 Bright; SBL2 L 1; SBL2 A 1 Bright; SBL2 G 1; SBL2 B 1 Bright; SBL2 H 1; SBL2 C 1 Bright; SBL2 I 1; SBL2 D 1 Bright; SBL2 J 1; SBL2 E 1 Bright; SBL2 K 1; SBL2 F 1 Bright; SBL2 L 1; TNT1 A -1; Stop; CrashBoltLeftC: TNT1 A 8; SBL3 A 1 Bright; SBL3 G 1; SBL3 B 1 Bright; SBL3 H 1; SBL3 C 1 Bright; SBL3 I 1; SBL3 D 1 Bright; SBL3 J 1; SBL3 E 1 Bright; SBL3 K 1; SBL3 F 1 Bright; SBL3 L 1; SBL3 A 1 Bright; SBL3 G 1; SBL3 B 1 Bright; SBL3 H 1; SBL3 C 1 Bright; SBL3 I 1; SBL3 D 1 Bright; SBL3 J 1; SBL3 E 1 Bright; SBL3 K 1; SBL3 F 1 Bright; SBL3 L 1; SBL3 A 1 Bright; SBL3 G 1; SBL3 B 1 Bright; SBL3 H 1; SBL3 C 1 Bright; SBL3 I 1; SBL3 D 1 Bright; SBL3 J 1; SBL3 E 1 Bright; SBL3 K 1; SBL3 F 1 Bright; SBL3 L 1; TNT1 A -1; Stop; CrashBoltRightA: TNT1 A 1; SBR1 A 1 Bright; SBR1 G 1; SBR1 B 1 Bright; SBR1 H 1; SBR1 C 1 Bright; SBR1 I 1; SBR1 D 1 Bright; SBR1 J 1; SBR1 E 1 Bright; SBR1 K 1; SBR1 F 1 Bright; SBR1 L 1; SBR1 A 1 Bright; SBR1 G 1; SBR1 B 1 Bright; SBR1 H 1; SBR1 C 1 Bright; SBR1 I 1; SBR1 D 1 Bright; SBR1 J 1; SBR1 E 1 Bright; SBR1 K 1; SBR1 F 1 Bright; SBR1 L 1; SBR1 A 1 Bright; SBR1 G 1; SBR1 B 1 Bright; SBR1 H 1; SBR1 C 1 Bright; SBR1 I 1; SBR1 D 1 Bright; SBR1 J 1; SBR1 E 1 Bright; SBR1 K 1; SBR1 F 1 Bright; SBR1 L 1; TNT1 A -1; Stop; CrashBoltRightB: TNT1 A 4; SBR2 A 1 Bright; SBR2 G 1; SBR2 B 1 Bright; SBR2 H 1; SBR2 C 1 Bright; SBR2 I 1; SBR2 D 1 Bright; SBR2 J 1; SBR2 E 1 Bright; SBR2 K 1; SBR2 F 1 Bright; SBR2 L 1; SBR2 A 1 Bright; SBR2 G 1; SBR2 B 1 Bright; SBR2 H 1; SBR2 C 1 Bright; SBR2 I 1; SBR2 D 1 Bright; SBR2 J 1; SBR2 E 1 Bright; SBR2 K 1; SBR2 F 1 Bright; SBR2 L 1; SBR2 A 1 Bright; SBR2 G 1; SBR2 B 1 Bright; SBR2 H 1; SBR2 C 1 Bright; SBR2 I 1; SBR2 D 1 Bright; SBR2 J 1; SBR2 E 1 Bright; SBR2 K 1; SBR2 F 1 Bright; SBR2 L 1; TNT1 A -1; Stop; CrashBoltRightC: TNT1 A 8+1; SBR3 A 1 Bright; SBR3 G 1; SBR3 B 1 Bright; SBR3 H 1; SBR3 C 1 Bright; SBR3 I 1; SBR3 D 1 Bright; SBR3 J 1; SBR3 E 1 Bright; SBR3 K 1; SBR3 F 1 Bright; SBR3 L 1; SBR3 A 1 Bright; SBR3 G 1; SBR3 B 1 Bright; SBR3 H 1; SBR3 C 1 Bright; SBR3 I 1; SBR3 D 1 Bright; SBR3 J 1; SBR3 E 1 Bright; SBR3 K 1; SBR3 F 1 Bright; SBR3 L 1; SBR3 A 1 Bright; SBR3 G 1; SBR3 B 1 Bright; SBR3 H 1; SBR3 C 1 Bright; SBR3 I 1; SBR3 D 1 Bright; SBR3 J 1; SBR3 E 1 Bright; SBR3 K 1; SBR3 F 1 Bright; SBR3 L 1; TNT1 A -1; Stop; } } #include "./weapon/basic.zs" #include "./weapon/rapid.zs" #include "./weapon/spread.zs" #include "./weapon/homing.zs" #include "./weapon/flame.zs" #include "./weapon/explode.zs" #include "./weapon/mirror.zs" #include "./weapon/charge.zs" #include "./weapon/boomerang.zs" #include "./weapon/missile.zs" #include "./weapon/impact.zs" #include "./weapon/laser.zs" #include "./weapon/botpower.zs" //----------------------------------------------------------------------- // SNAP THE SENTINEL //----------------------------------------------------------------------- // Copyright (C) 2020-2023 Sally Cochenour //----------------------------------------------------------------------- // This program is free software distributed under the // terms of the GNU General Public License, version 3. // See 'license.txt' and 'license.gpl.txt' for more details. //----------------------------------------------------------------------- class WormMissile : SnapMissile { Default { Radius 16; Height 32; Speed 15; Damage 0; RenderStyle "Add"; SeeSound "turret/shoot"; DeathSound "revolver/death"; Obituary "$OB_WORM"; SnapShadowActor.ShadowSize 16; SnapActor.TouchDamage 30; +RIPPER +RANDOMIZE +BRIGHT } override int SpecialMissileHit(Actor victim) { Actor source = target; if (source != null) { if (victim == source) { // Our shooter. return 1; } Actor owner = source.master; if (owner != null) { if (victim == owner || victim.master == owner) { // Our shooter's owner, or the shooter has the same owner as the victim. return 1; } } } return super.SpecialMissileHit(victim); } States { Spawn: WRMS ABACAD 2; Loop; Death: WRMS GGGHHIJ 1; Stop; } override void Tick() { super.Tick(); if (TickPaused() == true) { return; } uint timer = Level.maptime / 2; double ha = angle + 90; double va = (timer % 8) * 45; double dist = radius * 1.5; if (Level.maptime & 1) { va += 180.0; } Vector3 offset = ( dist * cos(ha) * cos(va), dist * sin(ha) * cos(va), (dist * 0.8) * sin(va) ); offset.Z += Height * 0.5; SnapActor particle = SnapActor(Spawn("WormMissileTrail", Pos + offset, ALLOW_REPLACE)); if (particle) { particle.target = self; particle.SetHitstunParent(self); particle.angle = self.angle; } } } class WormMissileTrail : SnapActor { Default { RenderStyle "Add"; +NOINTERACTION +NOBLOCKMAP +NOGRAVITY +RANDOMIZE +BRIGHT } States { Spawn: WRMS E 3; //TNT1 A 1; WRMS F 2; Stop; } } class LargeWormSeg : SnapMonster { Default { Health 100; SnapMonster.Poise 0; DamageFactor "Melee", 2.5; Radius 30; Height 36; Mass 100; Gravity 0.75; SnapActor.TouchDamage 10; //SeeSound "worm/see"; //ActiveSound "worm/idle"; PainSound "worm/hurt"; Obituary "$OB_WORM"; Tag "$TAG_WORM"; Species "Robot"; +DONTTHRUST -SnapActor.CANDROPAMMO -COUNTKILL +NOGRAVITY -FLOORCLIP +SLIDESONWALLS +NOTELEPORT -SnapMonster.ISCONTAINER } States { Spawn: WORM CD 1; Loop; Missile: WORM EF 3; Goto Spawn; Pain: WORM H 3; WORM H 3 A_SnapMonsterPain(); Goto Spawn; Death: WORM H 1; TNT1 A 35 DoSnapMonsterDie(); Stop; } override bool CanCollideWith(Actor other, bool passive) { if ((other is "LargeWormSeg") || (other is "LargeWormHead")) { return false; } return super.CanCollideWith(other, passive); } override int DamageMobj(Actor inflictor, Actor source, int damage, Name mod, int flags, double angle) { let Owner = LargeWormHead(Master); if (Owner != null) { let LastSeg = Owner.GetLastSeg(); if (LastSeg != null && self != LastSeg) { LastSeg.DamageMobj(inflictor, source, damage, mod, flags, angle); return 0; } } return super.DamageMobj(inflictor, source, damage, mod, flags, angle); } override void WasKicked( Actor source, Actor hitPuff, uint KickDamage, Vector3 KickSpeed, int HitlagFrames, bool FromFriendly) { let Owner = SnapActor(master); if (Owner != null) { Owner.WasKicked(source, hitPuff, KickDamage, KickSpeed, HitlagFrames, FromFriendly); return; } super.WasKicked(source, hitPuff, KickDamage, KickSpeed, HitlagFrames, FromFriendly); } } class LargeWormHead : SnapMonster { const NUMWORMSEGS = 6; const WORMFIREWAIT = TICRATE/2; const WORMFIREFREQ = 7; const WORMFLEETIME = 2*TICRATE; const WORMJUMPFREQ = 4*TICRATE; // 5*TICRATE const WORMJUMPSPEED = 16; // 20 const WORMJUMPSHORTSPEED = 8; const MAXTURN = 5.0; const MAXSEGMOVE = 64.0; Actor SegList[NUMWORMSEGS]; double SegDist[NUMWORMSEGS]; uint AtkTimer; int AtkSeg; int JumpTimer; bool ShortHop; uint FleeTime; uint PrevSegs; enum WormMoveModeType { WMM_DIRECT, WMM_CIRCLE, WMM_FLEE, } uint WormMoveMode; bool MoveFaster; Default { Health 100; SnapMonster.Poise 0; SnapActor.Score 1000; DamageFactor "Melee", 2.5; Radius 32; Height 36; Mass 100; Gravity 0.75; Speed 10; FastSpeed 20; SnapActor.TouchDamage 10; SeeSound "worm/see"; ActiveSound "worm/idle"; PainSound "worm/hurt"; Obituary "$OB_WORM"; Tag "$TAG_WORM"; Species "Robot"; -FLOORCLIP +SLIDESONWALLS +SnapMonster.NOBOSSIFYHP } States { Spawn: WORM A 1 A_SnapMonsterLook(); WORM BABABABAB 1; Loop; See: WORM AB 1 A_SnapChase(); Loop; Pain: WORM G 3; WORM G 3 A_SnapMonsterPain(); Goto See; Kicked: WORM G 3; WORM G 3 A_SnapMonsterPain(); KickLoop: WORM G 3 A_EndKick(); Loop; Death: WORM G 1; TNT1 A 35 DoSnapMonsterDie(); Stop; } // Manually trying to drag each segment has just resulted in failure... // Let's instead simply ... enforce their new position every frame to lag behind the worm's movements. const PositionLag = 8; const NumRecordedPos = PositionLag * NUMWORMSEGS; Vector3 RecordedPos[NumRecordedPos]; Vector3 RecordedAng[NumRecordedPos]; Vector3 WormAngleVec() { return (Angle, Pitch, Roll); } void UpdateWormPosition() { if (Pos ~== RecordedPos[0]) { return; } for (int i = NumRecordedPos-1; i > 0; i--) { RecordedPos[i] = RecordedPos[i-1]; RecordedAng[i] = RecordedAng[i-1]; } RecordedPos[0] = Pos; RecordedAng[0] = WormAngleVec(); } void WormAngle(Vector2 DestDir) { double SMaxTurn = MAXTURN / Scale.X; Angle = SnapUtils.AngleTowardsDir(self.Angle, DestDir, SMaxTurn); } override void ChaseUpdateAngle() { return; } override bool HandleChaseAttack(StateLabel MeleeStateLabel, StateLabel MissileStateLabel) { WormMoveMode = WMM_CIRCLE; // do not attack twice in a row if (bJustAttacked == true) { bJustAttacked = false; return false; } // [RH] Don't attack if just moving toward goal if (target == goal || (bChaseGoal == true && goal != null)) { Actor savedtarget = target; target = goal; bool ReachedGoal = CheckMeleeRange(); target = savedtarget; if (ReachedGoal == true) { let iterator = Level.CreateActorIterator(goal.args[0], "PatrolPoint"); let specit = Level.CreateActorIterator(goal.TID, "PatrolSpecial"); Actor spec = null; // Execute the specials of any PatrolSpecials with the same TID // as the goal. while (spec = specit.Next()) { A_CallSpecial(spec.special, spec.args[0], spec.args[1], spec.args[2], spec.args[3], spec.args[4]); } double LastGoalAngle = goal.angle; int delay = 0; Actor NewGoal = iterator.Next(); if (NewGoal != null && goal == target) { delay = NewGoal.args[1]; reactiontime = delay * TICRATE + Level.maptime; } else { delay = 0; reactiontime = Default.ReactionTime; Angle = LastGoalAngle; } if (target == goal) { target = null; } bJustAttacked = true; if (NewGoal != null && delay != 0) { bInCombat = true; SetIdle(); } goal = NewGoal; return false; } if (goal == target) { WormMoveMode = WMM_DIRECT; } } if (goal != target) { // Scared monsters don't attack if (bFrightened == true) { // Scared of everything WormMoveMode = WMM_FLEE; } else if (target != null) { // Scared of their target if ((target.bFrightening == true) || (target.player != null && (target.player.cheats & CF_FRIGHTENING))) { WormMoveMode = WMM_FLEE; } } // Worm temporary frighten if (FleeTime > 0) { FleeTime--; WormMoveMode = WMM_FLEE; } if (WormMoveMode == WMM_CIRCLE && bVeryRude == true && JumpTimer < TICRATE/2) { // You can move directly towards them if you're about to jump over them. WormMoveMode = WMM_DIRECT; } } return true; } override bool HandleChase() { // Possibly choose another target if ((multiplayer || TIDtoHate) && threshold == 0 && CheckSight(target) == false) { Actor oldTarget = target; bool success = LookForPlayers(true); if (success == true && target != oldTarget) { return false; // got a new target } } Vector2 WormMoveDir = ( cos(angle), sin(angle) ); Vector2 TempDir = WormMoveDir; switch (WormMoveMode) { case WMM_DIRECT: WormMoveDir = SnapUtils.SafeVec2Unit(Vec2To(target)); break; case WMM_CIRCLE: TempDir = SnapUtils.SafeVec2Unit(Vec2To(target)); if ((TempDir dot WormMoveDir) < 0.5) { WormMoveDir = TempDir; } break; case WMM_FLEE: TempDir = SnapUtils.SafeVec2Unit(Vec2To(target)) * -1; if ((TempDir dot WormMoveDir) < 0.25) { WormMoveDir = TempDir; } break; } if (AtkTimer > 0) { AtkTimer--; } if (JumpTimer > 0) { JumpTimer--; if (WormMoveMode == WMM_FLEE) { JumpTimer--; } } double spd = Speed; if (bFrightened == true) { spd *= 0.65; } WormAngle(WormMoveDir); Vel.XY = ( cos(angle), sin(angle) ) * spd * Scale.X; // make active sound // (This RNG is OK because it's not gameplay impacting!) if (random[snap_decor](0, 255) < 3) { PlayActiveSound(); } return true; } override void BeginPlay() { super.BeginPlay(); for (uint i = 0; i < NumRecordedPos; i++) { RecordedPos[i] = Pos; } AtkSeg = -1; AtkTimer = WORMFIREFREQ; JumpTimer = WORMJUMPFREQ; for (uint i = 0; i < NUMWORMSEGS; i++) { SegList[i] = Spawn("LargeWormSeg", Pos, ALLOW_REPLACE); if (SegList[i] == null) { break; } SegList[i].angle = self.angle; SegList[i].master = self; let sa = SnapActor(SegList[i]); if (sa) { sa.SetHitstunParent(self); } } } void SegTick(SnapActor Seg, Actor MoveToward, uint i) { if (i > NUMWORMSEGS) { return; } uint RecordIndex = (PositionLag * (i+1)) - 1; Vector3 NewPos = RecordedPos[RecordIndex]; Vector3 NewAng = RecordedAng[RecordIndex]; Seg.SetOrigin(NewPos, true); Seg.Angle = NewAng.X; Seg.Pitch = NewAng.Y; Seg.Roll = NewAng.Z; } override void Tick() { super.Tick(); if (TickPaused() == true) { return; } UpdateWormPosition(); bool OnGround = (CheckSolidFooting() & CSF_FLOORMASK); double WormLastZ = RecordedPos[0].Z; if (Vel.XY != (0, 0)) { Vector2 bounce = GetWallBounceDir(); if (bounce != (0, 0)) { Vel.XY = bounce * Speed * 2.0; Angle = VectorAngle(Vel.X, Vel.Y); } } double MoveZ = Vel.Z; if (OnGround == true) { MoveZ = Pos.Z - WormLastZ; } Pitch = -VectorAngle(Vel.XY.Length(), MoveZ); UpdateWormPosition(); // Handle segment movement Actor MoveToward = self; for (uint i = 0; i < NUMWORMSEGS; i++) { let Seg = SnapActor(SegList[i]); if (Seg == null || Seg.Health <= 0) { continue; } SegTick(Seg, MoveToward, i); MoveToward = Seg; } // Handle firing if (AtkTimer <= 0) { if (AtkSeg >= 0 && AtkSeg < NUMWORMSEGS) { let Seg = SnapMonster(SegList[AtkSeg]); if (Seg != null && Seg.Health > 0) { Seg.target = self.target; Seg.SetState(Seg.MissileState); Seg.A_SnapMonsterProjectile( "WormMissile", (0, 0, 8), Seg.Angle + 90.0, 0.0, SMP_DONTAIM|SMP_ABSOLUTEANGLE ); Seg.A_SnapMonsterProjectile( "WormMissile", (0, 0, 8), Seg.Angle - 90.0, 0.0, SMP_DONTAIM|SMP_ABSOLUTEANGLE ); } } if (AtkSeg <= 0) { AtkSeg = NUMWORMSEGS-1; AtkTimer = WORMFIREWAIT; } else { AtkSeg = max(0, AtkSeg-1); AtkTimer = WORMFIREFREQ; } } // Handle jumping if (JumpTimer <= 0 && bVeryRude == true) { if (ShortHop == true) { Vel.Z = WORMJUMPSHORTSPEED; } else { Vel.Z = WORMJUMPSPEED; } ShortHop = !ShortHop; JumpTimer = WORMJUMPFREQ; } uint SegCount = 0; for (int i = NUMWORMSEGS-1; i >= -1; i--) { Actor Seg = self; if (i >= 0 && i < NUMWORMSEGS) { Seg = SegList[i]; } if (Seg == null || Seg.Health <= 0) { continue; } SegCount++; } if (SegCount <= 1) { bFrightened = true; } if (SegCount < PrevSegs) { FleeTime = WORMFLEETIME; } PrevSegs = SegCount; } override void OnDestroy(void) { for (uint i = 0; i < NUMWORMSEGS; i++) { if (SegList[i] != null) { SegList[i].Destroy(); } } super.OnDestroy(); } override bool CanCollideWith(Actor other, bool passive) { if ((other is "LargeWormSeg") || (other is "LargeWormHead")) { return false; } return super.CanCollideWith(other, passive); } override void PostTeleport(Vector3 destpos, double destangle, int flags) { super.PostTeleport(destpos, destangle, flags); for (uint i = 0; i < NUMWORMSEGS; i++) { let Seg = SnapActor(SegList[i]); if (Seg != null) { Seg.Teleport(destpos, destangle, flags); } } for (uint i = 0; i < NumRecordedPos; i++) { RecordedPos[i] = Pos; } } override void InitBossMeter() { super.InitBossMeter(); for (uint i = 0; i < NUMWORMSEGS; i++) { let Seg = SnapActor(SegList[i]); if (Seg != null) { AddActorToBossMeter(Seg); } } } override void InitMonsterModifiers() { for (uint i = 0; i < NUMWORMSEGS; i++) { let Seg = SnapMonster(SegList[i]); if (Seg != null) { Seg.MonsterModifiers = self.MonsterModifiers; Seg.UpdateOurMonsterModifiers(); } } bool WasGiant = bGiant; bGiant = false; super.InitMonsterModifiers(); if (WasGiant == true) { Speed *= 1.5; } } Actor GetLastSeg() { for (int i = NUMWORMSEGS-1; i >= -1; i--) { Actor Seg = self; if (i >= 0 && i < NUMWORMSEGS) { Seg = SegList[i]; } if (Seg == null || Seg.Health <= 0) { continue; } return Seg; } return null; } override int DamageMobj(Actor inflictor, Actor source, int damage, Name mod, int flags, double angle) { let LastSeg = GetLastSeg(); if (LastSeg != null && self != LastSeg) { LastSeg.DamageMobj(inflictor, source, damage, mod, flags, angle); return 0; } return super.DamageMobj(inflictor, source, damage, mod, flags, angle); } }