Author Topic: Scripting Weapons  (Read 2013 times)

Hello there!
I've recently started making mods for Blockland, but so far I've only really made a few small simple ones. However, a friend and I want to make some weapons for our RPG, but I don't know much about making weapons. My friend has got the modeling covered, but I'm not very familiar with scripting weapons. I know that weapons need to have a trail, emitter, projectile, etc., but I don't know what each variable defined in those datablocks really means. I've looked at other weapons made by other people, but I can't really understand what each specific variable does for the weapon. Could someone please help explain what each variable does?

Thanks!

For the types you mentioned, just mess with them

For the types you mentioned, just mess with them

You can use tree(); while running a server to open a menu where you can mess with them. If you know the name of the datablock you want to edit, you can also use inspect(NameOfDatablock);

Just tweak something, hit apply, use the weapon, and see what's different. The exception would be the weapon image datablock, which is a bit stubborn when the state fields are changed. If you want to ask about something specific, go ahead.

You might also check the engine documentation on datablock types, http://docs.garagegames.com/tge/official/content/documentation/Engine/Reference/structGameBaseData.html
It's not specific to Blockland so some stuff will be inaccurate, but it might help fill in some gaps.
« Last Edit: March 27, 2015, 09:53:01 PM by -Jetz- »

You can use tree(); while running a server to open a menu where you can mess with them. If you know the name of the datablock you want to edit, you can also use inspect(NameOfDatablock);

Just tweak something, hit apply, use the weapon, and see what's different. The exception would be the weapon image datablock, which is a bit stubborn when the state fields are changed. If you want to ask about something specific, go ahead.

You might also check the engine documentation on datablock types, http://docs.garagegames.com/tge/official/content/documentation/Engine/Reference/structGameBaseData.html
It's not specific to Blockland so some stuff will be inaccurate, but it might help fill in some gaps.

Thanks! After experimenting with the tree(); method in the console, I've learned a lot. There are some certain factors I couldn't find though. For instance, how do I change the fire rate and animation rate of the weapon?

Thanks! After experimenting with the tree(); method in the console, I've learned a lot. There are some certain factors I couldn't find though. For instance, how do I change the fire rate and animation rate of the weapon?
In the weapon image, there's a huge block of a bunch of arrays, stateSequence, stateTimeout, stateName, etc.

I can't explain them much cuz I've barely used them myself

In the weapon image, there's a huge block of a bunch of arrays, stateSequence, stateTimeout, stateName, etc.

I can't explain them much cuz I've barely used them myself

Do you know where I could look more into that? I've been trying to search the forums and the internet in general but I can't find any resources that tells me more about those arrays. Experimenting with their values hasn't helped either, it doesn't seem to change anything.

Do you know where I could look more into that? I've been trying to search the forums and the internet in general but I can't find any resources that tells me more about those arrays. Experimenting with their values hasn't helped either, it doesn't seem to change anything.
You can't change them in tree(); - that's what I was saying here:
The exception would be the weapon image datablock, which is a bit stubborn when the state fields are changed.
Basically states need a server restart to apply the changes, and tweaking them to be just right can be an annoying process. Still, they're actually pretty self explanatory in how they work: The weapon is always in one state. It can transition to another state based on certain conditions, like triggerdown(when you click the mouse), timeout(after a certain amount of time), etc. The states do various things, like call scripts, play sounds, or attach emitters to the weapon. One of the most common scripts you'll see is in the fire state, onFire.

So a weapon might start with the activate state which plays the equip sound, after a split second switches to the ready state which waits for you to click the mouse, once you do it goes to the fire state which plays the effects and calls the onFire script, then to an idle state that causes a delay between shots, then in an automatic weapon might go right back to the ready state, or in semi-automatic may go to another state that waits for you to release the mouse that then goes back to ready.
« Last Edit: March 30, 2015, 09:59:51 PM by -Jetz- »

You can't change them in tree(); - that's what I was saying here: Basically states need a server restart to apply the changes, and tweaking them to be just right can be an annoying process. Still, they're actually pretty self explanatory in how they work: The weapon is always in one state. It can transition to another state based on certain conditions, like triggerdown(when you click the mouse), timeout(after a certain amount of time), etc. The states do various things, like call scripts, play sounds, or attach emitters to the weapon. One of the most common scripts you'll see is in the fire state, onFire.

So a weapon might start with the activate state which plays the equip sound, after a split second switches to the ready state which waits for you to click the mouse, once you do it goes to the fire state which plays the effects and calls the onFire script, then to an idle state that causes a delay between shots, then in an automatic weapon might go right back to the ready state, or in semi-automatic may go to another state that waits for you to release the mouse that then goes back to ready.

Thanks, I did end up getting some help on the states topic in particular. Although there are a few specific ones that I still don't know what they do, like stateSequence and stateScript. Specifically with stateScript, I know that it calls a function, but how does it know what parameters to use when calling the function?

I believe stateSequence is used for animations
And I think stateScript functions just have the same arguments always passed to them

If you still need help with the fire rate of a weapon, try to change the value for stateTimeoutValue.
like if its 0.5 that means it fires kind of slow, if you want it to shoot faster go for something like 0.04. There are also more then one stateTimeoutValue in the script. Hope this helped.
« Last Edit: March 31, 2015, 09:48:57 PM by RHK »

I think I understand stateTimeoutValue, but I'm still confused on stateSequence. From what Headcrab Zombie said, it's used for animations, but are the animation files in the folder that the value of stateSequence is referring to? Or is it more like specified keywords that are used and then Blockland understands what to do from there.

I think I understand stateTimeoutValue, but I'm still confused on stateSequence. From what Headcrab Zombie said, it's used for animations, but are the animation files in the folder that the value of stateSequence is referring to? Or is it more like specified keywords that are used and then Blockland understands what to do from there.
The animations are included in the model dts file. The sequence is the name of the animation that will play.