mtasa-blue icon indicating copy to clipboard operation
mtasa-blue copied to clipboard

Allow multiple ignored elements to be passed to processLineOfSight

Open Lpsd opened this issue 5 years ago • 5 comments

This allows multiple ignore elements to be passed to processLineOfSight, via table of elements.

It is backwards compatible. If you pass a single element, or nil as ignoredElements it has the same behaviour as before.

processLineOfSight ( float startX, float startY, float startZ, 
                       float endX, float endY, float endZ, 
                       [ bool checkBuildings = true, 
                       bool checkVehicles = true, 
                       bool checkPlayers = true, 
                       bool checkObjects = true, 
                       bool checkDummies = true, 
                       bool seeThroughStuff = false, 
                       bool ignoreSomeObjectsForCamera = false, 
                       bool shootThroughStuff = false, 
                       table ignoredElements = nil,
                       bool includeWorldModelInformation = false,
                       bool bIncludeCarTyres ] )

Partially [resolves] #1549

I will submit a separate PR for isLineOfSightClear

Lpsd avatar Jan 20 '21 22:01 Lpsd

Wouldn't it be better to take a table of elements?

elements = {}
processLineOfSight(...,unpack(elements),...) -- can't do this

I suppose you could the put last arguments as the last values in the table.

0xHexadecimal avatar Jan 20 '21 23:01 0xHexadecimal

I'll add the ability to pass a table, as well as vararg.

Having it at the end would be weird, because we have to keep the original argument order to some extent.

Lpsd avatar Jan 20 '21 23:01 Lpsd

Other than these comments you're fine imho.

Pirulax avatar Mar 19 '21 06:03 Pirulax

Time to merge this. @Lpsd address the comments, and I'll merge it. I hope you've tested it (But there's really nothing not to work, so)

Pirulax avatar Apr 30 '22 14:04 Pirulax

Vararg removed.

Test resource: los.zip

Spawns 50 bin objects in a row. Use command /los <amountToIgnore>

e.g /los 50 should return nil for processLineOfSight in debug output, as you're ignoring all elements /los 30 will output bin_31, as that's the next object to hit after 30 /los 0 will output bin_1 etc

This resource also tests backwards compatibility by passing nil as ignoredElements if 0 is supplied to the command. It shouldn't raise a warning / error (just like original behaviour).

Lpsd avatar Jul 16 '22 21:07 Lpsd

Is there anything left to do here or why is it not merged?

Einheit-101 avatar Apr 05 '23 13:04 Einheit-101

Is there anything left to do here or why is it not merged?

Nothing left to do here, not merged yet because feature freeze is on (https://discord.com/channels/801330706252038164/801330706252038167/1059094962853130250). Will be merged for 1.6.

patrikjuvonen avatar Apr 05 '23 13:04 patrikjuvonen