• Print

Author Topic: UDodge 2016  (Read 6328 times)

0 Members and 1 Guest are viewing this topic.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
UDodge 2016
« on: July 21, 2016, 03:01:12 pm »
I've been working a bit on UDodge, and I've gotten it to work without erroring, but I've run into a problem with the timed removal of the combine balls. The current code has an 'expire time' after which the pylon is removed from the pylons_firing table. Why is this? I don't understand the purpose of removing it from the table after a delay, because it prevents the combine ball removal code from running and the map gets filled with them. Hopefully you can remember your logic for this Megiddo.

The repo is on GitHub, and the code in question is in lua/entities/pylon/init.lua, if anyone wants to take a crack at it.
« Last Edit: July 21, 2016, 11:57:50 pm by roastchicken »
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: UDodge 2016
« Reply #1 on: July 21, 2016, 07:16:06 pm »
The timer for removal is independent of the pylons_firing table. That is, the removal is scheduled when the cball is created, and nothing removes that timer.

If the cballs aren't being removed in the current GMod, the cause is something else.
Experiencing God's grace one day at a time.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: UDodge 2016
« Reply #2 on: July 22, 2016, 12:31:03 am »
My experience in that the removal timer is never created.

Code: Lua
  1. -- Find the owner
  2. local pylon
  3. for i=#pylons_firing, 1, -1 do
  4.     local data = pylons_firing[ i ]
  5.     if data.expire < CurTime() then
  6.         table.remove( pylons_firing, i )
  7.     elseif (ent:GetPos() - data.pylon:GetPos()):LengthSqr() < data.pylon.fire_offset:LengthSqr() * 8 then
  8.         pylon = data.pylon
  9.         table.remove( pylons_firing, i )
  10.         break
  11.     end
  12. end
  13.  
  14. if pylon then
  15.     timer.Simple( pylon.cball_lifetime, removeCball, ent )
  16. end

This is the important part of the onEntityCreated function, the part that influences the creation of the timer. For the timer to be created, the for loop has to 'return' a pylon (set the local pylon variable to a pylon).

Code: Lua
  1. if data.expire < CurTime() then
  2.     table.remove( pylons_firing, i )

In my testing, this if statement is what is preventing the timer from being created. data.expire is set to CurTime() + 0.25 farther down in the file. If my logic is correct, this means the combine ball needs to be shot within .25 seconds. The line setting the expire time seems to suggest it is set to .25 seconds because that is how long the combine ball takes to spawn.

I will say that even setting the expire time to something higher (5 seconds) does not fix the issue, so the expire time is not exclusively to blame. However, I'm still unsure what purpose the expire time serves.

edit:

Should we move this discussion elsewhere, maybe the old UDodge thread or a new thread altogether?
« Last Edit: July 22, 2016, 12:42:04 am by roastchicken »
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline Michael Brady

  • Newbie
  • *
  • Posts: 12
  • Karma: -3
Re: UDodge 2016
« Reply #3 on: July 22, 2016, 04:17:27 pm »
sweet I'm adding it in to my server

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: UDodge 2016
« Reply #4 on: July 22, 2016, 08:08:13 pm »
Michael Brady, it's not truly ready yet.
This is a code discussion in progress.
Alpha version level ready

roastchicken - I'll split topic and link to it from this 'project idea' post.
I believe it's now worthy of it's own new home.

I'm excited every time I see it revive.
I never did make it across any of the mazes Stickly would make and save in adv dupe on gm_construct, but it was addicting to keep trying.
Though I never played flappy bird, Udodge and Stickly's advanced dupe maze reminded me of the general addicting idea.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: UDodge 2016
« Reply #5 on: July 24, 2016, 01:52:42 pm »
Thanks for splitting the topics JamminR. The other thread was getting a bit cluttered.

As for the attempt to port UDodge, I haven't been able to work on it since my last post. I think my plan of attack is to try to find another way to have the combine balls find their respective pylon. I would go with the current method but I'm afraid I don't understand how it's supposed to work, and I don't think I could figure it out myself.

I'm thinking creating the combine ball manually might work, but I won't know for sure until I test it as I don't have much experience with entities.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: UDodge 2016
« Reply #6 on: July 24, 2016, 02:51:54 pm »
I couldn't find a better way to identify the ball's owner than the current somewhat hackish method; though, it seemed to work fine in the past. :)

You'll make my day if you find a better way!
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: UDodge 2016
« Reply #7 on: July 24, 2016, 04:35:44 pm »
Is the combine ball an entity?
And if so, is this too simple?
Entity:SetOwner
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: UDodge 2016
« Reply #8 on: July 24, 2016, 05:07:31 pm »
Something I threw together after reading this thread. I didn't bother looking at the UDodge code at all, so I don't know if they perform of function the same, but it's just pylons that shoot balls (custom entity) at players killing them if hit.

https://www.youtube.com/watch?v=xyRYscm1G6Y

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: UDodge 2016
« Reply #9 on: July 24, 2016, 07:06:07 pm »
Way to go and think outside the box, Mr P. Here I was stuck on my original GM9 restrictions where I couldn't use a scripted entity so I used a combine ball instead, with its many limitations.

Good work! :)
Experiencing God's grace one day at a time.

  • Print