Some DLL issues / questions

Moderators: GSH, VSMIT, Red Devil, Commando

mase
Thunderbolt
Posts: 160
Joined: Sat Mar 05, 2011 11:17 am

Some DLL issues / questions

Post by mase »

Hello,

I'm currently trying to create an Instant Action AI using a DLL.
I do not want to use AIP's at all and I have deactivated them.

#1:

Now I'm trying to deploy the rec and then have it build a scavanger.
I do this:

Code: Select all

BuildStartingVehicle(m_CompTeam, m_CPUTeamRace, "*vrecycpu", "*vrecy", "RecyclerEnemy");
SetCommand(m_EnemyRecycler,CMD_DEPLOY,0,0,"RecyclerEnemy",0);	
This (alone) works. But then in execute I try:

Code: Select all



if(IsDeployed(m_EnemyRecycler)) {

SetCommand(m_EnemyRecycler,CMD_BUILD,0,0,0,CalcCRC("ivscav"));

}
Not only does this not work. (Is it the right command?) But when I have this line (SetCommand()...), then the recycler deploy animation will not be played and the recy sits there as a vehicle, even though the SetCommand line hasn't even been executed yet. That is, when I comment that line the
recy deploys. But in any case the IsDeployed function evaluates to true only after a the time it takes for the rec to deploy.
I do have enough scrap and it is the right handle. Also trying the same command on a constructor didn't work.

#2

When I deploy the recycler like that it is headed toward the wrong side.

I tried:

Code: Select all

SetCommand(m_EnemyRecycler,CMD_BUILD_ROTATE,0,0,0,0);
Before as well as after deploying the rec but it did not do anything.

#3

The next thing I wanna now is about the Handles.

I can do:

Code: Select all

myHandle = BuildStartingVehicle(m_CompTeam, m_CPUTeamRace, "*vrecycpu", "*vrecy", "RecyclerEnemy");
When I do this later the addObject method will be called with a Handle h. Now I got two Handles. Is that a problem?

#4

How can I get information about the pools, and the loose scrap on a map?
User avatar
General BlackDragon
Flying Mauler
Posts: 2408
Joined: Sat Feb 19, 2011 6:37 am
Contact:

Re: Some DLL issues / questions

Post by General BlackDragon »

Whats wrong with AIPs?

you can use very basic ones and then "create" units at the recy and fact via DLL if you want them to do something "special"

I haven't used SetCommand a lot, but the build command might not be formatted correctly.
User avatar
Red Spot
Attila
Posts: 1629
Joined: Mon Feb 21, 2011 6:14 pm
Location: The Netherlands

Re: Some DLL issues / questions

Post by Red Spot »

Use the AIPs, no need for dll-magic for what you try to do here.
The AI-recy will deploy, than have the 0-AIP simply never trigger an other (iirc you can even tell it to do so from the .inf AND from the AIPs). Than build units from the AIP (or spawn them via dll), and give them commands from the dll (only if you need a command that cant be set via the AIPs).

Have yet to see any dll 'create' units, afaik they all spawn them or let the AIPs build them.

mase wrote:How can I get information about the pools, and the loose scrap on a map?
You cant in the normal game environment. I made a dll that spawns all pools and starting loose, there you can track both (loose is tracked, except for units that drop it, so the dll knows when things are drying up). Do that and you can track both (loose from destroyed units will likelly be eaten first as it often is near bases/pools, and the 'geysers' can trow scrap all over the place, which you can store in an array and keep track of).
Last edited by Red Spot on Mon Nov 28, 2011 3:52 pm, edited 1 time in total.
mase
Thunderbolt
Posts: 160
Joined: Sat Mar 05, 2011 11:17 am

Re: Some DLL issues / questions

Post by mase »

Creating units at the recy is not realisitic. Because they have no build time.

AIPs are not flexible enough for me.

Also "might" not be formatted correcly is not a good answer. BZ2 gives no errors whatsoever if something is not right,
and I'm not starting another trial & error session. I need the exact command.
Also there is the Build(m_EnemyRecycler,"ivscav",1) command and that doesn't work either.
User avatar
General BlackDragon
Flying Mauler
Posts: 2408
Joined: Sat Feb 19, 2011 6:37 am
Contact:

Re: Some DLL issues / questions

Post by General BlackDragon »

Not flexible enough for what?

What are you trying to do?
User avatar
Red Spot
Attila
Posts: 1629
Joined: Mon Feb 21, 2011 6:14 pm
Location: The Netherlands

Re: Some DLL issues / questions

Post by Red Spot »

mase wrote:Also "might" not be formatted correcly is not a good answer. BZ2 gives no errors whatsoever if something is not right,
and I'm not starting another trial & error session. I need the exact command.
If the answer given isnt good enough, you'll have to figure it out yourself, thats life. Also when you code things, the first thing you do is make sure you have some form of feedback in place that you can easilly remove(comment out) later on. You only need to set up your message format once and can use it troughout your dll.
Any coding is bound to littered with trial&error, life isnt exact :)
mase
Thunderbolt
Posts: 160
Joined: Sat Mar 05, 2011 11:17 am

Re: Some DLL issues / questions

Post by mase »

General BlackDragon wrote:Not flexible enough for what?

What are you trying to do?
Implement advanced decision making.
mase
Thunderbolt
Posts: 160
Joined: Sat Mar 05, 2011 11:17 am

Re: Some DLL issues / questions

Post by mase »

Red Spot wrote:
mase wrote:Also "might" not be formatted correcly is not a good answer. BZ2 gives no errors whatsoever if something is not right,
and I'm not starting another trial & error session. I need the exact command.
If the answer given isnt good enough, you'll have to figure it out yourself, thats life. Also when you code things, the first thing you do is make sure you have some form of feedback in place that you can easilly remove(comment out) later on. You only need to set up your message format once and can use it troughout your dll.
Any coding is bound to littered with trial&error, life isnt exact :)
This is so wrong.
User avatar
Ded10c
Recycler
Posts: 3815
Joined: Sun Feb 20, 2011 11:05 am
Location: Stoke-on-Trent
Contact:

Re: Some DLL issues / questions

Post by Ded10c »

No, he's right.
User avatar
MrTwosheds
Recycler
Posts: 3059
Joined: Sat Feb 19, 2011 8:37 am
Location: Outer Space
Contact:

Re: Some DLL issues / questions

Post by MrTwosheds »

There are a whole bunch of new aip functions in 1.3 that could simulate advanced decision making, if your prepared to work out how to do it, and there is also Lua coding to help it out, (there is however not allot of info about lua and bz2 aip's to help you out yet) RD is probably the best guy to talk to.
The changelogs and Commandos modlog contain info on aip functions.
mase
Thunderbolt
Posts: 160
Joined: Sat Mar 05, 2011 11:17 am

Re: Some DLL issues / questions

Post by mase »

MrTwosheds wrote:There are a whole bunch of new aip functions in 1.3 that could simulate advanced decision making, if your prepared to work out how to do it, and there is also Lua coding to help it out, (there is however not allot of info about lua and bz2 aip's to help you out yet) RD is probably the best guy to talk to.
The changelogs and Commandos modlog contain info on aip functions.
I have looked now through the changelogs and modlog and both AIPs and LUA are not what I want.
User avatar
MrTwosheds
Recycler
Posts: 3059
Joined: Sat Feb 19, 2011 8:37 am
Location: Outer Space
Contact:

Re: Some DLL issues / questions

Post by MrTwosheds »

Sounds like you want to make a bz2 strategy AI, good to see people breaking new ground, good luck.
User avatar
Red Devil
Recycler
Posts: 4398
Joined: Fri Feb 18, 2011 5:10 pm
Location: High in the Rocky Mountains

Re: Some DLL issues / questions

Post by Red Devil »

tried using GetCurrentCommand() to see if it actually has the command?

what = GetCurrentCommand(m_EnemyRecycler);
sprintf_s(tmpstr, "Recycler Command after order = %s", what);
PrintConsoleMessage(tmpstr);


also, try this and see if it works:

SetCommand(m_EnemyRecycler,CMD_BUILD,1,0,NULL,CalcCRC("ivscav"));
User avatar
GSH
Patch Creator
Posts: 2486
Joined: Fri Feb 18, 2011 4:55 pm
Location: USA
Contact:

Re: Some DLL issues / questions

Post by GSH »

I have looked now through the changelogs and modlog and both AIPs and LUA are not what I want.
Then what you should do is describe what you're trying to do. Not just with single lines of code trying to do individual things to individual units. In BZ2 terms, switch to satellite view, and describe what you're trying to do at a high level. Getting caught up on lines of code make be what you think you need, but if you're going in the wrong direction, that's when you need to explain the high level.
Also "might" not be formatted correcly is not a good answer. BZ2 gives no errors whatsoever if something is not right,
and I'm not starting another trial & error session. I need the exact command.
Also there is the Build(m_EnemyRecycler,"ivscav",1) command and that doesn't work either.
Programming never has a "do what I mean" command. You have to think about what you're trying to do -- at both the low and high levels -- and adapt your thinking to the framework you're using. Once again, don't just describe a line like "Build(m_EnemyRecycler,"ivscav",1)". What are you really trying to accomplish here? Trust me, you're not giving away your mod or anything by describing that.

In scriptutils.h, it describes the closest match to that function like this:
// Build(rig, "sbsilo");
DLLEXPORT void DLLAPI Build(Handle me, char* odf, int priority = 1);
Note what it says in the comment. The Build() command is aimed at rigs, namely construction rigs. BZ2 does not have orthogonal AI or unit types. In other words, what works for one unit type may not work for another unit type. Recyclers were meant to be driven by players thru the command menu, or AIPs. You'll have to find another way to try and get that command in. It may be very hard. But, as long as you've arbitrarily ruled out AIPs, and won't describe things to others, it's going to be a rough journey.

Also, the Build()'s command priority field defaults to 1 if not specified. You can omit that third parameter just fine, this is basic C++. You should go read free C++ guides for more info.

-- GSH
mase
Thunderbolt
Posts: 160
Joined: Sat Mar 05, 2011 11:17 am

Re: Some DLL issues / questions

Post by mase »

I'm really only just trying to do some simple things to see how they work.
The real hard work will follow later once I got the basics down.

I thought that Build() might only work on rigs, I tried and that didn't work either.
I'll try some more.

I guess I will just make a bunch of simple AIPs for building stuff then and call them from DLL.

And yes I do not normally code in C++.
Post Reply