• 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
110
Solutions
1
Reaction score
4
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
 
 
Thanks if it worked
 
@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;
}*/
 
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)
 
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));
}
 
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
 
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....
 
Back
Top