Jump to content
Sign in to follow this  
JaykePC

Pushing Units.

Recommended Posts

I have placed some AI units which act as shops as you can see below;

 

RB3uSPU.jpg

 

Now, when I sprint into them.. They seem to move around, through walls sometimes they even rocket themselves into the middle of nowhere. As soon as I open the server I can see the odd retard abusing this and I just want to avoid it happening as the 'shop' will be unacceptable until the next restart. I am using this code in the initialization;

this disableAI "MOVE";

Is there anything I can do to make them walk-through, or solid on the spot?

 

Thanks guys!

Share this post


Link to post
Share on other sites

The above stops players moving it. If you want them to stop rocketing it, you can always place a marker called "aiPos1" then a trigger or something do:

aiShopDude setPosATL (getMarkerPos "aiPos1");

Share this post


Link to post
Share on other sites

 

Thank you Ranwer, once again! On the editor it worked fine, I was able to no-clip into the shop dude however when I tried it on my server the collision was back default. The unit I am placing is called 'Exile_Unit_Player'. This is the code I use in the initialization box;

this disableAI "MOVE"; this disableCollisionWith player;

By rocketing, I never meant physically shooting a rocket as damage is disable in the trade markers. I mean when you sprint into the AI shop, sometimes the unit flys like 50m.

Share this post


Link to post
Share on other sites

Place a trigger set to anybody near the AI Unit, and put this in your act: (set the trigger to repeatedly as well)

null = execVM "retard_buster.sqf";
retard_buster.sqf:

_dude = nearestObjects [Exile_Unit_Shopkeeper, ["CAManBase"], 5];
{ Exile_Unit_Shopkeeper disableCollisionWith _x } forEach _dude;
Exile_Unit_Shopkeeper is the name of your ai character. (I also put 5 in nearest objects as 5 meters in radius)

Hope it helps,

Ranwer135

  • Like 1

Share this post


Link to post
Share on other sites

Place a trigger set to anybody near the AI Unit, and put this in your act:

 

null = execVM "retard_buster.sqf";
retard_buster.sqf:

_dude = nearestObjects [Exile_Unit_Shopkeeper, ["CAManBase"], 5];
{ Exile_Unit_Shopkeeper disableCollisionWith _x } forEach _dude;
Exile_Unit_Shopkeeper is the name of your ai character. (I also put 5 in nearest objects as 5 meters in radius)

Hope it helps,

Ranwer135

 

 

And if I have more than 1 AI unit? Would I do this;

_dude = nearestObjects [Exile_Unit_Shopkeeper, ["CAManBase"], 5];
{ Exile_Unit_Shopkeeper,Exile_Unit_Shopkeeper1,Exile_Unit_Shopkeeper2,Exile_Unit_Shopkeeper3 disableCollisionWith _x } forEach _dude;

Or do I need to make a new .sqf file for each AI unit?

Share this post


Link to post
Share on other sites

Ok, having an issue here hopefully this information can point out where I am going wrong.

 

retard_buster.sqf

_dude = nearestObjects [Exile_Trader_WasteDump, ["CAManBase"], 5];
{ Exile_Trader_WasteDump disableCollisionWith _x } forEach _dude;

Trigger:

 

Y7xU96Z.jpg

 

Unit I am trying to disable collisions:

 

NGM5mAj.jpg

 

RPT Error:

7:32:19 Error in expression <ard_buster.sqf"
_dude = nearestObjects [Exile_Trader_WasteDump, ["CAManBase"], 5>
 7:32:19   Error position: <Exile_Trader_WasteDump, ["CAManBase"], 5>
 7:32:19   Error Undefined variable in expression: exile_trader_wastedump

Share this post


Link to post
Share on other sites

Trigger act:

null = [ShopkeeperName]  execVM "retard_buster.sqf";
retard_buster.sqf:

shopkeeper = (_this select 0);
_dude = nearestObjects [shopkeeper, ["CAManBase"], 5];
{ shopkeeper disableCollisionWith _x } forEach _dude;
Shopkeeper in the .sqf was made global to avoid undefined variables. (Global in MP doesn't mean all machines, but on all scopes in the script)

You need to give the units a name, otherwise it will not work. (ShopkeeperName is the name of the unit you named within that trigger)

  • Like 1

Share this post


Link to post
Share on other sites

Trigger act:

 

null = [ShopkeeperName]  execVM "retard_buster.sqf";
retard_buster.sqf:

shopkeeper = (_this select 0);
_dude = nearestObjects [shopkeeper, ["CAManBase"], 5];
{ shopkeeper disableCollisionWith _x } forEach _dude;
Shopkeeper in the .sqf was made global to avoid undefined variables. (Global in MP doesn't mean all machines, but on all scopes in the script)

You need to give the units a name, otherwise it will not work. (ShopkeeperName is the name of the unit you named within that trigger)

 

 

Ah, I get you! Top right corner name not the actual class name of the placed unit. Trying now, once again your help is highly appreciated!

Share this post


Link to post
Share on other sites

There is a bar called NAME in the unit's init. Give it a name such as "myguy", and Replace ShopkeeperName with the name you gave to the unit. (Without quotes)

The .sqf file I updated above should be universal now, so its just the ShopkeeperName you need to replace in the trigger.

  • Like 1

Share this post


Link to post
Share on other sites

There is a bar called NAME in the unit's init. Give it a name such as "myguy", and Replace ShopkeeperName with the name you gave to the unit. (Without quotes)

The .sqf file I updated above should be universal now, so its just the ShopkeeperName you need to replace in the trigger.

 

Done exactly as you said, everything has loaded fine (no errors in the server RPT) however I cannot walk through the unit. I am almost certain I have set it up correctly.

 

Trigger:

 

8CYNQZn.jpg

 

Unit:

 

2HXewX9.jpg

 

.sqf:

shopkeeper = (_this select 0);
_dude = nearestObjects [shopkeeper, ["CAManBase"], 5];
{ shopkeeper disableCollisionWith _x } forEach _dude;

- Just noticed I never gave the trigger a name, retrying now.

Share this post


Link to post
Share on other sites

If there is no errors, and you cannot walk through it, then it must be a locality issue then. :huh: (Try it in SP, just to confirm)

Share this post


Link to post
Share on other sites

If there is no errors, and you cannot walk through it, then it must be a locality issue then. :huh: (Try it in SP, just to confirm)

 

Does not work locally either, could it be this 'CAManBase'? The units used in the mod are all on Independent. Your first suggestion 'disableCollisionWith' worked perfectly, but that was local only. The only other thing I can think of is blocking the AI in witch sandbags or something similar, just looks messy.

Share this post


Link to post
Share on other sites

Not sure if this might work, but replace the code In the trigger with this:

[{[ShopkeeperName] execVM "retard_buster.sqf";}, "BIS_fnc_spawn", true, true ] call BIS_fnc_MP;
Many say it is not recommend to use spawn with this function, but it should make the script MP compatible.

Also, CAManBase returns all dead and alive characters.

  • Like 1

Share this post


Link to post
Share on other sites

Not sure if this might work, but replace the code In the trigger with this:

 

[{[ShopkeeperName] execVM "retard_buster.sqf";}, "BIS_fnc_spawn", true, true ] call BIS_fnc_MP;
Many say it is not recommend to use spawn with this function, but it should make the script MP compatible.

Also, CAManBase returns all dead and alive characters.

 

 

Still did not make a difference. I do not understand why this; 'disableCollisionWith works on the editor but does not work when its on a live server?

Share this post


Link to post
Share on other sites

I found this on the page:

"Command has to be executed where objects are local, and as long as they don't change locality, the effect of this command will be global.

If the 2 objects are not local to the same computer, then it has to be executed on both computers to achieve the desired effect.

If one or both objects change locality, the command needs to be executed again on the new owner's machine(s) to maintain the effect."

I got no clue what KK meant there, but it sounds like the code needs to be run on both machines. But this issue has got my brain worked up, so I might have to study this matter for tonight. :huh:

I encourage those who may have the answer to this locality issue, to please post a solution. (This thread, like always, will be made helpful to others that may view it)

I am still learning the MP side of scripting, so please forgive me if I have gone wrong somewhere.

Share this post


Link to post
Share on other sites

I found this on the page:

"Command has to be executed where objects are local, and as long as they don't change locality, the effect of this command will be global.

If the 2 objects are not local to the same computer, then it has to be executed on both computers to achieve the desired effect.

If one or both objects change locality, the command needs to be executed again on the new owner's machine(s) to maintain the effect."

I got no clue what KK meant there, but it sounds like the code needs to be run on both machines. But this issue has got my brain worked up, so I might have to study this matter for tonight. :huh:

I encourage those who may have the answer to this locality issue, to please post a solution. (This thread, like always, will be made helpful to others that may view it)

I am still learning the MP side of scripting, so please forgive me if I have gone wrong somewhere.

 

No no, you know more than me and I appreciate your help. Such a simple issue, yet so hard to solve. To anybody whom may stumble across this thread I am simply looking to stop people from sprinting into an NPC (causing it to move from its original position) either by making it static (like a rock) or turning off its collision (so people can walk through the unit).

 

Thanks.

  • Like 1

Share this post


Link to post
Share on other sites

Did you try to put it into the initPlayerLocal.sqf?

shopDude disableCollisionWith player;
The only other thing I can think of is blocking the AI in witch sandbags or something similar, just looks messy.

Doesn't need to be sandbags, what about a cashdesk and other crates? Only problem would be that stupid player would find a way to vault even through there.

Share this post


Link to post
Share on other sites

Did you try to put it into the initPlayerLocal.sqf?

shopDude disableCollisionWith player;
The only other thing I can think of is blocking the AI in witch sandbags or something similar, just looks messy.

Doesn't need to be sandbags, what about a cashdesk and other crates? Only problem would be that stupid player would find a way to vault even through there.

 

I never, I will try this now. If it fails to work I think I will take your advice using cash desks to make it look as sound as can be if that fails a rule will be made and I will just have to hold faith in my players.

Share this post


Link to post
Share on other sites

I've never run into this issue before are there any mods you have running that might affect AI behavior?

Share this post


Link to post
Share on other sites
initPlayerLocal.sqf SHOULD work (If its not in your mission, create one).

 

 

initPlayerLocal.sqf

 



TAG_CollisionStopper = {
 
shopkeeper = (_this select 0);
_dude = nearestObjects [shopkeeper, ["CAManBase"], 5];
{ shopkeeper disableCollisionWith _x } forEach _dude;
 
};


 

Your trigger act:

 



[waste] call TAG_CollisionStopper;


 

Take note that any script suspension (e.g. sleep, waitUntil, etc.) must be spawned, not called.

 

 

Hope it helps,

 

 

 

Ranwer135

  • Like 1

Share this post


Link to post
Share on other sites

 

initPlayerLocal.sqf SHOULD work (If its not in your mission, create one).
 
 
initPlayerLocal.sqf
 
TAG_CollisionStopper = {
 
shopkeeper = (_this select 0);
_dude = nearestObjects [shopkeeper, ["CAManBase"], 5];
{ shopkeeper disableCollisionWith _x } forEach _dude;
 
};
 
Your trigger act:
 
[waste] call TAG_CollisionStopper;
 
Take note that any script suspension (e.g. sleep, waitUntil, etc.) must be spawned, not called.
 
 
Hope it helps,
 
 
 
Ranwer135

 

 

I'll be sure to go through this, just lost 10 hours + worth of mapping so I am taking a break. You the man Ranwer!

  • Like 1

Share this post


Link to post
Share on other sites

I've never run into this issue before are there any mods you have running that might affect AI behavior?

 

Its possible, but it would not matter anyway if you had all mods turned off. Most likely this has been caused by the PhysX engine, as your character has a Geometric LOD, like the rest of all other Arma objects. (E.g. Running into a guy on an ATC tower could push him off it)

 

Geometric LODs are there to create 3D boundaries, such as a wall. But as mentioned above, the PhysX engine gives a bit of realism towards gravity such as collisions.

Share this post


Link to post
Share on other sites

I've been battling this same issue, and came up with a couple different solutions.

 

I'm not sure if it's been mentioned here already, but enableSimulationGlobal will effectively freeze a unit. This has the desired effect (disabling collision), but also comes with some side effects: nameplates will not appear, and normal animations will freeze. If you want to try this, just run something like this on the server side:

{
    _x enableSimulationGlobal false;
} foreach dudes_to_freeze;

The above-mentioned drawbacks weren't really acceptable for me, so I kept tinkering. What I discovered is that applying an animation to a unit has a similar effect to disabling simulation, in that it roots the unit to the spot. However, this comes with its own side effect: units will get rooted to the terrain level. So if you have a guy that's standing on top of a structure, for example, he'll get snapped down to the terrain and may clip through the floor. But there's a simple workaround: just determine his position, then reset him after the animation is applied. Again, on the server side:

{
    // _x enableSimulationGlobal false;
    _x disableAI "MOVE";
    _startingpos = getPosATL _x;
    [_x, "STAND", "ASIS"] call BIS_fnc_ambientAnim;
    _x setPos _startingpos;
} foreach dudes_to_freeze;

BIS_fnc_ambientAnim is notoriously troublesome in multiplayer, but this seems to work fine with both "STAND" and "GUARD".

 

 

Hope this helps. I'd go with solution #1 if you can deal with the animation freeze, as it's simpler and more foolproof. But #2 is what I'm using now, and it seems pretty decent in testing.

Edited by travhimself

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  

×