DF-21 Forums Forum Index DF-21 Forums
The Dark Forces Community
 
DF-21.net Home | FAQ | Search | Memberlist  | Register 
Profile | Log in to check your private messages | Log in

Weapon Scripting

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DF-21 Forums Forum Index -> DarkXL News
View previous topic :: View next topic  
Author Message
lucius
DarkXL Developer
DarkXL Developer

Joined: 17 Feb 2008

PostPosted: Jan 02, 2011 10:19    Post subject: Weapon Scripting View user's profile Send private message Send e-mail Reply with quote

I'm sorry to say that I missed the date of my Beta goal, though for good reason.

When I was tweaking the weapons I began to realize that the way the weapons were being coded was a bit hard to work with, it was purely code driven rather then being data driven. I obviously needed to fix that, not only to get the Beta done - but also to make my life easier in the long run.

So I've spent the day implementing the weapon scripting system. So now, in addition to having the logic scripts (CoreLogics.as) you have weapon scripts (CoreWeapons.as). In the future, mods can provide their own script files that override the core scripts. This means that DarkXL mods will be able to have custom enemies, items and weapons. Very Happy

To create a weapon requires multiple steps:
1) Register a weapon at a specific index (which maps to the inventory items and keys).
Weapon_Register(1, "Bryar Pistol");

2) Setup basic firing and projectile parameters. If this is a simple projectile, like the Bryar Pistol, Repeater or Fusion Cutter then you're done with this part.
Weapon_IntParameter(WPARAM_START_FRAME, 0);
Weapon_IntParameter(WPARAM_MAX_FRAME, 3);
Weapon_IntParameter(WPARAM_FRAME_DELAY, 4);
....(more parameters)....
Weapon_IntParameter(WPARAM_AMMO_TYPE, AMMO_ENERGY);
.....
Weapon_StrParameter(WPARAM_SHOOT_SOUND, "PISTOL-1.VOC");

You get the idea. You only set the parameters you need, everything else has a default of 0 or NULL. If this is a basic projectile weapon than the engine does all the heavy-lifting for you, using the parameters you've filled in to determine how much damage to do, which graphics to use, what sound effects to use, how fast the projectile travels, what type of ammo it uses and how much and so on.

3) Setup animation callbacks, that occur on animation frames or right as the animation finishes. This is needed for more complex or different behaviors that aren't handled by simple projectiles. This includes fists (punching), thermal detonators, mines and so on. Most weapons don't need these callbacks. Combining this with custom scripted projectile logics you can make totally new weapons - such as heat seeking missles, projectiles that circle around the player, trip wires and more.
Weapon_OnFrame_CB("TD_Throw");
and/or
Weapon_OnFinalFrame_CB("PunchLand");
This is the name of the function that exists somewhere in the script file. It can be any name you want.

4) Load render data - basically your weapon idle and animation frames.
Weapon_AddFrame("AUTOGUN1.BM");
Weapon_AddFrame("AUTOGUN2.BM");
Weapon_AddFrame("AUTOGUN3.BM");


5) Setup the Render Callback, which determines the final frame index and screen position of the weapon, given the current animation frame and firing state.
Weapon_OnRender_CB("Pistol_OnRender");

And to make things more convenient, you can reload the weapons scripts at any time from the in-game console. So you can make small tweaks and see them quickly in the game. The weapons now use this system, which is allowing me to remove per-weapon code out of the code-base.

So tomorrow (or later today - Sunday) I go back to finishing up the Beta. I'll try to get it out Sunday night, it is getting really close now. Smile

_________________
DarkXL....http://darkxl.wordpress.com

Barry Brien
Dark Trooper Phase 1

Joined: 26 Sep 2003

PostPosted: Jan 02, 2011 17:12    Post subject: View user's profile Send private message Send e-mail Reply with quote

So we can finally have a working lightsaber in DF? Smile

Kurgan
Dianoga

Joined: 18 Nov 2010

PostPosted: Jan 02, 2011 19:04    Post subject: View user's profile Send private message Reply with quote

You mean besides the dozens of "fist replaced by a basic saber animation with sounds" mods we had back in the day? It honestly looked more like Kyle was waving one of those foam "pool noodles" at enemies.

Better than these, and honestly the best lightsaber I've ever seen for a 2.5D FPS game was this (from the creator of Ghostbusters TC) for Doom2:

http://www.doomworld.com/gbd2/weapons/weapons/saber.htm

_________________
(JA Server: 208.43.15.76:29070)

Burning Gundam
Kell Dragon

Joined: 28 Sep 2003

PostPosted: Jan 02, 2011 23:39    Post subject: View user's profile Send private message Send e-mail Reply with quote

Can't wait, been itching to get back to work on my projects but during the last month I've had very little time to.

_________________
I don't think outside the box... I customize it.

klasodeth
Trandoshan

Joined: 03 Mar 2008

PostPosted: Jan 03, 2011 02:15    Post subject: View user's profile Send private message Reply with quote

Barry Brien wrote:
So we can finally have a working lightsaber in DF? Smile


Hey, don't give Lucius any reasons to withdraw scripting support for weapons. Razz

Kurgan
Dianoga

Joined: 18 Nov 2010

PostPosted: Jan 03, 2011 03:32    Post subject: View user's profile Send private message Reply with quote

Hey, if he's giving us the pitchfork and cigar, I don't see why he'd have a problem with a lightsaber.

_________________
(JA Server: 208.43.15.76:29070)

lucius
DarkXL Developer
DarkXL Developer

Joined: 17 Feb 2008

PostPosted: Jan 04, 2011 00:30    Post subject: View user's profile Send private message Send e-mail Reply with quote

The Beta will be slightly delayed, so I made another blog post that talks about it and the weapon scripting mentioned above. Read about it on the blog.

_________________
DarkXL....http://darkxl.wordpress.com

lucius
DarkXL Developer
DarkXL Developer

Joined: 17 Feb 2008

PostPosted: Jan 04, 2011 02:07    Post subject: View user's profile Send private message Send e-mail Reply with quote

Since there seems to be some confusion or questions regarding the upcoming source code release, I updated the blog post to clarify what is happening with the code and when it will be released.

_________________
DarkXL....http://darkxl.wordpress.com

lucius
DarkXL Developer
DarkXL Developer

Joined: 17 Feb 2008

PostPosted: Jan 04, 2011 07:35    Post subject: View user's profile Send private message Send e-mail Reply with quote

With Blood and Outlaws support coming, I've decided to put together new forums for non-Dark Forces related discussions to avoid Blood and Outlaws related discussions at DF-21. DF-21 has always been a Dark Forces related site and I don't want to change that. However DarkXL related Dark Forces discussions will continue to be done here, so the community doesn't have to move. The Dark Forces section of the forums actually links back to these forums. Smile

(And I will continue to discuss news items and things like that here as well).

If you want to check out the new forums, which also feature new screenshots of Blood and Outlaws in DarkXL, check it out http://darkxl.freeforums.org/

_________________
DarkXL....http://darkxl.wordpress.com

tnoyce
Ree-Yees

Joined: 20 Sep 2009

PostPosted: Jan 07, 2011 00:21    Post subject: Additional Forums for Blood & Outlaws View user's profile Send private message Reply with quote

Lucius,

That is an excellent idea! Keeping them separate avoids a lot of additional information to sift through on the main DarkXL board.

I'm looking forward to the update to DarkXL, whenever you get the chance to complete it.

_________________
Tim Noyce

Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DF-21 Forums Forum Index -> DarkXL News All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group