View unanswered posts | View active topics It is currently Thu Dec 26, 2024 6:02 pm



Reply to topic  [ 15 posts ] 
 Appearing behind target 
Author Message
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 Appearing behind target
I'm trying to make a gun that when it is fired it makes you appear behind your target and facing it, but it's not working.

Code:
elseif self.Technique == 8 then
      if self.target.HFlipped == false and self.parent.HFlipped == false then
         self.parent.Pos = self.target.Pos + Vector(18,0)
         self.parent.HFlipped = true
      elseif self.target.HFipped == true and self.parent.HFlipped == true then
         self.parent.Pos = self.target.Pos - Vector(18,0)
         self.parent.HFlipped = false
      elseif self.target.HFipped == false and self.parent.HFlipped == true then
         self.parent.Pos = self.target.Pos - Vector(18,0)
         self.parent.HFlipped = false
      elseif self.target.HFipped == true and self.parent.HFlipped == false then
         self.parent.Pos = self.target.Pos + Vector(18,0)
         self.parent.HFlipped = true
      end   
   end


I've already put some prints in other parts of the code to check that every variable is working, it recognizes the parent, the target, that self.Technique == 8, but it won't work.

Help?


Sat May 21, 2011 9:50 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Appearing behind target
So, the user doesn't teleport at all?


Sat May 21, 2011 9:56 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: Appearing behind target
No, it's not moving. Any ideas of why this is happening?


Sat May 21, 2011 10:01 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Appearing behind target
Everything looks fine to me. You sure 'self.Technique' is being set to 8?

Posting the entire script might help too.


Sat May 21, 2011 10:43 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: Appearing behind target


There, the entire script. I don't get errors at all, everything works perfect. Well, everything except Technique 8.


Sat May 21, 2011 10:45 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Appearing behind target
Dump a few print() inside 'Technique == 8'

Printing the 'self.target.Pos' might be helpful too.


Sat May 21, 2011 11: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: Appearing behind target
I added this:
Code:
   elseif self.Technique == 8 then
      print(self.target.Pos)
      if self.target.HFlipped == false and self.parent.HFlipped == false then
         self.parent.Pos = self.target.Pos + Vector(18,0)
         self.parent.HFlipped = true
         print(self.target.Pos.."LOL")
      elseif self.target.HFipped == true and self.parent.HFlipped == true then
         self.parent.Pos = self.target.Pos - Vector(18,0)
         self.parent.HFlipped = false

         print(self.target.Pos.."LOL2")
      elseif self.target.HFipped == false and self.parent.HFlipped == true then
         self.parent.Pos = self.target.Pos - Vector(18,0)
         self.parent.HFlipped = false

         print(self.target.Pos.."LOL34")
      elseif self.target.HFipped == true and self.parent.HFlipped == false then
         self.parent.Pos = self.target.Pos + Vector(18,0)
         self.parent.HFlipped = true

         print(self.target.Pos.."LOL69")
      end   
   end


To the script, but it is only printing the first print, so it is actually considering that it is in Technique == 8, but it is not considering the other if inside that if, because it hasn't printed anything with LOL.


Sun May 22, 2011 12:30 am
Profile
User avatar

Joined: Sat Feb 26, 2011 10:29 am
Posts: 163
Reply with quote
Post Re: Appearing behind target
Is your gun a super-close combat weapon? Cause I found the script only search target in function Create(self), and the detection range is only 35(the same as parent searching).


Sun May 22, 2011 4:47 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: Appearing behind target
Uhm, CQC Skills isn't enough clue?

Well, you know to code pretty well too, can you see why it isn't working?


Sun May 22, 2011 5:31 am
Profile
User avatar

Joined: Sat Feb 26, 2011 10:29 am
Posts: 163
Reply with quote
Post Re: Appearing behind target
I didn't notice the meaning of "CQC" before you remind me of it(shame
I put these code into my mod and tested several times, quite sure that the code in OP is the problem. Gonna make further checks.
-------------------------------------------------------------------
Done. More simple code, and it works. But I don't know why. The code's tested in an actor's script. Not sure if it works on bullets.


Sun May 22, 2011 7:07 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: Appearing behind target
You condemned Xery, I found out why you made it work!

It's because of this:
Code:
      if not self.target.HFlipped and not self.parent.HFlipped then
         self.parent.Pos = self.target.Pos + Vector(18,0)
         self.parent.HFlipped = true
      elseif self.target.HFlipped and self.parent.HFlipped then
         self.parent.Pos = self.target.Pos - Vector(18,0)
         self.parent.HFlipped = false
      elseif not self.target.HFlipped and self.parent.HFlipped then
         self.parent.Pos = self.target.Pos - Vector(18,0)
         self.parent.HFlipped = false
      elseif self.target.HFlipped and not self.parent.HFlipped then
         self.parent.Pos = self.target.Pos + Vector(18,0)
         self.parent.HFlipped = true


In the if statement, you must place self.HFlipped or not self.HFlipped rather than self.HFlipped == true or self.HFlipped == false!

Damn, thanks Xery, that was a lot of help. Serious.


Sun May 22, 2011 7:51 am
Profile
User avatar

Joined: Sat Feb 26, 2011 10:29 am
Posts: 163
Reply with quote
Post Re: Appearing behind target
But.....why? I'd replaced all of these in my mod because I feel it looking better, however, they should be the same in theory.

Also, your code can be simplified as

It's somewhat strange according to your description about the function.


Sun May 22, 2011 8:23 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: Appearing behind target
I'll try that Xery.

Much thanks, you are a pretty good scripter.


Sun May 22, 2011 8:10 pm
Profile
User avatar

Joined: Sat Feb 26, 2011 10:29 am
Posts: 163
Reply with quote
Post Re: Appearing behind target
Asklar wrote:
I'll try that Xery.

Much thanks, you are a pretty good scripter.


My pleasure. Btw, can anyone tell me that which choice below is better for detection?
1.ShortestDistance
2.dist < math.sqrt(avgx ^ 2 + avgy ^ 2)
3.CastMORay


Sun May 22, 2011 8:44 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Appearing behind target
I use (3) for line-based detection and (1) for area-based detection.


Sun May 22, 2011 9:01 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 15 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.325s | 13 Queries | GZIP : Off ]