Crossbow bolts as physics items?

  • Thread starter Thread starter AgentPothead
  • Start date Start date
A

AgentPothead

Guest
I have no experience doing the actual coding, and I couldn't find anything about this in Hammer so I thought I'd ask here. I wanted to make turn the crossbow bolts u fire into physics props. Like after it sticks in the wall or spears a person to the wall, I could pull it back out with the gravity gun and use it as a weapon. Is this possible? Or will an entire new weapon have to be constructed? Thanks for any help.
 
I'll have a guess here...
But I think instead of requiring a new weapon, it would require a new ammo type? Like, shotgun's ammo is called a Buckshot, pistol ammo is a Pistol, so I guess you would just create a new ammo type... C:\<ModLocation>\src\dlls\hl2_dll\item_ammo.cpp is where the type of ammo is defined, I guess you just add an entry to this, and wherever else it's needed...
But instead of being simply logical (Like the current ammo is) you'd have to make it a physical object in game, I guess you could steal some code from objects like barrels etc. (Objects you can pick up with the gravity gun) and create a custom oject.

I have no idea if what I think is even right, after all, it's simply a guess :/
Sorry if this doesn't help at all...
 
Any ideas help! Like I said i'm really new to the actual coding part so I dont even have a custom mod made or anything I was just making custom maps at the moment. I will take a look around at the cpp files thank you for suggestion!
 
Hasn't got anything to do with ammo types. Look for the code in which the thing sticks to the wall, and then work from there. I've never thought of doing anything with crossbow bolts, so I've no idea.

-Angry Lawyer
 
AgentPothead said:
I have no experience doing the actual coding, and I couldn't find anything about this in Hammer so I thought I'd ask here. I wanted to make turn the crossbow bolts u fire into physics props. Like after it sticks in the wall or spears a person to the wall, I could pull it back out with the gravity gun and use it as a weapon. Is this possible? Or will an entire new weapon have to be constructed? Thanks for any help.
I think, since you say you've no experience in coding, that you'd be much better off waiting for someone who can code to make something and let others play with the code to suit individual needs. It stikes me as not being all that easy though really.. Though I'm probably very wrong.
 
I have no coding experience either, but I think I agree with Dark Elf that it wouldn't be easy, or else Valve would have done it. Either that or they didn't think of it, which I don't think is likely. But, hey, your mod would be that much cooler if you successfully did that. Imagine killing five guys with the same bolt, since they wouldn't get wasted.

Good luck :)
 
archvilell said:
I have no coding experience either, but I think I agree with Dark Elf that it wouldn't be easy, or else Valve would have done it. Either that or they didn't think of it, which I don't think is likely. But, hey, your mod would be that much cooler if you successfully did that. Imagine killing five guys with the same bolt, since they wouldn't get wasted.

Good luck :)
I think the reason Valve didn't do it was probably down to the possible lag it might cause (they might have been thinking of HL2DM at that point) I guess.

I suppose for a coder to make it would, it would be a weapon that doesn't actually fire anything, but instead spawns some object moving very fast from just infront of the player (then match up the weapons animation sequence to fit)

I guess that could work?
 
i would imagine that the easiest way to do it would be jsut to use the code from the grav gun, with a custom model of a crossbow and right click anims of him loadin the bolt after picking it up i would imagine you could jsut reduce the effective range of the grav gun so its as if ur picking it up then left click would fire the bolt...

there ya go... thats what i would look at doing tbh
 
Look at the code maybe of the spears you find on the way to nova prospekt? They act pretty much like big crossbow bolts, pinning people to walls and such, and you can pick em back up using the gravity gun and use em as many times as you like. Pretty much you want those to be fired from the crossbow, only smaller and mory bolt looking :P
 
My theory of why Valve didnt do it is because they wanted a long-range sniping weapon affected by gravity, to show off that part of their engine, but it had to be more powerful than the regular guns because you got it later in the game. So it couldnt be a normal bow or whatever, it had to be a super energy bow, or it wouldnt be "realistic" to make it do more damage than the guns.

My personal idea of the best way to do it is to create a phys prop when firing the xbow like TDE says, and when the player uses that prop with the e key, to delete it and add to his ammo instead of picking it up. You could even look at ammo box code for how to do that. No muss, no fuss. The problem with using the grav gun as a base is that you would need to introduce the whole idea of ammo again.

The phys prop really wouldnt cause any more lag than the physgun throwing a barrel and is ripe for prediction.
 
I think it's just a matter of setting some flags for the CCrossbowBolt.

As for why valve didn't do it ... well, they don't have to think like us; maybe they saw problems with this or thought it wouldn't add much to the game.
It's either a design decision, or the idea just didn't come to them.
 
Well, having a reusable crossbow bolt would have meant the player could complete the game with just a crossbow bolt and the gravity gun, which Valve obviously didn't want, as they wanted people to be frugal with ammunition, and try all the weapons.

-Angry Lawyer
 
Thats a good question spooq. Looking at all the posts and thinking, it might be easier just to use the physics props they already gave us, the bolt and sawblade for example, and just coding a weapon that can launch physics props. And I appreciate the idea The Dark Elf, but having no posts here I felt weird saying, here is an idea I think is great, jump to it code monkeys :D Plus everybody has to start somewhere, and I think editing or coding a new weapon might be an ok place to start. Unless you guys really don't think it is feasible, because experience trumps gumption most of the time.
 
Its funny, but all the suggestions above about how to start are correct - they are just looking at the problem from different angles. Thats why coding is an art and not a science.

I am planning something very similar to your crossbow, but mine would trail a rope behind it for climbing up. Perhaps we could share code?

I was wrong about the grav-gun not using ammo by the way - it does, but in a hacky way. Im staying away from it :P
 
Sure if I code anything it will be public domain for anybody to add into anything, but I have yet to look into it at all :)
 
an idea

this may have been said already, however i am a coder, I dont know my way around HL2 code, but i do other stuff. form playing HL2 it seems to me that the bolts probably are physical objects as they interect with the people unlike bullet shots, by which i mean they cause a body to be pinned to the wall etc, if they hit. I would bet that they are simply not effected by the gravgun in hl2 like other items in the game, rather than not being a physical entity, anyways thats my 2 cents, as i say i dont know the hl2 code at all but thats how id code it, as they seem to have some physical effects which you wouldnt expect otherwise.
Mat
 
Back
Top