1

Topic: Adding own Entities / Game Layer Tiles to your Mod. Possible in 0.6?

Hey guys.
I'm currently writing an advanced City Mod, this means server AND client modified.
So, i wanted to add some Fields on my Game Layer.
Something like a field for money and so on.
But all i would need to know (as first) is, how to add them?
I really looked into the collision.cpp and so..
I added a function like:

bool CCollision::Tile_Is_Money(int x, int y) //i added TILE_MONEY in mapitems.h.... more down...
{
    return GetTile(x, y)&TILE_MONEY;
}

//or:

int CCollision::GetTrueTile(int x, int y) //eheheh lets see, what tile its really (16*16 fields!)
{
    int Nx = clamp(x/32, 0, m_Width-1);
    int Ny = clamp(y/32, 0, m_Height-1);

    return m_pTiles[Ny*m_Width+Nx].m_Index;
}

and in mapitems.h in a enum its like so:

.....
TILE_NOHOOK,
TILE_MONEY,
.....

In the Character.cpp at ::Tick()
i added a broadcast message (every frame / ms / tick) that does something like this:

char buf[512];
str_format(buf, sizeof(buf), "X: %d; Y: %d; Current Tile: %d", m_Pos.x, m_Pos.y, GetTrueTile(m_Pos.x, m_Pos.y));
//sending a broadcast (buf)
.....

Now i edited the entities (the entities.png) and added a new 64*64 field next to the nohook symbol.
I created a test map and added the MONEY TILE (near the nohook-tile).
But now when i enter it, it says everything like before: (Current Tile: 0)

So man..

Can anyone of the good coders help me at this problem?
I really need help.
I tried everything-
The oncest tiles its detecting is the spawn points (all, red, blue, as 192-194) and the other likes like for weapons.
But it wont find my added tiles.

You can add me in skype too: powachill
Or send me a email... felix@codingshare.de


Thank you all, if i find a soloution ill just give you a piece of love. smile

2

Re: Adding own Entities / Game Layer Tiles to your Mod. Possible in 0.6?

well... i dont wanna start a discussion again about how crapy city mods are or that this is the wrong topic as we dont support mods here ^^

i make it sohrt: your whole code is absolutely pointless xD

powachill4 wrote:
bool CCollision::Tile_Is_Money(int x, int y) //i added TILE_MONEY in mapitems.h.... more down...
{
    return GetTile(x, y)&TILE_MONEY;
}

u try to use bitwise calculation with an enum which is not supposed to... i suggest u to learn bitwise calculation first wink

powachill4 wrote:
int CCollision::GetTrueTile(int x, int y) //eheheh lets see, what tile its really (16*16 fields!)
{
    int Nx = clamp(x/32, 0, m_Width-1);
    int Ny = clamp(y/32, 0, m_Height-1);

    return m_pTiles[Ny*m_Width+Nx].m_Index;
}

what is this? every tile has the same tile... the only thing u do here is returning the index

about your test function... it is only logical that it shows 0. If u were able to read the code u would have seen that every useless tile is overwritten with 0 in the collision init function. So u have to edit that for your tile wink


to conclude: learn C/C++ before trying to hack on tw code wink

uptee - a simple web interface for hosting and maintaining teeworlds servers
teerace - a website gathering results of trusted Race-mod servers providing global ranking and statistics
*gV* rox ^^

3

Re: Adding own Entities / Game Layer Tiles to your Mod. Possible in 0.6?

Damn..
I now found it out at my own!
HAH!

at CCollision::Init()
at switch(Index)
add:

case TILE_MONEY:
            m_pTiles[i].m_Index = TILE_MONEY;
            break;

So now the function

bool CCollision::Tile_Is_Money(int x, int y)

works!!!
(it includes: >>return GetTile(x, y)&TILE_MONEY;<<) ;D

4

Re: Adding own Entities / Game Layer Tiles to your Mod. Possible in 0.6?

powachill4 wrote:

Damn..
I now found it out at my own!
HAH!

at CCollision::Init()
at switch(Index)
add:

case TILE_MONEY:
            m_pTiles[i].m_Index = TILE_MONEY;
            break;

So now the function

bool CCollision::Tile_Is_Money(int x, int y)

works!!!
(it includes: >>return GetTile(x, y)&TILE_MONEY;<<) ;D

No it doesn't. If TILE_MONEY is 9 (0101 in binary), tile_is_money will work all the tiles with "101" as last bits. Example:
It will return true for 9 (0101), for 17 (1101), for 25 (10101), etc...


Coming back to the Sushi point:

to conclude: learn C/C++ before trying to hack on tw code wink

Not Luck, Just Magic.

5

Re: Adding own Entities / Game Layer Tiles to your Mod. Possible in 0.6?

Man every time these kiddies who means "learn c++".
I'm currently learning it by TEEWORLDS.
So im looking for all these things, codes and so and i'm really good at my Mod (currently).
But so far... Can you explain a bit more please?
I've got a problem with that nohook tile and VIP (vip and nohook is the same id : 5..).
So can any1 help me at this spot?
And at another problem i wanted to explain:
I wanted to make the server reading out a file.
That works.
Then reading out the data (int x, int y, char *text).
that works too.
The server sends in some packets (CNetMsg_Sv_IngameText).
This packet includes the data x, y and text.
Now the client adds it into an array and lets the nameplates file (or whatever) draw a text (at x, y with text).
That works.
But then when the client is playing for a while (every time about 3 minutes) its crashing (the client).
I cant find the problem.
I tried everything like staying at the same spot, shooting at the text or somehting like this.
I believe the problem is because of some settings with the nameplates, but wheres the shit with that maaan...
If you can help me at City Mod, add me in skype (powachill) or write an EMAIL! sad

6 (edited by Dune 2011-08-05 16:20:48)

Re: Adding own Entities / Game Layer Tiles to your Mod. Possible in 0.6?

powachill4 wrote:

Man every time these kiddies who means "learn c++".
I'm currently learning it by TEEWORLDS.
So im looking for all these things, codes and so and i'm really good at my Mod (currently).

You are the one kiddie. Learning C++ via modding on Teeworlds is a point, I've partially been doing that, there is no problem in improving your C++ skills by practicing little modifications on the Teeworlds code.
I said "improving" your skills. You need some C++ basis before starting to look in the code. It may sound boring, but you'll have to learn these basis before trying to code something really useful. You're obviously lacking these basis, and we can't guide you through the code without them.
Get a C++ book or look in the Web, and learn these, we're not here to teach you them it, it would take us one week.

If you try to bypass this basic learning, you'll be fighting all the time errors and crashes you will not be able to deal with, and you will constantly have to ask, and will finally regret not having invested your time in this learning phase.

Not Luck, Just Magic.

7 (edited by powachill4 2011-08-05 16:41:31)

Re: Adding own Entities / Game Layer Tiles to your Mod. Possible in 0.6?

Hahahaaaaa. Lol. xD. Wtf^^.
I just can laugh at you.
Without basics i couldnt get to the point where i would be happy to say "I made a city mod in teeworlds with account system".
This means i know the data types, some about arrays and all the basics like operators, structures, classes, header files, imports!
You don't even know anything about my skills in C++ and say i'm gonna have to learn it before?!
Hah.
Lets say, im the best coder in C++ and you say im a noob.
You'd never seen my skills before.
Now shut up. I need someone else who could explain me this with the binary.
I made a little board:

Money_Tile: 001
VIP_Tile:101
NOHOOK: 11

These binarys dont say anything helpful eh?
Now. Help? smile

8 (edited by WrX 2011-08-05 18:05:05)

Re: Adding own Entities / Game Layer Tiles to your Mod. Possible in 0.6?

Then if you are so clever why you didn't learn sources of old versions of city mods?

9

Re: Adding own Entities / Game Layer Tiles to your Mod. Possible in 0.6?

Oh, apologizes for my lack of respect.
You're the best C++ coder but don't know anything about manipulating binary variables.

Not Luck, Just Magic.

10

Re: Adding own Entities / Game Layer Tiles to your Mod. Possible in 0.6?

I'd never said that im the best.
But thanks for the compliment wink
So i was looking into the nCity Source of 0.5.2 and i just cant learn anything of it. sad

11

Re: Adding own Entities / Game Layer Tiles to your Mod. Possible in 0.6?

powachill4: Go learn C++, please.