The Cathedral of Attnam

Iter Vehemens ad Necem (IVAN)
Login
Username
Password


 Valid CSS  Valid HTML 4.01 Strict

Adding a new location to the worldmap

The Cathedral of Attnam  >  Programming
Print

View profile
Send message
Find posts Find topics
 
Sep 10, 2010 at 1:57 am #1  !
Warheck's Avatar
Warheck
kobold lord


Joined: Sep 9, 2010
Occupation: Petty Functionary
Location: Eating pea soup in the world map
Interests: Mangoes
Posts: 118
Groups:
Adding a new location to the worldmap
Warning, parts of this may be a bit spoily, if you can decipher it.
I think holybanana intended on setting out a coding tutorial on this topic, but I decided to have a crack at it and have figured out how this is done. I reverse engineered it from differences between IVAN and LIVAN.

I will show how to add a new location to the worldmap. In this example I will add the rocket launch pad named Baikonur, situated amongst leafy forest. The parts I added are in bold.

1) In define.dat and in ivandef.h add the line: # define COSMODROME 5
i.e. I inserted into the following lines:

Code

...
#define RANDOM 0
#define ELPURI_CAVE 1
#define ATTNAM 2
#define NEW_ATTNAM 3
#define UNDER_WATER_TUNNEL 4
#define COSMODROME 5
#define UNDER_WATER_TUNNEL_EXIT 0x80
...



2) In wterras.h add an owterrain (over-world terrain) called cosmodrome (as per the other entries). For this example:

Code

...
OWTERRAIN(cosmodrome, owterrain)
{
public:
virtual const char* GetNameStem() const;
virtual v2 GetBitmapPos(int) const;
virtual int GetAttachedDungeon() const;
};

...



3) In wterras.cpp add a const char* cosmodrome (to the best of my knowledge, this adds the new location to IVAN, links the location bitmap to its position in wterra.pcx and attaches the relevant dungeon). Add the following lines of code:

Code

...
const char* cosmodrome::GetNameStem() const { return "The ancient rocket launch-pad, Baikonur, looms up from the forests"; }
v2 cosmodrome::GetBitmapPos(int) const { return v2(16, 64); } // I have used the same bitmap for new attnam in wterra.pcx, for simplicity
int cosmodrome::GetAttachedDungeon() const { return COSMODROME; }

...



4) To worldmap.cpp add the CosmodromePos codes, the SetEntryPos(COSMODROME, CosmodromePos) and the GetWSquare. This is slightly more elaborate, I want the cosmodrome to be situated in a leafy forest, so I had to fix that in as well.
Firstly inside the function: void worldmap::Generate(), I added another condition in this for loop, and in the statements that follow I added a couple of other lines:

Code

...
for(uint c = 1; c < Continent.size(); ++c)
if(Continent[c]->GetSize() > 25 && Continent[c]->GetSize() < 1000
&& Continent[c]->GetGTerrainAmount(EGForestType)
&& Continent[c]->GetGTerrainAmount(SnowType)
&& Continent[c]->GetGTerrainAmount(LForestType))
PerfectForAttnam.push_back(Continent[c]);

if(!PerfectForAttnam.size())
continue;

v2 AttnamPos, ElpuriCavePos, NewAttnamPos, TunnelEntry, TunnelExit, CosmodromePos;
truth Correct = false;
continent* PetrusLikes;

for(int c1 = 0; c1 < 25; ++c1)
{
game::BusyAnimation();
PetrusLikes = PerfectForAttnam[RAND() % PerfectForAttnam.size()];
AttnamPos = PetrusLikes->GetRandomMember(EGForestType);
ElpuriCavePos = PetrusLikes->GetRandomMember(SnowType);
CosmodromePos = PetrusLikes->GetRandomMember(LForestType);
...



Further along, still in worldmap.cpp, there is an if-statement after which is added:

Code

...
if(!Correct)
continue;

GetWSquare(AttnamPos)->ChangeOWTerrain(attnam::Spawn());
SetEntryPos(ATTNAM, AttnamPos);
RevealEnvironment(AttnamPos, 1);
GetWSquare(NewAttnamPos)->ChangeOWTerrain(newattnam::Spawn());
SetEntryPos(NEW_ATTNAM, NewAttnamPos);
SetEntryPos(ELPURI_CAVE, ElpuriCavePos);
GetWSquare(TunnelEntry)->ChangeOWTerrain(underwatertunnel::Spawn());
SetEntryPos(UNDER_WATER_TUNNEL, TunnelEntry);
GetWSquare(TunnelExit)->ChangeOWTerrain(underwatertunnelexit::Spawn());
SetEntryPos(UNDER_WATER_TUNNEL_EXIT, TunnelExit);
GetWSquare(CosmodromePos)->ChangeOWTerrain(cosmodrome::Spawn());
SetEntryPos(COSMODROME, CosmodromePos);

PLAYER->PutTo(NewAttnamPos);
CalculateLuminances();
CalculateNeighbourBitmapPoses();
break;
...




SPOILER ALERT. Click here to see text.



5) Then hit the Compile button. IVAN will crash if you enter into the location and haven't added the dungeon in dungeon.dat

6) Finally add the dungeon to dungeon.dat, from this position it is only a matter of scripting the dungeon to your hearts content. DON'T forget to increment the number of dungeons and levels! Enjoy.
 
Last edited by Warheck : Sep 10, 2010 at 8:34 am. Edited 3 times total
 
 Print


The Cathedral of Attnam  >  Programming  >  Adding a new location to the worldmap

Jump to