Author |
Message |
whitty
Joined: Sat Jun 16, 2007 2:31 am Posts: 2982 Location: Texas
|
 Re: Same-team turrent unselectablility
Grif wrote: try spawning the actor indirectly; eg, make an instant-gib aemitter that gibs into the actor rather than actually spawning through lua. if you do presetname checks when you find the two turret actors it should be pretty reliable Alright so uh what would the Lua part look like? And would it still work with 6 actor turrets or I have to make it be 6 different actors.
|
Wed Nov 25, 2009 12:20 am |
|
 |
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
 Re: Same-team turrent unselectablility
I would make the turrets emitters and the target finding and emitting Lua'd. If you don't want to do that, you could have the turrets not on your team and give them a really high CharHeight so they're invisible to your allies and have the turrets' firing Lua'd. Their controls are disabled by default, when an enemy is in range cast a ray towards them to make sure there isn't anything in the way and then enable controls + fire weapons. Just what I would do. EDIT: Script for the non-Team actor method: Code: -- In the Create function somewhere (not in an "if" statement)
self.DetectTimer[1] = Timer();
-- In the Update function somewhere (not in an "if" statement)
if MovableMan:IsActor(self.turret[1]) then self.turret[1]:SetControllerMode(Controller.CIM_DISABLED, -1); if not(MovableMan:IsActor(self.turrettarget[1])) and self.DetectTimer[1]:IsPastSimMS(200) then self.DetectTimer[1]:Reset(); for actor in MovableMan.Actors do local turretrange = 500 if actor.Team ~= self.Team and (actor.Pos-self.turret[1].Pos).Magnitude then local scanobject = SceneMan:CastMORay(self.turret[1].Pos,Vector(actor.Pos.X-self.turret[1].Pos.X,actor.Pos.Y-self.turret[1].Pos.Y),255,5,true,0); if scanobject ~= 255 and scanobject ~= self.ID and scanobject ~= self.turret[i].ID then local object = MovableMan:GetMOFromID(scanobject); local potentialtarget = MovableMan:GetMOFromID(object.RootID); if MovableMan:IsActor(potentialtarget) and potentialtarget.Team ~= self.Team then self.turrettarget[1] = potentialtarget; end end end end end
if MovableMan:IsActor(self.turrettarget[1]) then self.turret[1]:SetControllerMode(Controller.CIM_AI, -1); local targetdir = math.atan2(-(self.turrettarget[1].Pos.Y-self.turret[1].Y),(self.turrettarget[1].Pos.X-self.turret[1].X)); self.turret[1]:SetAimAngle(targetdir); self.turret[1]:GetController():SetState(Controller.WEAPON_FIRE,true); self.turret[1]:SetControllerMode(Controller.CIM_DISABLED, -1); end end I'm not sure if you can replace all the "[1]" with "[i]" an have the script work perfectly. If you can, just paste once in the designated areas. If you can't, paste each thing in your code for each turret you have and change the numbers accordingly.
|
Wed Nov 25, 2009 12:22 am |
|
 |
whitty
Joined: Sat Jun 16, 2007 2:31 am Posts: 2982 Location: Texas
|
 Re: Same-team turrent unselectablility
"ERROR: WWM.rte/Actors/Battleship/Battleship.lua:54: attempt to index field 'turret' (a nil value)" ...Doesn't seem to work.
|
Wed Nov 25, 2009 1:27 am |
|
 |
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
 Re: Same-team turrent unselectablility
Post your script.
|
Wed Nov 25, 2009 1:40 am |
|
 |
whitty
Joined: Sat Jun 16, 2007 2:31 am Posts: 2982 Location: Texas
|
 Re: Same-team turrent unselectablility
|
Wed Nov 25, 2009 1:44 am |
|
 |
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
 Re: Same-team turrent unselectablility
Change all "self.turret[#]" to "self.Turret[#]". In other words, match the case.
|
Wed Nov 25, 2009 2:05 am |
|
 |
whitty
Joined: Sat Jun 16, 2007 2:31 am Posts: 2982 Location: Texas
|
 Re: Same-team turrent unselectablility
"ERROR: WWM.rte/Actors/Battleship/Battleship.lua:5: attempt to index field 'DetectTimer' (a nil value)" It's in the crate function. 
|
Wed Nov 25, 2009 2:22 am |
|
 |
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
 Re: Same-team turrent unselectablility
You only have one timer. You need one for every turret.
|
Wed Nov 25, 2009 2:28 am |
|
 |
whitty
Joined: Sat Jun 16, 2007 2:31 am Posts: 2982 Location: Texas
|
 Re: Same-team turrent unselectablility
|
Wed Nov 25, 2009 3:23 am |
|
 |
Abdul Alhazred
DRL Developer
Joined: Tue Aug 11, 2009 5:09 am Posts: 395
|
 Re: Same-team turrent unselectablility
One hacky way of doing it is to force select the next actor when the turret is selected. Attach the code below to the turret. Code: function Create(self) self.Activity = ActivityMan:GetActivity() self.Ctrl = self:GetController() end
function Update(self) if self:IsPlayerControlled() then local NextActor = nil if self.Ctrl:IsState(Controller.ACTOR_NEXT) then NextActor = MovableMan:GetNextTeamActor(self.Team, self) elseif self.Ctrl:IsState(Controller.ACTOR_PREV) then NextActor = MovableMan:GetPrevTeamActor(self.Team, self) end if NextActor.ID ~= self.ID then self.Activity:SwitchToActor(NextActor, self.Team, self.Team) end end end
|
Wed Nov 25, 2009 8:53 am |
|
 |
Darlos9D
Joined: Mon Jul 16, 2007 9:50 am Posts: 1512 Location: Tallahassee, FL
|
 Re: Same-team turrent unselectablility
Here's your solution: instead of adding actors with MovableMan:AddActor(), use MovableMan:AddParticle(). They'll still appear and function properly, but you won't see their health and you won't be able to control them.
This basically simulates with Lua what Grif was talking about. If you spawn an actor in-game through gibs, emissions, or stuff out of a firearm, you'll wind up with the same effect. This is because these methods of spawning add all things as particles.
|
Wed Nov 25, 2009 5:11 pm |
|
 |
whitty
Joined: Sat Jun 16, 2007 2:31 am Posts: 2982 Location: Texas
|
 Re: Same-team turrent unselectablility
Ahhhhhh I see what you did there. I also had to change all IsActor to IsParticle, but it works now. Thanks guys!
|
Wed Nov 25, 2009 5:27 pm |
|
 |
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
 Re: Same-team turrent unselectablility
Darlos9D wrote: Here's your solution: instead of adding actors with MovableMan:AddActor(), use MovableMan:AddParticle(). They'll still appear and function properly, but you won't see their health and you won't be able to control them.
This basically simulates with Lua what Grif was talking about. If you spawn an actor in-game through gibs, emissions, or stuff out of a firearm, you'll wind up with the same effect. This is because these methods of spawning add all things as particles. Ah damn, I knew about that but wasn't sure if they still had AI.
|
Wed Nov 25, 2009 6:49 pm |
|
 |
Darlos9D
Joined: Mon Jul 16, 2007 9:50 am Posts: 1512 Location: Tallahassee, FL
|
 Re: Same-team turrent unselectablility
Like I said, it's exactly what happens when you emit/fire/gib into an actor, so if the AI works then it should work with AddParticle().
|
Wed Nov 25, 2009 8:15 pm |
|
 |
Abdul Alhazred
DRL Developer
Joined: Tue Aug 11, 2009 5:09 am Posts: 395
|
 Re: Same-team turrent unselectablility
That is brilliant. Too bad is it is invisible to all my targeting scripts since it won't be found when iterating over all actors.
Anyone knows what kind of AI is possible with a door, by the way?
|
Wed Nov 25, 2009 8:38 pm |
|
 |
|