Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is it possible to use AS to operate another file?
#1
Is it possible to use AS to input or output in another file?

I tried to use FILE as in C language, but it didn't work.
It would be soooo wonderful to have this function.


And I am using ddraw.dll to script AI, and learnt from YinYin.
But how do this ddraw.dll work? How can we change something, like changing the name of folder that the AS files are put in.


And is it possible to encode AS file in some sense that other people can use the AS file as a AI for LF2 but cannot see what was composed in the AS file?
Reply
Thanks given by:
#2
I think if it were so easy, Silva would hack it out already.
This is probably so hardcoded, that we don't have an exact path to reveal it.



[Image: NsiNMB9.png]

Help me and test my new game basis!




Reply
Thanks given by:
#3
Depending on your understanding of C++ you can basically add all of the above yourself. The source code is available and you are free to modify it however your want really.
I'll go into a bit more detail below:

(10-28-2014, 07:46 AM)like1996 Wrote:  Is it possible to use AS to input or output in another file?

I tried to use FILE as in C language, but it didn't work.
It would be soooo wonderful to have this function.
This was requested by zort, but I decided not to add it, as allowing modifying files is a pretty big vulnerability. That said adding it is entirely possible, and AngelScript already has an add on which is does this: http://www.angelcode.com/angelscript/sdk..._file.html

(10-28-2014, 07:46 AM)like1996 Wrote:  And I am using ddraw.dll to script AI, and learnt from YinYin.
But how do this ddraw.dll work? How can we change something, like changing the name of folder that the AS files are put in.
It is kind of hard to explain, and on top of that I am awful at explaining things, but I'll do my best.
Whenever "lf2.exe" starts it looks for a dll file named "ddraw.dll". ddraw stands for DirectDraw which is a part of the DirectX library, and normally this file is located on your computer within your windows installation. What we do is place a DLL with the same name so LF2 loads it instead. Our DLL loads the original "ddraw.dll" into the program, and reimplements the functionality.
On top of this the DLL also modifies the code of "lf2.exe" so whenever it runs its AI functions, a custom function within the DLL is called instead, which then checks whether or not a script exists for the ID. If it does then that script is called, if not then the function simply calls the original one in "lf2.exe".

(10-28-2014, 07:46 AM)like1996 Wrote:  And is it possible to encode AS file in some sense that other people can use the AS file as a AI for LF2 but cannot see what was composed in the AS file?
Yes, although it isn't something I'd recommend. You could either obfuscate the code, by putting in a bunch of code which does nothing, and renaming variables to crazy things, thus making it harder to read.
There is an alternative which I have no clue how will actually work. Basically before AngelScript can run a script it first has to compile it into bytecode. If you want you can save this bytecode to a file, and then read that file instead of a script (this would require modifying the DLL, take a look at this: http://www.angelcode.com/angelscript/sdk...mpile.html).
Like I said though it's not something I'd recommend doing. The first solution can cause a drop in performance (by adding code which does nothing, yet still has to be executed) and the second one may or may not behave weirdly, I have no clue basically. Either way I don't think protecting your code is that important if you are making a mod, or a character, and sharing it will generally benefit the community more.
Age ratings for movies and games (and similar) have never been a good idea.
One can learn a lot from reinventing wheels.
An unsound argument is not the same as an invalid one.
volatile in C++ does not mean thread-safe.
Do not make APIs unnecessarily asynchronous.
Make C++ operator > again
Trump is an idiot.
Reply
Thanks given by:
#4
(10-28-2014, 05:16 PM)Someone else Wrote:  Depending on your understanding of C++ you can basically add all of the above yourself. The source code is available and you are free to modify it however your want really.
I'll go into a bit more detail below:

(10-28-2014, 07:46 AM)like1996 Wrote:  Is it possible to use AS to input or output in another file?

I tried to use FILE as in C language, but it didn't work.
It would be soooo wonderful to have this function.
This was requested by zort, but I decided not to add it, as allowing modifying files is a pretty big vulnerability. That said adding it is entirely possible, and AngelScript already has an add on which is does this: http://www.angelcode.com/angelscript/sdk..._file.html

(10-28-2014, 07:46 AM)like1996 Wrote:  And I am using ddraw.dll to script AI, and learnt from YinYin.
But how do this ddraw.dll work? How can we change something, like changing the name of folder that the AS files are put in.
It is kind of hard to explain, and on top of that I am awful at explaining things, but I'll do my best.
Whenever "lf2.exe" starts it looks for a dll file named "ddraw.dll". ddraw stands for DirectDraw which is a part of the DirectX library, and normally this file is located on your computer within your windows installation. What we do is place a DLL with the same name so LF2 loads it instead. Our DLL loads the original "ddraw.dll" into the program, and reimplements the functionality.
On top of this the DLL also modifies the code of "lf2.exe" so whenever it runs its AI functions, a custom function within the DLL is called instead, which then checks whether or not a script exists for the ID. If it does then that script is called, if not then the function simply calls the original one in "lf2.exe".

(10-28-2014, 07:46 AM)like1996 Wrote:  And is it possible to encode AS file in some sense that other people can use the AS file as a AI for LF2 but cannot see what was composed in the AS file?
Yes, although it isn't something I'd recommend. You could either obfuscate the code, by putting in a bunch of code which does nothing, and renaming variables to crazy things, thus making it harder to read.
There is an alternative which I have no clue how will actually work. Basically before AngelScript can run a script it first has to compile it into bytecode. If you want you can save this bytecode to a file, and then read that file instead of a script (this would require modifying the DLL, take a look at this: http://www.angelcode.com/angelscript/sdk...mpile.html).
Like I said though it's not something I'd recommend doing. The first solution can cause a drop in performance (by adding code which does nothing, yet still has to be executed) and the second one may or may not behave weirdly, I have no clue basically. Either way I don't think protecting your code is that important if you are making a mod, or a character, and sharing it will generally benefit the community more.

Thank you very!!!much!!!!
But actually, I have no background in C or other more advanced language. I am a beginner.
I am learning from http://www.angelcode.com/angelscript/sdk...index.html now, which has tons of codes, and I am working on it.


Your explanation of the dll file makes sense to me! THANKS!
And maybe some time later, I will try to edit the dll file!

Coding the file is really something I would do when my code gets more complicated.
And it is useful when people cannot know how an AI works and try to beat the AI based on knowledge in LF2 but not from scripts.
And this is kind of why I need to operate another file by AngelScript, I can use another file to serve as a button or screen, which can be used to open/close functions and show some results.

And finally, I truly need to know how to input/output on another file, because when some core codes are modified, I want to use "machine learning" concept to make the AI evolve............Never mind, this is just a thought, as I said, i am a beginner, and is just learning, maybe the AI won't evolve , but who knows~ just find it out later, maybe.

(10-28-2014, 01:54 PM)Gad Wrote:  I think if it were so easy, Silva would hack it out already.
This is probably so hardcoded, that we don't have an exact path to reveal it.

Is silva another master in coding!!!!
I just come the day before yesterday~ no idea who he is, sorry~
Reply
Thanks given by:
#5
(10-28-2014, 06:49 PM)like1996 Wrote:  Is silva another master in coding!!!!
I just come the day before yesterday~ no idea who he is, sorry~
Silva was the one who originally created the AI DLL. At the time he was using another scripting language called ChaiScript which I complained about. He gave me the source code, so I could implement AngelScript instead, and asked me to release the source code as well when I had implemented it.
He is also known for having made a bunch of modifications on the executable, which is something most people find very hard to do.

His profile: http://www.lf-empire.de/forum/member.php...file&uid=8
Age ratings for movies and games (and similar) have never been a good idea.
One can learn a lot from reinventing wheels.
An unsound argument is not the same as an invalid one.
volatile in C++ does not mean thread-safe.
Do not make APIs unnecessarily asynchronous.
Make C++ operator > again
Trump is an idiot.
Reply
Thanks given by:
#6
(10-28-2014, 10:21 PM)Someone else Wrote:  
(10-28-2014, 06:49 PM)like1996 Wrote:  Is silva another master in coding!!!!
I just come the day before yesterday~ no idea who he is, sorry~
Silva was the one who originally created the AI DLL. At the time he was using another scripting language called ChaiScript which I complained about. He gave me the source code, so I could implement AngelScript instead, and asked me to release the source code as well when I had implemented it.
He is also known for having made a bunch of modifications on the executable, which is something most people find very hard to do.

His profile: http://www.lf-empire.de/forum/member.php...file&uid=8
Thanks!
I am about to transfer to ECE and will minor in CS.
So I may devote tons of hours in scripting or programming.

Doing the AI is a start.

I like playing LF2 more, and really want to do great AI for different uses, like for specific training.
But I am still thinking about this, and haven't figured out everything needed before coding.

I will come up later with some codes.

Let's keep in touch through this forum!
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)