Back to the Vavoom Forum Archives


Forum

Weapon variables

Wed, 02 Aug 2006 18:43:24

The 4th Class

Before I begin, let me just say that the weapons tutorials in the Vavoom wiki are infuriatingly cryptic, so I have to do much of my didactics through the old-fashioned ask-and-answer approach. <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) --> Anyway, I was wondering which section of the code was responsible for the numbering sequence of the weapons. For example, let's say I want the mage to press "7" to use the bloodscourge instead of "4." How do I do that? And if I want to put 2 or more weapons under the same button (like the staff and the gauntlets in Heretic, they both use "1"), how do I do that? How does the game know to choose the gauntlets over the staff when "1" is pressed? And looking in the Heretic weapons sections, I see some files like "WeaponGoldWand.vc" have a damage statement:
damage = 7 + (P_Random() & 7);
While others like "WeaponPhoenixRod.vc" don't. So which code determines how much damage this badass of a weapon deals? <!-- s:twisted: --><img src="{SMILIES_PATH}/icon_twisted.gif" alt=":twisted:" title="Twisted Evil" /><!-- s:twisted: -->
Wed, 02 Aug 2006 18:52:43

Crimson Wizard

Unfortunately I have not much time now, so I answer on your last question only. There are two types of weapons. (I mentioned this in my tutorial actually) 1. Weapons that fire instantly. 2. Weapons that shoot missiles. First type do damage by calling either Damage or LineAttack function. Second type creates corresponding missile objects that do damage on their own. For example, WeaponPhoenixRod shoots PhoenixFX1 object. And PhoenixFX1 class damages when hits anyone. Missiles use Actor::Touch() function where is this line:
damage = ((P_Random() & 3) + 2) * MissileDamage;
AS for MissileDamage, this variable is defined in each missile class. PhoenixFX1 has this line in "defaultproperties" section:
MissileDamage = 20;
Wed, 02 Aug 2006 19:12:56

Janis Legzdinsh

Anyway, I was wondering which section of the code was responsible for the numbering sequence of the weapons. For example, let's say I want the mage to press "7" to use the bloodscourge instead of "4." How do I do that? And if I want to put 2 or more weapons under the same button (like the staff and the gauntlets in Heretic, they both use "1"), how do I do that? How does the game know to choose the gauntlets over the staff when "1" is pressed?
It's handled by method PlayerImpulse in Player class.
Thu, 03 Aug 2006 03:43:16

The 4th Class

Well I'm no programmer, but it seems to me PlayerImpulse does a bit more than just determine the numbering sequence of the weapons. Does it also handle launching the items, or at least the 5-0 hotkeys? Heh, I thought this impulse variable would be type char instead of type int. This is what I would have had in mind:
if (impulse == "0")
{
    Use flechette
}
else if (impulse == "2")
{
    Take out axe/serpentstaff/iceweapon
}
But I guess there's a reason why you do it your way and not mine. <!-- s:wink: --><img src="{SMILIES_PATH}/icon_wink.gif" alt=":wink:" title="Wink" /><!-- s:wink: -->
Thu, 03 Aug 2006 07:52:34

Crimson Wizard

[quote="The 4th Class":26syodrv]Well I'm no programmer, but it seems to me PlayerImpulse does a bit more than just determine the numbering sequence of the weapons. Does it also handle launching the items, or at least the 5-0 hotkeys? AFAIK it handles everything binded to keys (using menu settings or console cmd "bind"), except for common actions like movement, use and fire. Thus you can add new user commands there if needed. [quote="The 4th Class":26syodrv]Heh, I thought this impulse variable would be type char instead of type int. There's no "char" type in VavoomC.
Thu, 03 Aug 2006 13:55:33

The 4th Class

So all text is handled by strings then? <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) -->
Thu, 03 Aug 2006 14:18:16

Crimson Wizard

Yep. To get a single character you have to use substring extracting function substr(). I am not sure that it is only way, since I never tried.
Thu, 03 Aug 2006 17:48:42

Janis Legzdinsh

Well I'm no programmer, but it seems to me PlayerImpulse does a bit more than just determine the numbering sequence of the weapons. Does it also handle launching the items, or at least the 5-0 hotkeys?
Yes.
Heh, I thought this impulse variable would be type char instead of type int. This is what I would have had in mind:
if (impulse == "0")
{
    Use flechette
}
else if (impulse == "2")
{
    Take out axe/serpentstaff/iceweapon
}
But I guess there's a reason why you do it your way and not mine. <!-- s:wink: --><img src="{SMILIES_PATH}/icon_wink.gif" alt=":wink:" title="Wink" /><!-- s:wink: -->
It's the number of impulse command, so it's integer. Having it as char would make no sense at all.

Back to the Vavoom Forum Archives