View unanswered posts | View active topics It is currently Tue Apr 23, 2024 2:10 pm



Reply to topic  [ 5 posts ] 
 ATTN: 
Author Message
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post ATTN:
Code:
   if not sentryActor.target then
      for actor in MovableMan.Actors do
         local diff = math.sqrt(math.pow((actor.Pos.X - sentryActor.Pos.X),2) + math.pow((actor.Pos.Y - sentryActor.Pos.Y),2))
         if diff < 500 and actor.ID ~= sentryActor.ID then
            sentryActor.target = actor;
         end
      end
   end
   if MovableMan:IsActor(sentryActor.target) then
      if SceneMan:ShortestDistance(sentryActor.Pos,sentryActor.target.Pos) < 300 then
            sentryActor:SetAimAngle(math.atan2(sentryActor.target.Pos.Y-sentryActor.Pos.Y,sentryActor.target.Pos.Y-sentryActor.Pos.Y));
            sentryActor:GetController():SetState(Controller.WEAPON_FIRE,true);
      end

      if sentryActor.Health <= 0 or MovableMan:IsActor(sentryActor) == false then
         self.WinnerTeam = Activity.TEAM_1;
         ActivityMan:EndActivity();
      end
   end


Or in english:

so we've got sentry ai mode done, now how about some golddig?


Wed Jun 10, 2009 5:38 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: ATTN:
Neat snippet.

I assume it's for a turret.

For gold, I would guess at sending multiple weakness and strength rays with each pair having ignored one of the materials with the same strength as gold(Xenocronium,Earth,Red Earth, Lunar Earth).

If all of them hit the same thing, it's either gold or a material with a strength equal to gold not in base.rte.

Start digging.


Last edited by mail2345 on Wed Jun 10, 2009 5:59 am, edited 1 time in total.



Wed Jun 10, 2009 5:51 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: ATTN:
Basically, yes.

It's also a proof of concept of a couple of functions. especially ShortestDistance (useful) and SetAimAngle.


Wed Jun 10, 2009 5:53 am
Profile
User avatar

Joined: Sat Nov 03, 2007 9:44 pm
Posts: 1916
Location: Flint Hills
Reply with quote
Post Re: ATTN:
So is this just firing in the direction of any actor within 300 px until it's terrain/gibs, and moving on to the next to come?
Useful for an 'xray' turret I suppose, since I see no raycasting to check for obstacles.
A mission where you have to work your way towards a turret to kill it as it cumulatively tears up your cover would be neat.

It's a good start for custom AI modes.

It looks like it would select multiple simultaneous targets if they were in range when it was searching though, and what happens then?


Wed Jun 17, 2009 12:41 am
Profile

Joined: Sat Feb 03, 2007 7:11 pm
Posts: 1496
Reply with quote
Post Re: ATTN:
Why did you make it end the game when it dies?

Also, if you applied the code directly to an actor, you could replace "sentryActor" with "self" right?

If so:
Code:
   if not self.target then
      for bullet in MovableMan.Particles do
         local diff = math.sqrt(math.pow((bullet.Pos.X - self.Pos.X),2) + math.pow((bullet.Pos.Y - self.Pos.Y),2))
         if diff < 100 and bullet.ID ~= self.ID and bullet.HitsMOs == 1 then
            self.target = bullet;
         end
      end
   end
   if MovableMan:IsParticle(self.target) then
      if SceneMan:ShortestDistance(self.Pos,self.target.Pos) < 100 then
            self:SetAimAngle(math.atan2(self.target.Pos.Y-self.Pos.Y,self.target.Pos.Y-self.Pos.Y));
      end
   end


Why not for Auto-Aiming Shield?

That code there can only focus on one bullet, until that bullet is dead, then it switches to the next one.
I guess I could fix it later, but I'm just throwing the idea out there now.


Thu Jun 18, 2009 9:00 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

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.056s | 15 Queries | GZIP : Off ]