Missing light when my monster is firing

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
PixelWAD
Posts: 188
Joined: Sun Jun 10, 2018 7:01 pm

Missing light when my monster is firing

Post by PixelWAD »

I have a script that replaces ShotgunGuy with custom animated MD3 model. So far I got everything to work, except when the monster is firing, it is still dark all around, unlikes rest of the game that is untouched. How do I add dynamic light to that frame?

Code: Select all

// TO-DO
// DROPITEM (SHOTGUN + ARMOR 1-4)
// GIBS


// ShotgunGuy Doom 2 replaced as Pig Cop
// http://doomwiki.org/wiki/Shotgun_guy
// http://dukenukem.wikia.com/wiki/Pig_Cop_(DN3D)

Class DN3DPigCop : Actor replaces ShotgunGuy
// https://zdoom.org/wiki/Classes:Doom
// https://zdoom.org/wiki/Classes:Actor
// https://zdoom.org/wiki/DECORATE_format_specifications
{
  Default
  // https://zdoom.org/wiki/actor_properties
  // The following properties can be set in an actor's DECORATE or ZScript's Default {} block definition.
  // They control various characteristics of your actor, from appearance to behavior or the actor's physical properties.
  // To use, simply specify the property and any associated values on its own line within the actor's definition and outside the state block.
    {
      Health 100;
      // https://zdoom.org/wiki/Classes:Health
      // A Health item adds a certain amount to the player's health points.
      // Items of this type are always effective when picked up. They cannot be placed in the inventory;
      // to have health items in inventory, use HealthPickup. Health is never used directly.
      // This class is only used as a base class for predefined items (like Doom's Stimpack or for items defined in DECORATE).
      
      Radius 20;
      // Collisions and Physics
      // Radius value
      // Defines the radius of this actor.
      // Default is 20.
      // Notes:
      // Using very small values can provoke glitches in collision detection.
      // The total diameter is double this value, so an actor with a radius of 64 is actually 128 units in length and width,
      // making it impossible for them to navigate through a corridor that's 128 units wide, for example.
      
      Height 56;
      // Height value
      // Defines the height of this actor.
      // Default is 16.
      // Note: using very small values can provoke glitches in collision detection.
      
      Mass 100;
      // Defines the mass of this actor. The larger the mass the less an actor moves when being thrust by damage.
      // If less than 10, the actor will also make small terrain splashes rather than normal ones.
      // Default is 100.
      // Note: Giving an actor an extremely high mass in an effort to make it unthrustable is not recommended.
      // If an actor is stuck in another or in a wall and A_RadiusThrust affects the actor, the actor could be killed
      // almost instantly if RTF_NOIMPACTDAMAGE isn't used. It's recommended to use the DONTTHRUST flag instead of 0x7FFFFFFF or the likes.
      
      Speed 5;
      // Defines how fast an actor moves. For projectiles this is the distance it moves per tic (1/35 seconds).
      // For monsters it defines the size of one step done in A_Chase.
      // Player's movement speed also depends on the Player.ForwardMove property.
      // Default is 0.

      PainChance 96;
      // Probability of entering the pain state (256 = always, 0 = never).
      // You can also specify PainChance per damage type. Sources of damage that have the FORCEPAIN flag ignore this property.
      // Default is 0.
      
      Monster;
      // A monster is an actor controlled by the computer using AI routines present in their DECORATE code.
      // https://zdoom.org/wiki/Monster
      
      +FLOORCLIP
      // Actor's lower part is clipped when standing in a sector with a liquid texture (defined in the TERRAIN lump).
      
      SeeSound "pig/sight";
      // SeeSound soundname
      // Defines the sound the actor makes when it sees the player (for monsters) or when a projectile is spawned.
      
      AttackSound "pig/shoot";
      // When enemy fires -- SiN
      
      PainSound "pig/pain";
      // PainSound soundname
      // Defines the sound the actor makes when in pain. To hear this sound A_Pain has to be called.
      
      DeathSound "pig/death";
      // DeathSound soundname
      // Defines the sound the actor makes when dying or when a projectile explodes.
      // For non-projectiles the death sound must be explicitly played with A_Scream.
		
		  ActiveSound "pig/active";
		  // ActiveSound soundname
      // Defines the sound the actor makes when active.
      
      Obituary "%o was shot by a Pig Cop.";
      // https://zdoom.org/wiki/actor_properties#Obituaries
      // Obituary string
      // Defines the obituary string for this actor.
      // For weapons, this property can be used either directly on the weapon or on the puff for hitscan or rail attacks,
      // but it should be on the projectile instead for missile attacks.
      
      Tag "Duke Nukem Pig Cop";
      // Tag name
      // Gives the actor a name. The names are used in the key display on Strife's status bar and the default
      // actor name in Strife's dialogs, as well as the name of the currently selected inventory item when
      // the invquery console command is called.
	}

// - ANIMATIONS -	
	States
	// https://zdoom.org/wiki/actor_states
	// An actor's states can be defined within its DECORATE definition. State sequences describe all the behavior of the actor as well as its animation.
	
	{
	
	Spawn:
	// Defines the state that is displayed when an actor is spawned. For monsters this is normally also the idle loop.
	//
	// Note: An actor that has just been spawned does not run the codepointer from its first “Spawn” frame.
	// An example of this behavior in the original games is ArchvileFire. It will be called, however, if the actor loops
	// or returns to its Spawn state later. An easy workaround to have actors call a codepointer immediately after
	// spawning consists in having the very first frame have a duration of 0 tics, followed by another frame in which the
	// codepointer instruction is given. Another solution is to use the NoDelay keyword.
	
		MOD1 AAAAAAAAA 4 A_Look;
		// https://zdoom.org/wiki/A_Look
		// Looks for players or other attackable actors in the game. If it finds a target, it enters its “See” state.
		
		MOD1 A 0 A_Jump (40, "StepForward");
		// https://zdoom.org/wiki/A_Jump
		// Randomly advances to different frame. The chance value can range between 0 and 256.
		// A chance of 0 will never jump, while a chance of 256 will always jump. If the jump does not happen,
		// then the frame or instruction immediately following the A_Jump will be used as if A_Jump had not been present.
		// If more than one offset or state values are present, A_Jump will choose one of them at random.
		
		Loop;
		// https://zdoom.org/wiki/Actor_states#Flow_control
		// Jumps to the most recently defined state label. This is used for a looping animation.
		// Do not put a loop on a state with a duration of -1, this is unnecessary and can cause problems.
		
		StepForward:
		// A custom frame sequencion name, as definied above? -- SiN
		    MOD1 BCDEFEDCB 4 A_Look;
		    goto Spawn;      

		See:
		// Defines the walking animation for a monster.
		// Note that this state must be present for actors which are able to chase and attack other actors.
		    MOD1 ABCDEFGHIJKLMNOPQR 2 A_Chase;
		    // https://zdoom.org/wiki/A_Chase
		    // This is the standard monster walking function which has to be used in the walking frames of a monster.
		    // Typically, it is used in an actor's "See" state or a custom equivalent. When called, actors usually change
		    // their directions to a strict 45 degree angle to give the effect of pursuit. This angle changes based on which
		    // direction the target is, no matter if the calling actor can see it or not.
		Loop;
		
		Missile:
		// https://zdoom.org/wiki/Actor_flags#MISSILE
		// Actor is a projectile. Actors with this flag set will enter their death state when hitting a solid
		// and constantly move at their speed value (without the need of any actor functions).
		// Actors with this flag will also be able to go through impassable linedefs.
    // -- Automatically given by the Projectile combo
		    MOD1 R 3 A_Jump(96,"Missile2");
		    MOD1 S 3 A_FaceTarget;
		    // MOD1 T 4 Bright A_CustomBulletAttack(8.6, 8.6, 6, 2, "PigCopPuff");
		    MOD1 T 4 Bright A_CustomBulletAttack(8.6, 8.6, 6, 2, "BulletPuff", 1, CBAF_NORANDOM);
		    // MOD1 T 4 Bright A_SPosAttackUseAtkSound(8.6, 8.6, 6, 2);
		    // MOD1 T 3 Bright A_SpawnProjectile ("DN3DShotgunFired", 32);
		    MOD1 T 2 A_PlaySound("pig/pump");
		    MOD1 VWXYZ 3;
		    MOD2 ABC 3;
		    // now he is firing second time
		    MOD1 S 3 A_FaceTarget;
		    MOD1 T 4 Bright A_CustomBulletAttack(8.6, 8.6, 6, 2, "BulletPuff", 0, CBAF_NORANDOM);
		    // MOD1 T 3 Bright A_SpawnProjectile ("DN3DShotgunFired", 32);
		    MOD1 T 2 A_PlaySound("pig/pump");
		    MOD1 VWXYZ 3;
		    MOD2 ABC 3;
		    		 goto See;

		Missile2:
		// https://zdoom.org/wiki/Actor_flags#MISSILE
		// Actor is a projectile. Actors with this flag set will enter their death state when hitting a solid
		// and constantly move at their speed value (without the need of any actor functions).
		// Actors with this flag will also be able to go through impassable linedefs.
    // -- Automatically given by the Projectile combo
		    MOD3 C 3 A_FaceTarget;
		    MOD3 DEFGHIJKLM 3;
		    MOD3 N 4 A_FaceTarget;
		    MOD3 N 3 Bright A_CustomBulletAttack(8.6, 8.6, 6, 2, "BulletPuff", 0, CBAF_NORANDOM);
//		    MOD3 N 3 Bright A_SpawnProjectile ("DN3DShotgunFired", 32);
		    MOD3 O 10 A_PlaySound("pig/pump");
		    MOD3 PQRST 2;
		    MOD3 U 8;
		    MOD3 N 3 A_FaceTarget;
		    MOD3 N 3 Bright A_CustomBulletAttack(8.6, 8.6, 6, 2, "BulletPuff", 0, CBAF_NORANDOM);
//		    MOD3 N 3 Bright A_SpawnProjectile ("DN3DShotgunFired", 32);
		    MOD3 O 10 A_PlaySound("pig/pump");
		    MOD3 PQRSTU 2;
		    MOD3 KJIHGFEDCB 2;
		    // ML deleted as its reverse fire
		    		 goto See;
		    		 
	  Pain:
	  // https://zdoom.org/wiki/Actor_states
	  // Defines the pain action. Multiple Pain states can be used depending on the type of damage inflicted. See custom damage types.
		    MOD2 DE 2;
		    MOD2 F 2 A_Pain;
		    // https://zdoom.org/wiki/A_Pain
		    // Plays the actor's pain sound.
		    MOD2 FDE 2; 
		         goto See;
		         // https://zdoom.org/wiki/Actor_states#Flow_control
		         // The statement goto See jumps to the walking animation that has been overriden in the current actor class,
		         // or if such does not exist, to the inherited class's state. goto is however static,
		         // i.e. will not do virtual jumps — for that, see A_Jump.

    Death:
    // Defines the normal death sequence. Multiple Death states can be used depending on the type of damage that kills the actor.
    // See custom damage types. Also entered by projectiles when hitting a wall
    // (or an actor as well if the Crash and/or XDeath states are not defined).
		    MOD2 G 2 A_Scream;
		    // https://zdoom.org/wiki/A_Scream
		    // Plays the actor's death sound if it has one. If the actor has the BOSS flag, the sound is heard
		    // at full volume regardless of distance, otherwise it diminishes by distance.
		    // The sound is played on the voice channel.
		    MOD2 H 2 A_NoBlocking;
		    // https://zdoom.org/wiki/A_NoBlocking
		    // It makes the actor visible if it is stealth.
        // It makes it non-solid.
        // It makes it spawn its dialogue-set and "regular" drop items.
        // It clears the dialogue that is assigned to it.
		    MOD2 IJKLMNOPQRSTUVWXYZ 2;
		    MOD3 A -1;
		    // MOD3 B 5;
		         Stop;
	}
}

// PIG COP PUFF
//actor PigCopPuff
//{
//  damagetype "PigCop";
//}

// The projectile shot by Pig Cop using Shotgun - maybe none?
//class DN3DShotgunFired : NormalBullet
//
//class DN3DShotgunFired : DoomImpBall
//{
//      Default
//  	{
//  		Scale 0.2;
//	  	Speed 30;
//  	}
//}
I know that is a lot of commands, but I'm trying to understand how everything works and having everything in one place might works in the beginning.
Don't laugh :mrgreen:
User avatar
Jekyll Grim Payne
 
 
Posts: 1073
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: Missing light when my monster is firing

Post by Jekyll Grim Payne »

If you want actual dynamic light, you'll need [wiki]GLDEFS[/wiki].
PixelWAD
Posts: 188
Joined: Sun Jun 10, 2018 7:01 pm

Re: Missing light when my monster is firing

Post by PixelWAD »

What do i need to include in my gldefs?
User avatar
ramon.dexter
Posts: 1529
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Missing light when my monster is firing

Post by ramon.dexter »

You need to define an dynamic light in GLDEFS in order to have a actor emitting light.

The rest is pretty clearly described in the link provided by Jekyll Grim Payne.
PixelWAD
Posts: 188
Joined: Sun Jun 10, 2018 7:01 pm

Re: Missing light when my monster is firing

Post by PixelWAD »

Oh I'm sorry, I have not noticed the link when I saw it on mobile.
I'll give it a try and report back!
PixelWAD
Posts: 188
Joined: Sun Jun 10, 2018 7:01 pm

Re: Missing light when my monster is firing

Post by PixelWAD »

Got it!

I compared to how it was done in Gene Tech mod.

I had to define this in GLDEFS file:

Code: Select all

flickerlight2 ENEMYATTACK1
{
    color 1.0 0.8 0.2
    size 48
    secondarySize 56
    interval 1
    offset 32 40 0
}

// below the name of the actor for MD3 file, and then certain frame indexed sprite name
object PigCop16
{
    frame MOD1T { light ENEMYATTACK1 }
    frame MOD3N { light ENEMYATTACK1 }
}
Post Reply

Return to “Scripting”