Photosensitive monsters?
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!)
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!)
- Hidden Hands
- Posts: 1053
- Joined: Tue Sep 20, 2016 8:11 pm
- Location: London, England
- Contact:
Photosensitive monsters?
I know I'm really pushing it here but it's just an idea I had... would it at all be possible to code a monster that is afraid of the light? This means you could enter a room with the lights out and the monster is in there. But flick the light switch on and it destroys or makes the monster vanish... at least until the lights return to being off again?
It's not the most important idea but I thought it could add a bit if strategy to my horror game.
Thanks in advance.
It's not the most important idea but I thought it could add a bit if strategy to my horror game.
Thanks in advance.
Re: Photosensitive monsters?
You can check the current sector's light level in ZScript using the following code:
So to check if a sector is lighter than 64, you can do a check like this:
Code: Select all
self.CurSector.lightLevel
Code: Select all
If(self.CurSector.lightLevel>64){/*Run away*/}
- Hidden Hands
- Posts: 1053
- Joined: Tue Sep 20, 2016 8:11 pm
- Location: London, England
- Contact:
Re: Photosensitive monsters?
Wow. So this can be done. Okay, so lets say I have a demon thats afraid of the light. If I wanted to implement this, exactly how would I go about it? Do I write the script in Slade3, as a lump, similar to a DECORATE or would this be run as a script in a map?
Re: Photosensitive monsters?
That code is written in ZScript, because I don't know of any DECORATE / ACS function that does the same.
If you don't want to rewrite your entire monster into ZScript, you can create a ZScript file and insert this actor in it:
Then make your monster inherit from this.
This actor has 2 new functions: A_JumpIfDarker and A_JumpIfLighter.
A_JumpIfDarker checks if the current sector's light level is darker than the specified amount and jumps to the state if it is. This check is lower than, instead of lower or equal to, so to check for 0 light, you'll have to check for 1.
A_JumpIfLighter does the same, but if the level is lighter than the specified number. Again, it's higher than, rather than higher or equal to.
If you don't want to rewrite your entire monster into ZScript, you can create a ZScript file and insert this actor in it:
Code: Select all
Class LightCheckingActor : Actor
{
Action state A_JumpIfDarker(int level, statelabel label)
{
If(self.CurSector.lightlevel<level){Return ResolveState(label);}
Else{Return null;}
}
Action state A_JumpIfLighter(int level, statelabel label)
{
If(self.CurSector.lightlevel>level){Return ResolveState(label);}
Else{Return null;}
}
}
This actor has 2 new functions: A_JumpIfDarker and A_JumpIfLighter.
A_JumpIfDarker checks if the current sector's light level is darker than the specified amount and jumps to the state if it is. This check is lower than, instead of lower or equal to, so to check for 0 light, you'll have to check for 1.
A_JumpIfLighter does the same, but if the level is lighter than the specified number. Again, it's higher than, rather than higher or equal to.
- Hidden Hands
- Posts: 1053
- Joined: Tue Sep 20, 2016 8:11 pm
- Location: London, England
- Contact:
Re: Photosensitive monsters?
Okay heres the idea I just had. This would be great if this works but I'm not entirely sure if it will or if it's possible.
I've designed a monster that looks like a regular one except it renders like the Nightmare Spectre in PSX Doom... I want this monster to be photosensitive BUT I want it to react to my flashlight.
Basically, this map I'm working on limits the bullets and these photosensitive monster are suppose to occupy its darkest areas. Is there a way I can use DECORATE or even ZSCRIPT or ACS to code this monster so that if you turn on your flash light it disappears when the beam from the flashlight hits it? So it basically kills it, but more evaporates it? If so how could I do it? Does anyone have an effective code idea?
I've designed a monster that looks like a regular one except it renders like the Nightmare Spectre in PSX Doom... I want this monster to be photosensitive BUT I want it to react to my flashlight.
Basically, this map I'm working on limits the bullets and these photosensitive monster are suppose to occupy its darkest areas. Is there a way I can use DECORATE or even ZSCRIPT or ACS to code this monster so that if you turn on your flash light it disappears when the beam from the flashlight hits it? So it basically kills it, but more evaporates it? If so how could I do it? Does anyone have an effective code idea?
Re: Photosensitive monsters?
A bit hacky method, but you can fire a hitscan attack from the flashlight with a specific damage type set, so that only this monster will take damage from it.
I don't know how your flashlight is implemented though.
I don't know how your flashlight is implemented though.
- Hidden Hands
- Posts: 1053
- Joined: Tue Sep 20, 2016 8:11 pm
- Location: London, England
- Contact:
Re: Photosensitive monsters?
My flashlight setup is like this: Please can you help me make this work on a monster to hurt it when hit by its beams?Jarewill wrote:A bit hacky method, but you can fire a hitscan attack from the flashlight with a specific damage type set, so that only this monster will take damage from it.
I don't know how your flashlight is implemented though.
GLDEFS
Code: Select all
//FLASHLIGHT
// GL Definitions
// Point Lights
PointLight FLASHLIGHT1
{
Color 1.0 1.0 1.0
Size 1
Offset 0 0 0
}
PointLight FLASHLIGHT2
{
Color 1.0 1.0 1.0
Size 1
Offset 0 0 0
}
PointLight FLASHLIGHT3
{
Color 1.0 1.0 1.0
Size 1
Offset 0 0 0
}
PointLight FLASHLIGHT4
{
Color 1.0 1.0 1.0
Size 1
Offset 0 0 0
}
PointLight FLASHLIGHT5
{
Color 1.0 1.0 1.0
Size 1
Offset 0 0 0
}
PointLight FLASHLIGHT6
{
Color 1.0 1.0 1.0
Size 2
Offset 0 0 0
}
PointLight FLASHLIGHT7
{
Color 1.0 1.0 1.0
Size 2
Offset 0 0 0
}
PointLight FLASHLIGHT8
{
Color 1.0 1.0 1.0
Size 3
Offset 0 0 0
}
PointLight FLASHLIGHT9
{
Color 1.0 1.0 1.0
Size 4
Offset 0 0 0
}
PointLight FLASHLIGHT10
{
Color 1.0 1.0 1.0
Size 5
Offset 0 0 0
}
PointLight FLASHLIGHT11
{
Color 1.0 1.0 1.0
Size 7
Offset 0 0 0
}
PointLight FLASHLIGHT12
{
Color 1.0 1.0 1.0
Size 9
Offset 0 0 0
}
PointLight FLASHLIGHT13
{
Color 1.0 1.0 1.0
Size 12
Offset 0 0 0
}
PointLight FLASHLIGHT14
{
Color 1.0 1.0 1.0
Size 16
Offset 0 0 0
}
PointLight FLASHLIGHT15
{
Color 1.0 1.0 1.0
Size 22
Offset 0 0 0
}
PointLight FLASHLIGHT16
{
Color 1.0 1.0 1.0
Size 29
Offset 0 0 0
}
PointLight FLASHLIGHT17
{
Color 1.0 1.0 1.0
Size 39
Offset 0 0 0
}
PointLight FLASHLIGHT18
{
Color 1.0 1.0 1.0
Size 52
Offset 0 0 0
}
PointLight FLASHLIGHT19
{
Color 1.0 1.0 1.0
Size 69
Offset 0 0 0
}
// Objects
Object FlashLightBeam1
{
Frame TNT1A { Light FLASHLIGHT1}
Frame TNT1B { Light FLASHLIGHT2}
Frame TNT1B { Light FLASHLIGHT3}
}
Object FlashLightBeam2
{
Frame TNT1A { Light FLASHLIGHT2}
Frame TNT1B { Light FLASHLIGHT3}
Frame TNT1B { Light FLASHLIGHT4}
}
Object FlashLightBeam3
{
Frame TNT1A { Light FLASHLIGHT3}
Frame TNT1B { Light FLASHLIGHT4}
Frame TNT1B { Light FLASHLIGHT5}
}
Object FlashLightBeam4
{
Frame TNT1A { Light FLASHLIGHT4}
Frame TNT1B { Light FLASHLIGHT5}
Frame TNT1B { Light FLASHLIGHT6}
}
Object FlashLightBeam5
{
Frame TNT1A { Light FLASHLIGHT5}
Frame TNT1B { Light FLASHLIGHT6}
Frame TNT1B { Light FLASHLIGHT7}
}
Object FlashLightBeam6
{
Frame TNT1A { Light FLASHLIGHT6}
Frame TNT1B { Light FLASHLIGHT7}
Frame TNT1B { Light FLASHLIGHT8}
}
Object FlashLightBeam7
{
Frame TNT1A { Light FLASHLIGHT7}
Frame TNT1B { Light FLASHLIGHT8}
Frame TNT1B { Light FLASHLIGHT9}
}
Object FlashLightBeam8
{
Frame TNT1A { Light FLASHLIGHT8}
Frame TNT1B { Light FLASHLIGHT9}
Frame TNT1B { Light FLASHLIGHT10}
}
Object FlashLightBeam9
{
Frame TNT1A { Light FLASHLIGHT9}
Frame TNT1B { Light FLASHLIGHT10}
Frame TNT1B { Light FLASHLIGHT11}
}
Object FlashLightBeam10
{
Frame TNT1A { Light FLASHLIGHT10}
Frame TNT1B { Light FLASHLIGHT11}
Frame TNT1B { Light FLASHLIGHT12}
}
Object FlashLightBeam11
{
Frame TNT1A { Light FLASHLIGHT11}
Frame TNT1B { Light FLASHLIGHT12}
Frame TNT1B { Light FLASHLIGHT13}
}
Object FlashLightBeam12
{
Frame TNT1A { Light FLASHLIGHT12}
Frame TNT1B { Light FLASHLIGHT13}
Frame TNT1B { Light FLASHLIGHT14}
}
Object FlashLightBeam13
{
Frame TNT1A { Light FLASHLIGHT13}
Frame TNT1B { Light FLASHLIGHT14}
Frame TNT1B { Light FLASHLIGHT15}
}
Object FlashLightBeam14
{
Frame TNT1A { Light FLASHLIGHT14}
Frame TNT1B { Light FLASHLIGHT15}
Frame TNT1B { Light FLASHLIGHT16}
}
Object FlashLightBeam15
{
Frame TNT1A { Light FLASHLIGHT15}
Frame TNT1B { Light FLASHLIGHT16}
Frame TNT1B { Light FLASHLIGHT17}
}
Object FlashLightBeam16
{
Frame TNT1A { Light FLASHLIGHT16}
Frame TNT1B { Light FLASHLIGHT17}
Frame TNT1B { Light FLASHLIGHT18}
}
Object FlashLightBeam17
{
Frame TNT1A { Light FLASHLIGHT17}
Frame TNT1B { Light FLASHLIGHT18}
Frame TNT1B { Light FLASHLIGHT19}
}
Object FlashLightBeam18
{
Frame TNT1A { Light FLASHLIGHT18}
Frame TNT1B { Light FLASHLIGHT19}
Frame TNT1B { Light FLASHLIGHT20}
}
Object FlashLightBeam19
{
Frame TNT1A { Light FLASHLIGHT19}
Frame TNT1B { Light FLASHLIGHT20}
Frame TNT1B { Light FLASHLIGHT21}
}
Code: Select all
const int flashlightVert = 18;
const int flashlightHoriz = 0; // 36 for over-the-shoulder effect
// Actors
ACTOR FlashlightSpawner : CustomInventory
{
States
{
Pickup:
TNT1 A 0 A_CustomMissile("FlashLightBeam1", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam2", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam3", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam4", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam5", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam6", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam7", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam8", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam9", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam10", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam11", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam12", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam13", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam14", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam15", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam16", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam17", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam18", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
TNT1 A 0 A_CustomMissile("FlashLightBeam19", flashlightVert, flashlightHoriz, 0, 2, ACS_NamedExecuteWithResult("PointerPitch", 0))
Stop
}
}
ACTOR FlashLightBeam
{
+NOGRAVITY
+NOCLIP
+NOBLOCKMAP
+DONTSPLASH
+THRUACTORS
Renderstyle None
Radius 1
Height 1
States
{
Spawn:
TNT1 AABC 1
Stop
}
}
ACTOR FlashLightBeam1 : FlashLightBeam
{
Speed 1
}
ACTOR FlashLightBeam2 : FlashLightBeam
{
Speed 2
}
ACTOR FlashLightBeam3 : FlashLightBeam
{
Speed 3
}
ACTOR FlashLightBeam4 : FlashLightBeam
{
Speed 4
}
ACTOR FlashLightBeam5 : FlashLightBeam
{
Speed 5
}
ACTOR FlashLightBeam6 : FlashLightBeam
{
Speed 7
}
ACTOR FlashLightBeam7 : FlashLightBeam
{
Speed 9
}
ACTOR FlashLightBeam8 : FlashLightBeam
{
Speed 12
}
ACTOR FlashLightBeam9 : FlashLightBeam
{
Speed 16
}
ACTOR FlashLightBeam10 : FlashLightBeam
{
Speed 21
}
ACTOR FlashLightBeam11 : FlashLightBeam
{
Speed 28
}
ACTOR FlashLightBeam12 : FlashLightBeam
{
Speed 37
}
ACTOR FlashLightBeam13 : FlashLightBeam
{
Speed 49
}
ACTOR FlashLightBeam14 : FlashLightBeam
{
Speed 65
}
ACTOR FlashLightBeam15 : FlashLightBeam
{
Speed 87
}
ACTOR FlashLightBeam16 : FlashLightBeam
{
Speed 116
}
ACTOR FlashLightBeam17 : FlashLightBeam
{
Speed 155
}
ACTOR FlashLightBeam18 : FlashLightBeam
{
Speed 207
}
ACTOR FlashLightBeam19 : FlashLightBeam
{
Speed 276
}
Code: Select all
DefaultBind "F" "ToggleFlashlight"
Code: Select all
flashlight/click click
- Hidden Hands
- Posts: 1053
- Joined: Tue Sep 20, 2016 8:11 pm
- Location: London, England
- Contact:
Re: Photosensitive monsters?
This is my zscript for the monster to be harmed by the flashlight. I only want it to affect this one creature.
Help please? Thanks in advance.
Code: Select all
class shadow : Revenant replaces Revenant
{
Default
{
Health 150;
PainChance 180;
Speed 10;
Radius 30;
Height 56;
Mass 400;
Renderstyle "Subtract";
Bloodcolor "Black";
Monster;
+NOGRAVITY
+DROPOFF
+FLOAT
+FLOORCLIP
+TELESTOMP
+DONTHARMCLASS
SeeSound "photokakos/sight";
AttackSound "photokakos/melee";
PainSound "photokakos/pain";
DeathSound "photokakos/death";
ActiveSound "photokakos/active";
Obituary "$OB_DEMONHIT";
Tag "$FN_DEMON";
}
States
{
Spawn:
SHDM ABCD 10 A_Look;
Loop;
See:
SHDM AAABBBCCCDDD 4 Fast A_Chase;
Loop;
Melee:
SHDM EF 8 Fast A_FaceTarget;
SHDM G 8 Fast A_CustomMeleeAttack (random (2, 6) *5, "ClawHit", "skeleton/swing");
SHDM HI 8 Fast A_FaceTarget;
SHDM J 8 Fast A_CustomMeleeAttack (random (2, 6) *5, "ClawHit", "skeleton/swing");
Goto See;
Missile:
Goto See;
Pain:
SHDM K 2 Fast;
SHDM K 2 Fast A_Pain;
Goto See;
Death:
DCPS A 8;
DCPS B 8 A_Scream;
DCPS C 4;
DCPS D 4 A_NoBlocking;
DCPS EFGHI 4;
DCPS J -1;
Stop;
Raise:
SHDM P 5;
SHDM ONML 5;
Goto See;
}
}
Re: Photosensitive monsters?
That should be pretty simple, since the flashlight already is made out of projectiles.
The first example on the DamageType definition in MAPINFO does what you want.
You'd need a definition like this in MAPINFO:
And your monster to have this:
Now for the flashlight projectiles, I'd change the +NOCLIP flag with the +RIPPER flag and add the Projectile property to them, alongside the new damage type:
The first example on the DamageType definition in MAPINFO does what you want.
You'd need a definition like this in MAPINFO:
Code: Select all
DamageType Light
{
Factor = 0
ReplaceFactor
}
Code: Select all
ACTOR DemonLight : Demon replaces Demon
{
DamageFactor "Normal", 0
DamageFactor "Light", 1.0
}
Spoiler:
- Hidden Hands
- Posts: 1053
- Joined: Tue Sep 20, 2016 8:11 pm
- Location: London, England
- Contact:
Re: Photosensitive monsters?
Absolutely incredible, this works like a DREAM. Thank you so much Jarewill!! One side note though, I wonder if you can help me solve, when I aim the flashlight at a normal monster it makes blood fly out of it as if taking damage (it doesn't take any damage since only bullets hurt the regular kind). But it makes it bleed as if taking damage. How can I make that not happen for other monsters and only affect the Shadow demon?Jarewill wrote:That should be pretty simple, since the flashlight already is made out of projectiles.
The first example on the DamageType definition in MAPINFO does what you want.
You'd need a definition like this in MAPINFO:And your monster to have this:Code: Select all
DamageType Light { Factor = 0 ReplaceFactor }
Now for the flashlight projectiles, I'd change the +NOCLIP flag with the +RIPPER flag and add the Projectile property to them, alongside the new damage type:Code: Select all
ACTOR DemonLight : Demon replaces Demon { DamageFactor "Normal", 0 DamageFactor "Light", 1.0 }
Spoiler:
Re: Photosensitive monsters?
You can make the flashlight not spawn blood by also adding the +BLOODLESSIMPACT flag on it.
However I don't think there's a way to make only 1 monster spawn blood, at least without the use of ZScript.
However I don't think there's a way to make only 1 monster spawn blood, at least without the use of ZScript.
- Hidden Hands
- Posts: 1053
- Joined: Tue Sep 20, 2016 8:11 pm
- Location: London, England
- Contact:
Re: Photosensitive monsters?
Ah ok, so basically, if I add the +BLOODLESSIMPACT flag, this will fix the issue totally? Because the flashlight isnt meant to make the monster bleed anyway just fade away so this will fix it?Jarewill wrote:You can make the flashlight not spawn blood by also adding the +BLOODLESSIMPACT flag on it.
However I don't think there's a way to make only 1 monster spawn blood, at least without the use of ZScript.
Re: Photosensitive monsters?
That should fix it, yes.Hidden Hands wrote:Ah ok, so basically, if I add the +BLOODLESSIMPACT flag, this will fix the issue totally? Because the flashlight isnt meant to make the monster bleed anyway just fade away so this will fix it?