• Vote in September Mapping Competition to select a winner!
  • There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Monster and floor

cabrera2608

New Member
Joined
Dec 21, 2018
Messages
109
Best answers
0
Reaction score
3
Hello otland people how can I do this function
that at the moment when a player is above or below some floor the monster stays still?
I am using otx based on tfs 0.3.7
Monster and floors
 

M0ustafa

1337
Premium User
Support Team
Joined
Mar 4, 2017
Messages
2,072
Best answers
263
Reaction score
804
Location
Egypt
 
OP
C

cabrera2608

New Member
Joined
Dec 21, 2018
Messages
109
Best answers
0
Reaction score
3
Thanks if it worked
 
OP
C

cabrera2608

New Member
Joined
Dec 21, 2018
Messages
109
Best answers
0
Reaction score
3
@M0ustafa I had a problem modifying some monsters if they attack and others not because: /

I leave the code I modified
C++:
/*bool Creature::canSee(const Position& myPos, const Position& pos, uint32_t viewRangeX, uint32_t viewRangeY)   FLOOR MONSTER
{
    if(myPos.z == pos.z)
        return true;

    return false;
}*/
 
OP
C

cabrera2608

New Member
Joined
Dec 21, 2018
Messages
109
Best answers
0
Reaction score
3
Any idea why only some can see me.

but if I relogue these attack?
 

Anyjia

KillaBeez
Premium User
Joined
Jun 10, 2007
Messages
202
Best answers
0
Reaction score
34
Location
Sweden
not mine script but try this :
Code:
Code:
bool Creature::canSee(const Position& pos) const
{
    const Position& myPos = getPosition();
    const Monster* isMonster = getMonster();

    if(isMonster && myPos.z != pos.z)
        return false;

    if(myPos.z <= 7)
    {
        //we are on ground level or above (7 -> 0)
        //view is from 7 -> 0
        if(pos.z > 7)
            return false;
    }
    else if(myPos.z >= 8)
    {
        //we are underground (8 -> 15)
        //view is +/- 2 from the floor we stand on
        if(std::abs(myPos.z - pos.z) > 2)
            return false;
    }

    int offsetz = myPos.z - pos.z;
    if((pos.x >= myPos.x - Map::maxViewportX + offsetz) && (pos.x <= myPos.x + Map::maxViewportX + offsetz) &&
        (pos.y >= myPos.y - Map::maxViewportY + offsetz) && (pos.y <= myPos.y + Map::maxViewportY + offsetz))
        return true;

    return false;
}
Change the whole bool Creature::canSee to it (start on line 121 @ creature.cpp)
 
OP
C

cabrera2608

New Member
Joined
Dec 21, 2018
Messages
109
Best answers
0
Reaction score
3
it still makes me an error

my code

C++:
bool Creature::canSee(const Position& myPos, const Position& pos, uint32_t viewRangeX, uint32_t viewRangeY)
{
    if(myPos.z <= 7)
    {
        //we are on ground level or above (7 -> 0)
        //view is from 7 -> 0
        if(pos.z > 7)
            return false;
    }
    else if(myPos.z >= 8)
    {
        //we are underground (8 -> 15)
        //view is +/- 2 from the floor we stand on
        if(std::abs(myPos.z - pos.z) > 2)
            return false;
    }

    int32_t offsetz = myPos.z - pos.z;
    return (((uint32_t)pos.x >= myPos.x - viewRangeX + offsetz) && ((uint32_t)pos.x <= myPos.x + viewRangeX + offsetz) &&
        ((uint32_t)pos.y >= myPos.y - viewRangeY + offsetz) && ((uint32_t)pos.y <= myPos.y + viewRangeY + offsetz));
}
 

Shalaby

Time has made me wiser, but no more patient.
Joined
Feb 17, 2011
Messages
152
Best answers
2
Reaction score
28
Location
Pharaohs
it still makes me an error

my code

C++:
bool Creature::canSee(const Position& myPos, const Position& pos, uint32_t viewRangeX, uint32_t viewRangeY)
{
    if(myPos.z <= 7)
    {
        //we are on ground level or above (7 -> 0)
        //view is from 7 -> 0
        if(pos.z > 7)
            return false;
    }
    else if(myPos.z >= 8)
    {
        //we are underground (8 -> 15)
        //view is +/- 2 from the floor we stand on
        if(std::abs(myPos.z - pos.z) > 2)
            return false;
    }

    int32_t offsetz = myPos.z - pos.z;
    return (((uint32_t)pos.x >= myPos.x - viewRangeX + offsetz) && ((uint32_t)pos.x <= myPos.x + viewRangeX + offsetz) &&
        ((uint32_t)pos.y >= myPos.y - viewRangeY + offsetz) && ((uint32_t)pos.y <= myPos.y + viewRangeY + offsetz));
}
post the error log
 
OP
C

cabrera2608

New Member
Joined
Dec 21, 2018
Messages
109
Best answers
0
Reaction score
3
I still have the problem: /
how can I solve it
 
OP
C

cabrera2608

New Member
Joined
Dec 21, 2018
Messages
109
Best answers
0
Reaction score
3
guys i still don't succeed
Some of the monsters keep happening if they see me and others don't.
and since there are almost no related posts, I can't make it work

someone could help me, it would be much appreciated
first of all thanks....
 
OP
C

cabrera2608

New Member
Joined
Dec 21, 2018
Messages
109
Best answers
0
Reaction score
3
several days without success
could you help me
 
Top