[Event] Walkthrough everything Ctrl + Arrow keys [TFS 1.X]

Discussion in 'GlobalEvents, Spells & CreatureEvents' started by Printer, Jan 10, 2015.

  1. Printer

    Printer if Printer then print("LUA") end Premium User

    Joined:
    Dec 27, 2009
    Messages:
    5,601
    Likes Received:
    1,897
    Best Answers:
    5
    Hello,

    Well some people have requested this missing feature which could be found in 0.3 series. Well i have made one for TFS 1.x.

    I will send a pull request to the forgottenserver project, but in case it may not be accepted. Due to, this is mby a personal future. This way is alot better than 0.3, since 0.3 was hardcoded while this is made by lua with few lines. Which make it even more easier to edit stuff.

    Go to events/events.xml and onTurn make sure write from 0 to 1.
    Now go to events/scripts and open player.lua and find Player:eek:nTurn(direction) and replace with this:
    Code (Text):
    1. function Player:onTurn(direction)
    2.     if self:getGroup():getAccess() and self:getDirection() == direction then
    3.         local nextPosition = self:getPosition()
    4.         nextPosition:getNextPosition(direction)
    5.  
    6.         self:teleportTo(nextPosition, true)
    7.     end
    8.  
    9.     return true
    10. end
    Cheers.
     
    Last edited: Aug 31, 2015
    Apollos, imkingran, kito2 and 12 others like this.
  2. Evan

    Evan A splendid one to behold Premium User

    Joined:
    May 6, 2009
    Messages:
    7,011
    Likes Received:
    923
    Best Answers:
    0
    Pretty clever
     
  3. Printer

    Printer if Printer then print("LUA") end Premium User

    Joined:
    Dec 27, 2009
    Messages:
    5,601
    Likes Received:
    1,897
    Best Answers:
    5
    Thanks :)
     
  4. tigerx2

    tigerx2 Member

    Joined:
    Apr 5, 2010
    Messages:
    102
    Likes Received:
    2
    Best Answers:
    0
    Hello :)
    I'm testing it and I found two problems:
    1. You can't just turn your character direction without moving too
    2. The whole account get this benefit, while it should only affect the GOD character
     
  5. Printer

    Printer if Printer then print("LUA") end Premium User

    Joined:
    Dec 27, 2009
    Messages:
    5,601
    Likes Received:
    1,897
    Best Answers:
    5
    That is what it meant todo, it should not autowalk to that direction ^^

    About the second thing you could replace:
    Code (Text):
    1. if self:getAccountType() == ACCOUNT_TYPE_GOD then
    with:
    Code (Text):
    1. if self:getGroup():getId() == 3 then
     
    tigerx2 likes this.
  6. tigerx2

    tigerx2 Member

    Joined:
    Apr 5, 2010
    Messages:
    102
    Likes Received:
    2
    Best Answers:
    0
    I know this is what it's meant todo, but in 0.3 you could turn yourself (without moving), and then after a sec (with the keys pressed) the character started to walkthrough. I mean, you can't turn yourself without moving, do you get it now?
     
  7. Printer

    Printer if Printer then print("LUA") end Premium User

    Joined:
    Dec 27, 2009
    Messages:
    5,601
    Likes Received:
    1,897
    Best Answers:
    5
    No? Just hold ctrl + arrow key. Then it should walkthrough walls.
     
  8. Ninja

    Ninja 「Speedwagon Foundation」 Staff Member Global Moderator

    Joined:
    Apr 6, 2010
    Messages:
    5,888
    Likes Received:
    1,490
    Best Answers:
    15
    It shouldn't move the player if the parameter direction is not the same as player direction.

    Replace
    Code (Text):
    1. if self:getAccountType() == ACCOUNT_TYPE_GOD then
    with
    Code (Text):
    1. if self:getDirection() == direction and self:getGroup():getAccess() then
     
    tigerx2 and Codinablack like this.
  9. Printer

    Printer if Printer then print("LUA") end Premium User

    Joined:
    Dec 27, 2009
    Messages:
    5,601
    Likes Received:
    1,897
    Best Answers:
    5
    Oh, now i see. But i like the way i did :p
     
  10. zbizu

    zbizu Retired

    Joined:
    Nov 22, 2010
    Messages:
    2,440
    Likes Received:
    1,347
    Best Answers:
    1
    Here is same way as it works on 0.4:
    Code (Text):
    1.  
    2. local dir = {}
    3. function Player:onTurn(direction)
    4.   if self:getAccountType() == ACCOUNT_TYPE_GOD then
    5.      local cid = self:getId()
    6.      if not dir[cid] then
    7.        dir[cid] = direction
    8.        return true
    9.      end
    10.    
    11.      if dir[cid] == direction then
    12.        local nextPosition = self:getPosition()
    13.        nextPosition:getNextPosition(direction)
    14.        dir[cid] = direction
    15.        self:teleportTo(nextPosition, true)
    16.      else
    17.        dir[cid] = direction
    18.      end
    19.   end
    20.   return true
    21. end
    22.  
    info: if script doesn't work and there are no errors set this in events.xml to "1" as here:
    Code (Text):
    1. <event class="Player" method="onTurn" enabled="1" />
     
  11. Ninja

    Ninja 「Speedwagon Foundation」 Staff Member Global Moderator

    Joined:
    Apr 6, 2010
    Messages:
    5,888
    Likes Received:
    1,490
    Best Answers:
    15
    Why are you using table to store player direction? :p
     
  12. zbizu

    zbizu Retired

    Joined:
    Nov 22, 2010
    Messages:
    2,440
    Likes Received:
    1,347
    Best Answers:
    1
    @Ninja
    This way it doesn't need storage to run.
     
  13. Ninja

    Ninja 「Speedwagon Foundation」 Staff Member Global Moderator

    Joined:
    Apr 6, 2010
    Messages:
    5,888
    Likes Received:
    1,490
    Best Answers:
    15
    @zbizu But you don't need to store player direction in a table in order to make it work like TFS 0.4 :p

    Code (Text):
    1. function Player:onTurn(direction)
    2.     if self:getDirection() == direction and self:getGroup():getAccess() then
    3.         local nextPosition = self:getPosition()
    4.         nextPosition:getNextPosition(direction)
    5.  
    6.         self:teleportTo(nextPosition, true)
    7.     end
    8.     return true
    9. end
     
    imkingran, HeberPcL and zbizu like this.
  14. zbizu

    zbizu Retired

    Joined:
    Nov 22, 2010
    Messages:
    2,440
    Likes Received:
    1,347
    Best Answers:
    1
    @Ninja
    Nice. You made it very short.
     
  15. strutZ

    strutZ Australian OT Member {AKA Beastn}

    Joined:
    Nov 16, 2014
    Messages:
    1,269
    Likes Received:
    446
    Best Answers:
    3
    Should edit main paste with ninjas code as printers wont work with TFS 1.2 =)
     
  16. Jaed Le Raep

    Jaed Le Raep ★Gaeming★

    Joined:
    Sep 3, 2007
    Messages:
    991
    Likes Received:
    192
    Best Answers:
    0
    This is awesome
     
  17. Moj mistrz

    Moj mistrz Monster Creator

    Joined:
    Feb 1, 2008
    Messages:
    919
    Likes Received:
    257
    Best Answers:
    5
    Hi guys, this script is really nice, I tried to remake it for monster spell(so monster can go through players and other monsters, but no blocking objects like walls), but I failed. This is where I get so far. I wanted to make it for TFS 1.2.
    Code (Text):
    1. function onCastSpell(creature, var)
    2.     local direction = creature:getDirection()
    3.     local nextPosition = creature:getPosition()
    4.     if (queryTileAddThing(creature, nextPosition) == RETURNVALUE_NOERROR) then
    5.         nextPosition:getNextPosition(direction)
    6.          
    7.         creature:teleportTo(nextPosition, true)
    8.     end
    9.     return true
    10. end
    Actually it works only for players + it checks if item is blockable only when you are already teleported on it :/, it wouldn't be so bad, but it still don't work for monsters, dunno why. It only works when I remove queryTileAddThing line, but it gives monster opportunity to walk on walls etc. I am sorry if it's not good thread for that, but I didn't wanted to make new one just to fix some easy(I suppose :D) thing. Would be also good if it moves creatures on its way(just like giant spider pushes minotaur for example).
    Thanks for any help :).
     
    Last edited: Aug 31, 2015
  18. bertil430

    bertil430 Kebab

    Joined:
    Nov 25, 2015
    Messages:
    190
    Likes Received:
    32
    Best Answers:
    0
    Hello I want this ability on my server, but im using OThire 2.0 so how should my script look like and where should I put it? I dont have events on my OT since its not newer versions
     
  19. HeberPcL

    HeberPcL [PowerOT.com.br]

    Joined:
    Aug 21, 2007
    Messages:
    1,275
    Likes Received:
    39
    Best Answers:
    0
    Thanks!!
     
  20. Dyabl0

    Dyabl0 Yes!

    Joined:
    Sep 22, 2009
    Messages:
    1,859
    Likes Received:
    257
    Best Answers:
    9
    How do you do instead of moving with Ctrl+Arrows (direction look), just press arrows and moves on.
    Also, if this is possible it should be allowed only between players and in pz tiles, nothing else.
     

Share This Page

Loading...