View unanswered posts | View active topics It is currently Sat Apr 27, 2024 4:22 am



Reply to topic  [ 8 posts ] 
 Modification of aiming distance [SOLVED] 
Author Message

Joined: Fri Jul 06, 2012 7:20 am
Posts: 44
Reply with quote
Post 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.


Last edited by Visage on Mon Jul 16, 2012 9:58 pm, edited 2 times in total.



Fri Jul 06, 2012 7:48 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post 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
Profile

Joined: Fri Jul 06, 2012 7:20 am
Posts: 44
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: Modification of aiming distance
Try ToHDFirearm(self.EquippedItem).SharpLength


Sun Jul 15, 2012 9:48 am
Profile
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post 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
Profile YIM

Joined: Fri Jul 06, 2012 7:20 am
Posts: 44
Reply with quote
Post 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
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post 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.


Mon Jul 16, 2012 7:55 pm
Profile

Joined: Fri Jul 06, 2012 7:20 am
Posts: 44
Reply with quote
Post 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.


Mon Jul 16, 2012 9:43 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.088s | 15 Queries | GZIP : Off ]