• 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!

Remove floor limitation, can target in every floor, Z 0, 1, 2, 3, 4.

Delitaheiral

New Member
Joined
Apr 11, 2015
Messages
12
Reaction score
0
I didn't know this tread exists, at this point i'm going to get banned from OTLAND cause of triple damn post, but I'm kinda stucked at this to continue the project...

Hello, I am a beginner programmer in C++, I mostly just Edit some already made codes (to be honest) and I have a question, just to know if its hard work or maybe can be done easily.

I am not asking how to do it, I just want to know if Its very hard in a way that I will have to change the whole structure of the code or can I do it with some ease without changing much...

I want to start a project were I need to see and target people on other floor, unlike Tibia that you can see only the floor you are. I don't want to use minus Z, like Z = -1, just the zero and above...

Someone please enlighten me
 
u need if u are in floor 6 see player in floor 5 ??
 
I'm on floor 1, I want to be able to attack players at floor 2 if I am ranged or using magic...

I just saw this on the c++ codes:

  1. ReturnValue Actions::canUse(const Player* player, const Position& pos)
  2. {
  3. if (pos.x != 0xFFFF) {
  4. const Position& playerPos = player->getPosition();
  5. if (playerPos.z != pos.z) {
  6. return playerPos.z > pos.z ? RETURNVALUE_FIRSTGOUPSTAIRS : RETURNVALUE_FIRSTGODOWNSTAIRS;
  7. }

  8. if (!Position::areInRange<1, 1>(playerPos, pos)) {
  9. return RETURNVALUE_TOOFARAWAY;
  10. }
  11. }
  12. return RETURNVALUE_NOERROR;
  13. }
Maybe its the key... Actions.cpp

Bump :X
 
Last edited by a moderator:
don't bump be4 24 hours or ur post will delete " about me i don't do something like this be4" maybe anyone can help you again don't Bump be4 24 hours
 
Ok, im sorry, wont bump before 24 hours. I sent a message to the creator of TFS, maybe him can help? xD
If I get any information I post it here, thanks.
 
I dont think so that @Mark will help you in private. You can some discussion on official Github.
 
Maybe if I change the red part of this code and instead of the error I put a "Return True"... Will I be able to cast spells on high / low ground?

Its on Combat.cpp:

  1. ReturnValue Combat::canDoCombat(const Creature* caster, const Tile* tile, bool isAggressive)
  2. {
  3. if (tile->hasProperty(CONST_PROP_BLOCKPROJECTILE)) {
  4. return RETURNVALUE_NOTENOUGHROOM;
  5. }

  6. if (tile->floorChange()) {
  7. return RETURNVALUE_NOTENOUGHROOM;
  8. }

  9. if (tile->getTeleportItem()) {
  10. return RETURNVALUE_NOTENOUGHROOM;
  11. }

  12. if (caster) {
  13. const Position& casterPosition = caster->getPosition();
  14. const Position& tilePosition = tile->getPosition();
  15. if (casterPosition.z < tilePosition.z) {
  16. return RETURNVALUE_FIRSTGODOWNSTAIRS;
  17. } else if (casterPosition.z > tilePosition.z) {
  18. return RETURNVALUE_FIRSTGOUPSTAIRS;
  19. }

  20. if (const Player* player = caster->getPlayer()) {
  21. if (player->hasFlag(PlayerFlag_IgnoreProtectionZone)) {
  22. return RETURNVALUE_NOERROR;
  23. }
  24. }
  25. }


Edit: Grammar.

Edit 2: Someone can please explain me this:

  1. bool Monster::canSee(const Position& pos) const
  2. {
  3. return Creature::canSee(getPosition(), pos, 9, 9);
  4. }
I think if I know what to do with this I can solve one of my problems...


Edit 3: Well at npc.cpp I found this:

  1. bool Npc::canSee(const Position& pos) const
  2. {
  3. if (pos.z != getPosition().z) {
  4. return false;
  5. }
  6. return Creature::canSee(getPosition(), pos, 3, 3);
  7. }

Seems like I can just remove this "if" and see all npcs in all floors, but Im afraid it will bug the entire thing, tomorrow I will test this and post here...
 
Last edited:
To start, this is if the NPC is able to see you, not if you can see the NPC.

I am not sure about this but.....

  1. bool Npc::canSee(const Position& pos) const
  2. {
  3. if (pos.z != getPosition().z) {
  4. return false;
  5. }
  6. return Creature::canSee(getPosition(), pos, 3, 3);
  7. }
This is saying if you are on the wong Z access then it will return false (the NPC cant see you)

However, the 3, 3 in Creature::canSee(getPosition(), pos, 3, 3); I am assuming is the value of X and Y that the NPC can see.

So if you are 3 X positions away, and/or 3 Y positions away you can still be seen.

I am not sure if this is supported but you might be able to do 1 of 2 things.....

1) Change:
  1. bool Npc::canSee(const Position& pos) const
  2. {
  3. if (pos.z != getPosition().z) {
  4. return false;
  5. }
  6. return Creature::canSee(getPosition(), pos, 3, 3);
  7. }
to

  1. bool Npc::canSee(const Position& pos) const
  2. {
  3. if (pos.z != getPosition().z) {
  4. return Creature::canSee(getPosition(), pos, 3, 3);
  5. }
  6. return Creature::canSee(getPosition(), pos, 3, 3);
  7. }
This I am assuming would mean no matter what Z access you are on, if you are within 3 X positions and 3 Y positions of the NPC's position the NPC can still see/talk to you.

2) IDK if this part is supported or not...

You might be able to add another value after 3, 3 so making it this....

return Creature::canSee(getPosition(), pos, 3, 3, 2);

The 2 being how many floors up or down the NPC can see.

In the end you need to return the value of the NPC being able to see the position stated. returning it true won't do anything other then saying that its not a false, or error value. It doesn't make it know what you want.
 
Last edited:
  1. if (caster) {
  2. const Position& casterPosition = caster->getPosition();
  3. const Position& tilePosition = tile->getPosition();
  4. if (casterPosition.z < tilePosition.z) {
  5. return RETURNVALUE_FIRSTGODOWNSTAIRS;
  6. } else if (casterPosition.z > tilePosition.z) {
  7. return RETURNVALUE_FIRSTGOUPSTAIRS;
  8. }
Can be,

  1. if (caster) {
  2. const Position& casterPosition = caster->getPosition();
  3. const Position& tilePosition = tile->getPosition();
  4. if (casterPosition.z < tilePosition.z) {
  5. return RETURNVALUE_NOERROR;
  6. } else if (casterPosition.z > tilePosition.z) {
  7. return RETURNVALUE_NOERROR;
  8. }

However, I am not sure how the animated effects will implement with this. It's very possible the distance effects will break and only the onhit effects will go through.
 
don't bump be4 24 hours or ur post will delete " about me i don't do something like this be4" maybe anyone can help you again don't Bump be4 24 hours
How is responding to someone's question considered bumping a thread?
 
How is responding to someone's question considered bumping a thread?
You can see his post was last edited by moderator. Most likely he had additional posts that were combined into his first post by said moderator.
 
Back
Top