Data Realms Fan Forums http://45.55.195.193/ |
|
ATTN: http://45.55.195.193/viewtopic.php?f=73&t=15292 |
Page 1 of 1 |
Author: | Grif [ Wed Jun 10, 2009 5:38 am ] |
Post subject: | 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? |
Author: | mail2345 [ Wed Jun 10, 2009 5:51 am ] |
Post subject: | 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. |
Author: | Grif [ Wed Jun 10, 2009 5:53 am ] |
Post subject: | Re: ATTN: |
Basically, yes. It's also a proof of concept of a couple of functions. especially ShortestDistance (useful) and SetAimAngle. |
Author: | Azukki [ Wed Jun 17, 2009 12:41 am ] |
Post subject: | 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? |
Author: | zalo [ Thu Jun 18, 2009 9:00 pm ] |
Post subject: | 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. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |