Author |
Message |
Pumone
Joined: Wed Dec 28, 2011 4:18 pm Posts: 86
|
AI enemy control
my big question is:
is it possible to create a simple code that allows you to switch by team A to team B by clicking a button (for example button "1") and vice-versa?
|
Sat Jan 26, 2013 12:37 am |
|
|
Pumone
Joined: Wed Dec 28, 2011 4:18 pm Posts: 86
|
Re: AI enemy control
I suppose there is no way to make it real
|
Sat Feb 02, 2013 12:04 pm |
|
|
Bad Boy
Joined: Fri Sep 10, 2010 1:48 am Posts: 666 Location: Halifax, Canada
|
Re: AI enemy control
Add this to their individual script or straight to HumanAI (or any other AI) in base.rte/Actors/AI: Code: if self:IsPlayerControlled() and MovableMan:IsActor(self) and UInputMan:KeyPressed(28) then if self.Team == 0 then self.Team = 1; elseif self.Team == 1 then self.Team = 0; end end As requested this uses 1 as the key to change team. You can change it by changing the number inside the brackets of UInputMan:KeyPressed(28). For the rest of the keys, look here: http://wiki.datarealms.com/KeylistKeep in mind that though I haven't had any crashes, I can't guarantee that they won't happen; switching teams for actors once they're spawned can be an odd business.
|
Sat Feb 02, 2013 5:06 pm |
|
|
Pumone
Joined: Wed Dec 28, 2011 4:18 pm Posts: 86
|
Re: AI enemy control
thanks bad boy,
i tried to add your code to their individual script or straight to HumanAI bu with no result, sometimes the game crashes, sometimes starts but without the code's function.
so what i wish to do isn't to transform 1 unit of team A in 1 unit of team B;
i would make a thing that allows me to switch team, so all AI units in the battlefield become my units and vice-versa.
|
Sat Feb 02, 2013 9:45 pm |
|
|
Pumone
Joined: Wed Dec 28, 2011 4:18 pm Posts: 86
|
Re: AI enemy control
maybe i'm wrong to enter the code
where to put it? at the top of lua file? or at the bottom?
sorry for multiple questions, but this is my final project to this wonderful game
|
Sun Feb 03, 2013 2:13 pm |
|
|
Bad Boy
Joined: Fri Sep 10, 2010 1:48 am Posts: 666 Location: Halifax, Canada
|
Re: AI enemy control
Assuming it doesn't turn out to be a very lenghty process I'll be giving you an updated version that'll do what you want sometime soonish. For this, put it at the bottom of AIHuman.lua in base.rte/Actors/AI. You don't have to paste over anything, just add it directly below what's already there. Edit: Scratch that, I'm not sure how doable what you want actually is. For what it's worth here's a glitchy version that sort of does it. While it doesn't really work it's still pretty fun. Replace your HumanAI with this one: Attachment:
HumanAI.lua [838 Bytes]
Downloaded 334 times
|
Sun Feb 03, 2013 8:14 pm |
|
|
Pumone
Joined: Wed Dec 28, 2011 4:18 pm Posts: 86
|
Re: AI enemy control
first of all, thank you so much,
this is what I wanted to do
but has a problem
when I press "1" all actors change in opposite team
but it seems that AI die so I can control only one actor and all other soldiers in my team moves concurrently all together
example: if I press jetpack "w" not only my actors will fly, but all actors in my team do this
so you made a great mod but still correctable
|
Sun Feb 03, 2013 9:33 pm |
|
|
Bad Boy
Joined: Fri Sep 10, 2010 1:48 am Posts: 666 Location: Halifax, Canada
|
Re: AI enemy control
Yeah, I know, it's glitchy (it work properly sometimes) and seems to crash a good deal of the time. I'll see if I can make a decent version of it sometime but I'm not sure how doable it actually is. If I can make it work properly I will but don't hold your breath.
|
Sun Feb 03, 2013 9:42 pm |
|
|
Pumone
Joined: Wed Dec 28, 2011 4:18 pm Posts: 86
|
Re: AI enemy control
ok thanks for your kindness
|
Mon Feb 04, 2013 10:07 am |
|
|
|