Battlezone Universe

Battlezone Universe => Battlezone 2 => Maps and Modding => Topic started by: shane ward on November 10, 2008, 09:05:02 PM

Title: Dll Object placement Help
Post by: shane ward on November 10, 2008, 09:05:02 PM
Yep need a little help, how can I get my children to be good ;)

Oopss, sorry wrong thing... Never mind, I thought I know everything about using the scriptor but even I gets into a little trouble, OK Down to business.

What I am after is a way or command to get objects that are placed in a map to face a given position, like dropships,

I need my dropships to face each other and units will then come out of them into a centre point, Like the dropships are all in a circle formation then the doors open and the ships all come out into the middle of the circle.

But I need the dll to add the landing dropship, replace it with the flying one and then take off.  But I am not sure how to get the dropships to face in the correct angle..

Thanks
Shane
Title: Re: Dll Object placement Help
Post by: GSH on November 10, 2008, 09:34:01 PM
To set an angle, pass in a matrix to BuildObject. To set the angle you want, look at http://en.wikipedia.org/wiki/Rotation_matrix (http://en.wikipedia.org/wiki/Rotation_matrix) -- given an angle, you can build the matrix you want.

Some sample code, based on the wiki matrices:

Matrix m;

// Make matrix rotated around X axis
memset(&m, 0, sizeof(m)); // clear to all 0's
m.right.x = m.positw = 1.0f;
m.up.y = m.front.z = portable_cos(angle); // angle needs to be in radians, i.e. degrees * 180.0f / Pi
m.front.y = portable_sin(angle);
m.up.z = -m.front.y; // == -1.0f * portable_sin(angle);


// Make matrix rotated around Y axis
memset(&m, 0, sizeof(m)); // clear to all 0's
m.up.y = m.positw = 1.0f;
m.right.x = m.front.z = portable_cos(angle); // angle needs to be in radians, i.e. degrees * 180.0f / Pi
m.right.z = portable_sin(angle);
m.front.x = -m.right.z; // == -1.0f * portable_sin(angle);

etc

-- GSH
Title: Re: Dll Object placement Help
Post by: shane ward on November 10, 2008, 09:49:16 PM
Thanks very much for the help GSH, But I one major disavantage. I cannot code in C++ or whatever the dll's are made, I am using the dll scriptor, so I need the command for the scriptor...

Hay I bet the people that made the dll's when the game was being made wished they had all the tools we have now ;)

Shane
Title: Re: Dll Object placement Help
Post by: GSH on November 10, 2008, 09:59:57 PM
Knowing what I do now, if we had the chance for a do-over, I'd make the DLL & AIP files big lua files. Then again, lua wasn't really in a usable state back in 1998. I know some people would prefer python, but I've used lua far more, and its memory footprint is far more reasonable, which would have been important in 1999/2000.

-- GSH
Title: Re: Dll Object placement Help
Post by: shane ward on November 10, 2008, 10:27:01 PM
Would be easy if the dll's where just simple script laid out like the dll scriptor and I think the aip files are fine, remember it is easy for modders to learn and make, but I do believe the dll's are far more complicated which can throw a lot of people of making mods if it was not for the dll scriptor, just imagine if the game was popular back then.

I also find it useful that everything is not all bunched into one big file, ODF, Graphics, Shell, Cfgs, maps, sounds and that. Makes it easy to know what you are doing, but can get into a mess if the modder is not organised

shane
Title: Re: Dll Object placement Help
Post by: Nielk1 on November 10, 2008, 10:29:35 PM
DLLs are simple scripts! That is when they are still in C++ source code form.

I need to see how to replace an object with C++, IIRC, there is no replace command, which means what the scriptor does is actually remove and place an item in the same area. I have to look, there might have been a replace.
Title: Re: Dll Object placement Help
Post by: OvermindDL1 on November 11, 2008, 12:32:03 AM
Quote from: GSH on November 10, 2008, 09:59:57 PM
Knowing what I do now, if we had the chance for a do-over, I'd make the DLL & AIP files big lua files. Then again, lua wasn't really in a usable state back in 1998. I know some people would prefer python, but I've used lua far more, and its memory footprint is far more reasonable, which would have been important in 1999/2000.
True, lua is much better for basic game scripting.  I only used Python because at the time LUA did not have coroutine support (I did make a LUA scriptor for BZ2 as well, and it is functional, might still be to this day, I have the source code around here somewhere, just needs to be updated from version 4.0 to the current), and full coroutine support is just way to freaking nice for scripts like these missions. :P
(http://www.overminddl1.com/image_scripts/image_sig.php?type=ODL1signitures&image/sig.gif)
Generated by OvermindDL1's Signature Auto-Add Script (http://overminddl1.com) that OvermindDL1 did manually since Greasemonkey does not work in Firefox 3.1 yet...

Title: Re: Dll Object placement Help
Post by: GSH on November 11, 2008, 01:05:54 AM
Quote
I need to see how to replace an object with C++, IIRC, there is no replace command, which means what the scriptor does is actually remove and place an item in the same area. I have to look, there might have been a replace.

Replace is just a remove and create. It's not hard to do this in C++:

// Replaces an object with a new one sharing characteristics. Returns 0 on any problems.
Handle ReplaceObject(Handle h, char* odf)
{
if(h == 0)
return 0;

float healthRatio = GetHealth(h);
float ammoRatio = GetAmmo(h);
int team = GetTeamNum(h);
Matrix m;
GetPosition(h, m);

RemoveObject(h);

Handle newH = BuildObject(odf, team, m);
if(newH == 0)
return 0;

SetCurHealth(newH, healthRatio * GetMaxHealth(newH));
SetCurAmmo(newH, ammoRatio * GetMaxAmmo(newH));
return newH;
}

If I can do this in 3-4 minutes eyeballing scriptutils.h, so can you.

-- GSH
Title: Re: Dll Object placement Help
Post by: Warfreak on November 11, 2008, 01:24:04 AM
I don't know why, but i can READ lua, jsut cant WRITE in it, i tried once.... lets jsut the game completely crashed.  :cry:
Title: Re: Dll Object placement Help
Post by: TheJamsh on November 11, 2008, 02:27:03 PM
i can only use .dll scriptor... learning C++ is jsut something i dont have time for these days.
Title: Re: Dll Object placement Help
Post by: AHadley on November 11, 2008, 04:44:45 PM
Why have both of you both spelt jsut wrong?

I have got to learn C++ and other languages... any ideas where I can go?

gotta learn scriptor too, maybe I'll do that first.
Title: Re: Dll Object placement Help
Post by: Warfreak on November 11, 2008, 05:06:00 PM
http://www.functionx.com (http://www.functionx.com)

Has tutorials on C++ and all derivatives of it. Even has tutorials on how to use the programming enviroments that are avaliable.
Title: Re: Dll Object placement Help
Post by: AHadley on November 11, 2008, 05:29:11 PM
Ouch, that's gonna take a while.
Title: Re: Dll Object placement Help
Post by: GSH on November 11, 2008, 06:36:56 PM
I recommend Bruce Eckel's Thinking in C++ as a reference to learn C++. It's a free download from http://www.mindview.net/Books/DownloadSites/ (http://www.mindview.net/Books/DownloadSites/) -- his main site is http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html (http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html) .

There are recommendations for *how* to compile & modify C++ DLLs included w/ the DLL source that's been released with the 1.3 patches.

-- GSH
Title: Re: Dll Object placement Help
Post by: AHadley on November 12, 2008, 07:54:00 AM
Hmm, thanks!

*looks*

Sheesh, that's gonna take even longer!
Title: Re: Dll Object placement Help
Post by: Nielk1 on November 12, 2008, 04:14:29 PM
I said I would check but ya beat me to it GSH, thx again for more code.
Title: Re: Dll Object placement Help
Post by: AHadley on November 12, 2008, 06:42:58 PM
And still more code.
Title: Re: Dll Object placement Help
Post by: shane ward on November 12, 2008, 09:52:07 PM
OK Managed to find out how to do this, I just placed a spawn point on the map facing the direction I needed, then the dll will replace the spawnpoint with a dropship. Workes like a charm.....

Shane