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?
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.
Code:
function Create(self) self.Ugraded = false --a variable for the actor to determine whether the range has been tampered with or not end
function Update(self) if self:IsInventoryEmpty() ~= true then -- if the cupbards ain't bare if (self.Ugraded == false) and (self:GetController():IsState(13) == true) then -- if our scope is still lame, but we're trying to use it ToHDFirearm(self.EquippedItem).SharpLength = ToHDFirearm(self.EquippedItem).SharpLength*5 -- MAKE IT SHINY!!!!!!! self.Ugraded = true -- and make sure it doesn't get TOO out of hand... Oh, wait, it's already 5x :P end if (self.Ugraded == true) and (self:GetController():IsState(13) ~= true) then -- Sharpaiming is state 13 -- and the gun's been tampered with, but we aren't scoping ToHDFirearm(self.EquippedItem).SharpLength = ToHDFirearm(self.EquippedItem).SharpLength/5 -- keep ppl from cheating self.Ugraded = false -- make sure we know to FUN when we next scope in end end end
Last edited by Visage on Mon Jul 16, 2012 9:58 pm, edited 2 times in total.
Fri Jul 06, 2012 7:48 am
Asklar
Data Realms Elite
Joined: Fri Jan 07, 2011 8:01 am Posts: 6211 Location: In your office, earning your salary.
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.
Sat Jul 07, 2012 4:50 am
Visage
Joined: Fri Jul 06, 2012 7:20 am Posts: 44
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?
Sun Jul 15, 2012 9:35 am
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
Re: Modification of aiming distance
Try ToHDFirearm(self.EquippedItem).SharpLength
Sun Jul 15, 2012 9:48 am
Arcalane
Joined: Sun Jan 28, 2007 10:32 pm Posts: 1609 Location: UK
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.
Sun Jul 15, 2012 10:33 am
Visage
Joined: Fri Jul 06, 2012 7:20 am Posts: 44
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.
Mon Jul 16, 2012 6:57 pm
Asklar
Data Realms Elite
Joined: Fri Jan 07, 2011 8:01 am Posts: 6211 Location: In your office, earning your salary.
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)
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.
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