I am making a custom script and was wondering if it would be possible to spawn AI at a certain location and have them defend it and when you get close they start shooting you, but you can obviously shoot at them and kill them as well.
Well I got it to spawn the AI finally, but how do I give them a gun through script? right now they are using the MP40, which I am using the UGX mod so that isnt going to work . Would I use the normal giveweapon but instead of calling it on player call it on the ai? Also how can I stop the players from picking up the gun after the AI dies.
Well I got it to spawn the AI finally, but how do I give them a gun through script? right now they are using the MP40, which I am using the UGX mod so that isnt going to work . Would I use the normal giveweapon but instead of calling it on player call it on the ai? Also how can I stop the players from picking up the gun after the AI dies.
You could create a new AI type with a gun of your choice using AssetManager (see: http://ugx-mods.com/forum/index.php/topic,8086.0.html) which would allow you to give the spawner new/different weapons and change its model.
Thanks! Will try this when I wake up in the morning. One final question, I was hoping to make the gun that the AI get is random each time he spawns, but I guess with this way it isn't possible to do that.
Thanks! Will try this when I wake up in the morning. One final question, I was hoping to make the gun that the AI get is random each time he spawns, but I guess with this way it isn't possible to do that.
You can. Creating a new ai type just lets you set defaults for the AI without having to script it(less code). You can still change an AI's weapon through script.
I added that code to the end of my script, and threaded it on the spawner but he still spawns with an mp40
i had this problem as well, except it would change the text that says what type of friendly they were like "submachine gunner", "rifleman" or "heavy machine gunner" but the weapon never changed. i finally managed to change it by editing the character file of the type of spawner i was using
That's how I would try it. You could randomize it that way too prob. with an array and randomize the array and then use the first one in the array?
i just made a switch based off of a random number and then for each case gave the AI a different weapon, and then changed their accuracy depending on what type of weapon they were given in that case
Thanks a bunch guys! I got him to spawn in with a different weapon now, should be able to make the weapon randomize each time no problem. +1 to all who helped