View unanswered posts | View active topics It is currently Tue Jul 01, 2025 7:26 pm



Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next
 Same-team turrent unselectablility 
Author Message
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post 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
Profile
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Same-team turrent unselectablility
Post your script.


Wed Nov 25, 2009 1:40 am
Profile
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post Re: Same-team turrent unselectablility
http://pastebin.com/f15a36f05


Wed Nov 25, 2009 1:44 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post 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
Profile
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Same-team turrent unselectablility
You only have one timer. You need one for every turret.


Wed Nov 25, 2009 2:28 am
Profile
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post Re: Same-team turrent unselectablility
Still getting it.
http://pastebin.com/f14c983c4


Wed Nov 25, 2009 3:23 am
Profile
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post 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
Profile
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post 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
Profile YIM
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post 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
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post 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
Profile
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post 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
Profile YIM
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post 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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 31 posts ]  Go to page Previous  1, 2, 3  Next

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.381s | 14 Queries | GZIP : Off ]