Jump to content
Sign in to follow this  
5133p39

AI won't fire after removeWeapon and AddWeapon

Recommended Posts

I am spawning few EAST units by CreateUnit.

From within an init field i remove their weapons, but leave ammo (i have even tried to remove everything and add everything back, but it won't help).

Then, after something particular happens, i give them the AK back.

But they won't fire. They are behaving like they have no weapons at all.

I have tried to SetCombatMode to "RED", SetBehaviour to "COMBAT", even forced them to rearm and get weapons in hand by action command, but they simple put them on back again.

They do this even when they are under enemy fire, or when looking into eyes of unarmed enemy who is twenty meters in front of them (normally they would shot him instantly).

(i have checked if they have ammo, if they could fire, their combatMode, and their Behaviour, and everything is exactly how i set it up. And when ordered to fire by action command, they do it, so their weapons are even loaded! But they alone won't shoot at anything!)

If i don't remove their weapons, then everything works ok, but i NEED them to have no weapons when they spawn.

How do i force them to behave normally (use their weapons) ?

Share this post


Link to post
Share on other sites

AHA!

They WILL fire, they WILL use their newly added weapons, but only after i hit them - and most often i need to hit them two times into their legs, before they start to fire at me.

...but they should try to kill me on sight, because i am West unit and they are East units.

I really don't understand it why is this happening.

..and again, if i don't remove their weapons first, they will kill me in the moment they see me. So the problem IS related to removing/adding weapons.

Share this post


Link to post
Share on other sites

here is what i am doing:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"SoldierEB" CreateUnit [[4129,4948,0], Group Player, "[this] exec ""east_init.sqs""", 1]

And in the script "east_init.sqs" is:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_u = _this select 0

[_u] join GrpNull

RemoveAllWeapons _u

EAST_UNITS = EAST_UNITS + [_u]

_u setSpeedMode "FULL"

_u setUnitPos "UP"

_u SetMimic "Smile"

_u AddEventHandler ["Killed", {_this exec "east_killed.sqs"}]

The "east_killed.sqs" contains:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Player setCaptive false

"_x AddMagazine ""AK74""" ForEach EAST_UNITS

"_x AddWeapon ""AK74""" ForEach EAST_UNITS

"_x SelectWeapon ""AK74""" ForEach EAST_UNITS

"_x SetCombatMode ""RED""" ForEach EAST_UNITS

"_x SetBehaviour ""COMBAT""" ForEach EAST_UNITS

"_x DoTarget Player" ForEach EAST_UNITS

When i kill the first one, they should attack me.

But i can dance the kazachoc right before them, and they simply won't fire, until i hit someone twice in the legs - then only he will fire at me.

But, when i omit the line // RemoveAllWeapons _u // in "east_init.sqs", they will shoot me where i stand, no need to fire at them.

Please, help me, before i will going crazy.

Share this post


Link to post
Share on other sites

Your problem is the group you spawn them into.

You spawn them into the players group (WEST) therefore they become West units that merely look like East units.

Replace the "Group Player" in your createunit line with "grpNull". Then they won't need to join grpNull later on either.

Spawning east units into a west players group has always had ill side-effects for me. I suggest avoiding it whenever possible.

Share this post


Link to post
Share on other sites

OMG! Few days and only one reply - and it's all wrong.

1. I think you can't spawn them into GrpNull - they won't spawn at all. You must specify an EXISTING group (but i haven't tried it, so maybe you are right, but i doubt it).

2. This definitely is NOT the problem, because if you read carefully my posts, you see that they ARE SHOOTING at me even if i spawn them into my group and then join grpnull - they won't shoot only after i remove and add back their weapons.

Anyway, even if you spawn them into preplaced enemy group, they WON'T shoot after you remove and add back their weapons - this was the first thing i have tested.

So, thanks for your effort, but don't talk about something you don't know - it makes me sad and then angry. Now i need to go and smash some more of my Chinese Ming dynasty vases collection

Share this post


Link to post
Share on other sites

With what attitude? Did i anything wrong? :-)

Share this post


Link to post
Share on other sites
Quote[/b] ]So, thanks for your effort, but don't talk about something you don't know - it makes me sad and then angry. Now i need to go and smash some more of my Chinese Ming dynasty vases collection

This could maybe prevent alot of ppl from trying to help you,

as everybody might be scared about you destroying even

your last Chinese Ming dynasty vase because HE said something wrong wink_o.gif

~S~ CD

Share this post


Link to post
Share on other sites

The spawning into the players group is indeed a problem I think. Try creating a dummy east unit that you only use to spawn units into its group and then let them be in separate groups.

The same method is e.g. used when mission makers want to get west units on the east sides, it works simply with an east leader and deleting the east leader on start, then you'll have a group of west units but belonging to east.

Edit: It's right that you can't spawn in GrpNull, at least it doesn't work for me.

Share this post


Link to post
Share on other sites

Why spawn units into a west group if you want them to be east?

And FYI CrashDome does know a little about MP scripting, if you want proof all you need to do is take a look in his sig.

RED

Share this post


Link to post
Share on other sites

I may have been wrong about the grpNull within the createUnit (it's been awhile since I wrote a createUnit line..not sure about that anymore) but the point still holds. You are spawning East units into YOUR group. Of course they won't shoot at you. When you have them join grpNull later they are still considered west units. The reason they are shooting at you after you shoot them is a result of OFPs built in prevent-TKing mechanism (rating). To prove this, put a trigger over all the units and set it to anybody - make it a radio command. Add to the activation line: hint format["%1",thisList] and you'll get a list of units. I bet they are all WEST units.

Share this post


Link to post
Share on other sites

Thanks everyone for their efforts to help me, but could you please stop talking about spawning units into Players group?

I have wrote two times, that it doesn't matter.

Now i am writing it for third time:

It doesn't matter into which group i am spawning them (east, west, resistance, or civilian) it is allways the same - when i remove their weapons, and then after some time i give the weapons back to them, they won't fire on ANY enemy unit (until i told them to do so, by DoTarget nad Fire - but i don't want to do it this way, because they should have do this automatically).

So pleeeeeeeeeeease, i really really don't think this problem is related to the Group you are spawning them into.

If someone still don't understand, then i am very sorry for my foul english, i will try to improve it, but not this time - instead please, try reading all my posts again smile_o.gif

Share this post


Link to post
Share on other sites

If you have tried spawing them into East groups as you have said and you still are experience problems, perhaps you have discovered another OFP 'bug'.

I'm sorry that my suggestion didn't help. I've spawned units via scripts I have made and using scripts others have made. I know I have removed weapons before and replaced them. However, I've never experienced that problem....

The one thing I do notice I never did that you are doing is perform the removeWeapons via an init script. Try capturing the unit into a global variable by replacing the init line with

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{SpawnUnit = this}

then perform the init right after the createUnit command:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"SoldierEB" CreateUnit [[4129,4948,0], Group Player, {SpawnUnit = this}, 1]

SpawnUnit exec "east_init.sqs"

This may sound counter productive, but trust me... even the most stupidest sounding fixes can sometimes work wonders in OFP  smile_o.gif  I'm just saying...try it! It may or may not work, but it's definately worth trying.

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  

×