Where is the weapon code stored?

3 replies [Last post]
TitaneerYonatha...
TitaneerYonathanYeager's picture
User offline. Last seen 8 weeks 1 day ago. Offline
Joined: 2015-09-24
Posts: 34

To start off, I didn't know whether to post this in support or content creations, so I asked it here.

My question is: Where is the weapon code stored?

The reason I ask this is that I am considering making my own weapons and submitting the code. I had searched my game files for the weapon code(that files I can open and read that is) and found nothing.
I wanted to take a look at your weapon code to get a feel for how you guys made the ones that exist now.

A little disclaimer: I have a little experience(very little, basically just starting) in python and while I am able to read Lua, and this is kind of new to me, but I want to try.

xiongmao
User offline. Last seen 3 weeks 6 hours ago. Offline
Joined: 2018-11-03
Posts: 8

Generally the weapon handling is located in https://hg.hedgewars.org/hedgewars/file/tip/hedgewars/uGearsHandlersMess.pas (doStep procedures). There are also few other places that define common weapon properties and where are they located in configuration menus, but this file is enough if you want to try modifying behavior of existing weapons first. Unlike Lua scripts, it's necessary to be able to build Hedgewars from source to see those changes though.

nemo
nemo's picture
User offline. Last seen 22 hours 30 min ago. Offline
Joined: 2009-01-28
Posts: 1808

Note some lua scripts do create new "weapons" by overriding existing weapon behaviour. For example you can hook into grenade spawn and delete to make a grenade that does other things like, oh, teleport stuff or create dirt/snow or somesuch. Naturally those weapons are specific to that script, although it is possible to chain lua scripts together like Gravity.lua does

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

TitaneerYonatha...
TitaneerYonathanYeager's picture
User offline. Last seen 8 weeks 1 day ago. Offline
Joined: 2015-09-24
Posts: 34

Okay, thanks!
After taking a look, I'll admit, it'll take me a little to fully comprehend everything. Big Grin (learning .pas)

Copyright © 2004-2017 Hedgewars Project. All rights reserved. [ contact ]