Adding a new location to the worldmap

https://attnam.com/topics/Adding-a-new-location-to-the-worldmap

The Cathedral of Attnam > Other Coding

#1 Sep 9, 2010, 8:57 pm Hide

fejoa

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:
...
#define RANDOM 0
#define ELPURI_CAVE 1
#define ATTNAM 2
#define NEW_ATTNAM 3
#define UNDER_WATER_TUNNEL 4
[b]#define COSMODROME 5[/b]
#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:
...
[b]OWTERRAIN(cosmodrome, owterrain)
{
 public:
  virtual const char* GetNameStem() const;
  virtual v2 GetBitmapPos(int) const;
  virtual int GetAttachedDungeon() const;
};[/b]
...

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:
...
[b]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]// I have used the same bitmap for new attnam in wterra.pcx, for simplicity[/i]
int cosmodrome::GetAttachedDungeon() const { return COSMODROME; }[/b]
...

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:
...
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)
	 [b]&& Continent[c]->GetGTerrainAmount(LForestType)[/b])
	PerfectForAttnam.push_back(Continent[c]);

if(!PerfectForAttnam.size())
      continue;

    v2 AttnamPos, ElpuriCavePos, NewAttnamPos, TunnelEntry, TunnelExit[b], CosmodromePos[/b];
    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);
      [b]CosmodromePos = PetrusLikes->GetRandomMember(LForestType);[/b]
...

Further along, still in worldmap.cpp, there is an if-statement after which is added:
...
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);
    [b]GetWSquare(CosmodromePos)->ChangeOWTerrain(cosmodrome::Spawn());
    SetEntryPos(COSMODROME, CosmodromePos);[/b]
    [i]PLAYER->PutTo(NewAttnamPos);[/i]
    CalculateLuminances();
    CalculateNeighbourBitmapPoses();
    break;
...

SPOILER ALERT. Click here to see text.
In the above codeblock in italics note the line: PLAYER->PutTo(NewAttnamPos);
Could be useful to change this to your desired world map location for testing purposes.


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.
#2 Nov 29, 2013, 6:05 pm Hide

Chiko

I've been interested in adding a new town and dungeons... This will definitely help. There are some files I don't recognize, though. Like ivandef.h and wterras.h so I'm guessing this can only be done in LIVAN, right?
#3 Nov 29, 2013, 6:35 pm Hide

capristo

No, it means you need the source code, not just a binary. So after you make changes you would have to recompile the code too.
#4 Nov 29, 2013, 6:39 pm Hide

fejoa

First off, to create a new location you will need some means of compiling the source files.
You can use IVAN CVS or LIVAN as a starting point, or you can also use CLIVAN, but personally I think it too buggy.
The header files like ivandef.h and wterras.h etc are part of the source.

To avoid compiling, there is a precooked map location in LIVAN.
What you can do, is use a normal distribution of LIVAN, and simply use the dragon tower (which is an unfinished location) on that map and use the script files to develop a whole new dungeon to your heart's content. Wizard mode to find this location.
In this way, you can help contribute to IVAN development by creating an exciting new dungeon for people to play. The dungeon script files are fun and confusing. But mostly fun. IVAN will crash a couple of times before you get it right. See if you can work out what ``BoundedRandom'' does. If you understand how it works, then you know the right shit for making beautiful dungeons with high replayability. The original devs were so clever. Hardest thing is to balance the levels, but if you use a spreadsheet and some rough calculations you will be sweet.
#5 Nov 29, 2013, 7:38 pm Hide

4zb4

The dragon tower shows up outside of wizard mode too - but good luck finding the thing, damn. Reminds me of the times I've gotten lost trying to find Attnam and starved.
#6 Nov 29, 2013, 8:39 pm Hide

Chiko

I got LIVAN and went into Wizard Mode but I can't find it. I can only find the vanilla locations. Anyways, I wanted to add more than one location like a town and a dungeon but since I can only do this with scripting, I guess I can do both in one. Typical town with an infested cave or temple. If I can find the place, that is.

Another easier way to add a town would be like adding it as a simple dungeon lvl. An underground village or something like that. It's probably easier that way too.

I've trying the dungeon.dat to see how complicated it was and, after some crashes, I managed to add a new General Store in New Attnam. It works with no problems.


#7 Nov 29, 2013, 9:44 pm Hide

4zb4

Chiko wrote
Typical town with an infested cave or temple. If I can find the place, that is.

Another easier way to add a town would be like adding it as a simple dungeon lvl. An underground village or something like that. It's probably easier that way too.
A la Dwarven Vault.

A good place to do this would be to have a dungeon below Attnam or New Attnam seeing as they're already established locations.
For example, New Attnam already has the sumo ring set up as a dungeon level as it is, so you could put some sort of horrible ancient catacombs of the Tweraifian ancestors down there or something, and have the entrance hidden in the sumo ring somewhere in the walls.
Of course to get there you'd have to sneak past (or kill) the sumo so as not to trigger challenging him to a match.
Play it off as the sumo being the guardian of the tomb or something?

Chiko wrote
I've trying the dungeon.dat to see how complicated it was and, after some crashes, I managed to add a new General Store in New Attnam. It works with no problems.
Well done!
#8 Nov 29, 2013, 11:26 pm Hide

capristo

4zb4 wrote
The dragon tower shows up outside of wizard mode too - but good luck finding the thing, damn. Reminds me of the times I've gotten lost trying to find Attnam and starved.

You know you can 'l'ook to find it right? I starved many times as well but then I read about that on here.
#9 Nov 30, 2013, 4:32 pm Hide

4zb4

Does it? I could swear I've had it spawn in the most backward ass-end of the world then.
#10 Dec 2, 2013, 1:07 pm Hide

fejoa

It's possible to generate extremely large continents. So yes, it's not surprising that you'd have difficulty finding the dragon tower, or that it be a long way off. The worldmap generation system is awful, and so probably needs to be looked at with some due consideration.
#11 Feb 18, 2014, 5:05 pm Hide

[Eire]MadHatter

I'd like to have a good mess with that location stuff add a few forests locations similar to say....hunting grounds.

I wandered onto the atheist gods land....starving I went and attacked the nearest animal only to be chopped into little pieces by invisible things as punishment for not silently starving to death.
#12 Feb 19, 2014, 12:37 pm Hide

fejoa

Yeah the people and animals on that level are all on the same team.
#13 Feb 19, 2014, 1:12 pm Hide

Ernomouse

Hehe... In the genuine IVAN style.