View unanswered posts | View active topics It is currently Tue Apr 16, 2024 12:46 pm



Reply to topic  [ 8 posts ] 
 Changing offset of weapon when reloading? 
Author Message

Joined: Tue Dec 04, 2012 1:31 am
Posts: 45
Reply with quote
Post Changing offset of weapon when reloading?
It's always bothered me how the riot shield has "disappeared" (clipped into the actor) when reloading, and I was wondering if it was possible to create a script to check if the parent actor is reloading, and then if the actor is, change the offset of the shield to make it still protect the actor?


Sat Mar 02, 2013 8:14 pm
Profile

Joined: Fri Dec 14, 2012 5:44 am
Posts: 201
Reply with quote
Post Re: Changing offset of weapon when reloading?
Yeah, I'm thinking you just attach a script to the Shield Item, to check if reloading offset vector = <front vector>

although im not sure if the lua needs a special vector definition for left facing or right facing or if it just does it automatically based on where the actor is facing by default.

But anyway something like a

If = actor_reload(or the state where the "Reloading..." sprite pops overhead, as I know there is a function that calls for that.)

movpos = vector_infront_coords

else = regular vector

buuuuut when that happens im not sure the hand will follow.....



I really shoud learn to write lua.......


Sun Mar 03, 2013 5:11 am
Profile

Joined: Tue Dec 04, 2012 1:31 am
Posts: 45
Reply with quote
Post Re: Changing offset of weapon when reloading?
Whether or not the hand follows it is immaterial. I just want it to be there, infront of the actor. Protecting him instead of clipping inside of him and being useless. And the problem I face is how to check if the weapon the actor is holding is reloading. It's fairly simple when the script is attached to the weapon itself, but it gets more difficult when I'm referencing a different object not spawned in or defined already by lua.


Sun Mar 03, 2013 8:47 am
Profile

Joined: Fri Dec 14, 2012 5:44 am
Posts: 201
Reply with quote
Post Re: Changing offset of weapon when reloading?
nubbles wrote:
Whether or not the hand follows it is immaterial. I just want it to be there, infront of the actor. Protecting him instead of clipping inside of him and being useless. And the problem I face is how to check if the weapon the actor is holding is reloading. It's fairly simple when the script is attached to the weapon itself, but it gets more difficult when I'm referencing a different object not spawned in or defined already by lua.


Ah, I tried the functions page

http://wiki.datarealms.com/List_of_all_Lua_functions

all I can think of as a hack in the meantime is just force set your shield once it is spawned, so it never moves for any reason. So you just check to make sure that if it is equipped it overrides its position, but it wont look natural I guess.. cuz it wont be bound to the position of the hands I think... not too sure.

I'll keep searching for ya


Sun Mar 03, 2013 9:56 am
Profile

Joined: Tue Dec 04, 2012 1:31 am
Posts: 45
Reply with quote
Post Re: Changing offset of weapon when reloading?
It might be possible to add a callout to the actor to find if it's got a weapon, and then check if that weapon is reloading, but I can't seem to figure out exactly how to go about that.


Sun Mar 03, 2013 5:56 pm
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post Re: Changing offset of weapon when reloading?
Put the script on the shield then find the parent like:
Code:
function Create(self)
   self.Parent = nil;
   self.ParentPickTimer = Timer();
   local actor = MovableMan:GetMOFromID(self.RootID);

   if MovableMan:IsActor(actor) then
      self.Parent = ToActor(actor);
      self.Parentpickingdone = true;
   end
end
function Update(self)
   --Set the parent to nil if he's dead
   if not MovableMan:IsActor(self.Parent) then
      self.Parent = nil;
   end
   --This part is a safety check to make sure we do get the parent. You can end up without a parent when you spawn them in base editor or manually drop them out of a dropship if you don't put the parent finding in here too.
   if self.ParentPickTimer:IsPastSimMS(500) then
      local actor = MovableMan:GetMOFromID(self.RootID);
      if MovableMan:IsActor(actor) then
         self.Parent = ToActor(actor);
         self.Parentpickingdone = true;
      end
   end
end

I don't have time or desire to write the full thing right now but for the rest you use self.Parent:GetController():IsState(Controller.WEAPON_RELOAD ) to find if it's reloading. The rest can be done with simple position changes or you can probably get more complex and do it properly.


Sun Mar 03, 2013 6:00 pm
Profile

Joined: Tue Dec 04, 2012 1:31 am
Posts: 45
Reply with quote
Post Re: Changing offset of weapon when reloading?
You are a better man than I. I'll play around with it, and see what I can come up with. It'll most likely be a quick and dirty, just moving the shield and not the actor's BG arm, as I don't understand the more complex aspects to it. Thanks Bad Boy.


Mon Mar 04, 2013 3:27 am
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post Re: Changing offset of weapon when reloading?
Happy to help. Maybe at some point I'll see if I can come up with a better script but I haven't had much time lately. Feel free to send me a pm if you do run into trouble though, if it's not too difficult I'll try to help you out. Or of course, you can just keep posting here.


Mon Mar 04, 2013 7:07 am
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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.040s | 15 Queries | GZIP : Off ]