Random Editing Questions

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
amv2k9
Posts: 2178
Joined: Sun Jan 10, 2010 4:05 pm
Location: Southern California

Re: Random Editing Questions

Post by amv2k9 »

Any chance I could get some help with this? Please?
User avatar
FDARI
Posts: 1097
Joined: Tue Nov 03, 2009 9:19 am

Re: Random Editing Questions

Post by FDARI »

With
Having a problem with a friendly monster in a project I'm working on. I've narrowed it down to the following; if the monster is killed when its in an attack state, it crashes the game. I've tried some tweaks to the code, but nothing seems to solve the problem.
?

Can you describe the crash? (Do you get a crash report? Does it hang first and crash after a while?)

If you change the attack states to "####" "#" 80, and kill during these states; does crash go away?
If you keep the attacks complex, but use some standard death sequences (zombieman); does crash go away?

I could try to provoke the crash in a debugged zdoom session if I don't suddenly see in your code what is going wrong. But then I'd need a ready-to-crash mod.
User avatar
amv2k9
Posts: 2178
Joined: Sun Jan 10, 2010 4:05 pm
Location: Southern California

Re: Random Editing Questions

Post by amv2k9 »

Hangs, then crashes. I don't think it always produces a report, either. I'll try the other possible solutions in a bit.
User avatar
amv2k9
Posts: 2178
Joined: Sun Jan 10, 2010 4:05 pm
Location: Southern California

Re: Random Editing Questions

Post by amv2k9 »

I believe I've fixed the problem; at least, I can't reproduce the glitch anymore. Thanks for the help!
User avatar
amv2k9
Posts: 2178
Joined: Sun Jan 10, 2010 4:05 pm
Location: Southern California

Re: Random Editing Questions

Post by amv2k9 »

I'm writing an acs script and I've come across some very bizzare bugs:

Here's the script:

Code: Select all

script "2xAmmoFactorSkillCheck" (void)
{
	if (GameSkill () <1) 
	{
		SetResultValue(2);
	}
	if (GameSkill () >0)
	{
		if (GameSkill () == 4)
		{
			SetResultValue(2);
		}
		else
		{
			SetResultValue(1);
		}
	}
}
It's called from this custominventory item:

Code: Select all

ACTOR SmartClipBox : CustomInventory replaces ClipBox
{
	States
	{
	Spawn:
		AMMO A 1
		Loop
	Pickup:
		TNT1 A 0 A_JumpIfInventory("Backpack",1,"PlayerHasBackpack")
	 PlayerHasNoPack:
		TNT1 A 0
	  NoPackCheckFor2xAmmo:
		TNT1 A 0 A_JumpIf(2 == ACS_NamedExecuteWithResult("2xAmmoFactorSkillCheck",0,0,0),"2xAmmoFactorSkillNoPack")
		Goto 1xAmmoFactorSkillNoPack
	   2xAmmoFactorSkillNoPack:
		TNT1 A 0 A_JumpIfInventory("Clip",101,"SpawnClips")
		TNT1 A 0 A_GiveInventory("FullClipBox",50)
		Stop
	   1xAmmoFactorSkillNoPack:
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("Clip",151,"SpawnClips")
		TNT1 A 0 A_GiveInventory("FullClipBox",50)
		Stop
	 PlayerHasBackpack:
		TNT1 A 0
	  HasPackCheckFor2xAmmo:
		TNT1 A 0 A_JumpIf(2 == ACS_NamedExecuteWithResult("2xAmmoFactorSkillCheck",0,0,0),"2xAmmoFactorSkillWithPack")
		Goto 1xAmmoFactorSkillWithPack
	   2xAmmoFactorSkillWithPack:
		TNT1 A 0 A_JumpIfInventory("Clip",301,"SpawnClips")
		TNT1 A 0 A_GiveInventory("FullClipBox",50)
		Stop
	   1xAmmoFactorSkillWithPack:
		TNT1 A 0 A_JumpIfInventory("Clip",351,"SpawnClips")
		TNT1 A 0 A_GiveInventory("FullClipBox",50)
		Stop
	 SpawnClips:
		AMMO AAAAA 1 A_SpawnItemEx("Clip",0,0,0,frandom(-2,2),frandom(-2,2),frandom(1,2)) 
	  FadeLoop:		
		AMMO A 1 A_FadeOut(0.1,1)
		Loop
	}
}
So, the bug:
When the proper conditions are fulfilled (the player picks up the actor, and is fifty ammo units away or less from maxing out Clip ammo) the CustomInventory actor jumps to its "SpawnClips" state. Instead of then spawning five Clip actors and moving to the FadeLoop state, it spawns more like two dozen Clips, freezes the player in place but continues to bob up and down (and after a while the view jolts from ceiling to floor and back again), and makes the weapon fade out.

Just what the heck have I done wrong?
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: Random Editing Questions

Post by Blue Shadow »

The FadeLoop state is the culprit here; A_FadeOut is affecting the player himself and not the item (this is usually the case with custom inventory items; they affect the actor that picks them up or given to it).

For the fade out effect, you can have it spawn another actor in its place that'll carry on the effect.
User avatar
amv2k9
Posts: 2178
Joined: Sun Jan 10, 2010 4:05 pm
Location: Southern California

Re: Random Editing Questions

Post by amv2k9 »

Blue Shadow wrote:...A_FadeOut is affecting the player himself and not the item (this is usually the case with custom inventory items; they affect the actor that picks them up or given to it).
Ah, I figured it might have something to do with the ACS script. Thanks!
User avatar
amv2k9
Posts: 2178
Joined: Sun Jan 10, 2010 4:05 pm
Location: Southern California

Re: Random Editing Questions

Post by amv2k9 »

What's the best way to have one actor check for the existance of another actor in a level? I think ClassifyActor is what I'm looking for, but I'm unsure of how exactly to use it for this; I've messed around with it, without success.
User avatar
amv2k9
Posts: 2178
Joined: Sun Jan 10, 2010 4:05 pm
Location: Southern California

Re: Random Editing Questions

Post by amv2k9 »

For something I'm working on, I have a stationary, defenseless monster that spawns robots that are assigned to be its children and can be repeatedly resurrected by the parent, until it is destroyed. At that point it kills any live 'children' and removes any dead ones. Problem is, it doesn't resurrect them! It was working OK for a while, but then I changed something unrelated to the resurrection and now it broke. It kills and removes them properly, so the parent/child thing *is* being set correctly.

Code: Select all

ACTOR SwarmerControlUnit
{
	MONSTER
	+NOBLOOD
	+LOOKALLAROUND
	Speed 0
	Height 32
	Radius 16
	XScale 0.35
	YScale 0.30
	Health 220
	Mass 0x7FFFFFFF
	States
	{
	Spawn:
		CONT A 1 A_Look
		Loop
	See:
		TNT1 AAAA 0 A_SpawnItemEx("Swarmer",0,0,0,0,0,0,0,SXF_SETMASTER|SXF_NOCHECKPOSITION)
	 SeeLoop:
		CONT A 3
		CONT B 2
		TNT1 A 0 A_PlaySound("DSFIRXPL")
		CONT CDEFGHIJKLM 1
		CONT N 2
		CONT O 3
		TNT1 A 0 A_RaiseChildren
		CONT P 20 
		Loop
	Death:
		TNT1 A 0 A_KillChildren("CUDeath")
		TNT1 A 0 A_PlaySound("DSINQACT")
		COND ABC 4
		TNT1 A 0 A_NoBlocking
		COND D 5
		COND EDEDEDEDEDE 2
		TNT1 AAAAAA 0 A_SpawnItemEx("SmallJunk",0,0,0,frandom(-6,6),frandom(-6,6),frandom(4,8))
		TNT1 AA 0 A_SpawnItemEx("SCUExplosionA",frandom(-2,2),frandom(-2,2))
		TNT1 A 0 A_SpawnItemEx("SCUExplosionB")
		TNT1 A 0 A_RemoveChildren
		COND F -1
		Stop
	}
}

ACTOR Swarmer : Stalker
{
	-NOGRAVITY
	-SPAWNCEILING
	-NOVERTICALMELEERANGE
	Scale 0.75
	Radius 20
	Translation "160:223=%[0.0,0.0,0.0]:[1.0,0.0,0.0]",
				"128:143=%[0.0,0.0,0.0]:[1.0,0.0,0.0]",
				"96:111=112:127",
				"241:246=112:127"
	States
	{
	Spawn:
		STLK J 1 A_Look
		Loop
	Drop:
		TNT1 A 0
	See:
		STLK J 3 A_StalkerWalk
		STLK KK 3 A_Chase
		STLK L 3 A_StalkerWalk
		STLK L 3 A_Chase
		Loop
	Melee:
		STLK J 3 A_FaceTarget
		STLK K 3 A_StalkerAttack
		Goto See
	XDeath:
	Death:
		STLK O 4
		STLK P 4 A_Scream
		STLK QRST 4
	 DeathLoop:
		STLK KK 4 A_SpawnItemEx("SwarmSpark",frandom(-10,10),frandom(-10,10),frandom(2,10))
		STLK K 16
		STLK K 4 A_SpawnItemEx("SwarmSpark",frandom(-10,10),frandom(-10,10),frandom(2,10))
		STLK K 8
		STLK K 4 A_SpawnItemEx("SwarmSpark",frandom(-10,10),frandom(-10,10),frandom(2,10))
		STLK K 32
		Loop
	Death.CUDeath:
		STLK O 4
		STLK P 4 A_Scream
		STLK QRST 4
		STLK U 4 A_NoBlocking
		STLK VW 4
		STLK "X" 4 BRIGHT
		TNT1 AAAAAA 0 A_SpawnItemEx("SmallJunk",0,0,0,frandom(-8,8),frandom(-8,8),frandom(4,8))
		STLK "Y" 4 BRIGHT
		STLK "Z[" 4 Bright
		Stop
	Raise:
		STLK TSRQPO 4
		Goto See
	}
}
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: Random Editing Questions

Post by Blue Shadow »

According to the source code (if I'm reading it right), one of the requirements for an actor to be successfully resurrected is to already be at a state with -1 tic duration when the function is called. Your Swarmer cannot fill this requirement as it is, as it needs to loop in order to continually spawn the sparks while in that state.
User avatar
amv2k9
Posts: 2178
Joined: Sun Jan 10, 2010 4:05 pm
Location: Southern California

Re: Random Editing Questions

Post by amv2k9 »

Ah. I guess I can have the Swarmer spawn an actor that spawns the sparks before stting itself to a frame with -1 duration, then. That way I can have the resurrect effect still work and not lose the sparks. Thanks!
User avatar
amv2k9
Posts: 2178
Joined: Sun Jan 10, 2010 4:05 pm
Location: Southern California

Re: Random Editing Questions

Post by amv2k9 »

In a project I'm making, I have a proximity mine that the player can drop. When an enemy gets close to it, it explodes. When the player gets close to it, it deactivates. The player can also manually detonate it if they want.

The way it works is, the mine is actually a pseudo-monster that is +TOUCHY. That takes care of the 'proximity mine' part; when a monster's collision box comes into contact with the mine's, the mine enters its death state.

The mine is also not friendly to the player; this enables it to check distance to the target (the player) and once the target gets close enough, it goes into a different death state and spawns a pickup. That handles the 'deactivating when player is close' part. It also has the player as a target so that it can check target inventory for the presence or lack thereof of a dummy item; that handles the 'manual detonation' part.

The problem is, even though this actor has the +NOTARGETSWITCH flag, it *is* switching targets! Sometimes when an enemy gets close to it, it will deactivate, which it should only do when the player is close. Sometimes when the player gets close, it will detonate, instead of deactivating as it should. And sometimes, it won't manually detonate when the appropriate dummy item is in the player's inventory.

Code: Select all

ACTOR ActualGasProxMine
{
 MONSTER
 -FRIENDLY
 -COUNTKILL
 -SOLID
 +NOTONAUTOMAP
 +TOUCHY
 +NOBLOOD
 +NOTARGETSWITCH
 +LOOKALLAROUND
 Mass 0x7FFFFFFF
 Height 5
 Radius 24
 BloodType ""
 States
 {
 Spawn:
  TNT1 A 0
  TNT1 A 0 Thing_ChangeTID(0,501)
 SpawnLoop:
  GASG AABBCC 1 A_Look
  Loop
 See:
  TNT1 A 0 A_JumpIfCloser(64,"Deactivate")
  GASG A 1 A_JumpIfInTargetInventory("GasMineFired",1,"Detonate")
  TNT1 A 0 A_JumpIfCloser(64,"Deactivate")
  GASG B 1 A_JumpIfInTargetInventory("GasMineFired",1,"Detonate")
  TNT1 A 0 A_JumpIfCloser(64,"Deactivate")
  GASG B 1 A_JumpIfInTargetInventory("GasMineFired",1,"Detonate")
  TNT1 A 0 A_JumpIfCloser(64,"Deactivate")
  TNT1 A 0 A_SpawnItemEx("GasProxMinePulse",0,0,10,0,0,5)
  GASG C 1 A_JumpIfInTargetInventory("GasMineFired",1,"Detonate")
  TNT1 A 0 A_JumpIfCloser(64,"Deactivate")
  GASG C 1 A_JumpIfInTargetInventory("GasMineFired",1,"Detonate")
  Loop
 Deactivate:
  TNT1 A 0 A_Die("Deactivate")
  Stop
 Detonate:
  TNT1 A 0 A_Die("Detonate")
  Stop
 Death:
 Death.Detonate:
  TNT1 A 0 A_TakeFromTarget("GasMineFired")
  TNT1 A 0 A_AlertMonsters
  TNT1 A 0 A_SpawnItemEx("MainGasCloud",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION|SXF_TRANSFERPOINTERS)
  GASG C 70
 FadeOut:
  GASG C 1 A_FadeOut(0.1,1)
  Loop
 Death.Deactivate:
  TNT1 A 0
  TNT1 A 0 A_SpawnItemEx("GasProxMineAmmoSingle",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
  Stop
 }
}
User avatar
phantombeta
Posts: 2217
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Random Editing Questions

Post by phantombeta »

Maybe it's getting something else as an actor before it sees the player...
Try adding +NOINFIGHTING.
User avatar
amv2k9
Posts: 2178
Joined: Sun Jan 10, 2010 4:05 pm
Location: Southern California

Re: Random Editing Questions

Post by amv2k9 »

phantombeta wrote:Maybe it's getting something else as an actor before it sees the player...
Try adding +NOINFIGHTING.
I'll have to try that. Thanks! I suppose if that doesn't work, [wiki]A_RearrangePointers[/wiki] might.
User avatar
amv2k9
Posts: 2178
Joined: Sun Jan 10, 2010 4:05 pm
Location: Southern California

Re: Random Editing Questions

Post by amv2k9 »

Ehhh, neither one works. This mod is meant for Strife; I'm wondering if Strife's alerting of enemies is somehow messing things up?
Locked

Return to “Editing (Archive)”