Jump to content
Sign in to follow this  
jjj666

How do i make enemy not

Recommended Posts

I've tried to search for a solution for my problem, but couldn't find one. I'm trying to make an assassination mission where enemies don't shoot at me untill I start shooting or they see my weapon. I know commands like dotarget and dofire, but is there a way to make them shoot only when I take my weapon in hand? Thank you guys!

confused.gif

Share this post


Link to post
Share on other sites

In your players init field, put 'this setcaptive true'

Now the enemies won't shoot at you.

How do you mean 'see my weapon'? Is it a pistol, so they can't see it while its holstered?

I'm not sure about having weapon in hand, but to detect if your player has fired you should have use eventhandler 'fired'

I *think* it would be this addeventhandler ["fired", F1 = true]

then a trigger to set setcaptive to false on F1.

Share this post


Link to post
Share on other sites

To make them only shoot you if you have shot your weapon, use:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">addEventHandler ["fired", {player setcaptive false}]<span id='postcolor'>

Make sure your unit is setcaptive true at the start of the mission though.

This solution will only work with V1.91.

RED

Share this post


Link to post
Share on other sites

Baron,

Yes, I mean when I'm having only a pistol and put weapon on back. I'm not sure, but I think the weapon is hidden by using that option? Btw, those soldiers having only a handgun are really dumb looking on safe mode holding their invisible rifle.

Thank you and Red both for that AddEventHandler. That would propably have been my next question...  biggrin.gif

But still, does anyone know is there a solution for the original problem?

Share this post


Link to post
Share on other sites

You could maybe have it so that player wouldn't have a weapon to begin w/ and add an action to the action menu that says like Take out gun, and when the player clicks it add the pistol and mags to the player, though I think I tried to add a weapon to me in a game and OFP CTD'd.

Share this post


Link to post
Share on other sites

Use hasWeapon command, which indicates whether or not a unit is carrying a specific weapon type.

?(MyGuy hasWeapon "M16"):MyGuy sidechat "I've got an M16!"

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Lupina @ April 22 2003,07:12)</td></tr><tr><td id="QUOTE">Use hasWeapon command, which indicates whether or not a unit is carrying a specific weapon type.

?(MyGuy hasWeapon  "M16"):MyGuy sidechat "I've got an M16!" <span id='postcolor'>

Only trouble with that, is that it only shows if the unit has a weapon, not whether he's drawn said weapon.

Share this post


Link to post
Share on other sites

If you use the method edc suggested it will work fine.

RED

Share this post


Link to post
Share on other sites

Another Solution:

Player Init field: this setcaptive true

Make a Trigger:

Radiuses: 0/0

Leave everythng else alone.

In condition field put: (MyGuy ammo "weaponname" ==10)

Activation Field: MyGuy setcaptive false

------------------------

Where it has ==10, change the 10 to however many bullets are in the magazine.

Then when you pull the weapon out, it will detect that you have, say... 10 bullets in your mag, the Trigger should then set off.

I havnt tried this. But im certain it works.

Share this post


Link to post
Share on other sites

Red,

For some reason it didn't work for me. I got the gun without bullets, and couldn't use the optics. I created the action menu and that worked fine, but I guess something went wrong in typing my little script. Well that's quite understandable with my scripting skills...  biggrin.gif

Share this post


Link to post
Share on other sites

Add the ammo first, then add the weapon. The code you used now probably does work, hit your spacebar.

RED

Share this post


Link to post
Share on other sites

I didn't remember to hit the spacebar... and you can imagine for how many ours I cursed this editor and scripting.

Lol biggrin.gif Well, at least it works now.

Hope that others too have got new ideas for mission making of this thread. For me this has been a big help. Thanks to every one!

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  

×