Jump to content
Sign in to follow this  
ghandolhagen

I script a specific hat on an AI and it changes to a random hat when I test...

Recommended Posts

Hey all, running into a bug? I have a pack of civilians that I want to turn into a ragtag bunch of asshole mercs. The problem is that when I give them specific hats that I want them to wear and test the game, their hats change to a random civilian hat. Kind of hard to take a merc seriously when he is wearing a wicker fedora... Any ideas? Thanks a bunch.

Share this post


Link to post
Share on other sites

removeAllAssignedItems this; 
removeHeadgear this; 
removeUniform this;  
this addHeadgear "H_Cap_blk"; 

This is the code that is relevant. I start by stripping the civilian down to nothing and then start adding everything back in that I want. In this case, the above code should give the civilian a black ball cap. Every time I test the mission, the character is given a random hat out of all possible hats. It changes every time I test. Thanks for any assistance.

Share this post


Link to post
Share on other sites

You probably just need a little delay to make sure your headgear is applied last.

Try this:

nul = this spawn {
sleep 1;
removeAllAssignedItems _this; 
removeHeadgear _this; 
removeUniform _this;  
_this addHeadgear "H_Cap_blk";
};

Share this post


Link to post
Share on other sites

Cheers! I'll give it a try. :D

---------- Post added at 19:24 ---------- Previous post was at 19:09 ----------

Hey thanks it works! Just so I understand what the code is doing would you mind walking through it? I am getting the delay of sleep 1; However I don't understand how spawn is used or rather nul in this context. Thanks again for your help! My pack of scumbag opportunists now look serious instead of ridiculous.

Edited by ghandolhagen

Share this post


Link to post
Share on other sites

From the bit of code you posted, I assumed you are using a unit's init line. If you are executing this from within a script you wouldn't need the spawn.

nul =

Is there because spawn requires some handle when used in unit init lines. It's useless to have a handle in this case so we use a non-existing variable for it. Just because we have to assign something.

spawn

Is there because delays (sleep) are not allowed within the mission scope itself (vehicle/unit init lines). So we have to spawn a new thread/virtual machine to use sleep.

I'm not very good at explaining things, I hope you get it. :)

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  

×