Author Topic: DLL Coding (With SDK)  (Read 1787 times)

Offline Leviathan

  • Hero Member
  • *****
  • Posts: 4055
DLL Coding (With SDK)
« on: March 30, 2005, 07:02:10 AM »
Using the sets in BaseData for the bases means each base has own sets but what about items not based on players.

What im talking about is adding a Beacon Set to the map which is not based on a player. So you would place the real map cords in it. Id like to be able to add more mines to the map.

Also how and where do you add to set unit lights on?

And how to set SF's to have cargo?

And how do you add the Message command?

Offline BlackBox

  • Administrator
  • Hero Member
  • *****
  • Posts: 3093
DLL Coding (With SDK)
« Reply #1 on: March 30, 2005, 07:25:22 AM »
To set unit lights on, for all the units of a player, you can use SetAllVehicleLightsForPlayer from the OLD SDK. (I believe it's in OP2Helper.cpp)

example code, would turn on lights for all players:
Code: [Select]
for (int i=0; i<TethysGame::NoPlayers()-1; i++) {
 SetAllVehicleLightsForPlayer(i, 1);
}
(PlayerID cant be -1, you have to go thru and do each one like that)

Here's the code for that function, in case you don't have it from the old SDK:
Code: [Select]
// Note: can NOT use playerNum = -1 for all players
void SetAllVehicleLightsForPlayer(int playerNum, int bOn)
{
PlayerVehicleEnum unitEnum(playerNum); // Enumerate vehicles for given player
Unit curUnit;

// Enumerate through all vehicles of this player
while (unitEnum.GetNext(curUnit))
{
  curUnit.DoSetLights(bOn); // Turn on the headlights
}
}

Setting cargo in Factories:
Code: [Select]
factory.SetFactoryCargo(bayId, contents, cargoWeaponType);
bayId is a number 0-5 that chooses the bay to set.
contents and cargoWeaponType are the map_ids of the unit/structure, and cargo/weapon it carries, if any, in the bay. (Set cargoWeaponType = mapNone if youre doing a struct fac)

Message Command. There are two ways to do it:
Code: [Select]
TethysGame::AddMessage(int pixelX, int pixelY, char *message, int recipientPlayerNum, int soundID);
TethysGame::AddMessage(class Unit owner, char *message, int recipientPlayerNum, int soundID);
the owner is a unit its associated with, pixelX/pixelY are the location in Pixels on the map its associated with. (For a tile position, take the tile X,Y and multiply each by 32. None of the typical tile position offsets apply here, so 0,0 is the upper left corner of the map) If you don't need the message to be associated with a location use the first form with pixelX and pixelY both -1.

playerNum, is who sees the message. Use -1 for all players.

soundID is the ID of the sound file to use for the message. 0 is the generic beep. The list of sounds is in EnumSoundID.h.
« Last Edit: March 30, 2005, 07:58:00 AM by op2hacker »

Offline BlackBox

  • Administrator
  • Hero Member
  • *****
  • Posts: 3093
DLL Coding (With SDK)
« Reply #2 on: March 30, 2005, 07:54:17 AM »
Okay, making a beacon set that's not based off a player, but off absolute map coordinates:

First you need to define a new beacon set in BaseData.h, like so:
Code: [Select]
struct BeaconInfo extraSet[] = 
{
{ 12,  7, mapMiningBeacon, 0, 0, -1},
{ 31,  40, mapMiningBeacon, 0, 0, -1},
{ 60,  17, mapMiningBeacon, 1, 0, -1},
};

edit the rows accordingly to your liking, or add some for more. Remember you can include fumaroles and magmavents too.

Now, in BaseBuilder.cpp (the file containing all the processor functions for these structures) there's a generic one called CreateBeacons.

Using it to create the set up above is a one line process, somewhere in InitProc.
Code: [Select]
CreateBeacons(numof(extraSet), extraSet);

And that's all, it should create this extra set of beacons for you then, regardless of # of players.
« Last Edit: April 01, 2005, 01:09:14 PM by Leviathan »

Offline Leviathan

  • Hero Member
  • *****
  • Posts: 4055
DLL Coding (With SDK)
« Reply #3 on: March 30, 2005, 07:57:31 AM »
Great I shall give it a go later :)

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
DLL Coding (With SDK)
« Reply #4 on: March 30, 2005, 02:55:24 PM »
Just a quick correction, but for:
Code: [Select]
TethysGame::AddMessage(int pixelX, int pixelY, char *message, int recipientPlayerNum, int soundID);
The usual tile offsets DO apply. You have to multiply the adjuested tile offsets by 32 to get the pixel offsets. So using 0,0 is actually far off the map.


And yes, the old way of placing beacons that aren't associated with a player still works. Just in the example in the SDK, all the beacons were essentially attached to player locations, so the older method wasn't used. All the old helper functions from older SDKs should still be in there though.
 
« Last Edit: March 30, 2005, 02:56:53 PM by Hooman »