Duke4.net Forums: Looking for help improving my alternate-fire CON script - Duke4.net Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Looking for help improving my alternate-fire CON script

User is offline   Padlowan 

#1

Current code is as follows:

GAME.CON:
//ALTERNATE FIRE MODE FOR PISTOL (Laser Pistol)
gamevar ALT_WEAP1 0 //var to store the pistol's current fire mode
onevent EVENT_WEAPKEY2	//when pistol select button pressed
ife WEAPON 1 			//if pistol already selected
{
	soundonce SELECT_WEAPON		//sounds
	soundonce PISTOL_BODYHIT
	ife ALT_WEAP1 0				//if alt fire off
	{
		quote 128
		setvar ALT_WEAP1 1			//turn alt fire on
		setvar WEAPON1_SHOOTS FIRELASER  
		setvar WEAPON1_FIRESOUND PRED_ATTACK  

	}
	else 						//if alt fire on
	{
		quote 128
		setvar ALT_WEAP1 0			//turn alt fire off 
		setvar WEAPON1_SHOOTS SHOTSPARK1 
		setvar WEAPON1_FIRESOUND PISTOL_FIRE 
	}
}
endevent

//ALTERNATE FIRE MODE FOR RPG (Morter Launcher)
//The default morter seems to explode when near the player (I.E as soon as the player fires it), so a new projectile is created
defineprojectile PLAYERMORTER PROJ_WORKSLIKE 6150
defineprojectile PLAYERMORTER PROJ_SPAWNS EXPLOSION2
defineprojectile PLAYERMORTER PROJ_VEL 1000
defineprojectile PLAYERMORTER PROJ_DROP -256
defineprojectile PLAYERMORTER PROJ_ISOUND PIPEBOMB_EXPLODE
defineprojectile PLAYERMORTER PROJ_HITRADIUS 2560
defineprojectile PLAYERMORTER PROJ_BOUNCES 3
defineprojectile PLAYERMORTER PROJ_OFFSET 224
defineprojectile PLAYERMORTER PROJ_CLIPDIST 24
defineprojectile PLAYERMORTER PROJ_TRAIL SMALLSMOKE

gamevar ALT_WEAP4 0 //var to store the RPG's current fire mode
onevent EVENT_WEAPKEY5	//when RPG select button pressed
ife WEAPON 4 			//if RPG already selected
{
	soundonce SELECT_WEAPON		//sounds
	soundonce PISTOL_BODYHIT
	ife ALT_WEAP4 0				//if alt fire off
	{
		quote 128
		setvar ALT_WEAP4 1			//turn alt fire on
		setvar WEAPON4_SHOOTS PLAYERMORTER

	}
	else 						//if alt fire on
	{
		quote 128
		setvar ALT_WEAP4 0			//turn alt fire off 
		setvar WEAPON4_SHOOTS RPG

	}
}
endevent

//Alternate fire modes using alt fire button
onevent EVENT_ALTWEAPON	//When alt-fire button pressed
ife WEAPON 1 			//if pistol selected
{
	soundonce SELECT_WEAPON		//sounds
	soundonce PISTOL_BODYHIT
	ife ALT_WEAP1 0				//if alt fire off
	{
		quote 128
		setvar ALT_WEAP1 1			//turn alt fire on
		setvar WEAPON1_SHOOTS FIRELASER  
		setvar WEAPON1_FIRESOUND PRED_ATTACK  

	}
	else 						//if alt fire on
	{
		quote 128
			setvar ALT_WEAP1 0			//turn alt fire off 
			setvar WEAPON1_SHOOTS SHOTSPARK1 
		setvar WEAPON1_FIRESOUND PISTOL_FIRE 

	}
}
ife WEAPON 4 			//if RPG selected
{
	soundonce SELECT_WEAPON		//sounds
	soundonce PISTOL_BODYHIT
	ife ALT_WEAP4 0				//if alt fire off
	{
		quote 128
		setvar ALT_WEAP4 1			//turn alt fire on
		setvar WEAPON4_SHOOTS PLAYERMORTER

	}
	else 						//if alt fire on
	{
		quote 128
			setvar ALT_WEAP4 0			//turn alt fire off 
			setvar WEAPON4_SHOOTS RPG 

	}
}
endevent


USER.CON:
definequote 128		  SWITCHED FIRE MODE


This code seems to function correctly, however there is no way to see which fire-mode is currently selected without firing the weapon. Ideally, I would like to change the weapon texture depending on current selection, or change the ammo symbol. If that isn't possible, I could have a simple HUD addition in a corner somewhere showing which is selected.

I'm already confident in adding new textures to the ART files, but I can't find a way to swap out textures on screen (weapon texture & ammo symbol).

I'd love to hear any general suggestions for improvements or additions I can make too.
0

User is online   Danukem 

  • Duke Plus Developer

#2

You could make right-mouse shoot altfire and left-mouse shoot regular fire, then there's no need switch modes. EDuke32 supports this.
0

User is online   Danukem 

  • Duke Plus Developer

#3

View PostPadlowan, on 08 July 2025 - 09:50 PM, said:

I'm already confident in adding new textures to the ART files, but I can't find a way to swap out textures on screen (weapon texture & ammo symbol).


I have bad news for you. You can't just "swap out" textures on screen.

Any different tiles appearing on the HUD from the hardcoded ones requires that you have your own HUD code that pretty much redraws the relevant parts of the HUD from scratch. You can try copying from another mod that does this and then changing them to your own tile numbers, but its still going to require tweaking to fit what you want to do, and judging from your post you have zero knowledge in that area.

EDuke32 downloads do come with a CON file written by Hendricks266 (at least I think its still included) that completely replicates all the hardcoded HUD stuff. If you start with that, it can make the job easier.
0

User is offline   Padlowan 

#4

View PostDanukem, on 09 July 2025 - 10:41 AM, said:

You could make right-mouse shoot altfire and left-mouse shoot regular fire, then there's no need switch modes. EDuke32 supports this.

Realising now this will probably work a lot better than what I had in mind lol :/. For context, I was originally going for something similar to swapping out attachments in DOOM Eternal, but I think I'll just make it more akin to the way altfire works in Blood.

Thanks for all your help!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options