View unanswered posts | View active topics It is currently Fri Dec 27, 2024 6:41 am



Reply to topic  [ 8 posts ] 
 Could you give me a quick hand? 
Author Message
User avatar

Joined: Sun Feb 17, 2008 11:21 am
Posts: 54
Reply with quote
Post Could you give me a quick hand?
Right, I asked mail about this a while ago but I still can't get it to work.

There are two scripts. One attached to a particle fired from a gun, the other to an actor. When the particle is created it creates the actor and destroys the firer of the gun.

What I want is for the player to automaticaly select the actor after the gun is fired.

I know this should involve the code
Code:
ActivityMan:GetActivity():SwitchToActor()
, with some args.

Were should I put that snippet to have it work? I have tried different positions with different args. and I can't get it to work.

Here's the code for the actor

Code:
function Create(self)   
   self.reloadTimer = Timer();
   self.reloadTime = 3000
   self.repartTimer = Timer();
   self.repartTime = 10000
self.gravTester = CreateMOPixel("3DSniper Grav Tester");
   self.gravTester.Pos = Vector(self.Pos.X, self.Pos.Y);
   self.gravTester.Vel = Vector(0,0);
   MovableMan:AddParticle(self.gravTester);
self.gravAcc = 0
self.gravTester2 = CreateMOPixel("3DSniper Grav Tester2");
   self.gravTester2.Pos = Vector(self.Pos.X, self.Pos.Y);
   self.gravTester2.Vel = Vector(0,0);
   MovableMan:AddParticle(self.gravTester2);
self.Fog2 = CreateMOSParticle("Fog of War Inverter");
self.Fog2.Pos = Vector(self.Pos.X, self.Pos.Y - 3);
self.Fog2.Vel = Vector(0,0);
MovableMan:AddParticle(self.Fog2);
self.Fog = CreateMOSParticle("Fog of War");
self.Fog.Pos = Vector(self.Pos.X, self.Pos.Y - 3);
self.Fog.Vel = Vector(0,0);
MovableMan:AddParticle(self.Fog);

end

function Update(self)
   
   if not(self:IsDead()) then
   
   
   
      if self.gravAcc == 0 then
         if self.gravTester.Vel.Y > 0 then
            self.gravAcc = self.gravTester.Vel.Y;
         end
      end
   
      self.RotAngle = 0;
      
      local ownController = self:GetController();
      
      
      
      if ownController:IsState(Controller.HOLD_LEFT) then
         self.Vel.X = self.Vel.X - 0.5;
         
         if self.Vel.X < -15 then
         self.Vel.X = -15;
         end
      elseif ownController:IsState(Controller.HOLD_RIGHT) then
         self.Vel.X = self.Vel.X + 0.5;
         if self.Vel.X > 15 then
            self.Vel.X = 15;
         end
      elseif self.Vel.X < 0 then
         self.Vel.X = self.Vel.X + 0.5;
         if self.Vel.X > 0 then
         self.Vel.X = 0;
         end
      elseif self.Vel.X > 0 then
         self.Vel.X = self.Vel.X - 0.5;
         if self.Vel.X < 0 then
            self.Vel.X = 0;
         end
      end
      
      if ownController:IsState(Controller.HOLD_UP) then
         self.Vel.Y = self.Vel.Y - 0.5;
         if self.Vel.Y < -15 then
            self.Vel.Y = -15;
         end
      elseif ownController:IsState(Controller.HOLD_DOWN) then
            self.Vel.Y = self.Vel.Y + 0.5;
            if self.Vel.Y > 15 then
               self.Vel.Y = 15;
            end
      elseif self.Vel.Y < 0 then
            self.Vel.Y = self.Vel.Y + 0.5;
            if self.Vel.Y > 0 then
               self.Vel.Y = 0;
            end
      elseif self.Vel.Y > 0 then
         self.Vel.Y = self.Vel.Y - 0.5;
         if self.Vel.Y < 0 then
            self.Vel.Y = 0;
         end
      end
   
      if ownController:IsState(Controller.WEAPON_FIRE) and self.reloadTimer:IsPastSimMS(self.reloadTime) then
         self.gravTester2 = CreateMOPixel("3DSniper Grav Tester2");
            self.gravTester2.Pos = Vector(self.Pos.X + 25, self.Pos.Y + 1);
            self.gravTester2.Vel = Vector(-100,0);
            MovableMan:AddParticle(self.gravTester2);
         self.gravTester2 = CreateMOPixel("3DSniper Grav Tester2");
            self.gravTester2.Pos = Vector(self.Pos.X - 25, self.Pos.Y + 1);
            self.gravTester2.Vel = Vector(100,0);
            MovableMan:AddParticle(self.gravTester2);
         self.gravTester2 = CreateMOPixel("3DSniper Grav Tester2");
            self.gravTester2.Pos = Vector(self.Pos.X, self.Pos.Y - 25);
            self.gravTester2.Vel = Vector(0,100);
            MovableMan:AddParticle(self.gravTester2);
         self.gravTester2 = CreateMOPixel("3DSniper Grav Tester2");
            self.gravTester2.Pos = Vector(self.Pos.X, self.Pos.Y + 25);
            self.gravTester2.Vel = Vector(0,-100);
            MovableMan:AddParticle(self.gravTester2);
            self.gravTester2 = CreateMOPixel("3DSniper Grav Tester2");
            self.gravTester2.Pos = Vector(self.Pos.X + 25, self.Pos.Y + 1);
            self.gravTester2.Vel = Vector(-100,0);
            MovableMan:AddParticle(self.gravTester2);
         self.gravTester2 = CreateMOPixel("3DSniper Grav Tester2");
            self.gravTester2.Pos = Vector(self.Pos.X - 25, self.Pos.Y + 1);
            self.gravTester2.Vel = Vector(100,0);
            MovableMan:AddParticle(self.gravTester2);
         self.gravTester2 = CreateMOPixel("3DSniper Grav Tester2");
            self.gravTester2.Pos = Vector(self.Pos.X, self.Pos.Y - 25);
            self.gravTester2.Vel = Vector(0,100);
            MovableMan:AddParticle(self.gravTester2);
         self.gravTester2 = CreateMOPixel("3DSniper Grav Tester2");
            self.gravTester2.Pos = Vector(self.Pos.X, self.Pos.Y + 25);
            self.gravTester2.Vel = Vector(0,-100);
            MovableMan:AddParticle(self.gravTester2);
         print("CREATE: TURBOKAT - SUCCESS")
         self.reloadTimer = Timer();
      end
      
      for particle in MovableMan.Particles do
         if particle.PresetName == ("Fog of War Inverter") or particle.PresetName == ("Fog of War") then
            particle.Pos = self.Pos
         end
         if self.repartTimer:IsPastSimMS(self.repartTime) then
            if particle.PresetName == ("Fog of War Inverter") or particle.PresetName == ("Fog of War") then
               particle.Lifetime = 1
               print ("deleted")
            end
         self.Fog = CreateMOSParticle("Fog of War");
         self.Fog.Pos = Vector(self.Pos.X, self.Pos.Y);
         self.Fog.Vel = Vector(0,0);
         MovableMan:AddParticle(self.Fog);
         self.Fog2 = CreateMOSParticle("Fog of War Inverter");
         self.Fog2.Pos = Vector(self.Pos.X, self.Pos.Y);
         self.Fog2.Vel = Vector(0,0);
         MovableMan:AddParticle(self.Fog2);
         self.repartTimer = Timer();
         print ("reparted")
         end
      
         -- if self:IsPlayerControlled() == false then
            -- if particle.PresetName == ("Fog of War Inverter") or particle.PresetName == ("Fog of War") then
               -- particle.Lifetime = 0
            -- end
            -- self.Lifetime = 1
            -- self.Health = 0
         -- end
      end
         
      self.Vel.Y = self.Vel.Y - self.gravAcc
   end
end


And here it is for the gun

Code:
function Create(self)
   local curdist = 40;
   for actor in MovableMan.Actors do
      local avgx = actor.Pos.X - self.Pos.X;
      local avgy = actor.Pos.Y - self.Pos.Y;
      local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
      if dist < curdist then
         curdist = dist;
         guy = CreateACrab("3D Sniper")
         guy.Team = actor.Team
         guy.Pos = actor.Pos
         guy.AIMode = Actor.AIMODE_SENTRY
         MovableMan:AddActor(guy)
         actor.Pos.Y = actor.Pos.Y + 999999999
      end   
   end
end


Thanks


Thu Aug 20, 2009 9:49 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Could you give me a quick hand?
Scripts run on an HDFirearm will not run until you drop it; when held it's considered an attachable.


Thu Aug 20, 2009 2:56 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Could you give me a quick hand?
Attach an AEmitter to the gun and attach the script to it.
Theoretically, it should work as if it is the gun, though you may need to add a line that checks what if the fire button is pressed, and then do the rest of the script.


Thu Aug 20, 2009 4:12 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Could you give me a quick hand?
An attached aemitter will not function for the same reason.

You have to attach an emitter that emits particles that do the required lua functions.


Thu Aug 20, 2009 11:45 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Could you give me a quick hand?
Grif wrote:
An attached aemitter will not function for the same reason.

You have to attach an emitter that emits particles that do the required lua functions.


Really?
Lua works directly on AEs, so it shouldn't do that... Though I never got to check it on a weapon.

Well, then just have it emit 120 particles per minute (or you can go with 60, though there shouldn't be much difference) and attach the script to each particle.


Thu Aug 20, 2009 11:54 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Could you give me a quick hand?
Grif wrote:
Scripts run on an HDFirearm AEmitters will not run until you drop it when they are attached; when held attached it's considered an attachable.


Thu Aug 20, 2009 11:57 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Could you give me a quick hand?
Grif wrote:
Grif wrote:
Scripts run on an HDFirearm AEmitters will not run until you drop it when they are attached; when held attached it's considered an attachable.


Ok, ok, I understand. >________________>'
I will, though, check if I can make it work directly (Maybe i'll come up with some hacky solution). But that is unlikely to happen in the next few days. >______________>'


Fri Aug 21, 2009 12:04 am
Profile
User avatar

Joined: Sun Feb 17, 2008 11:21 am
Posts: 54
Reply with quote
Post Re: Could you give me a quick hand?
Sorry, forgot I posted this. but I would still like some help


xerxys wrote:
There are two scripts. One attached to a particle fired from a gun, the other to an actor. When the particle is created it creates the actor and destroys the firer of the gun.


Sat Aug 22, 2009 6:34 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.072s | 13 Queries | GZIP : Off ]