Jump to content
avibird 1

Help needed making a UAV damage false.

Recommended Posts

So I have 12 man recon squad that has a UAV operator that I would like to have his drone not take damage. 

 

I attempted to place a drone down and checked off allow damage inside the drone does not work. I also placed the code inside it's init box this allow damage false; still the drone gets shot down.  Why does this not work when it works for other unit types. Avibird 1

Share this post


Link to post
Share on other sites

try this in init field of the UAV:

d = this addEventHandler ["HandleDamage", {0}];

 

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, avibird 1 said:

So I have 12 man recon squad that has a UAV operator that I would like to have his drone not take damage. 

 

I attempted to place a drone down and checked off allow damage inside the drone does not work. I also placed the code inside it's init box this allow damage false; still the drone gets shot down.  Why does this not work when it works for other unit types. Avibird 1

Because allowDamage must be applied locally, then each time the owner shifts.
sarogahtyp gave you the solution (the EH must be run on each PC, so init field is OK).

Share this post


Link to post
Share on other sites

I have not tried out the above suggestion. I definitely will but I still don't understand. If I have unit a man soldier that I check off allow damage in its attributes or simply put this allow damage in  it's init box it works the unit won't take damage. A drone is just a unit I think so I don't really understand what you're saying above with the scripting jogging. Plain English no pun intended. Please explain that again in simpler terms lol 😫😭☹️ I really don't understand why this can't work. I've been playing this game for a very long time I love messing around in the editor spend 90% of my time there. I'm not really good at  scripting I understand a few basic concepts I'm also able to run a few snippets together to create a function but clueless really lol.

 

Share this post


Link to post
Share on other sites

Your problem shows another potential use for UnitTrait CamouflagCoef and AudibleCoef. From my testing if you set camouflageCoef and AudibleCoef to zero for a vehicle or remote unit then the enemy basically doesn't see them. The advantage of this is that you don't need any loops or event handlers. It's a way to make the enemy almost blind to the presence of a particular unit but without impacting the behaviour of the unit and would mean you don't need event handlers to handle damage. Might be worth a try. I've mentioned this in my recent posts on the DynamicCamo thread.  It's just a different angle on the problem.

  • Like 2

Share this post


Link to post
Share on other sites

if this works as desired by op then it is much better performance wise

  • Like 1

Share this post


Link to post
Share on other sites

Yes that's what struck me when I thought about it. i might have a go at this myself with a UAV, it certainly worked perfectly with a remote designator in a similar scenario so I can't think why it shouldn't work for a UAV.

Share this post


Link to post
Share on other sites
12 hours ago, avibird 1 said:

I have not tried out the above suggestion. I definitely will but I still don't understand. If I have unit a man soldier that I check off allow damage in its attributes or simply put this allow damage in  it's init box it works the unit won't take damage. A drone is just a unit I think so I don't really understand what you're saying above with the scripting jogging. Plain English no pun intended. Please explain that again in simpler terms lol 😫😭☹️ I really don't understand why this can't work. I've been playing this game for a very long time I love messing around in the editor spend 90% of my time there. I'm not really good at  scripting I understand a few basic concepts I'm also able to run a few snippets together to create a function but clueless really lol.

 

 

1 - When you place a code into an init field of a unit or an object, this code runs each time a player join the mission (he runs the mission.sqm file).

2 - this is a good thing to make some code global (for everyone) but the code is not updated (you run it at server start and when you join, but not further)

3 - usually, your units belong to a player if in his group (as he is leader), or to the server (for AIs managed by it usually). I skip details you can read locality things.

4 - As you can read on the link above, commands and functions work with different cases for arguments and effects. So, this point is very important for any attempt to script for multiplayer.

5 - the allowDamage command (I gave you the link and the warning box is important) needs to be re-run when the owner (see locality) changes.

6 - on contrary of usual AI units who stays on server, a UAV has its owner(s) changed when a player jumps into the driver (or gunner slot). Normal, his local PC can takes the command and the server doesn't know what he intends to do with. So, a non-controlled UAV is on server ("autonomous"),  the driver slot can be owned by a player (on connection) and the gunner one can be owned by another player (PC) as well.

7 - If you need (not for all commands/functions, fortunately) to re-apply a code like for allowDamage, you need to detect the owner shift. there is some event handler for that, or to apply a working code depending on damage (here) which will run at each attempt to damage the vehicle (so what ever the owner could be at this time).

 

To conclude: Multiplayer scripting is far more tricky than for single player. Two ways: learning if you have a lot of time, or trusting in what people code for you.

 

The Real Bunch suggests you another way, for units, without test. Roughly, it's question about making UAV invisible but unit traits are for units, not vehicles...

 

You can also just setCaptive FALSE the UAV (vehicle) as well. That doesn't matter indestructible but AIs will not fire at it (players can). Not tested. I think all players in a captive vehicle (or in UAV slot) are considered as captive the time they controls/are inside the vehicle... If yes, you don't need to do more thing than writing : this setCaptive TRUE on UAV init field. Sorry, I don't have time to test that.

Share this post


Link to post
Share on other sites

PierreMGI - you say that unit trait is for units not vehicles but I reported recently that I explicitly tested this (in the DynamicCamo thread). I have tested this with a) a remote designator b) a panther c) a tank and d) a helicopter. In all cases setting camouflageCoef to zero effectively stopped the AI from seeing the vehicle and any unit inside such a vehicle wasn't seen either even if their camouflage coefficient wasn't set. On leaving such a vehicle the unit was immediately spotted.

Share this post


Link to post
Share on other sites

Bah, my bad. Did you test it in MP and repeatedly? I mean more than one in/out jump on vehicle?

Share this post


Link to post
Share on other sites

I've just tested it for UAVs. I flew a darter up to a full assault squad in broad daylight at low altitude and they completely ignored me. Hovered over them, no reaction. I can come in and out of the UAV control and it's just the same. Camouflage and AudibleCoef appear to be persistent values until changed. Not tested in MP.

Share this post


Link to post
Share on other sites

If I put the code in the object init box ie man tank truck this allow damage false then the object does not take damage SP or MP however it does not work if I use it in a UAV why ???? I don't understand this. this has nothing to do with single player or multiplayer code? 

Share this post


Link to post
Share on other sites
33 minutes ago, avibird 1 said:

however it does not work if I use it in a UAV why ????

how should we be able to answer this?

 

try to find something about it here:

https://feedback.bistudio.com

 

or open a ticket if there is none for this...

 

did you test this?

23 hours ago, The Real Bunc said:

Your problem shows another potential use for UnitTrait CamouflagCoef and AudibleCoef. From my testing if you set camouflageCoef and AudibleCoef to zero for a vehicle or remote unit then the enemy basically doesn't see them. The advantage of this is that you don't need any loops or event handlers. It's a way to make the enemy almost blind to the presence of a particular unit but without impacting the behaviour of the unit and would mean you don't need event handlers to handle damage. Might be worth a try. I've mentioned this in my recent posts on the DynamicCamo thread.  It's just a different angle on the problem.

 

Share this post


Link to post
Share on other sites

No! there is no problem. If you place a darter on Vanilla, then disable damage on it, you can't shoot down it in preview. Simple as that. Tested.

So, two hints:

- you have an extra code, running after the mission start, who makes your darter vulnerable again;

- you didn't pay attention for the owners as I wrote above.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×