• Congratulations to the OTLand January Mapping Competition Winner! The grand prize of Otland Premium goes to Andréew.
  • Sign up for February Mapping Competition! The prize includes Otland Premium time.
  • 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
87
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

Î Àm ŁĕğẹňĎ
Premium User
Support Team
Joined
Mar 4, 2017
Messages
1,321
Best answers
156
Reaction score
488
Location
Egypt
 
OP
C

cabrera2608

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

cabrera2608

New Member
Joined
Dec 21, 2018
Messages
87
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
87
Best answers
0
Reaction score
3
Any idea why only some can see me.

but if I relogue these attack?
 

Anyjia

KillaBeez
Joined
Jun 10, 2007
Messages
193
Best answers
0
Reaction score
33
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
87
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));
}
 

tarekadel

Member
Joined
Feb 17, 2011
Messages
116
Best answers
2
Reaction score
5
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
 
Top