Data Realms Fan Forums http://45.55.195.193/ |
|
If holding this and person fires then crouch. http://45.55.195.193/viewtopic.php?f=73&t=24003 |
Page 1 of 1 |
Author: | Kettenkrad [ Sun May 29, 2011 4:11 am ] |
Post subject: | If holding this and person fires then crouch. |
I need a reliable script for a weapon that forces the actor holding it to crouch when it fires. I was playing around with the shovel script to find the device, but I don't know what do do from there on... Please? |
Author: | Asklar [ Sun May 29, 2011 5:00 am ] |
Post subject: | Re: If holding this and person fires then crouch. |
EDIT: Code: function Create(self) local curdist = 70 -- Change this distance based on your own gun 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; self.parent = actor; self.parent:GetController():SetState(10, true) end end end function Update(self) self.parent:GetController():SetState(10, true) end This should work fine. |
Author: | Xery [ Sun May 29, 2011 5:37 am ] |
Post subject: | Re: If holding this and person fires then crouch. |
You should first make sure the actor is not walking(MOVE_RIGHT or MOVE_LEFT) or in the air(actor:GetAltitude(0,0) < ?), then lock the state to 10(BODY_CROUCH) about the whole process(not only in function Create). Give the gun an ActivationDelay, leaving actor some time to crouch down, or, I donno if there's a method to judge whether the actor is already crouch down. |
Author: | Kettenkrad [ Sun May 29, 2011 7:40 am ] |
Post subject: | Re: If holding this and person fires then crouch. |
lol, I attached it to the fired particle, and it was created when it fired, about every second. It made the actor bum shuffle his was across the tutorial bunker ![]() Any way to enforce the crouch as long as the actor holds fire? EDIT: nvm, increased lifetime Thanks for the help guys ![]() EDITEDIT: what about a .lua controlled hinge, just to make something dangle? |
Author: | Xery [ Sun May 29, 2011 10:27 am ] |
Post subject: | Re: If holding this and person fires then crouch. |
Kettenkrad wrote: lol, I attached it to the fired particle, and it was created when it fired, about every second. It made the actor bum shuffle his was across the tutorial bunker ![]() Any way to enforce the crouch as long as the actor holds fire? EDIT: nvm, increased lifetime Thanks guys ![]() EDITEDIT: what about a .lua controlled hinge, just to make something dangle? eh, I'll suggest you to attach a lua-attached particle to the gun. the lua code:when create. look for its parent gun, then keep checking whether there's a actor hold the weapon.(If you don't keep checking in the function Update, the lua will not work right after you drop it or change user of it) after that: |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |