Is there a way with Decorate and/or Zscript to prevent attacks, or at least damage, to friendly actors? Or even just actors with a certain TID?
I've read +GHOST and +THRUGHOST may help. Just not clear how that can be done while still allowing the actor to be damaged by other monsters or other player classes.
Prevent Player From Attacking or Damaging Certain 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!)
-
- Posts: 2
- Joined: Fri Dec 29, 2023 9:00 am
-
- Posts: 1
- Joined: Tue Jan 02, 2024 11:47 am
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
Re: Prevent Player From Attacking or Damaging Certain Monsters?
To prevent attacks or damage to friendly actors, you can set the CollisionType property of the actor to a unique string value, and then set the CollisionGroup property of other actors to the same string value. This will allow the actors to pass through each other without causing damage.
Here’s an example of how to use CollisionType and CollisionGroup properties to prevent attacks or damage to friendly actors:
Actor FriendlyActor : DoomActor
{
+FRIENDLY
CollisionType "Friendly"
}
Actor EnemyActor : DoomActor
{
CollisionGroup "Friendly"
}
In this example, FriendlyActor is set as a friendly actor by using the +FRIENDLY flag. The CollisionType property of FriendlyActor is set to "Friendly". The CollisionGroup property of EnemyActor is set to "Friendly". This will allow EnemyActor to pass through FriendlyActor without causing damage.
Here’s an example of how to use CollisionType and CollisionGroup properties to prevent attacks or damage to friendly actors:
Actor FriendlyActor : DoomActor
{
+FRIENDLY
CollisionType "Friendly"
}
Actor EnemyActor : DoomActor
{
CollisionGroup "Friendly"
}
In this example, FriendlyActor is set as a friendly actor by using the +FRIENDLY flag. The CollisionType property of FriendlyActor is set to "Friendly". The CollisionGroup property of EnemyActor is set to "Friendly". This will allow EnemyActor to pass through FriendlyActor without causing damage.
-
-
- Posts: 1853
- Joined: Sun Jul 21, 2019 8:54 am
Re: Prevent Player From Attacking or Damaging Certain Monsters?
CollisionType and CollisionGroup aren't valid actor properties, was that message written by an AI?
As for the question itself, you can do that in ZScript by overriding DamageMobj in the monster actor and checking if it has the friendly flag and if the damage source is the player.
Or using inventory items and ModifyDamage if you don't want to replace monster classes, you can automatically give each monster that item using an event handler.
For example:
As for the question itself, you can do that in ZScript by overriding DamageMobj in the monster actor and checking if it has the friendly flag and if the damage source is the player.
Or using inventory items and ModifyDamage if you don't want to replace monster classes, you can automatically give each monster that item using an event handler.
For example:
Code: Select all
Class FriendlyDamageHandler : EventHandler{
Override void WorldThingSpawned(WorldEvent e){
If(e.Thing.bISMONSTER && e.Thing.bFRIENDLY){ //This checks if a friendly monster spawned
e.Thing.GiveInventory("FriendlyDamagePrevent",1); //And gives them this item
}
}
}
Class FriendlyDamagePrevent : Inventory{
Override void ModifyDamage(int damage, Name damageType, out int newdamage, bool passive, Actor inflictor, Actor source, int flags){
If(passive && source is "PlayerPawn"){ //This checks if the monster took damage by a player
newdamage = 0; //And nullifies all damage
Return;
}
}
}
-
- Posts: 2
- Joined: Fri Dec 29, 2023 9:00 am
Re: Prevent Player From Attacking or Damaging Certain Monsters?
thanks jarewill
though overriding the DamageMobj method on the class doesn't seem to stop blood splatter on the target actor
is there a way to prevent the splatter too?
though overriding the DamageMobj method on the class doesn't seem to stop blood splatter on the target actor
is there a way to prevent the splatter too?
-
-
- Posts: 1853
- Joined: Sun Jul 21, 2019 8:54 am
Re: Prevent Player From Attacking or Damaging Certain Monsters?
For that you have to override SpawnLineAttackBlood in the monster class:
Code: Select all
Override void SpawnLineAttackBlood(Actor attacker, Vector3 bleedpos, double SrcAngleFromTarget, int originaldamage, int actualdamage){
If(attacker is "PlayerPawn" && actualdamage==0){Return;} //If player attacked and the damage was 0, don't spawn anything.
Super.SpawnLineAttackBlood(attacker,bleedpos,SrcAngleFromTarget,originaldamage,actualdamage);
}
-
- Posts: 91
- Joined: Mon Aug 26, 2019 9:18 pm
- Graphics Processor: nVidia with Vulkan support
Re: Prevent Player From Attacking or Damaging Certain Monsters?
No ChatGPT, GZDoom has no such properties, only the ThruBits property allows for collision groups like that. Although it would definitely be nice to not just have 32 possible collision groups, since that is very limited.DeonteLangworth wrote: ↑Tue Jan 02, 2024 11:51 am To prevent attacks or damage to friendly actors, you can set the CollisionType property of the actor to a unique string value, and then set the CollisionGroup property of other actors to the same string value. This will allow the actors to pass through each other without causing damage.
Here’s an example of how to use CollisionType and CollisionGroup properties to prevent attacks or damage to friendly actors:
Actor FriendlyActor : DoomActor
{
+FRIENDLY
CollisionType "Friendly"
}
Actor EnemyActor : DoomActor
{
CollisionGroup "Friendly"
}
In this example, FriendlyActor is set as a friendly actor by using the +FRIENDLY flag. The CollisionType property of FriendlyActor is set to "Friendly". The CollisionGroup property of EnemyActor is set to "Friendly". This will allow EnemyActor to pass through FriendlyActor without causing damage.