Making C4 Stick Props/Doors/People and Destroy Props/Open Doors on explosion
17 replies, posted
Hello, I was recently working on making this C4 that i have able to stivk to props, doors, and people.
I thought I was on the right track, (edited blast radius and model, as well as plant anim), but now, I am stuck as hell.
I tried changing
if trace.Entity and trace.Entity:IsValid() then
if boxes and trace.Entity:GetPhysicsObject():IsValid() then
C4:SetParent(trace.Entity)
trace.Entity.Planted = true
elseif not trace.Entity:IsNPC() and not trace.Entity:IsPlayer() and trace.Entity:GetPhysicsObject():IsValid() then
constraint.Weld(C4, trace.Entity)
To
if trace.Entity and trace.Entity:IsValid() then
if boxes and trace.Entity:GetPhysicsObject():IsValid() then
C4:SetParent(trace.Entity)
trace.Entity.Planted = true
elseif not trace.Entity:IsNPC() then
constraint.Weld(C4, trace.Entity)
end
Figuring it would then allow props and players at least, but yet I got nothing.
And for making doors unlock and props unfrozen and unwelded, im lost as hell. Any support would be fantastic!
Ok, I made an attempt to add the unfreeze, unweld portion by adding
self.Entity:EmitSound(Sound("C4.Explode"))
self.Entity:Remove()
local en = ents.FindInSphere(self.Entity:GetPos(), 400)
for k, v inpairs(en) doif (v:GetPhysicsObject():IsValid()) then
// Unweld and unfreeze props
if (math.random(1, 100) < 45) then
v:Fire("enablemotion", "", 0)
constraint.RemoveAll(v)
if v:Getclass() == "prop_physics"then
v:Remove()
end
end
end
end
That didnt seem to work either :/
For the doors, you could just hide it and then spawn a prop version in the same spot. THen after a timer is reached you could remove the prop version and then show the original.
^ The way is to ghost the actual door, then create a clone that acts as the physic object (blowing away?) then unghost the door after x seconds.
Also I would use a entity instead of constraints. Spawn the entity, and parent it to the door and/or remove the swep from player.
It has to be a functioning door, I have seen it before on door breachers
Entity/GetClass? Lua is case sensitive
I think I pasted this from my backup file, but I do remember (I think) changing this to uppercase, but i will check, thank you
Also, I dont think I made it specific or used the wrong words, I just wanted the door to unlock and open after an explosion, not blow off cause thats a bit much. (Sorry for confusion)
Alright, Just got home, heres whats exactly written in the file.
self.Entity:Remove()
local en = ents.FindInSphere(self.Entity:GetPos(), 400)
for k, v inpairs(en) doif (v:GetPhysicsObject():IsValid()) then
// Unweld and unfreeze props
if (math.random(1, 100) < 45) then
v:Fire("enablemotion", "", 0)
constraint.RemoveAll(v)
if v:GetClass() == "prop_physics"then
v:Remove()
end
end
end
end
Ok, so, just a bit of an update.
I figured out the unwelding/unfreezing, as well as removing of other constraints.
Now, i need help getting this thing to stick to people, props, and doors.
What do I do?
So like, anyone gonna help me figurr out how to get it to stick to props, people and doors or no?
So like, are you even gonna attempt anything or no?
I mean, I already figured out the prop unfreeze/unweld and door unlock.
So like, are you gonna give me something that I CAN make an attempt with?
Only thing someone gave me was how to attempt to make a door breach, which as I mentioned, wasnt even trying to do.
I also posted my attempts for the unfreeze and unweld, and waited and waited for someone to tell me, yet received nothing.
So, would you like to give me links so I can try to do something?
So there Mr. Swept, hows that?
Cant really attempt somethng if I dont know what I am doing, and I dont see any posts from you helping, which if I recall correctly, thats what this is about.
Here’s a link to help
Garry's Mod
You are one unhelpful bastard.
Do I use parenting?
Do I use constraint.Weld?
Why dont you get off your high horse, aye?
Im trying to do something myself, and you give me that shit? Like actually what the hell is your problem man? If you do not know how to help then fuckin dont reply my dude...
Like, you do realize the problem I am having is I sincerely have no idea where to start? I never asked for copy/paste code, I never asked for someone to do it for me, I want to learn, and you being unhelpful like this does nothing but waste my time, and make you look like a cunt.
You have no idea where to start but have an idea that it might be parenting or constraint.weld?
It seems like to me you already have some ideas on what to use. Why don’t you try to use either of them?
Yes, I spent 10+ hours trying to find it out on my own, when I came to this forum to get help. Too bad Facepunch has asswipes like you :shrug:
Oh well, thanks for finally giving me an answer after getting smart, then being a dickhead, some more sarcasm, and a whole 24 hours.
You never said you tried either of the things you thought of.
You never said you tried something and it didn't work.
You never told us of any issues you had.
If you want help, you need to give the people you're asking help from something to work with. Don't be afraid to make mistakes.
I'm sorry I went out with some friends and that you're not the top of my priorities, I guess.
I don't think I'm cool, especially not for knowing Lua, and I don't think you're inferior.
And if the video game is dying, why are you still trying to make stuff for it?
Enough of that, though. Try a constraint.weld, try to parent it, show us what you did to try that, and what didn't work.
Alright, after a long, long time of trial and error, I figured it out.
I realized, all I had to do after these 4 days, was remove 1 line... Something along the lines of
trace.Entity.Planted = true
So, there we go. Problems solved.
Sorry, you need to Log In to post a reply to this thread.