Jump to content
Sign in to follow this  
DChristy87

Script for AI to fire upon individual unit that leaves trigger area?

Recommended Posts

Because its not really a scenario rather a multiplayer continuous gameplay. This is just the setting of stratis. Players will be surviving: avoiding or attacking opFor convoys for supplies and such. If you die then you have to start within the camp and escape again.

---------- Post added at 15:01 ---------- Previous post was at 14:09 ----------

F2K Sel, can you confirm that this script will work for a respawned unit if killed later in game?

Share this post


Link to post
Share on other sites

You'd just want to rerun limits.sqf as part of your respawn.

null=[player,nameOfGameLogic,30] execvm "limits.sqf";  

Share this post


Link to post
Share on other sites

ahh, i see. Sweet! I can't wait to try this out tonight. I'll let you know how it goes (if you care lol) I really appreciate all of your help!

---------- Post added at 15:24 ---------- Previous post was at 15:14 ----------

Any chance you can point me to a post that could help or explain to me how to get all players to respawn without any gear? In all of the players init box I had typed in removeallassigneditems this; removeallweapons this; removevest this; removeuniform this; and it works fine in the beginning but once killed, they respawn with weapons and gear?

Share this post


Link to post
Share on other sites

remove the remove stuff from your player init.

In init.sqf:

playerRespawned = CompileFinal preprocessFileLineNumbers "playerRespawned.sqf";
player addMPEventHandler ["mprespawn", {_this spawn playerRespawned}];  

[player] spawn playerRespawned;

playerRespawned.sqf:

_unit = _this select 0;
_corpse = _this select 1;

hideBody _corpse;

removeallassigneditems _unit; 
removeallweapons _unit; 
removevest _unit; 
removeuniform _unit;

// and so on.

Share this post


Link to post
Share on other sites

So where do I type that in the game logic? I find game logic in module under misc...do I type the code in the game logics initialization?

Share this post


Link to post
Share on other sites

If you're talking about my last example for respawning naked that has nothing to do with gamelogics. It's a standalone script and a few lines to add into init.sqf, also a separate script.

Share this post


Link to post
Share on other sites

So I'm starting to feel hopeless. The furthest I got was to have players respawn without gear but the AI would still consider players to be enemy after respawn.. :-\

Any idea if they're bringing back the switch sides module that armaidiot shows in his tutorial?

I'd like to get this script working but I'm new to scripting and my talent is limited.

Share this post


Link to post
Share on other sites

lol sorry, you're very fast to respond to both of these forums. It's hard for me to keep up with which one you're replying on. I'll check it out.

Share this post


Link to post
Share on other sites

For completeness sake here's the solution I posted:

init.sqf:

playerRespawned = CompileFinal preprocessFileLineNumbers "playerRespawned.sqf";
player addMPEventHandler ["mprespawn", {_this spawn playerRespawned}];

[player] spawn playerRespawned;

playerRespawned.sqf:

_unit = _this select 0;
_corpse = _this select 1;

hideBody _corpse;

removeallassigneditems _unit;
removeallweapons _unit;
removevest _unit;
removeuniform _unit;
_unit setcaptive TRUE;

waituntil {_unit distance powCamp > 45};
_unit setcaptive FALSE;
hint "Run!";

Share this post


Link to post
Share on other sites

Finally got to test this with my buddy. All bluFor units were set as a playable unit. The only unit that the script worked completely and accurately for was the first created playable unit (Alpha 1-1). My buddy as any of the other playable units spawned in with gear and was considered enemy. I switched through the other units myself while he played as Alpha 1-1 and then I spawned in with gear and was immediately shot at. Any idea what might be causing this?

Share this post


Link to post
Share on other sites

Okay so after some further testing, I've found that it's not just the first unit on the mission...i'ts the first unit joined into by a player. So the script is only running for the first unit occupied by a player. Any thoughts? TIA!

Share this post


Link to post
Share on other sites

Can you upload your mission to mediafire.com so we can see how you're doing things please?

Share this post


Link to post
Share on other sites

Best to just rclick the mission.stratis folder and Send To -> Compressed Folder. Then upload the one zip that it makes. That way there's only one thing to download and you can just unpack the mission right into the editor folder. Checking it out now.

---------- Post added at 02:41 PM ---------- Previous post was at 02:26 PM ----------

Ahh I see the problem. Put this at the top of the init.sqf:

waitUntil{player == player};

Share this post


Link to post
Share on other sites

hmm, I just tried that out Kylania and it didn't change anything, everything still reacts the same. Maybe a forEach needs to be somewhere?

---------- Post added at 16:23 ---------- Previous post was at 16:21 ----------

Heres a link to the compressed folder with the suggested change to the init. http://www.mediafire.com/download/9k742m7p9d75a4f/SERE.Stratis.zip

Share this post


Link to post
Share on other sites

I'm not sure what to tell you. Testing with the original version had the first guy naked everyone else equiped. Added in the waitUntil and every time we tested (3 times in all - once with everyone present at start, once with someone JIP'ing in and once with someone leaving and coming back in) it worked as expected. You re-exported the mission to MP after making the change? Did you have others delete their cached copy of the mission?

Share this post


Link to post
Share on other sites

Interesting, I've been saving the mission each time and hitting export to multiplayer each change as well. I have not tried having my friend delete their cached copy but will try that tonight. Where would the cached copy be located? In their default Arma 3 folder in program files - or in the documents directory?

Share this post


Link to post
Share on other sites

Neither. :)

C:\Users\Username\AppData\Local\Arma 3\MPMissionsCache

Share this post


Link to post
Share on other sites

Okay, for the most part you got it working! Just one problem. My friend deleted his cache, and everything was exported properly to multiplayer. However, when my friend respawns, he immediately gets shot, then upon the second REspawn the guards go back to normal. The "Run" hint, happens during the third life, after the second respawn, but has no effect and everything returns to normal. As the host, with me, everything works as expected. But basically, the script only works every other respawn for him... Any thoughts?

Share this post


Link to post
Share on other sites

Oh, and I'm not talking about just hitting "respawn" on the menu but actually running out of the area and letting the AI consider him as enemy.

Share this post


Link to post
Share on other sites

Maybe if I put

waitUntil{player == player};

after the preprocessfile line?

Share this post


Link to post
Share on other sites

No, needs to be before. The problem was that players were missing the function entirely somehow.

Share this post


Link to post
Share on other sites

So you think maybe he isn't getting the function at all for every other life?

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
Sign in to follow this  

×