1. Post #1
    Athos's Avatar
    July 2007
    87 Posts


    My primary language is not english, so this text may contain lots of mistakes, please forgive them...

    MBilliards, it's a billiard game in gmod, unique and complete!
    The code lacks at comments, but it's not that difficulty to understand how it works, and the addon
    was tested in SinglePlayer and Multiplayer in LAN.

    All models (billiard tables, cue and balls) are Real Scaled:
    Balls: 57mm of diamenter;
    Cue: 154cm length, cue tip with 12mm of diameter;

    Features:
    (*) Full Singleplayer and Multiplayer support;
    (*) High quality models/materials;
    (*) Custom wood style GUI (built for 1024x768, but you'll not have any problem with other resolutions [I hope]);
    (*) 3 table sizes (9ft, 10ft, 12ft) and 3 table colors (Green, Light blue, Red);

    Commands: (These commands doesn't have to be called directly from the console):
    (*) "billiard_quit" - used to get you out of a billiard game, NOTE: If you quit, you'll lose the game.
    (*) "billiard_acceptorefuse" Bool - only the "owner" of a billiard table can use this command,
    this is used to accept or refuse a "join game" request from other players.

    Server ConVars:
    (*) "billiard_admins_only" def: false - Sets whether if only admins can create new billiard tables or not
    (*) "billiard_max_tables" def: 4 - How many billiard tables are allowed to be created, this value is global.
    (*) "billiard_req_time" def: 20 - Request time limit, in seconds, if one player requested to join a billiard table,
    the "owner" of that table will have 20 seconds to refuse or accept, it's automatically refused if it reaches zero.
    (*) "billiard_no_training" def: true - Should Training mode be disabled? In MY point of view, the training mode should
    always be disabled unless in single player or LAN with low players, because in the Training mode only one
    player is allowed per billiard table.

    Known bugs:
    (*) When a ball collides with other ball or with the table at low velocity (usually less than ~0.15) the ball's velocity
    will be increased (Not much), I'm sure it's related to the engine, so most of these kind of problems can't be fixed.
    Keep in mind that Source Engine physics isn't perfect nor optmized for billiard playing.
    (*) If you quit the game while no-clipping inside the world or any other prop it'll cause errors, I really don't understand why this
    happens.

    The Options when creating a billiard table:


    (*) Enable Anti BFH (BFH means Ball Flying over Hole) - If the ball's velocity is high enough and has been stroke
    into a pocket the possibilities that the ball hits the pocket and returns back are huge, so to avoid such things I have created
    a way to force this ball to be pocketed (althought that effect still happens), actually there's two methods of doing so:
    Method 1 - Uses the ball's think function to detect if it's over a hole, by using a trace.
    Method 2 - Uses the Billiard table think function to detect if any ball is over a pocket, by using ents.FindInSphere()
    for each pocket.
    Disabling this option may increase performance.

    (*) MingeBag Protection - I've included a way to protect billiard tables (also cues and balls) from being messed up
    by mingebags, if enabled, the table will be un-moveable, tools won't work, etc. Also, a special model is placed over
    the billiard table to avoid mingebags from moving the balls by walking over them or using other models to mess up
    with the game.

    (*) Training Mode - If enabled, no other player will be able to request to play with you, also, you can move any ball
    at any time (Game rules still apply!).

    (*) SmartCue - If enabled, the Cue won't pass trought into any ball (but still passes trough the table), it uses a trace to
    check if there's a ball in it's "route", this feature is just visual, it doesn't affect gameplay.
    Disabling this option may increase performance.

    (*) Cue FirstPerson - If enabled, you will have a FirstPerson camera in the cue during your Turn, like I said before, it uses the
    server Move hook to do it's movement. Disabling this option may increase performance.

    (*) GameType - Here you can choose what game type you want to play, currently there is 8-Ball, 9-Ball, Snooker and Rotation.
    Each gametype has it's own rules.

    (*) Round Time - Amount of time that the player will have to position cue ball / aim / shoot, if it reaches zero, it's a foul
    and the incoming player will have the CueBall in hand. You can choose 15sec, 30sec, 45sec or 60sec.

    (*) TableSize - You can choose between 3 table sizes: 9ft, 10ft and 12ft
    You cannot play Snooker in 9ft table!

    The HUD


    Mouse Client Configuration:
    As of revision 6, a new feature has been added, it's the client mouse configuration, which allows each client to
    configure mouse sensitivity and inverted X/Y axis.
    This mouse configuration only affects mouse while playing in a billiard game!
    You can access this menu by pressing F7

    "Mouse Sensitivity" def: "2" - Mouse sensitivity, value range from 0.5 to 10.
    "Cue Invert Mouse Horizontally" def: 0 - Mouse inverted horizontally? Only works while in Cue Camera
    "Cue Invert Mouse Vertically" def: 0 - Mouse inverted vertically? Only works while in Cue Camera
    "Invert Mouse Horizontally" def: 0 - Mouse inverted horizontally?
    "Invert Mouse Vertically" def: 0 - Mouse inverted vertically?

    Note: These mouse setting are saved locally, which means you don't have to configure each time you enter a server or re-open gmod.

    Controls:
    Entering a Billiard table:
    Just walk close to one table and press "Use" button (usually it's the E button), but if the table already has a player
    he is considered the "owner" of such table and will be his decision if you will be able to play with him or not.

    Exiting a billiard table:
    Just press the "Use" button again (usually it's the E button) and you be prompted if you really want to quit the game.
    Note: by quiting a game you'll automatically lose the game.

    If the option CueFirstPerson is enabled:
    Cue controlling is done by moving your mouse(forward/backward/left/right);
    to strike, keep pressing your "Attack2" button (usually it's the right mouse button) and move the mouse forward/backward;
    You can also zoom in and zoom out by binding your mouse wheel (just type this in the console):
    bind mwheelup "invprev; decbzoom"
    bind mwheeldown "invnext; incbzoom"
    Mouse Tip:
    After striking with the mouse, don't release the right mouse button until your mouse is fully stopped.

    else if the option CueFirstPerson is disabled:
    Aiming the cue is done by player movement, to shoot you'll have to set the shot force manually by using the same
    zoom binding, and the shot is done by pressing the "Attack" button (usually it's the left mouse button)
    This is a light weight method, but is harder to aim.

    Ball positioning (only while in hand) is done by keeping pressed the "Sprint" button (usually it's the Left Shift button)
    and moving your mouse forward/backward/left/right.

    To set a biliard table's configuration after it's creation, exit the game (if you are playing) and keep the "Reload" button pressed
    (usually it's the R button) and press "Use" button (usually it's the E button), a window will appear with the current
    table's configuration.

    In Training Mode, to change the ball press the Forward button (usually it's the W button) or Back button (usually it's the S button)
    and you'll be able to move it.

    Other notes:
    If a player jumps in a table with the mingebag protection on, he automatically loses the game.
    Pocketing the CueBall is a foul and in all games (except in Snooker) the incoming player have the CueBall in hand.

    For LUA developers:
    If you want to implement a gambling system, I've also made some cool hooks for it:
    hook.Add("CanPlayerEnterBilliard", "myCanPlayerEnter", function(ptable, ply) end)
    hook.Add("OnBilliardGameStart", "myBilliardStartFunc", function(ptable, ply1, ply2) end)
    hook.Add("OnBilliardGameEnd", "myBilliardEndFunc", function(ptable, winner, loser) end)

    NOTE: You should always verify if ply2/loser exist, because these hooks are called even with only one player!
    The hook "OnBilliardGameStart" is called before anything and "OnBilliardGameEnd" is called after everything else.
    Slot1 should Always have a player if is intend to play!

    When creating a billiard table, make sure you set its size before call Spawn(), and never forget to call SetConfig()
    example:
    Code:
    local ent = ents.Create("billiard_table")
    ent:SetSize(9) -- Can be 9, 10 or 12
    ent:SetPos(pos)
    ent:Spawn()
    ent:SetConfig() -- As of revision 9, you can leave blank to use the default config
    [release]Gameplay video: (Recorded in SinglePlayer):
    http://youtube.com/watch?v=jptgCXE1PKI



    [/release][release]SVN Download: http://mbilliards.googlecode.com/svn/trunk/
    If you don't know how to use SVN, follow this tutorial[/release][release]ChangeLog:
    =========================
    Version 1.0.4 - Revision 12
    (*) "Move" hook no longer returns CMoveData, which was causing issues with other "Move" hooks.

    =========================
    Version 1.0.4
    (*) Added new gametype: Carambol
    (*) Fixed Camera problem in training mode

    =========================
    Version 1.0.3
    (*) Added Client Mouse adjustments, can be accessed by pressing F7
    (*) Added one more LOD to cue and to each billiard table

    =========================
    Version 1.0.2
    (*) Fixed problem related to requests menu
    (*) Using now the "base_anim" base for the entites
    (*) Ball entities are now stored directly in the billiard table, less use of ents.GetByIndex()
    (*) After player respawns their weapons are stripped
    (*) Addded Play area, leaving this area may result in a loss of game

    =========================
    Version 1.0.1
    (*) Fixed "unknown" foul reason in Snooker
    (*) Fixed the problem where sometimes the next player is wrong
    (*) Changed ball's speed loss when collides with other ball
    (*) Improved some functions

    (*) New Icon.tga image

    =========================
    Version 1.0.0
    (*) Addon released[/release]
    Please let me know if you find any other bug.

    MBilliards by Athos
    Reply With Quote Edit / Delete Reply Brazil Show Events Lua King Lua King x 68Winner Winner x 2Zing Zing x 2Dumb Dumb x 1 (list)

  2. Post #2
    Jvs
    PENISCorp's First Employee
    Jvs's Avatar
    June 2009
    1,596 Posts
    I don't even know what to say,just looked at the video and it's awesome.
    How much time have you spent on it?
    (*) If you quit the game while no-clipping inside the world or any other prop it'll cause errors, I really don't understand why this
    happens.
    This probably happens because you try to access to an entity on the client when you are out of the world.
    The entity will not be streamed in that case,and you'll get errors because of this.
    Reply With Quote Edit / Delete Reply Italy Show Events Lua Helper Lua Helper x 2Lua King Lua King x 1 (list)

  3. Post #3
    : D
    : D's Avatar
    August 2010
    936 Posts
    Wow.... AWESOME!
    Reply With Quote Edit / Delete Reply Norway Show Events Agree Agree x 5 (list)

  4. Post #4
    Gold Member
    BummieHEad's Avatar
    January 2010
    466 Posts
    Really cool.

  5. Post #5
    Risingmoon_01's Avatar
    December 2010
    82 Posts
    I can tell already this is going to get some attn. Excellent job man.

  6. Post #6
    Rayjingstorm's Avatar
    June 2010
    1,536 Posts
    Looks great man. Nice work!

  7. Post #7
    Dizla's Avatar
    November 2010
    73 Posts
    Wow, I really need to try this out. Looks great man!
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Agree Agree x 1 (list)

  8. Post #8
    RudobikuKatsuyo's Avatar
    December 2010
    1 Posts
    Just one thing to say:
    Niiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiice〜
    Reply With Quote Edit / Delete Reply France Show Events Dumb Dumb x 3Funny Funny x 1 (list)

  9. Post #9
    Gold Member
    .\\Shadow}'s Avatar
    November 2009
    893 Posts
    Holy shit.

  10. Post #10
    laxplayer77alt's Avatar
    July 2009
    568 Posts
    SHITS LEGIT I LOVE YOU :)

    also make poker man i'd make babies with you!

    ( if you don't ill still make babby w/ you mang)
    Reply With Quote Edit / Delete Reply United States Show Events Optimistic Optimistic x 1Friendly Friendly x 1 (list)

  11. Post #11
    Athos's Avatar
    July 2007
    87 Posts
    Update!
    Check first post to get the update and changelog.

  12. Post #12
    Nimhster's Avatar
    April 2009
    656 Posts
    I miss my billiard table, but this will bring back the fun I always used to have. Excellent work!

  13. Post #13
    Gold Member
    LuaStoned's Avatar
    September 2007
    1,356 Posts
    It's really nice to see new people coming up with such great stuff :)
    Reply With Quote Edit / Delete Reply Austria Show Events Agree Agree x 5 (list)

  14. Post #14

    June 2010
    241 Posts
    This is frickin' awesome!!

    Keep up the good work!

  15. Post #15
    Ex-Least Respected Usergroup
    icemaz's Avatar
    June 2007
    7,113 Posts
    Works brilliantly.

  16. Post #16
    yokko's Avatar
    June 2009
    39 Posts
    Excellent work :)
    Reply With Quote Edit / Delete Reply Hungary Show Events Agree Agree x 1Disagree Disagree x 1 (list)

  17. Post #17
    xomaxhox's Avatar
    April 2010
    254 Posts
    Wow, that is just

    MINDBLOWING

  18. Post #18
    yokko's Avatar
    June 2009
    39 Posts
    if one or two players are playing and one of them disconnect then its unuseable

  19. Post #19
    Athos's Avatar
    July 2007
    87 Posts
    You mean the table "stops" working right?
    If yes, that's what I'm working on...

    edit:
    There is a mistake in sv_billiards.lua, go to line #84 and change from "PlayerDisconnect" to "PlayerDisconnected"

    just a temp fix for that until I commit the changes...
    Reply With Quote Edit / Delete Reply Brazil Show Events Lua Helper Lua Helper x 2Lua King Lua King x 1 (list)

  20. Post #20
    Gold Member
    dj_night's Avatar
    January 2008
    1,058 Posts
    That's nice, I love it.

    Bom trabalho ;)

  21. Post #21
    yokko's Avatar
    June 2009
    39 Posts
    You mean the table "stops" working right?
    If yes, that's what I'm working on...

    edit:
    There is a mistake in sv_billiards.lua, go to line #84 and change from "PlayerDisconnect" to "PlayerDisconnected"

    just a temp fix for that until I commit the changes...
    oh cool. Make an exit range too, i mean if player go away like ~400 unit then he lose.

  22. Post #22
    Athos's Avatar
    July 2007
    87 Posts
    Make an exit range too, i mean if player go away like ~400 unit then he lose.
    Just finished such system, if the player get away 200 units from the billiard table a warn is sent and he'll have 5 seconds to get back.
    Reply With Quote Edit / Delete Reply Brazil Show Events Agree Agree x 1 (list)

  23. Post #23
    Gold Member
    noobcake's Avatar
    November 2006
    3,651 Posts
    If you're planning to make any more such games, how about Darts?
    Reply With Quote Edit / Delete Reply United States Show Events Agree Agree x 5 (list)

  24. Post #24
    Gold Member
    blackops7799's Avatar
    December 2006
    1,714 Posts
    There seems to be an issue where if a player sends a request when the request menu is open, the menu breaks and is unable to close glitching out the game.

    I would like to recommend using the entity base "base_anim" rather than "base_gmodentity" so it can be used outside of sandbox. You may also want to make the cue's think function predicted to make it a lot smoother in multiplayer.

  25. Post #25
    Hanibal's Avatar
    June 2010
    2,726 Posts
    LAN billiard party, wohoo
    Reply With Quote Edit / Delete Reply United States Show Events Winner Winner x 2 (list)

  26. Post #26
    Athos's Avatar
    July 2007
    87 Posts
    You may also want to make the cue's think function predicted to make it a lot smoother in multiplayer.
    Yes, but when the server changes angles (as example) it is synced to client, returning to where it was

  27. Post #27
    |FlapJack|'s Avatar
    July 2009
    6,138 Posts
    Yes, but when the server changes angles (as example) it is synced to client, returning to where it was
    Yeah, the idea is when the server changes the angles the client's already doing it so it doesn't need to snap to where it should be.

  28. Post #28
    Athos's Avatar
    July 2007
    87 Posts
    But thats problem, example:
    Client->Changed Angle to (0,5,0)->Sent to server;
    After 0.2 secs the server returns the (0,5,0) to all clients;
    The client who made move now it is in angle at (0,15,0);
    But because the server sent the angle to all clients, the player who made the move will have his angles changed to (0,5,0)... creating a non-smooth movement...

  29. Post #29
    |FlapJack|'s Avatar
    July 2009
    6,138 Posts
    That's why you write prediction that works properly and doesn't have a massive delay like that.

  30. Post #30
    Gold Member
    BummieHEad's Avatar
    January 2010
    466 Posts
    Possible you could add something that shows how many times a player has won and lost ?

  31. Post #31
    yokko's Avatar
    June 2009
    39 Posts
    If I send the request to an other player who is playing, the menu does not show up for him, so players can not play with each other.
    Reply With Quote Edit / Delete Reply Hungary Show Events Agree Agree x 1 (list)

  32. Post #32
    Athos's Avatar
    July 2007
    87 Posts
    If I send the request to an other player who is playing, the menu does not show up for him, so players can not play with each other.
    Fixed in Revision 3

    edit:
    That's why you write prediction that works properly and doesn't have a massive delay like that.
    The only way I could think of doing this was:
    Every time the new round starts it sends the current cue angles (or reset it to be lightweight), then on each x seconds the client will send the new angles (through command?) to update the server cue angles.
    Reply With Quote Edit / Delete Reply Brazil Show Events Agree Agree x 1Friendly Friendly x 1 (list)

  33. Post #33
    ORIGOADAM's Avatar
    April 2008
    24 Posts
    We have a problem on our server with your biliard mod. Basicly it causes enormous lagg, i think thats because it sends the angles to every player.
    Reply With Quote Edit / Delete Reply Hungary Show Events Agree Agree x 1 (list)

  34. Post #34
    Athos's Avatar
    July 2007
    87 Posts
    Are you sure it's with mbilliards? The current version doesn't send any vector data (It's only sent once when creating a billiard table)

    Also, play with CueFirstPerson disabled and post results here.

  35. Post #35
    Waxx's Avatar
    January 2005
    236 Posts
    Is there a way to go about making a table spawn automatically via hammer?
    Reply With Quote Edit / Delete Reply Show Events Agree Agree x 2 (list)

  36. Post #36
    Gold Member
    blackops7799's Avatar
    December 2006
    1,714 Posts
    The only way I could think of doing this was:
    Every time the new round starts it sends the current cue angles (or reset it to be lightweight), then on each x seconds the client will send the new angles (through command?) to update the server cue angles.
    Prediction is when you have the same stuff being calculated on both the client and server. If you were to get the cue's think function working in the shared.lua file, it would be predicted. The client would be instantly updated without having to wait for the server to update making it smooth.

    Maybe someone else can explain this better.


    Is there a way to go about making a table spawn automatically via hammer?
    I got it working by doing this.

    function GM:InitPostEntity()
    
    	local BilliardSizes = { 9, 9, 10, 12 } -- I have 4 tables in the map
    	
    	for k,v in ipairs( ents.FindByClass( "billiard_table" ) ) do
    		if BilliardSizes[ k ] then
    			local ent = ents.Create("billiard_table")
    			local skin = math.random( 0, 2 )
    			ent.Size = BilliardSizes[ k ]
    			ent:SetPos(v:GetPos())
    			ent:SetAngles(v:GetAngles())
    			ent:Spawn()
    			ent:GetPhysicsObject():EnableMotion(false)
    			ent:SetConfig( 0, 2, false, true, 2, true, true )
    			ent:Activate()
    			if(ent.GameType == BILLIARD_GAMETYPE_SNOOKER) then skin = skin + 3 end
    			ent:SetSkin(skin)
    			BilliardTables = BilliardTables + 1
    			SafeRemoveEntity( v )
    		end
    	end
    	
    end

    It's hacky, but it works.
    Reply With Quote Edit / Delete Reply United States Show Events Friendly Friendly x 2Informative Informative x 1 (list)

  37. Post #37
    Viking Member
    Hellsten's Avatar
    November 2008
    5,518 Posts
    Cues tend to fuck up when they touch a player.

    Also, I was playing some Billiard and this guy appears behind the counter as I was looking for a good shot.

    Reply With Quote Edit / Delete Reply Sweden Show Events Artistic Artistic x 1Funny Funny x 1 (list)

  38. Post #38
    Waxx's Avatar
    January 2005
    236 Posts
    Did you add entities in hammer to define where they're located, or is that done via script?

  39. Post #39
    Athos's Avatar
    July 2007
    87 Posts
    Cues tend to fuck up when they touch a player.
    What exactly happens ?
    Cues have a "weapon" collision group, which means it collides with everything but player...

  40. Post #40
    Viking Member
    Hellsten's Avatar
    November 2008
    5,518 Posts
    Hmm, maybe it's just the "disableplayercollision" plugin for assmod that fucks it up.

    I'll try removing it.

    And to answer your question, the cue spazzes out of control and flies away.
    Reply With Quote Edit / Delete Reply Sweden Show Events Agree Agree x 1 (list)