Freelancer Community Network
Reminder: Internet Explorer 6 or below are NOT supported.
HomeHome
ForumForum
WikiWiki
DownloadsDownloads
ForgeForge
Multiplayer Connection Tutorial
Collapse/Expand Random Image
Collapse/Expand Login
Username:

Password:

Remember me



Lost Password?

Register now!
Collapse/Expand Chat
Collapse/Expand Who's Online
77 user(s) are online (14 user(s) are browsing Forum)

Members: 0
Guests: 77

more...
Collapse/Expand Donations
Monthly costs: -30€
Income (ads): +4€
Donations (last month): +71€

Current balance: -25€
(last updated 09/2019)

Please make a donation if you want to help keeping The-Starport online:

Bitcoin address:
Thanks!
Collapse/Expand Links
Collapse/Expand Advertisement
There are currently 21 users playing Freelancer on 34 servers.
September. 20, 2019

Browsing this Thread:   1 Anonymous Users



 Bottom   Previous Topic   Next Topic  Register To Post

« 1 (2) 3 4 »


Re: Ship Spawning
Starport Admin
Joined:
2009/2/21 21:42
Group:
Webmasters
Registered Users
Posts: 3519
Offline
Well spawning ships is rock solid now, can spawn any ship with a custom AI at will.

What I'm trying to figure out now are, in order:
-How to stop the NPC from dropping all of its equipment on death
-How to control the NPC
-How to add the NPC to the "normal" NPC list so that it disappears automatically when out of range

I'm pretty sure the 1st point's key is in the ShipInfo struct, while the second point obviously lies in the reversal of the Op structs.

I wish I knew just how you can find things out so fast, adoxa

Posted on: 2010/7/1 1:30
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try."
-Peggy Noonan
Top
Re: Ship Spawning

Joined:
2008/5/29 1:28
Group:
Registered Users
Posts: 47
Offline
Quote:
I wish I knew just how you can find things out so fast, adoxa


He is the one, he can see the code

Posted on: 2010/7/1 2:48
Top
Re: Ship Spawning
Just can't stay away
Joined:
2008/6/9 1:11
Group:
Registered Users
Senior Members
Posts: 316
Offline
Yeah, me too. How is that even possible? Maybe I'm just not knowledgeable enough in the subject matter but I wasn't aware that you could even pull something so detailed (especially with regard to names of things) from just assembly level de-compilation.

Posted on: 2010/7/1 4:07
Open in new window
Top
Re: Ship Spawning
Home away from home
Joined:
2009/8/16 2:58
From Qld, Aus.
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 1908
Offline
Defining those structures was relatively trivial, due to exported constructors. Doing the points above will take a bit more effort, which I'll not do (not for a while, anyway, by which time I'll have forgotten). I expect point two can be solved by set_current_directive, so I suppose you want IDirectiveInfo and the remaining Ops?

Posted on: 2010/7/1 12:45
Top
Re: Ship Spawning
Starport Admin
Joined:
2009/2/21 21:42
Group:
Webmasters
Registered Users
Posts: 3519
Offline
I'm not asking you to do them at all, you're a busy man with a lot on your plate

What I wondered is whether you could give some insight on how to do what you do. A tutorial if you want, just some tips otherwise. I'd like to stop having to ask you or w0d all the time, but I've never gleaned much from disassemblies

Posted on: 2010/7/1 15:27
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try."
-Peggy Noonan
Top
Re: Ship Spawning
Home away from home
Joined:
2009/8/16 2:58
From Qld, Aus.
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 1908
Offline
Well, if you want to give it a go, here's an example using DirectiveFollowOp.

Code:
* Exported function [email protected]@[email protected]@[email protected]
|
=1<=====
062DAF30 8BC1                   mov     eax, ecx
062DAF32 33C9                   xor     ecx, ecx
062DAF34 C7400404000000         mov     dword[eax+04], 00000004
062DAF3B 894808                 mov     [eax+08], ecx
062DAF3E C7001CE13906           mov     dword[eax], [email protected]@[email protected]@[email protected]
062DAF44 89480C                 mov     [eax+0C], ecx
062DAF47 C7401000001643         mov     dword[eax+10], 43160000         ; 150
062DAF4E 894814                 mov     [eax+14], ecx
062DAF51 894818                 mov     [eax+18], ecx
062DAF54 89481C                 mov     [eax+1C], ecx
062DAF57 C740200000C843         mov     dword[eax+20], 43C80000         ; 400
062DAF5E C3                     ret

I have a separate program to demangle names, which gives us the namespace and constructor. [eax] is the virtual function table, [eax+04] & [eax+08] are from BaseOp. Looking at Follow in the mission files and where it reads it in content.dll (6F27400), +0C would be the nickname, but I still don't know what the other values are, apart from being float (probably maximum distance, x,y,z offset and something else). So assuming that, we can say:

Code:
namespace pub
{
  namespace AI
  {
    enum OP_TYPE { FollowOp = 4 }; // and the others, of course

    class DirectiveFollowOp : public BaseOp // inheritance based on observation
    {
    public:
      DirectiveFollowOp()/* : BaseOp( FollowOp )*/;
      // some more functions here, should be in the CoreSDK

      virtual bool validate();

      UINT   leader;       // 0
      float  max_distance; // 150
      Vector ofs;          // 0, 0, 0; copy constructor indicates Vector
      float  unknown;      // 400
    };
  }
}

Posted on: 2010/7/1 16:05
Top
Re: Ship Spawning
Starport Admin
Joined:
2009/2/21 21:42
Group:
Webmasters
Registered Users
Posts: 3519
Offline
Very nice, that should help a lot!

Can I know what program(s)/steps you use to get the output you've shown? I think I read you use Ollydbg to disassemble the DLLs, but how do you get the values like 150 or 400? From the INIs, from a debug process?

Posted on: 2010/7/1 19:38
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try."
-Peggy Noonan
Top
Re: Ship Spawning
Starport Admin
Joined:
2008/2/26 20:36
From Germany
Group:
Webmasters
Registered Users
Posts: 1772
Offline
0x43C80000 in float is 400

Posted on: 2010/7/1 21:14
Top
Re: Ship Spawning
Starport Admin
Joined:
2009/2/21 21:42
Group:
Webmasters
Registered Users
Posts: 3519
Offline
Excuse me while I go hang myself for being so blind. -_-

Posted on: 2010/7/1 21:21
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try."
-Peggy Noonan
Top
Re: Ship Spawning
Home away from home
Joined:
2009/8/16 2:58
From Qld, Aus.
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 1908
Offline
The listing was generated by a customised PEReaDeR, which I've attached, since I should do a bit more on it before releasing the patch (I haven't updated my first patches with Freddy's better code). Use perdr -b common.dll >common.lst for the listing shown. I've also included the demangler:

[tde] c:/Projects/undec ??[email protected]@[email protected]@[email protected]
public: __thiscall pub::AI::DirectiveFollowOp::DirectiveFollowOp(void)

Attach file:


zip perdr.zip Size: 285.80 KB; Hits: 225

Posted on: 2010/7/2 7:11
Top
Re: Ship Spawning
Home away from home
Joined:
2008/6/2 10:17
Group:
Registered Users
$$$ Supporters $$$
Senior Members
Posts: 1847
Offline
Quote:

FriendlyFire wrote:
Excuse me while I go hang myself for being so blind. -_-


Never do that.

Go blow away a criminal who escapes justice.

You will feel a lot better afterwards!

And then 8 years later they will let you out and you can do another one! Open in new window

Posted on: 2010/7/2 9:43
"C" for "Caterpillar"... "Cool"... "Cheesey"!
Top
Re: Ship Spawning
Starport Admin
Joined:
2009/2/21 21:42
Group:
Webmasters
Registered Users
Posts: 3519
Offline
Code:
class IMPORT DirectiveGotoOp : public BaseOp
{
public:
DirectiveGotoOp(class DirectiveGotoOp const &);
DirectiveGotoOp(void);
virtual bool validate(void);

public:
int x00;
int iGotoType; // 1 = Vec, 0 = Ship
Vector vPos; // pos
int iTargetID; // id
Vector vSpline1; // ?
Vector vSpline2; // ?
Vector vSpline3; // ?
Vector vSpline4; // ?
float fRange;
float fThrust;
bool x58; // in INIs, don't know what it does
bool x59; // Always true?
short iFlag; // 0 = goto, 1 = goto_cruise, 256 = goto_no_cruise
int x5C;
float x60; // 200
float x64; // 500
int x68;
int x6C;
};

Posted on: 2010/7/3 4:03
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try."
-Peggy Noonan
Top
Re: Ship Spawning
Home away from home
Joined:
2009/8/16 2:58
From Qld, Aus.
Group:
Registered Users
FLServer Admins
Trusted Speciality Developers
Senior Members
Posts: 1908
Offline
Remove x00.
iGotoType also has 2 = spline, 3 = undefined (I guess, that's what the constructor does).
short iFlag; is actually bool goto_cruise; bool goto_no_cruise; ("goto" is ignored).
x59 has no apparent reference in content (certainly not where it reads the Goto lines), maybe it gets used in common.

Posted on: 2010/7/3 8:55
Top
Re: Ship Spawning
Starport Admin
Joined:
2009/2/21 21:42
Group:
Webmasters
Registered Users
Posts: 3519
Offline
I gathered as much for the types (I just hadn't tested it). For the iFlag, I kinda guessed they'd be bools. It seems that goto_cruise overrides goto_no_cruise, too, if both are set to true inadvertently.

As for x00, I had to add that because of a hack I did to BaseOp. I can tell you it works perfectly right now so the definitions are proper

Posted on: 2010/7/3 15:08
"Cynicism is not realistic and tough. It's unrealistic and kind of cowardly because it means you don't have to try."
-Peggy Noonan
Top
Re: Ship Spawning

Joined:
2009/8/19 22:31
Group:
Registered Users
FLServer Admins
Posts: 22
Offline
Hello everyone,

I'm very interested in this topic, and I follow it since its beginning. Thanks to your great work, I slowly understand how to make NPC's spawning.

As Wodk4 said, It would be nice to give Waypoints to NPC. Unfortunately, I didn't reach this objective.

Here the first thing I tried to do :

Code:
pub::AI::DirectiveGotoOp testOP; testOP.iGotoType = 1; testOP.vPos.x = -14507; testOP.vPos.y = 124; testOP.vPos.z = 11492; testOP.iFlag = 256;
pub::AI::SubmitState(iSpaceObjID, (pub::AI::BaseOp*)&testOP);


but this does'nt work. (This would be too simple, you can laugh at me)

so I tried to use the Personality.cpp given by Adoxa, but unfortunately, I don't know how to use it. I tried to place it into server.h, in the AI namespace, but I have some errors.

Can you help me to find what's wrong ?
(No code required, but at least a little clue)

Thanks a lot,
Kid

Posted on: 2010/7/27 19:32
Top
« 1 (2) 3 4 »