WorldLineDamaged is ignored

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!)
User avatar
Laskow
Posts: 54
Joined: Tue Feb 16, 2021 7:35 am

WorldLineDamaged is ignored

Post by Laskow »

According to the wiki, WorldLineDamaged/WorldSectorDamaged are called before dealing damage to a line or sector. However, it seems a line doesn't care about the event handler.

ZScript:

Code: Select all

Class WallHandler : EventHandler
{
	override void WorldLineDamaged (WorldEvent e)
	{
		bool isExplosiveAttack = ( e.DamageType == "Explode" );

		if (!isExplosiveAttack) 
		e.NewDamage = 0;

		else e.NewDamage = e.damage;
	}
}
ACS:

Code: Select all

script 2 (void)
{
	if(GetLineHealth(3) > 1) terminate;

	SetLineSpecial (3, 0, 0, 0, 0, 0, 0);
	Line_SetBlocking (3, 0, BLOCKF_EVERYTHING);

	Thing_Remove (2); //crack
	Delay (6);
	Radius_Quake2 (0, 1, 40, 0, 5, "");
	SpawnSpot ("Explosion", 3);
	SetLineTexture(3, SIDE_FRONT, TEXTURE_MIDDLE, "-");
}
If the event handler works well, the wall never gets any damage except the explosive damage, but it seems it didn't work as I wanted. The line gets the damage from any weapons.

For example, when set the "DamageSpecial" is true and the line health is more than 1, it works without a problem until the health is getting lower than 1. After the line is dead, the script is executed by any attack (even if the grenade just hits the wall). On the other hand, when set the "DeathSpecial" is true and the line health is more than 1, I don't need to check the line health using the ACS function "GetLineHealth" but the ACS script executes immediately after getting attacked.

Why is it not able to check the damage type in WorldLineDamaged? Or am I overlooking something?



By the way, I've tried viewtopic.php?f=105&t=63907&hilit=Destructible+geometry before; I couldn't understand how to set the material to only the specified line and executing the ACS script after the line died.
User avatar
Laskow
Posts: 54
Joined: Tue Feb 16, 2021 7:35 am

Re: WorldLineDamaged is ignored

Post by Laskow »

Hmm. Maybe, maybe this is a problem related to ACS. It has always happened when the explosive barrel is near the wall. If there are no explosive barrels nearby the wall, this mechanism works well. So, I think the problem is the "habit" of ACS, not ZScript.

A few months ago, I encountered a similar problem. For example, I set this ACS script to 2, or more actors.

Code: Select all

script "SpawnItem" (int id)
{
	int tid = id;

	If(GetActorProperty(tid, APROP_Health) <1)
	{		SpawnSpot ("Item", tid);	}
}
Next, when the actors are dead at the same time, the item isn't spawned from all actors. One of them spawns the item but the others do not. Somehow I feel the same problem has happened as this.


Back to the topic. To avoid that, I make a new script and set it to the explosive barrel; it runs after the explosive barrel is dead.

Code: Select all

bool CheckBarrel1 = false;

script "Barrel1Dead" (void)
{
	CheckBarrel1 = true;
	ACS_ExecuteAlways (2, 0, 0, 0, 0);
}
And check the barrel is dead or not.

Code: Select all

script 2 (void)
{
   if(GetLineHealth(3) > 1 || !CheckBarrel1) terminate;

   SetLineSpecial (3, 0, 0, 0, 0, 0, 0);
   Line_SetBlocking (3, 0, BLOCKF_EVERYTHING);

   Thing_Remove (2); //crack
   Delay (6);
   Radius_Quake2 (0, 1, 40, 0, 5, "");
   SpawnSpot ("Explosion", 3);
   SetLineTexture(3, SIDE_FRONT, TEXTURE_MIDDLE, "-");
}
Then, it works as I wanted for now. There still might be another problem though, this is what I can do to avoid it.

Return to “Scripting”