Function to filter damage types
under review
Soap Frenzy
I would like to suggest a function to filter llDamage types either by rejecting or accepting the specific type wanted. Possibly functioning similar to llCollisionFilter
As a suggestion
llDamageFilter(integer type, integer accept);
integer type - bit mask, DAMAGE_TYPE_* flags
integer accept - TRUE only process types that match, FALSE instead excludes matches
this would be useful to prevent unwanted script events for damage_types that we do not want to account for in code
Log In
Albino Rabbit
This function should be subject to the same restrictions as llAdjustDamage and thus be disabled in regions which have also disabled that feature.
Soap Frenzy
Albino Rabbit I agree but only if the damage target is an avatar. if it is an object such as a sitbase it should continue to function normally. Otherwise you can turn damage adjust off and we're back to every damage event triggering the script defeating the purpose of this function existing
Nexii Malthus
Albino Rabbit this function is not intended to adjust damage, so having it disabled by that setting wouldn't do anything but increase script lag in your region, so good job
Albino Rabbit
Nexii Malthus It can be used to effectively disable damage from specific sources, so what it is intended to do is irrelevant. Misuse of a similar function to achieve a similar result is why a lot of combat arenas have already disabled llAdjustDamage. So good job, and keep the snide remarks to yourself.
Nexii Malthus
Albino Rabbit it doesn't disable damage though this function is only for the script events. So that's your misunderstanding, but I should be more clear on this for everyone involved.
So for clarity for Linden Lab:
llDamageFilter does not affect sim side processing of avatar damage. The filtering is purely for how the scripted damage events are generated.
llDamageFilter does not adjust damage.
Only llAdjustDamage adjusts damage.Nexii Malthus
Intention to optimise scripts from running excessive damage events for scripted object health systems.
Large vehicles and buildings/walls are exposed to a lot of damage events from firearms. However these vehicles/structures aren't actually damageable by normal gunfire but explosives, other vehicles and anti-armor equipment like RPGs.
In SLMC: vehicles, structures, deployables, buildings have always had custom damage before Combat2 as LBA, or Listen Based Armor. LBA is ingrained in a lot of equipment and the desire is to move over to Combat2. There are two LBA classes: Full and Light.
- Full LBA is immune to gunfire and used for main/heavy vehicles and structures
- Light LBA is for small deployables like sandbags and can be damaged by gunfire
Vehicles and buildings encounter a lot of gunfire in combat. An urban setting with 30-40 damageable buildings would be awesome and SL is great/flexible for, but each one having to process bullets bouncing everywhere is not great.
We want something like listen/collision filters. In this case filtering based on damage types.
Damage type is flexible integer tho, as intended by Rider Linden -- a set of tools for residents and the damage type enum constants are convenience. Therefore I can see some system developers using the damage type as a bitfield. So the filter function should be able to support that usecase, performing a bitwise AND to filter incoming damage types with.
There are also ways to use the damage type to pack multiple enums or other bit information but I can't expect the filter function to support those.
My suggested API would be one of:
- llDamageFilter(list types)-- simple whitelist, expects types to be enums
- llDamageFilter(list types, integer accept)-- accept can switch it between allow/deny lists
- llDamageFilter(list types, integer accept, integer bitmask)-- bitmask is a boolean whether types should be interpreted as bitmask(s) instead
- llDamageFilter(list options)-- list based options likeDAMAGE_FILTER_TYPE, integer type(which can be defined multiple times to cover different enum types or only once for OR'd bitmasks),DAMAGE_TYPE_ACCEPTto switch between allow/deny lists,DAMAGE_FILTER_USAGE, integer usagewhich can be set to one ofDAMAGE_FILTER_ENUMERATION(default) for enums orDAMAGE_FILTER_BITMASKfor interpretingDAMAGE_FILTER_TYPEas bitmasks
- llDamageFilter(list types, list options)-- mix of above, instead moving the damage types into separate list
Nexii Malthus
llDamageFilter(list types, list options)
or llDamageFilter(list options)
would be my personal gotos.To summarise:
* The filter should be able to filter for multiple damage types, filtering what damage instances can pass through into the
on_damage
and final_damage
events for object-based health systems* Optionally be able to switch the filter from allowlist to denylist
* Optionally be able to support treating damage types integers as bitmasks instead of default of enums
Undefined:
* Will this work on attachments? E.g. gas mask filters
DAMAGE_TYPE_POISON
and adjusts damage to zero or resists it 50-90%Spidey Linden
marked this post as
under review
Spidey Linden
marked this post as
needs info
Can you add a little more detail about how you would use this? This will help us to review your request. Thanks!
Soap Frenzy
Spidey Linden Certainly. I'm working on a heavy vehicle armor system for tanks and I want it to only take damage from DAMAGE_TYPE_HEAVY, Ignoring damage types I’m not interested in but with the current system even if I dont accept other damage types it still triggers a script event.
For instance, if I have two or three people shooting at the tank with regular firearms, each firing hundreds of rounds per minute, the constant script events for non-heavy damage types could impact the performance of the simulator.
Ideally, I'd like to set up a filter that only accepts DAMAGE_TYPE_HEAVY, ensuring that only heavy damage triggers the script. This would prevent unnecessary script events for other damage types, thereby improving performance and reducing the strain on the simulation.
Nenenxi Resident
Spidey Linden Following what Soap has said, I believe this could serve some other uses and encourage a wider use case than just direct combat and vehicles.
Another use, for example, could be a door with a generator next to it. If the generator was "Charged" by being dealt DAMAGE_TYPE_ELECTRIC, it would open the door.
The current way to do this includes IF statements, llAdjustDamage, and triggers script events for each damage event, regardless of type.
Filtering out damage types using a function such as the "llDamageFilter" Soap has proposed could optimize this process, minimizing script events, reducing the use of unnecessary functions and only triggering the event in the script when it receives DAMAGE_TYPE_ELECTRIC.