• Welcome to Battlezone Universe.
 

News:

Welcome to the BZU Archive dated December 24, 2009. Topics and posts are in read-only mode. Those with accounts will be able to login and browse anything the account had access granted to at the time. No changes to permissions will be made to be given access to particular content. If you have any questions, please reach out to squirrelof09/Rapazzini.

Main Menu

Spinoff: Uncle Avatar's Scriptor, C++ and Python Time...

Started by General BlackDragon, April 23, 2008, 06:03:45 PM

Previous topic - Next topic

OvermindDL1

Quote from: Sonic on April 24, 2008, 09:22:54 AM
Don't forget with the scriptor, you can come up with a hybrid of C++ and Scriptor code. The source code for the scriptor's dll is available and can be tweeked. If you have functions that are common for you (say look for a pod x being built than do this..that...then this), you could have that written in C++ into the DLL Scriptor's common code. This is basicly how FE's portals are working, the code is in the base C++ code for the scriptor.
And in my Python scriptor you can arbitrarilly load other dll's that have helper functions or what-not all you want, without needing to change the base scriptor dll and possible breaking other scripts if you are not careful and reuse it later. :P

Generated by OvermindDL1's Signature Auto-Add Script via GreaseMonkey


Sonic

I don't see how you would break other scripts. The scriptor lets you choose your 'base' DLL code. So your custom code will only be applied to the DLL you choose to compile with that code. Thus, my night light map is not affected by my custom code in my theory x/y map dll which used custom code.
"Linux is user friendly...
...it's just very selective about who its friends are."

Nielk1

Quote from: OvermindDL1 on April 24, 2008, 12:12:30 PM
And in my Python scriptor you can arbitrarilly load other dll's that have helper functions or what-not all you want, without needing to change the base scriptor dll and possible breaking other scripts if you are not careful and reuse it later. :P

Generated by OvermindDL1's Signature Auto-Add Script via GreaseMonkey



I want to do that in C++. I was thinking about making some DLLs to do things like -anti shield towers- that monitored for any object of a classlabel (new ODF inheritance would let me fake a new class label) and then threw the appropriate things into vectors, maps, or arrays and processed them later.


ALSO, after the split my post about making a "Stalker Nielk1's DLL Time" looks odd and misplaced :-P

EDIT: I should state I am proficient in Java, but can get around many languages, which is why something obvious might not occur to me.

EDIT2:
So far I am editing existing DLLs:

I should note that was before I finally found the toggle for release build instead of debug build and stopped the odd debug over spawn that caused issues likes lost AI units and 1 bot meaning 10, all in the same spacial coordinate.

Click on the image...

OvermindDL1

By that I meant if it reused that code, but some alteration was made that was not accounted for when used later on.  I prefer explicit rather then implicit as coding terminology goes. :)

Generated by OvermindDL1's Signature Auto-Add Script via GreaseMonkey


Nielk1

How can I program a mission DLL in C++, and have it call in other compiled mission DLL functions? Or is that imposable in C++ and I am thinking about Java's recompiled classes?

EDIT:
I'm just messing around now:
void instantMission::Execute(void)
{
ElapsedGameTime++;
player=GetPlayerHandle();
turn_counter++;
DoGenericStrategy();

DoNielk1();
}
void instantMission::DoNielk1()
{
if(n1QuakeOn)
{
if(GetCurAmmo(GetPlayerHandle()) == 0)
{
StopEarthQuake();
n1QuakeOn = false;
}else{
UpdateEarthQuake(GetCurAmmo(GetPlayerHandle()));
}
}else{
n1QuakeOn = true;
}
}

Click on the image...

OvermindDL1

Just be sure to expose the other functions/classes/whatever from the other dll as per the normal library ways (external definition file, ccall exposing, ordinal link, etc... there are a few ways to do so), then just link it in to the dll that is going to use it, quite simple. :)

Do remember, pretty much nothing is impossible in C/C++, java is far far far more restrictive then C/C++ could ever be. :P

Generated by OvermindDL1's Signature Auto-Add Script via GreaseMonkey


Nielk1

Quote from: OvermindDL1 on May 09, 2008, 11:05:58 AM
external definition file, ccall exposing, ordinal link, etc...

OK, you just threw terms at me that I don't yet begin to pretend to understand. I guess the correct question would be, how would YOU do it? I want it to be simple enough that anyone making a DLL can take my helper DLL and easily include it, then just have to send it the right info.

--

So, I would need to make a DLL from scratch, somehow include it into the BZ2 DLL, and then call its functions?
I am so used to just creating an instance of a precompiled Java class and then using it, how exactly do I go about using the DLL?

I take it that to make the DLL I just need a simple blank project set to compile as a DLL, and then the functions that are public are accessible. There might be a template in Visual Studio for DLL, I am not sure. The most I have done in C++ is make console APPS.

Click on the image...

Nielk1

I'm just toying around atm, this was a fun bit of code for visual effect:

int team1color = 0;
bool team1colorup = true;

void instantMission::Execute(void)
{
...
TeamColorFun();
}

void instantMission::TeamColorFun(void)
{
if(team1colorup)
{
team1color+=5;
if(team1color>=255)
{
team1colorup = false;
}
}else{
team1color-=5;
if(team1color<=0)
{
team1colorup = true;
}
}
SetTeamColor(1, team1color, 255-team1color, 0);
}

Click on the image...

OvermindDL1

Export functions as normal, set them to extern "C" calling convention (if you start up a new shared DLL project in VisualStudio you can see examples of that) and declspec them to be visible (also shown in a new shared dll project).  To import into another just loadlibrary (look that up in the VisualStudio help, good example there) and load the function by name from that and assign it to a function pointer (also demonstrated on that msdn page).  That would be the easiest way to do it if you are only dealing with a few and you do not want to hard link those files together (and it lets you see the return value of loadlibrary to see if it exists, if it doesn't then you can turn off certain features that it would have given, else if it returns a good value then the library is available and you can have special stuff happen).

Generated by OvermindDL1's Signature Auto-Add Script via GreaseMonkey


bigbadbogie

... and you expect us numnuts to be able to do c++??  :-D
Others would merely say it was good humour.


My BZ2 mods:

QF2: Essence to a Thief - Development is underway.

Fleshstorm 2: The Harvest - Released on the 6th of November 2009. Got to www.bz2md.com for details.

QF Mod - My first mod, finished over a year ago. It can be found on BZ2MD.com

OvermindDL1

Everything I mentioned is C, not C++ (well, the extern "C" is C++, telling it to make the calling convention of that function/variable/etc... C style, thus it is not there for C...). :P


Generated by OvermindDL1's Signature Auto-Add Script via GreaseMonkey


bigbadbogie

Others would merely say it was good humour.


My BZ2 mods:

QF2: Essence to a Thief - Development is underway.

Fleshstorm 2: The Harvest - Released on the 6th of November 2009. Got to www.bz2md.com for details.

QF Mod - My first mod, finished over a year ago. It can be found on BZ2MD.com

OvermindDL1

Well Nielk1 was the one who asked, as such I was responding to his question. :P


Generated by OvermindDL1's Signature Auto-Add Script via GreaseMonkey


Nielk1

Ah, found the add object function... Should have looked at the interface of the DLLBase class I was inheriting in the first place. DOIY! This solves a lot of headaches.

This is kinda fun now, I love working in looped logic like this.

Click on the image...

BNG Da BZ Fool

Is C different then C#? Just though I'd ask for clarification. I'm just getting started with C++, but the Dark Basic GDK looks very interesting for gaming applications. I've also come across a few code snippets that I'd like to experiment to help me get a clue about how C++ logically works. I'm also hoping that C++ eventually reveals some of it's cool little secrets. I guess it's more or less having a lot of patients and then connecting the dots as they reveal themselves...BNG
When I'm not in hot water with the community I'm usually making models for BZII. I've made a few models for other peeps. BNG.