• Print

Author Topic: Can I edit Ulx Maul?  (Read 6119 times)

0 Members and 1 Guest are viewing this topic.

Offline DrCheesepuffs

  • Newbie
  • *
  • Posts: 25
  • Karma: 0
Can I edit Ulx Maul?
« on: July 04, 2016, 05:56:55 pm »
I want to know if I can edit the ULX Maul command to make the zombies have higher HP or unkillable, because wehn I maul my friends they will kill them which leaves their corpses on the server until next restart.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Can I edit Ulx Maul?
« Reply #1 on: July 04, 2016, 08:51:09 pm »
You can, but I'd first troubleshoot why your players aren't dying before getting a chance to kill them.
Likely a conflicting addon or gamemode itself.
I'm pretty sure that we either cause the player to die pretty darn quickly (we remove armor from the player), and/or have zombies keep repawning until the player is dead.
Whatever our condition, death should be certain.

"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: Can I edit Ulx Maul?
« Reply #2 on: July 05, 2016, 01:03:24 am »
From what I can tell after a cursory look over the code, it does indeed seem that the zombies are respawned (new ones are created if one dies) until the player in question is killed.

This appears to hold true in-game (tested in DarkRP), however the corpses of any killed zombies do remain after death.

There's a bug with Garry's Mod wherein clientside ragdolls (the corpses in this case) are not removed by garbage collection. This code should remove all fast zombie and headcrab corpses. It must be run on the client, as that is where the ragdolls are.

Code: Lua
  1. local ents = ents.FindByClass( "class C_ClientRagdoll" )
  2. for k, ent in ipairs( ents ) do
  3.   local model = ent:GetModel()
  4.   if model == "models/zombie/fast.mdl" or model == "models/headcrab.mdl" then
  5.     ent:Remove()
  6.   end
  7. end
« Last Edit: July 05, 2016, 01:39:25 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 DrCheesepuffs

  • Newbie
  • *
  • Posts: 25
  • Karma: 0
Re: Can I edit Ulx Maul?
« Reply #3 on: July 05, 2016, 12:51:34 pm »
JamminR, it doesn't kill them as fast when my friends are in a part where they really can't be reached. So other players kill the ragdolls until I move my friend by them to get finished off.

Roastchicken, where would I put that code?

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Can I edit Ulx Maul?
« Reply #4 on: July 06, 2016, 01:00:23 am »
Roastchicken, where would I put that code?

It will be a bit complicated, seeing as that's client side code. You'll first want to make a folder in garrysmod/addons/, then create folders until your folder structure is like this: garrysmod/addons/<myaddon>/lua/ulx/modules/cl/

Then in the cl folder you made, create a lua file that contains the code I gave you in a ULX function (a function with the name 'ulx.<functionname>'). Now you're going to want to make a sh folder in the modules folder (so you have the following structure: garrysmod/addons/<myaddon>/lua/ulx/modules/sh/). In that folder you're going to want to create a ULX command that runs the following code:

Code: Lua
  1. ULib.clientRPC( calling_ply, "<myfunction>" )

You can look at other ULX commands in the shared modules folder (garrysmod/addons/ulx/lua/ulx/modules/sh/) if you're not sure how to create a ULX command. Feel free to ask for help if you don't understand any of these steps.
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 DrCheesepuffs

  • Newbie
  • *
  • Posts: 25
  • Karma: 0
Re: Can I edit Ulx Maul?
« Reply #5 on: July 06, 2016, 03:33:08 pm »
Sorry but I'm confused. :x

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Can I edit Ulx Maul?
« Reply #6 on: July 06, 2016, 06:16:06 pm »
A quick work around for the clientside ragdolls of the zombies staying would be to make sure that "ai_serverragdolls" is disabled and that "g_ragdoll_maxcount" is set to 32. You can also set "g_ragdoll_maxcount" to 0 (then set it back to 32) to clear all dead bodies from your server (as long as they are not actual serverside ragdolls.)

As a more direct answer to your question, you shouldn't ever edit an addons files directly but you can add an alternative maul command or even overwrite it. You would probably want to make the following changes...

Find the line... "local ent = newZombie( newpos, newang, v )" and add the following right after it...

ent:SetHealth(2^32/2-1)
ent:AddFlags( FL_GODMODE )

That should make the NPC have really high HP and attempt to add the god mode flag on to it. Also for extra credits you can try figuring out how to strip (remove the weapons) of the person your mauling. http://wiki.garrysmod.com/page/Player/StripWeapons
I cry every time I see that I am not a respected member of this community.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Can I edit Ulx Maul?
« Reply #7 on: July 07, 2016, 04:49:49 am »
Unfortunately if DrCheesepuffs is confused by my instructions I'm not sure how successful they would be with modifying a ULX command, as doing so requires a similar process.

DrCheesepuffs, what exactly are you confused about? Is it a specific step?
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 DrCheesepuffs

  • Newbie
  • *
  • Posts: 25
  • Karma: 0
Re: Can I edit Ulx Maul?
« Reply #8 on: July 07, 2016, 01:06:24 pm »
Isn't client only on one persons end? Wouldn't it just disappear for me or everyone?

Sorry, working too much my brain overloads :P

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Can I edit Ulx Maul?
« Reply #9 on: July 08, 2016, 04:29:19 am »
Well yes, if you only ran that code on one person then it would only effect them. I meant it as a command for players to use if they got bothered by the amount of ragdolls. If you don't want anyone to see ragdolls then you could have the command loop through everyone and run the function on them. Or you could eliminate the possibility of ragdolls all together with LuaTenshi's suggestion.
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 DrCheesepuffs

  • Newbie
  • *
  • Posts: 25
  • Karma: 0
Re: Can I edit Ulx Maul?
« Reply #10 on: July 08, 2016, 05:38:56 am »
Alright thanks!

  • Print