1. Post #1
    Gold Member
    Feihc's Avatar
    October 2006
    1,016 Posts
    So I was looking around for TF2 skins the other day when I came across this pokeball model for the scouts Sandman ball, when the idea for a Pokeball SWEP hit me. I did some searching and found that there were indeed a few of them already out there, but none lived up to the standards that I was looking for. In my day we only have 151 Pokemon and we were damn proud of them!

    So I started coding my own and man, it's been a lot more tricky that I anticipated but I am keeping with it!

    I think I have enough done (about half) of this to make a WIP thread for it.

    Have some media:


    Updated: Improved wobble of ball
    Added: Darkening on successful capture

    Highly highly highly improbable capture of a full health antlion guard - 1% chance of ever happening.


    The formula I used (which I'm hoping is correct) is from: http://bulbapedia.bulbagarden.net/wiki/Catch_rate
    and is as follows (copy pasta win)

    There are a multitude of factors that go into determining whether or not you catch an NPC, such as:
    -Their max health (ent:GetMaxHealth())
    -Their current health (ent:Health())
    -The rate of catch for each NPC (Determined by their size ent:GetPhysicsObject():GetVolume() / 1000) - I had to divide by 1000 to make it easier to work with
    -Any status ailments on them (currently only checks for ent:IsOnFire(), will probably add a system later to determine if they were hit with poison damage recently for a poison check)
    -There currently is no bonus provided by the ball, because it is simply the 1x Pokeball, but if I make more later (if I get the models) then I will add this variable in
    These factors also determine how many times the ball twitches on the ground

    Once you have that value (the "a" value) you then go on to calculate b, which is more directly related to determining the catch


    Then generate 4 random numbers between 0 and 65535, inclusive. For each number, check whether it's less than b; if so, the ball shakes once. If any number is greater than or equal to b, the Pokémon immediately breaks free. If all four of the numbers are less than b, then the Pokémon is caught. Note that if a is 255 or greater, then b is 65535 or greater, and then the Pokémon is guaranteed to be caught.

    So how does all of that nonsense translate into code?
    function ENT:DetermineCapture(ent)
    	if not ent then return end	
    	local shakes, maxhp, curhp, size, maxsize, pctrate, rate, a, b
    	shakes = 1
    	maxhp = ent:GetMaxHealth()
    	curhp = ent:Health()
    	size = ent:GetPhysicsObject():GetVolume() / 1000
    	maxsize = 650
    	pctrate = (maxsize - math.Clamp(size, 0, maxsize)) / maxsize
    	if pctrate == 0 then pctrate = .0005 end --To make it not impossible to catch really big shit
    	rate = 255 * pctrate
    	if ent:IsOnFire() then bonus = 1.5 else bonus = 1 end
    	a = (((3 * maxhp - 2 * curhp) * rate) / (3 * maxhp)) * bonus
    	if a > 255 then return 5 end --Instant catch
    	b = 1048560 / math.sqrt(math.sqrt(16711680/a))
    	for i = 1, 4 do
    		local rand = math.random(0, 65535)
    		if rand < b then
    			shakes = shakes + 1
    		elseif rand >= b then
    			shakes = 0
    			break
    		end
    	end
    	return shakes
    end
    

    Expensive? Yes. Awesome? Yes. Could probably use some work? Most definitely.

    With the rates and everything that I'm using currently, out of all of the default NPC's, an antlion guard with full health and not on fire will be the hardest thing to catch

    Lets show you some math to show you what I mean:
    An antlion guard has 500 health when you spawn him.
    His rate is around 7.85
    Non-burning bonus = 1
    a = (((3 * 500 - 2 * 500) * 7.85) / (3 * 500)) * 1
    a = 2.62
    Then b would = 1048560 / sqrt(sqrt(16711680/2.62))
    b = 20864.77
    The probability p of catching a Pokémon, given the values a and b calculated above, is:

    p = ((b+1)/(2^16))^4
    p = .010275

    Giving you a 1.0275% chance to catch a non-burning, full health Antlion Guard (And I caught it on film, suckas!)

    PROTIP: Damaging NPC's before trying to capture them makes it MUCH MUCH easier! (so does setting them on fire)

    So not only will this have the fancy, shiny, awesome effects of a real pokeball (I'm being a stickler on that one) but it also uses the same formula that the gameboy games do.

    Your Garrymon will also (in the end product) be able to evolve! (Because NPC's as large/larger than the Antlion Guard are damn near impossible to catch)
    Evolution tree's are as follows:

    City/Shield Scanner -> Manhack
    --(Not quite sure how the Scanners are going to gain experience, but I'll figure that out when I get to that point)
    Rollermine -> Hunter
    Headcrab -> Zombie Torso -> Zombie -> Zombine
    Fast Headcrab -> Fast Zombie Torso -> Fast Zombie
    Black Headcrab -> Poison Zombie
    Antlion -> Antlion Worker -> Antlion Guard
    --(Reasoning for why Worker comes after regular: they can both do the same things melee wise, can both fly, but the Worker can spit, giving it a ranged advantage, i.e. higher level skill)


    --Completed--
    -Throwing
    -"Absorb" effect
    -Catching (For the most part)
    -Pickup

    --To do--
    -Deploy system (large part of this project)
    -Menu (partially complete)
    -Evolution system


    FAQ
    Q: Can you catch other players Garrymon
    A: No. This is not meant to be a fight over who has what, its supposed to be a fight between the Garrymon

    Q: Can you catch players
    A: No. I'm not going to enable someone to carry you around on their waist for the entire time that you're on their server.

    Q: What's the point of all the complicated math?
    A: Because I can and I want it to resemble the games

    Q: Can I beta test it?
    A: No. If I want testers I will let you know.
    Reply With Quote Edit / Delete Reply United States Show Events Lua King x 49Funny x 5Winner x 1Informative x 1Artistic x 1 (list)

  2. Post #2
    Dennab
    February 2009
    1,983 Posts
    Looking forward to this, I'm pretty sure you can make the capture effects better though.
    Reply With Quote Edit / Delete Reply Italy Show Events Dumb Dumb x 1 (list)

  3. Post #3
    Gold Member
    Feihc's Avatar
    October 2006
    1,016 Posts
    Looking forward to this, I'm pretty sure you can make the capture effects better though.
    Yeah I was planning on improving them a bit. It's currently too fast for what I would like, I'm just focusing on the mechanics of it before I get the "ooh shiny" done. I want to make it so the model kind of shrinks and LERPs into the ball, but thats inflater work and I haven't messed with it yet.

    Edited:

    Was just doing a little more theory crafting and even with an Antlion Guard at 1 health, there is still only about a 3% chance to catch him if he's not on fire.
    Difficult Garrymon are difficult O.o

  4. Post #4
    moo
    CowThing's Avatar
    November 2006
    4,584 Posts
    For the past few weeks I've had a sudden Pokemon craze, and I am really liking this. How will the fighting work?

  5. Post #5
    If clothing didn't exist and everyone walked around with their penises fully erect I would have all the bitches.
    ROFLBURGER's Avatar
    May 2009
    18,443 Posts
    It's nice you found a good catchrate formula.

  6. Post #6
    Gold Member
    Feihc's Avatar
    October 2006
    1,016 Posts
    For the past few weeks I've had a sudden Pokemon craze, and I am really liking this. How will the fighting work?
    When you "choose" your Garrymon and send it out, it will from then on hate anything that attacks you and automatically hate things that hate you to begin with (even if they aren't attacking)
    All the actual fighting will be done with their own abilities or what ever they can do. They will spawn with whatever weapon they had when you caught them (sort of like the abilities in real pokemon)

  7. Post #7
    Ghor's Avatar
    February 2009
    213 Posts
    oh god damnit I was just about to do this too

    oh well. It looks pretty good, at any rate. That ball-twitching seems really rigid though. Why not rope or ballsocket constrain it to the world or something and apply random or alternating force to it?
    Reply With Quote Edit / Delete Reply United States Show Events Winner Winner x 2 (list)

  8. Post #8
    Cool Kid
    meatwad253's Avatar
    December 2009
    821 Posts
    Very cool looking, if you can make it so that they follow your commands "kinda like Spacetech's pet mod" then it'd be awesome.

  9. Post #9
    Gold Member
    Feihc's Avatar
    October 2006
    1,016 Posts
    oh god damnit I was just about to do this too

    oh well. It looks pretty good, at any rate. That ball-twitching seems really rigid though. Why not rope or ballsocket constrain it to the world or something and apply random or alternating force to it?
    Because that makes too much sense :facepalm:
    I worked a WHILE on getting the ball to even twitch like it is, but the sound effect I'm using for it now makes me want to change that as well, even though it makes me sad.

    However last time I tried using constraints in a SENT it didn't work too well.

    Edited:

    I just tried changing it to a ballsocket constraint when it lands, but you can't constrain in ENT:PhysicsCollide() and there's really no other good place to put it (I tried and I cant seem to get it to work either way)
    Reply With Quote Edit / Delete Reply United States Show Events Useful Useful x 1 (list)

  10. Post #10
    MerzBro's Avatar
    January 2011
    1,149 Posts
    you should make a gamemode and name it Pokemon:Source
    Reply With Quote Edit / Delete Reply Canada Show Events Agree Agree x 3 (list)

  11. Post #11
    Gold Member
    Feihc's Avatar
    October 2006
    1,016 Posts
    Good news, everyone!

    I got the Ballsocket idea to work - the wobble looks much better now. Will record a new video once I tweak it a little more.

    +1 internets to Ghor for the idea

    Edited:

    Updated OP with video of fluid wobble.
    Reply With Quote Edit / Delete Reply United States Show Events Winner Winner x 3 (list)

  12. Post #12
    RusselG's Avatar
    February 2011
    493 Posts
    This is great! Will there be a release soon?

  13. Post #13
    Free Bradley Manning!
    Persious's Avatar
    April 2010
    2,193 Posts
    Wow. Amazing. You japanese OP? (Just though about it because its Pokemon :3)
    Reply With Quote Edit / Delete Reply Faroe Islands Show Events Dumb Dumb x 10Funny Funny x 1Disagree Disagree x 1 (list)

  14. Post #14
    Gold Member
    Crap-Head's Avatar
    May 2010
    346 Posts
    Wow. Amazing. You japanese OP? (Just though about it because its Pokemon :3)
    Yea. Hes Japanese.

    About Feihc
    Location: Michigan, USA

    Anyways, good work. The videos looks great!
    Reply With Quote Edit / Delete Reply Denmark Show Events Zing Zing x 8Funny Funny x 1 (list)

  15. Post #15
    Gold Member
    Feihc's Avatar
    October 2006
    1,016 Posts
    Wow. Amazing. You japanese OP? (Just though about it because its Pokemon :3)
    So because I'm a Pokemon fan I must be from Japan, rite? XD

    Still trying to think of the best way to save and store what you've caught and all - as well as waiting to see if Garry puts in a function I requested in the bug tracker (which would help a lot more people than just myself, I would think)
    Reply With Quote Edit / Delete Reply United States Show Events Agree Agree x 3 (list)

  16. Post #16
    Free Bradley Manning!
    Persious's Avatar
    April 2010
    2,193 Posts
    Nah bro, I'm just asking. This looks great, and I don't mean it in any disrespecting way (:

    Edited:

    And, I'm not even living near Japan and I've got many nintendo 64 pokemon games, and for my gameboy.
    Reply With Quote Edit / Delete Reply Faroe Islands Show Events Dumb Dumb x 4 (list)

  17. Post #17
    Skapocalypse's Avatar
    November 2008
    760 Posts
    Diggin' the new wobble. Looking good

  18. Post #18
    Hentie's Avatar
    May 2010
    1,843 Posts
    Because that makes too much sense :facepalm:
    I worked a WHILE on getting the ball to even twitch like it is, but the sound effect I'm using for it now makes me want to change that as well, even though it makes me sad.

    However last time I tried using constraints in a SENT it didn't work too well.

    Edited:

    I just tried changing it to a ballsocket constraint when it lands, but you can't constrain in ENT:PhysicsCollide() and there's really no other good place to put it (I tried and I cant seem to get it to work either way)
    Set damping to really high, use a user message and send the EntIndex and the number of wobbles, grab the entity and set a variable on it, meanwhile do a smooth wobble using math.sin() and Entity:SetAngle() on the ENT:Draw() hook if the variable is true.

    Using physics to do the wobble sounds unoptimized and can look really bad if you're on a slightly laggy server. It also has the con of friction when it rotates.
    Reply With Quote Edit / Delete Reply United States Show Events Lua Helper Lua Helper x 1 (list)

  19. Post #19
    Gold Member
    Feihc's Avatar
    October 2006
    1,016 Posts
    Set damping to really high, use a user message and send the EntIndex and the number of wobbles, grab the entity and set a variable on it, meanwhile do a smooth wobble using math.sin() and Entity:SetAngle() on the ENT:Draw() hook if the variable is true.

    Using physics to do the wobble sounds unoptimized and can look really bad if you're on a slightly laggy server. It also has the con of friction when it rotates.
    Hrm, didn't think about an Ent:Draw() wobble. I can always disable the friction on it though. It seems to work fine now.

  20. Post #20
    Gold Member
    noobcake's Avatar
    November 2006
    3,541 Posts
    Amazing

    Putting this on my "Anticipated Mods" list.

  21. Post #21
    Gold Member
    Feihc's Avatar
    October 2006
    1,016 Posts
    Starting work on the selection menu - let me know what you think
    Reply With Quote Edit / Delete Reply United States Show Events Lua King Lua King x 3 (list)

  22. Post #22
    Gold Member
    Crap-Head's Avatar
    May 2010
    346 Posts
    Starting work on the selection menu - let me know what you think
    Pictureszzzz
    Looks cool. I like how the top left cornor is cutted of. Maybe make the pokeball spin around? And remove the white background of the picture/making the picture background transperant.

  23. Post #23
    Gold Member
    Feihc's Avatar
    October 2006
    1,016 Posts
    It's a DModelPanel - it does spin around, the pokeball model is just a placeholder for whatever Garrymon that you'll be displaying in that main display window (the rest will be on the right in a simple list)

    Edited:

    Anyone have the equation or whatever to slowly change a health bar from green to red the lower your health gets? I forgot the math and lost my copies of it =(

  24. Post #24
    Fantym420's Avatar
    October 2010
    870 Posts
    here ya go
    local percentCalc = 255 * (traceEntHealth / traceEntMaxHealth)
    
    greenToRed = Color(255-percentCalc,percentCalc,0,255)
    
    Reply With Quote Edit / Delete Reply United States Show Events Friendly Friendly x 1 (list)

  25. Post #25
    Gold Member
    Feihc's Avatar
    October 2006
    1,016 Posts
    here ya go
    local percentCalc = 255 * (traceEntHealth / traceEntMaxHealth)
    
    greenToRed = Color(255-percentCalc,percentCalc,0,255)
    
    Thank you, kind sir!

    Edited:


    'nother update

  26. Post #26
    CakeMaster7's Avatar
    October 2010
    11,184 Posts
    This is awesome, so what exactly can be catchable, any NPC?




    And also, we really need a gamemode for this.
    Reply With Quote Edit / Delete Reply United States Show Events Agree Agree x 1 (list)

  27. Post #27
    Gold Member
    Crap-Head's Avatar
    May 2010
    346 Posts
    This is awesome, so what exactly can be catchable, any NPC?
    And also, we really need a gamemode for this.
    Someone will probably do a gamemode when this is released.
    Reply With Quote Edit / Delete Reply Denmark Show Events Agree Agree x 2Informative Informative x 1 (list)

  28. Post #28
    Free Bradley Manning!
    Persious's Avatar
    April 2010
    2,193 Posts
    Thank you, kind sir!

    Edited:


    'nother update
    Wow. Realy, wow. This looks god damn epic.

  29. Post #29
    TheSmartass's Avatar
    January 2010
    1,131 Posts
    Pokeball should stay still after darkening, emit some stars and play the caught pokemon theme for a while.

    Edited:

    Duh-duh-du-duh duh duh, dum-de-dum doo...
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Agree Agree x 2Funny Funny x 1 (list)

  30. Post #30
    TGiFallen's Avatar
    January 2010
    1,364 Posts
    Thank you, kind sir!

    Edited:


    'nother update
    Looks really good, but it's spelled "Controller"

  31. Post #31
    Gold Member
    Feihc's Avatar
    October 2006
    1,016 Posts
    Looks really good, but it's spelled "Controller"
    s'what I get for coding in the middle of the night again XD

    Edited:

    This is awesome, so what exactly can be catchable, any NPC?




    And also, we really need a gamemode for this.
    My end goal: you have discovered it.

  32. Post #32
    moo
    CowThing's Avatar
    November 2006
    4,584 Posts
    I don't think the bar should smoothly go down to red, it should go green, yellow, red, like in the game.

  33. Post #33
    Gold Member
    PortalGod's Avatar
    August 2009
    1,841 Posts
    Back from the first gamemode I started working on, my code for that looked like this:
    (HPPercent > 0.5) and Color(113, 247, 168) or ((HPPercent > 0.25) and Color(224, 219, 57) or Color(237, 91, 60))
    
    Those are the colors from the actual game, too.
    Looking through this code, it's absolutely terrible. I can't believe it got me an interview and everything..

  34. Post #34
    President of the Luigi Fanclub and creator of the Pikmin Mod and Ultimate Chimera Hunt
    Aska49's Avatar
    October 2006
    889 Posts
    This looks pretty cool so far, any plans to make it available on Toybox too?

    Are you basing the wobble off of the one shown in the anime, or the "1...2...3...DING" they use in the games? Your current effect seems to point to the former, whereas before it didn't.

  35. Post #35
    Gold Member
    Feihc's Avatar
    October 2006
    1,016 Posts
    This looks pretty cool so far, any plans to make it available on Toybox too?

    Are you basing the wobble off of the one shown in the anime, or the "1...2...3...DING" they use in the games? Your current effect seems to point to the former, whereas before it didn't.
    I've gone through tons of different versions of the wobble, not exactly sure what I planned for it, but this one looks OK for now.

    Updating health bar to use set health points.
    Reply With Quote Edit / Delete Reply United States Show Events Winner Winner x 1 (list)

  36. Post #36
    Gold Member
    BurningPride's Avatar
    August 2008
    1,610 Posts
    This is... amazing.
    Reply With Quote Edit / Delete Reply United States Show Events Agree Agree x 1 (list)

  37. Post #37
    Gold Member
    Feihc's Avatar
    October 2006
    1,016 Posts
    I'm really in need of a few models for this, but the modeling request section never yields me any results. If anyone can model, or knows someone whose willing to help me that would be awesome.

    I need an animated pokeball - one that has an animation for opening and closing, because just having it stay closed all the time looks wonky.
    Also if you could put the garrysmod "g" on top of it like the masterball has an "M" that would be awesome. The font for it is "coolvectica".

    I also need some kinda pokecenter type thing with 6 attachments - one for each possible ball to be placed onto it.

    In my wildest dreams I'd have a view model with several awesome animations:
    1) When you draw out the weapon, you'd hold a tiny pokeball in your fingers that would slowly grow out to be the full sized one, like in the anime
    2) A good throwing animation or two, perhaps an overhead and a side throw
    3) Rotate the pokeball forward for the return command.

    Granted I know I'm probably not gonna get any of these, but a coder can dream right?

    Edited:

    Or if someone wanted to make a pokemon map with Pokecenter, Gym, Arena and a wilds area that would be awesome =P
    Reply With Quote Edit / Delete Reply United States Show Events Friendly Friendly x 2Agree Agree x 1 (list)

  38. Post #38
    Gold Member
    Killer_Steel's Avatar
    October 2007
    1,362 Posts
    Talk to FluxMage, he could give you a hand if he isn't busy. If not, I think Generic could be good also.

    I've been wanting to try some modelling meself, so if I get any time soon, I could toss in my own attempt, if you don't mind. Shouldn't be hard...I'm just a complete novice at texturing.

  39. Post #39
    Gold Member
    Feihc's Avatar
    October 2006
    1,016 Posts
    Found a much better model on gamebanana that solves a lot of the sticking problems it had when wobbling, and doesn't have the vertex issues on the front face that the original model did. Only problem now the wobble goes from slow to spinning OUT OF FUCKING CONTROL - working on it still.

    Edited:



    Added stars - shows new model (not visibly different from the back)
    Reply With Quote Edit / Delete Reply United States Show Events Artistic Artistic x 2 (list)

  40. Post #40
    johnny guitar was here
    comet1337's Avatar
    February 2010
    5,486 Posts
    does A+B+DOWN help?
    Reply With Quote Edit / Delete Reply Finland Show Events Funny Funny x 4Winner Winner x 1Lua Helper Lua Helper x 1 (list)