Data Realms Fan Forums http://45.55.195.193/ |
|
Modification of aiming distance [SOLVED] http://45.55.195.193/viewtopic.php?f=75&t=31409 |
Page 1 of 1 |
Author: | Visage [ Fri Jul 06, 2012 7:48 am ] |
Post subject: | Modification of aiming distance [SOLVED] |
Could you make an actor that changes the aiming distance itself by .ini or script? As in make the actor aim at least/always 100 pixels(px), or 50 more than the given value, or multiply the value by something? Examples (pistol 50px, sniper 150px): -always 100px: --pistol: 100px --sniper: 100px -add 50px: --pistol: 100px --sniper: 200px -multiply x2: --pistol: 100px --sniper: 300px This is the code I came up with. It's pretty well safeguarded against cheating. It currently multiplies the range by 5x. I also commented it for great justice. |
Author: | Asklar [ Sat Jul 07, 2012 4:50 am ] |
Post subject: | Re: Modification of aiming distance |
I suppose that you could change the SharpLength of the equipped item of an actor via lua script, so I think it's possible, but I'm not sure. |
Author: | Visage [ Sun Jul 15, 2012 9:35 am ] |
Post subject: | Re: Modification of aiming distance |
I did some fooling around, and it seems SharpLength is simply inaccessible to Lua. All of this is in the actor's script's function Update(self) self.Health = 50 -- works fine print(self.EquippedItem.ClassName) -- works fine self.EquippedItem.SharpLength = 5 -- has no effect in the two below, "tostring" 's presence or absence makes no difference print(tostring(self.EquippedItem.SharpLength)) -- passes nil... after I just set it to 5. print(tostring(self.EquippedItem.SharpLength.ClassName)) -- says there isn't anything there, so I can't find anything in it Thoughts? |
Author: | CaveCricket48 [ Sun Jul 15, 2012 9:48 am ] |
Post subject: | Re: Modification of aiming distance |
Try ToHDFirearm(self.EquippedItem).SharpLength |
Author: | Arcalane [ Sun Jul 15, 2012 10:33 am ] |
Post subject: | Re: Modification of aiming distance |
Visage wrote: I did some fooling around, and it seems SharpLength is simply inaccessible to Lua. ... Thoughts? I can tell you for a fact that it isn't inaccessible - that is to say, that it is accessible to Lua. Mehman made an autoadjusting sniper rifle scope a while ago, very nice piece of work. Other than that I can't really offer any help, though I would suggest being careful with how you do this. If possible, it might be a good idea to try and figure out how to get the weapon's existing sharpaim and back it up, then restore it when the actor switches away from that weapon. Otherwise you're looking at other actors being able to take advantage of that modified sharpaim range (not that it does much) and possibly oddities like the sharpaim range increasing erratically because it's constantly adding to -- or multiplying -- the existing sharpaim value, since this will run every time the Update(self) section runs. Which is very frequently. |
Author: | Visage [ Mon Jul 16, 2012 6:57 pm ] |
Post subject: | Re: Modification of aiming distance |
Sweet. Thanks, guys. This makes me much more happy than it should. On the topic of limiting, I don't seem to be able to access the actor's UpperBodyState, a la this check: Code: if (self.UpperBodyState == 1) then print("self works") elseif (ToActor(self).UpperBodyState == 1) then print("ToActor(self) works") else print("BLARG") end Is there some way I can find whether an actor (AHuman, specifically) is sharpaiming or not? I posted a question about whether Lua events can be triggered by dropping items in the Q&A thread. |
Author: | Asklar [ Mon Jul 16, 2012 7:55 pm ] |
Post subject: | Re: Modification of aiming distance |
As far as I remember, you can't access the UpperBodyState (I wanted to access it for an old mod, but couldn't, though there is a huge workaround to get it which involved lots of tables and metatables and wierd things). But, you could use GetController():IsState(Controller.AIM_SHARP) For further help on that, check this. |
Author: | Visage [ Mon Jul 16, 2012 9:43 pm ] |
Post subject: | Re: Modification of aiming distance [SOLVED] |
Thanks for the tip. Anyways, I messed with the code, and it works now. My only real worry is if being gibbed while scoping will make the range permanent. I'm putting the code in the OP. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |