News:

One Minute Game Review by The Happy Friar: https://ugetube.com/@OneMinteGameReviews
Also on Rumble: https://rumble.com/c/c-1115371

idTech 4 (aka Doom 3 tech) Discord Server! https://discord.gg/9wtCGHa

Main Menu

Weapon toggle?

Started by calan, November 02, 2014, 04:00:34 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

calan

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

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

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

I thought that was what the "toggle" parameter in the player.def file was supposed to do?
Old bastard but kid at heart...

BielBdeLuna

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

#5
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?
Old bastard but kid at heart...

calan

#6
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.


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.  :)
Old bastard but kid at heart...

Ivan_the_B

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

#8
Quote from: Ivan_the_B 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.

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

From this:


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:


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.   ;)
Old bastard but kid at heart...

Dafama2k7

#9
Quote from: calan 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.

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.