[RESOLVED] Request to create plugin

Everything about development and the OpenMW source code.
Post Reply
Glorfdev
Posts: 77
Joined: 02 Mar 2013, 19:55
Location: Poznań, Poland

[RESOLVED] Request to create plugin

Post by Glorfdev »

I look for somebody who can create plugin that will show if player is detected by some NPC. I cannot use CS because I'm currently only on linux machine and I've discovered that I cannot create plugins there.

The plugin could be based on code from Morrowind Scripting for Dummies (the best piece code that I've found). I've pasted it below:

Code: Select all

Begin PCLookAtMe
float fPCX
float fPCY
float fPCAngle
float fdx
float fdy
float fRatio
short sPCLookAtMe
set sPCLookAtMe to 1
;you could probably also add a GetLOS check in here
; however i could never get GetLOS to work properly...although i didn't try very hard
;is PC really far away
if ( GetDistance, Player > 8000 )
set sPCLookAtMe to 0
else
;yay trigonometry
;this basically does a rough calculation of the PCs direction relative
;to the Actor, it only uses 45 degree chunks, though
set fPCX to ( player->GetPos, X )
set fPCY to ( player->GetPos, Y )
set fPCAngle to ( player->GetAngle, Z )
set fdx to GetPos, X
set fdy to GetPos, Y
set fdx to ( fdx - fPCX )
set fdy to ( fdy - fPCY )
set fRatio to ( fdx / fdy )
if ( fdx > 0 )
if ( fdy > 0 )
if ( fRatio > 1 )
if ( fPCAngle < -45 )
set sPCLookAtMe to 0
endif
else
if ( fPCAngle < -90 )
set sPCLookAtMe to 0
endif
if ( fPCAngle > 135 )
set sPCLookAtMe to 0
endif
endif
else
if ( fRatio < -1 )
if ( fPCAngle < 0 )
if ( fPCAngle > -135 )
set sPCLookAtMe to 0
endif
endif
else
if ( fPCAngle < 45 )
if ( fPCAngle > -90 )
set sPCLookAtMe to 0
endif
endif
endif
endif
else 
if ( fdy > 0 )
if ( fRatio < -1 )
if ( fPCAngle > 45 )
set sPCLookAtMe to 0
endif
else
if ( fPCAngle > 90 )
set sPCLookAtMe to 0
endif
if ( fPCAngle < -135 )
set sPCLookAtMe to 0
endif
endif
else
if ( fRatio > 1 )
if ( fPCAngle > 0 )
if ( fPCAngle < 135 )
set sPCLookAtMe to 0
endif
endif
else
if ( fPCAngle > -35 )
if ( fPCAngle < 90 )
set sPCLookAtMe to 0
endif
endif
endif
endif
endif
endif
if ( sPCLookAtMe == 0 )
;do something while the PC is not looking
endif
End 
When this concrete NPC is looking, something should change, because I must recognize this situation... Just use your imagination, move some objects, show message or something like that.

Thanks in advance!
Last edited by Glorfdev on 21 Aug 2013, 17:14, edited 1 time in total.
Glorfdev
Posts: 77
Joined: 02 Mar 2013, 19:55
Location: Poznań, Poland

Re: Request to create plugin (for reversing formulas purpose

Post by Glorfdev »

No way. It breaks when launching on linux.
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Request to create plugin (for reversing formulas purpose

Post by scrawl »

CS in wine can't save new files, but it can open existing files and save them.
Glorfdev
Posts: 77
Joined: 02 Mar 2013, 19:55
Location: Poznań, Poland

Re: Request to create plugin (for reversing formulas purpose

Post by Glorfdev »

You're right! Thanks scrawl
User avatar
potatoesmaster
Posts: 112
Joined: 26 Dec 2012, 17:01

Re: Request to create plugin (for reversing formulas purpose

Post by potatoesmaster »

For that kind of thing, I use MWEdit to create the plugin, and open it in the CS to save it again (it remove some error messages when I load the plugin in vanilla). MWEdit works well with Wine and load files more rapidly than vanilla CS, but it does not have a 3d view.
Post Reply