Author Topic: Weapon toggle?  (Read 1882 times)

0 Members and 1 Guest are viewing this topic.

calan

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
  • Doom Newbie
    • View Profile
Weapon toggle?
« on: November 02, 2014, 04:00:34 AM »
Are there any tutorials or info on how to set up multiple weapons on a single key (toggle), in the player.def file?

I'm not having much luck with Google, and I can't find whatever it was that I read about it a couple years ago. I just remember it didn't work as I expected for some reason.
Old bastard but kid at heart...

BloodRayne

  • Old Forum Goer
  • Full Member
  • ***
  • Posts: 136
  • Karma: +13/-0
  • Doom Newbie
    • View Profile
    • Grimm Quest for the Gatherer's Key
Re: Weapon toggle?
« Reply #1 on: November 02, 2014, 04:13:11 AM »
As far as I recall there is no weapon toggle in regular Doom3. I know it's present in ROE, you could take a look in the player.def file for that?

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 897
  • Karma: +42/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Weapon toggle?
« Reply #2 on: November 02, 2014, 06:44:09 AM »
If you're making a mod with SDK there's no reason to not use Roe vs stock D3.  If you're not making a mod with SDK I think a mod years ago did weapon switching w/o SDK.  Fragging Free maybe?  I forget, but I thought someone did it.

calan

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
  • Doom Newbie
    • View Profile
Re: Weapon toggle?
« Reply #3 on: November 02, 2014, 02:04:20 PM »
I thought that was what the "toggle" parameter in the player.def file was supposed to do?
Old bastard but kid at heart...

BielBdeLuna

  • Full Member
  • ***
  • Posts: 242
  • Karma: +8/-20
  • Doom Newbie
    • View Profile
    • my Github repositories
Re: Weapon toggle?
« Reply #4 on: November 02, 2014, 02:43:37 PM »
Toggle is for returning from the current weapon to the previous weapon (whatever that was), you need to do sdk work to bring the toggle-weapons-in-the-same-slot ROE functionality to vanilla (it's not that difficult)

I would suggest to use the ROE codebase for coding as it's the actual codebase used in the much more advanced BFG engine.

calan

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
  • Doom Newbie
    • View Profile
Re: Weapon toggle?
« Reply #5 on: November 02, 2014, 03:31:55 PM »
Well, I haven't stepped up to the SDK yet... still playing with the basic stuff.  :)

With that said, the reason I asked is that I'm having an issue with a weapon I've added (DblSG). It works fine, shows up in the GUI, etc. My problem is, when I switch "down" to it with previous weapon (mouse scroll down), it works fine; but when I switch "up" to it with next weapon (mouse scroll up), the ammo GUI doesn't show up. What would cause the GUI to show up based on which direction you were going when switching to it?

EDIT: Has anyone updated the code to add impulses for weapons 13,14,and 15, or to allow weapons to be re-ordered?
« Last Edit: November 02, 2014, 05:22:46 PM by calan »
Old bastard but kid at heart...

calan

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
  • Doom Newbie
    • View Profile
Re: Weapon toggle?
« Reply #6 on: November 02, 2014, 05:22:07 PM »
For future reference, I figured out the reason the ammo counters weren't showing up. I needed to add a section to "onNamedEvent weaponChange {" in the hud.gui file to display the values for weapon 13.

Code: [Select]
if ("gui::weapon13" == 2) {
resetTime "WeapIcon13" "0" ;
set "weapon0::matcolor" "0 0.6 0.6 0.4" ;
set "weapon1::matcolor" "0 0.6 0.6 0.4" ;
set "weapon2::matcolor" "0 0.6 0.6 0.4" ;
set "weapon3::matcolor" "0 0.6 0.6 0.4" ;
set "weapon4::matcolor" "0 0.6 0.6 0.4" ;
set "weapon5::matcolor" "0 0.6 0.6 0.4" ;
set "weapon6::matcolor" "0 0.6 0.6 0.4" ;
set "weapon7::matcolor" "0 0.6 0.6 0.4" ;
set "weapon8::matcolor" "0 0.6 0.6 0.4" ;
set "weapon9::matcolor" "0 0.6 0.6 0.4" ;
set "weapon10::matcolor" "0 0.6 0.6 0.4" ;
set "weapon11::matcolor" "0 0.6 0.6 0.4" ;

set "AmmoFlash2::visible" "1" ;
set "AmmoFlash1::visible" "0" ;
set "ScanLineLA::visible" "1" ;
set "ScanLineLAG::visible" "0" ;
set "BorderLAGrenades::visible" "0" ;
set "BorderLA::visible" "1" ;
set "weaphud" "0" ;
set "BgLA::visible" "1" ;
set "Lines1A::visible" "1" ;
set "Lines1B::visible" "0" ;
set "Lines2A::visible" "1" ;
set "ammovalue2Black::visible" "1" ;
set "ammovalue2::visible" "1" ;
set "ammovalue3Black::visible" "1" ;
set "ammovalue3::visible" "1" ;
}

*****

I have one remaining issue that is fixable without SDK work (I think). When cycling weapons, the current weapon lowers and then for a very brief moment, the next weapon flashes into view at the normal position, and then disappears as the weapon comes up into place normally. The net effect is that a ghost image of the next weapon appears before it is raised into place. It doesn't happen with the chainsaw or soulcube, but does with every other weapon. (Could it have something to do with the other weapons using custom skins?)

Any ideas on how to fix that? I can't "not see it" and it drives me nuts.  :)
« Last Edit: November 03, 2014, 04:02:09 AM by calan »
Old bastard but kid at heart...

Ivan_the_B

  • Newbie
  • *
  • Posts: 18
  • Karma: +3/-0
  • Doom Newbie
    • View Profile
Re: Weapon toggle?
« Reply #7 on: November 03, 2014, 03:45:50 AM »
It sounds more like there's something wrong with weapon scripts.
A skin cannot make such a difference.

I did use multiple weapons on the same key in Fragging Free, but it was ROE mod so the support was already there.

calan

  • Newbie
  • *
  • Posts: 44
  • Karma: +0/-0
  • Doom Newbie
    • View Profile
Re: Weapon toggle?
« Reply #8 on: November 03, 2014, 04:41:26 AM »
It sounds more like there's something wrong with weapon scripts.
A skin cannot make such a difference.

Figured it out, thanks to your tip. I have some simple flashlight code in the raise function. Moving that code fixed it.

From this:

Code: [Select]
void weapon_rocketlauncher::Raise() {
UpdateSkin();
weaponRising();

        if ( WEAPON_FLASHLIGHT ) {
flashlight( true );
}

playAnim( ANIMCHANNEL_ALL, "raise" );
waitUntil( animDone( ANIMCHANNEL_ALL, ROCKETLAUNCHER_RAISE_TO_IDLE ) );
weaponState( "Idle", ROCKETLAUNCHER_RAISE_TO_IDLE );
}

to this:

Code: [Select]
void weapon_rocketlauncher::Raise() {
UpdateSkin();
weaponRising();
playAnim( ANIMCHANNEL_ALL, "raise" );

if ( WEAPON_FLASHLIGHT ) {
flashlight( true );
}

waitUntil( animDone( ANIMCHANNEL_ALL, ROCKETLAUNCHER_RAISE_TO_IDLE ) );
weaponState( "Idle", ROCKETLAUNCHER_RAISE_TO_IDLE );
}

I was initially setting the flashlight between states, which caused the issue. Placing that code right after I start the raise animation fixes it.

You guys rock.   ;)
« Last Edit: November 03, 2014, 05:06:06 AM by calan »
Old bastard but kid at heart...

Dafama2k7

  • Newbie
  • *
  • Posts: 1
  • Karma: +1/-0
  • Doom Newbie
    • View Profile
Re: Weapon toggle?
« Reply #9 on: March 06, 2015, 11:23:28 AM »
Are there any tutorials or info on how to set up multiple weapons on a single key (toggle), in the player.def file?

I'm not having much luck with Google, and I can't find whatever it was that I read about it a couple years ago. I just remember it didn't work as I expected for some reason.

Yes, it can be done in Doom 3 base and with a simple small script, use this on your raise script, not defs, of course, for example, in scripts/weapon_shotgun.script use this...:


void weapon_shotgun::Raise() {
   weaponHolstered();   //start of new code
   entity owner = getOwner();
   sys.println( "owner " + owner.getName() );
   string previous = owner.getPreviousWeapon();
   sys.println( "previous " + previous );
   string current = owner.getCurrentWeapon();
   sys.println( "current1 " + current );
   if ( previous != "weapon_shotgun_double" ) {
      owner.selectWeapon( "weapon_shotgun_double" );
      current = owner.getCurrentWeapon();
      sys.println( "current2 " + current );
      if ( current == "weapon_shotgun_double" ) {
         //on = true;
         return;
      }
   }
   //end of new code

   weaponRising();
   playAnim( ANIMCHANNEL_ALL, "raise" );
   waitUntil( animDone( ANIMCHANNEL_ALL, SHOTGUN_RAISE_TO_IDLE ) );
   weaponState( "Idle", SHOTGUN_RAISE_TO_IDLE );
}


And just replace the  "weapon_shotgun_double" for the weapon you want to toggle and the weapon_shotgun script, for another weapon script, ok ?

Remember also, that the first one of the weapons should be toggle on the player.def also.
« Last Edit: March 06, 2015, 11:27:00 AM by Dafama2k7 »