Duke4.net Forums: EDuke32 Scripting - Duke4.net Forums

Jump to content

  • 117 Pages +
  • « First
  • 68
  • 69
  • 70
  • 71
  • 72
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

#2071

View PostHendricks266, on 15 October 2017 - 07:04 PM, said:

You'll want to set WEAPON3_SHOTSPERBURST to 4, and probably add AMMOPERSHOT to WEAPON3_FLAGS.


Declaring the gamevar in your con files will erase the ones already there and only set the flags you name.


They're hardcoded into the exe.


Thank you once again for the clarification!
0

#2072

Hmm, how do I alter the speed which the pipebomb is thrown at? I think this could be tricky to work with because there has to be a lot of hardcoding involved in those pipes :excl: I want to be able to throw the pipebomb ridicously far :rolleyes:
And how do I add a new weapon? Like for example the expander that exchanges the shrinker when you switch to shrinker once again. I would like a secondary shotgun..

This post has been edited by thisbecasper: 16 October 2017 - 12:45 PM

0

#2073

Is it possible to make the shotgun for example shoot normally when pressing the fire button, but shoot, lets say rockets, when turnaround is pressed instead?
0

User is offline   Hendricks266 

  • Weaponized Autism

  #2074

Untested, but let me know how this goes.

onevent EVENT_TURNAROUND
    setvar WEAPON2_SHOOTS RPG
    setplayer[THISACTOR].kickback_pic 1

    setvar RETURN -1
endevent

onevent EVENT_PRESSEDFIRE
    setvar WEAPON2_SHOOTS SHOTGUN
endevent

0

#2075

View PostHendricks266, on 16 October 2017 - 02:55 PM, said:

Untested, but let me know how this goes.

onevent EVENT_TURNAROUND
    setvar WEAPON2_SHOOTS RPG
    setplayer[THISACTOR].kickback_pic 1

    setvar RETURN -1
endevent

onevent EVENT_PRESSEDFIRE
    setvar WEAPON2_SHOOTS SHOTGUN
endevent



This actually works, although it shoots 7 rockets on top of eachother. This is just a matter of redefining a couple of more things in the first bit of the code I guess. It does only fire in rpg-mode a single time when holding down the fire button, BUT, if you tap the turnaround you can spam the rockets heheh. Thank you for the reply, I learn quite a bit reading code like this :-) Maybe I can continue working on the code myself too..
0

User is offline   Hendricks266 

  • Weaponized Autism

  #2076

Hmm

onevent EVENT_TURNAROUND
    setvar WEAPON2_SHOOTS RPG
    ifvare player[].kickback_pic 0
        setplayer[].kickback_pic 1

    setvar RETURN -1
endevent

onevent EVENT_PRESSEDFIRE
    setvar WEAPON2_SHOOTS SHOTGUN
endevent

0

#2077

View PostHendricks266, on 16 October 2017 - 07:01 PM, said:

Hmm

onevent EVENT_TURNAROUND
    setvar WEAPON2_SHOOTS RPG
    ifvare player[].kickback_pic 0
        setplayer[].kickback_pic 1

    setvar RETURN -1
endevent

onevent EVENT_PRESSEDFIRE
    setvar WEAPON2_SHOOTS SHOTGUN
endevent



"GAME.CON: In event `EVENT_TURNAROUND':
GAME.CON:215: error: symbol `player' is not a game array.
GAME.CON:215: error: parameter `.kickback_pic' is undefined.
GAME.CON:215: error: expected a keyword but found `0'.
GAME.CON:216: error: symbol `kickback_pic' is not a game variable.
GAME.CON:216: error: syntax error."
0

User is offline   Hendricks266 

  • Weaponized Autism

  #2078

How old of an EDuke32 are you using?
0

#2079

View PostHendricks266, on 16 October 2017 - 07:30 PM, said:

How old of an EDuke32 are you using?

EDuke32-OldMP (Maintenance Build) Release 9 20120912
- And that's what's causing it. It works on my "normal" Eduke :-) A bit annoying tho, because the stuff I'm trying to make is for multiplayer purposes only :/

This post has been edited by thisbecasper: 16 October 2017 - 07:35 PM

0

User is offline   Hendricks266 

  • Weaponized Autism

  #2080

define INPUT_TURN_AROUND       268435456

gamevar temp 0 0
gamevar bits 0 1

onevent EVENT_PRESSEDFIRE
    setvar WEAPON2_SHOOTS SHOTGUN
    setvar WEAPON2_SHOTSPERBURST 7
endevent

onevent EVENT_TURNAROUND
    setvar RETURN -1
endevent

onevent EVENT_PROCESSINPUT
    getinput[THISACTOR].bits bits
endevent

onevent EVENT_GAME
    ifactor APLAYER
    {
        ifvarand bits INPUT_TURN_AROUND
        {
            ifvare currentweapon SHOTGUN_WEAPON
            {
                ifvare weaponcount 0
                {
                    getplayer[THISACTOR].ammo_amount SHOTGUN_WEAPON temp
                    ifvarg temp 0
                    {
                        setvar WEAPON2_SHOOTS RPG
                        setvar WEAPON2_SHOTSPERBURST 1

                        setplayer[THISACTOR].kickback_pic 1
                    }
                }
            }
        }
    }
endevent

0

#2081

View PostHendricks266, on 16 October 2017 - 07:45 PM, said:

define INPUT_TURN_AROUND       268435456

gamevar temp 0 0
gamevar bits 0 1

onevent EVENT_PRESSEDFIRE
    setvar WEAPON2_SHOOTS SHOTGUN
    setvar WEAPON2_SHOTSPERBURST 7
endevent

onevent EVENT_TURNAROUND
    setvar RETURN -1
endevent

onevent EVENT_PROCESSINPUT
    getinput[THISACTOR].bits bits
endevent

onevent EVENT_GAME
    ifactor APLAYER
    {
        ifvarand bits INPUT_TURN_AROUND
        {
            ifvare currentweapon SHOTGUN_WEAPON
            {
                ifvare weaponcount 0
                {
                    getplayer[THISACTOR].ammo_amount SHOTGUN_WEAPON temp
                    ifvarg temp 0
                    {
                        setvar WEAPON2_SHOOTS RPG
                        setvar WEAPON2_SHOTSPERBURST 1

                        setplayer[THISACTOR].kickback_pic 1
                    }
                }
            }
        }
    }
endevent



Damn... Thank you so much! Works like a charm.. It even acts exactly as it should now. I just need to know why I need to do this step:

"onevent EVENT_TURNAROUND
setvar RETURN -1
endevent"

- And I guess gamevar bits is used to remember last keypress, if im right?
0

User is offline   Hendricks266 

  • Weaponized Autism

  #2082

Setting RETURN to -1 in EVENT_TURNAROUND disables the Turn Around action from taking place.

The bits gamevar is updated with the current state of the keys at all times.
0

#2083

View PostHendricks266, on 16 October 2017 - 08:05 PM, said:

Setting RETURN to -1 in EVENT_TURNAROUND disables the Turn Around action from taking place.

The bits gamevar is updated with the current state of the keys at all times.


Yep! Just found out myself. I actually made a toggle instead.

define INPUT_TURN_AROUND       268435456

gamevar choice 0 1

onevent EVENT_TURNAROUND
    setvar RETURN -1
endevent

onevent EVENT_TURNAROUND
    ifvare currentweapon SHOTGUN_WEAPON
    {
    	ifvare choice 0
    	{
    		setvar choice 1
    	}
    	else
    	{
    		setvar choice 0
    	} 
    	}
endevent

onevent EVENT_PRESSEDFIRE
	ifvare choice 0
	{
		setvar WEAPON2_SHOOTS SHOTGUN
    	setvar WEAPON2_SHOTSPERBURST 7
	}
	else
	{
		setvar WEAPON2_SHOOTS RPG
        setvar WEAPON2_SHOTSPERBURST 1
	}	    
endevent


Although it doesn't work when I add the RETURN -1 bit. I guess it wont let the next onevent EVENT_TURNAROUND get executed. I think I would have to use the "bits" var like you did! But thanks for the help!

This post has been edited by thisbecasper: 16 October 2017 - 08:22 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#2084

View Postthisbecasper, on 16 October 2017 - 08:21 PM, said:

Although it doesn't work when I add the RETURN -1 bit.


It should work. You don't need two different declarations of the same event; I wonder if that's related.

View Postthisbecasper, on 16 October 2017 - 08:21 PM, said:

I guess it wont let the next onevent EVENT_TURNAROUND get executed.


The value of RETURN is not saved; it is constantly getting set to different values by various events and such.
0

#2085

View PostTrooper Dan, on 16 October 2017 - 11:39 PM, said:

It should work. You don't need two different declarations of the same event; I wonder if that's related.


Thanks! That was what caused it.
0

#2086

Hi, just tried it with my friend, and we get an out-of-sync when one of us dies. Heres the code, I hope I can make a getaround:

define INPUT_TURN_AROUND       268435456

gamevar SHOTGUNAMMO 0 1
gamevar choice 0 1

onevent EVENT_TURNAROUND
{
	setvar RETURN -1
    ifvare choice 0
    {
  		setvar choice 1
  		sound SELECT_WEAPON        
      quote 34
    }
    else
  	{
  		setvar choice 0
    		sound SHOTGUN_COCK
        quote 35
    	} 
    }    
endevent

onevent EVENT_PRESSEDFIRE
{	 
	ifvare choice 0
	{
		setvar WEAPON2_SHOOTS SHOTGUN
  	setvar WEAPON2_SHOTSPERBURST 7
    setvar WEAPON2_FIRESOUND SHOTGUN_FIRE
    setvar WEAPON2_FLAGS 1024
	}
	else
	{
		ifvarl SHOTGUNAMMO 10
		{
			setvar choice 0
			quote 40
			sound SHOTGUN_COCK

		}
		setvar WEAPON2_SHOOTS 1092
    setvar WEAPON2_SHOTSPERBURST 10
    setvar WEAPON2_FIRESOUND PISTOL_RICOCHET
   	setvar WEAPON2_FLAGS 17472 				
	}
}

endevent


Also the sound won't update accordingly between "weapon-switch".
0

User is offline   Hendricks266 

  • Weaponized Autism

  #2087

If you're using a switch style, you should update the vars directly in EVENT_TURNAROUND instead of using PRESSEDFIRE.

What is that SHOTGUNAMMO variable? I suspect you don't need it.
0

#2088

View PostHendricks266, on 17 October 2017 - 08:09 AM, said:

If you're using a switch style, you should update the vars directly in EVENT_TURNAROUND instead of using PRESSEDFIRE.

What is that SHOTGUNAMMO variable? I suspect you don't need it.


Thank you for the help. I've got it to work now like this:

gamevar SHOTGUNAMMO 0 1
gamevar choice 0 1
gamevar PWEAPON 0 1

onevent EVENT_TURNAROUND
{
	setvar RETURN -1
	ifvare PWEAPON 2
   	{
    	ifvare choice 0
    	{
    		ifvarl SHOTGUNAMMO 10
    		{
    			quote 36
    			break
    		}
    		setvar choice 1
    		sound SELECT_WEAPON
    		setvar WEAPON2_SHOOTS 1092
       		setvar WEAPON2_SHOTSPERBURST 10
       		setvar WEAPON2_FIRESOUND PISTOL_RICOCHET
       		setvar WEAPON2_FLAGS 17472 	
        	quote 34
    	}
    	else
    	{
    		setvar choice 0
    		sound SHOTGUN_COCK
    		setvar WEAPON2_SHOOTS SHOTGUN
    		setvar WEAPON2_SHOTSPERBURST 7
    		setvar WEAPON2_FIRESOUND SHOTGUN_FIRE
    		setvar WEAPON2_FLAGS 1024
        	quote 35
    	} 
    }
}	    
endevent

onevent EVENT_DOFIRE
{
	ifvare PWEAPON 2
	{
		ifvare choice 1
		{
			ifvarl SHOTGUNAMMO 10
			{
				setvar choice 0
    			sound SHOTGUN_COCK
    			setvar WEAPON2_SHOOTS SHOTGUN
    			setvar WEAPON2_SHOTSPERBURST 7
    			setvar WEAPON2_FIRESOUND SHOTGUN_FIRE
    			setvar WEAPON2_FLAGS 1024
        		quote 40
			}
		}
	}
}
endevent


I think I need the var SHOTGUNAMMO inorder to keep track of current ammo of the shotgun?. Can I do it without the var and without causing an out-of-sync error? I've btw also managed to get rid of the out-of-sync thing - I still don't see the big difference between using a var like I do to keep track of the players current weapon and a call to currentweapon, which was what caused it..

This post has been edited by thisbecasper: 17 October 2017 - 12:11 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#2089

View Postthisbecasper, on 17 October 2017 - 12:05 PM, said:

I think I need the var SHOTGUNAMMO inorder to keep track of current ammo of the shotgun?


Where you have

ifvarl SHOTGUNAMMO 10


you should be able to replace it with

ifvarl player[THISACTOR].ammo_amount 2 10

0

User is offline   Hendricks266 

  • Weaponized Autism

  #2090

View Postthisbecasper, on 17 October 2017 - 12:05 PM, said:

I think I need the var SHOTGUNAMMO inorder to keep track of current ammo of the shotgun?. Can I do it without the var and without causing an out-of-sync error? I've btw also managed to get rid of the out-of-sync thing - I still don't see the big difference between using a var like I do to keep track of the players current weapon and a call to currentweapon, which was what caused it..

The game already keeps track of things like ammo counts and current weapon. Attempting to circumvent this by using your own vars at best is a duplication of effort, and at worst is asking for a lot of trouble when you let them get out of sync.

Yeah, currentweapon was a mistake, it should only be used in HUD drawing events.

You're going to need to get comfortable with global scratch variables. While you're at it, take the time to indent your code correctly. (8 spaces per tab stop is unnecessary, use 4 at the max.)

definegamefuncname 36 Switch_Weapon_Function

gamevar temp 0 0

gamevar subweapon_choice 0 1

onevent EVENT_TURNAROUND
    setvar RETURN -1

    getplayer[THISACTOR].curr_weapon temp
    ifvare temp 2
    {
        ifvare subweapon_choice 0
        {
            ifvarl SHOTGUNAMMO 10
            {
                quote 36
                break
            }
            setvar subweapon_choice 1
            sound SELECT_WEAPON
            setvar WEAPON2_SHOOTS 1092
            setvar WEAPON2_SHOTSPERBURST 10
            setvar WEAPON2_FIRESOUND PISTOL_RICOCHET
            setvar WEAPON2_FLAGS 17472
            quote 34
        }
        else
        {
            setvar subweapon_choice 0
            sound SHOTGUN_COCK
            setvar WEAPON2_SHOOTS SHOTGUN
            setvar WEAPON2_SHOTSPERBURST 7
            setvar WEAPON2_FIRESOUND SHOTGUN_FIRE
            setvar WEAPON2_FLAGS 1024
            quote 35
        }
    }
endevent

onevent EVENT_DOFIRE
    getplayer[THISACTOR].curr_weapon temp
    ifvare temp 2
    {
        ifvare subweapon_choice 1
        {
            getplayer[THISACTOR].ammo_amount SHOTGUN_WEAPON temp
            ifvarl temp 10
            {
                setvar subweapon_choice 0
                sound SHOTGUN_COCK
                setvar WEAPON2_SHOOTS SHOTGUN
                setvar WEAPON2_SHOTSPERBURST 7
                setvar WEAPON2_FIRESOUND SHOTGUN_FIRE
                setvar WEAPON2_FLAGS 1024
                quote 40
            }
        }
    }
endevent


View PostTrooper Dan, on 17 October 2017 - 12:11 PM, said:

Where you have

ifvarl SHOTGUNAMMO 10


you should be able to replace it with

ifvarl player[THISACTOR].ammo_amount 2 10


He's using OldMP, which doesn't support quick structure access. Also, use SHOTGUN_WEAPON instead of the magic constant '2'.
0

User is offline   Danukem 

  • Duke Plus Developer

#2091

View PostHendricks266, on 17 October 2017 - 12:15 PM, said:

Also, use SHOTGUN_WEAPON instead of the magic constant '2'.


Now you are just being pedantic. :rolleyes: There's no advantage to typing the label there except for readability, but anyone who has worked with the game very long knows which weapons the numbers correspond to.
0

User is offline   Hendricks266 

  • Weaponized Autism

  #2092

View PostTrooper Dan, on 17 October 2017 - 12:31 PM, said:

Now you are just being pedantic. :rolleyes: There's no advantage to typing the label there except for readability, but anyone who has worked with the game very long knows which weapons the numbers correspond to.

You're basically telling me "Who cares?", which is a pet peeve when I'm trying to get across something important. Your argument is a slippery slope to completely neglecting your code style, after all, you know what it does.

This stands opposed to every commit Helix or I have made regarding "enumifying" a set of magic constants.

Furthermore, what if you want to search for all code effecting the shotgun at once? The Unix utility for this is called grep, and you'll usually see it used as a verb. You'll have much more luck grepping for SHOTGUN_WEAPON than "2".
1

#2093

View PostHendricks266, on 17 October 2017 - 12:15 PM, said:

The game already keeps track of things like ammo counts and current weapon. Attempting to circumvent this by using your own vars at best is a duplication of effort, and at worst is asking for a lot of trouble when you let them get out of sync.

Yeah, currentweapon was a mistake, it should only be used in HUD drawing events.

You're going to need to get comfortable with global scratch variables. While you're at it, take the time to indent your code correctly. (8 spaces per tab stop is unnecessary, use 4 at the max.)

definegamefuncname 36 Switch_Weapon_Function

gamevar temp 0 0

gamevar subweapon_choice 0 1

onevent EVENT_TURNAROUND
    setvar RETURN -1

    getplayer[THISACTOR].curr_weapon temp
    ifvare temp 2
    {
        ifvare subweapon_choice 0
        {
            ifvarl SHOTGUNAMMO 10
            {
                quote 36
                break
            }
            setvar subweapon_choice 1
            sound SELECT_WEAPON
            setvar WEAPON2_SHOOTS 1092
            setvar WEAPON2_SHOTSPERBURST 10
            setvar WEAPON2_FIRESOUND PISTOL_RICOCHET
            setvar WEAPON2_FLAGS 17472
            quote 34
        }
        else
        {
            setvar subweapon_choice 0
            sound SHOTGUN_COCK
            setvar WEAPON2_SHOOTS SHOTGUN
            setvar WEAPON2_SHOTSPERBURST 7
            setvar WEAPON2_FIRESOUND SHOTGUN_FIRE
            setvar WEAPON2_FLAGS 1024
            quote 35
        }
    }
endevent

onevent EVENT_DOFIRE
    getplayer[THISACTOR].curr_weapon temp
    ifvare temp 2
    {
        ifvare subweapon_choice 1
        {
            getplayer[THISACTOR].ammo_amount SHOTGUN_WEAPON temp
            ifvarl temp 10
            {
                setvar subweapon_choice 0
                sound SHOTGUN_COCK
                setvar WEAPON2_SHOOTS SHOTGUN
                setvar WEAPON2_SHOTSPERBURST 7
                setvar WEAPON2_FIRESOUND SHOTGUN_FIRE
                setvar WEAPON2_FLAGS 1024
                quote 40
            }
        }
    }
endevent



He's using OldMP, which doesn't support quick structure access. Also, use SHOTGUN_WEAPON instead of the magic constant '2'.


It makes sense that you can do it like this, without declaring a new var. Regarding indentation: Yeah, it happens when I copy paste into duke4net, it's good in sublime text :rolleyes:
If I don't use my SHOTGUNAMMO like I coded, and instead like in your code, It doesn't work - It's like it doesn't register the current ammo at all, maybe I'm missing some declaration?
- Is there a way to change the color of the crosshair together with weapon-switches?? Can't seem to find anything about it online.

This post has been edited by thisbecasper: 17 October 2017 - 01:02 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#2094

View PostHendricks266, on 17 October 2017 - 12:35 PM, said:

You're basically telling me "Who cares?", which is a pet peeve when I'm trying to get across something important. Your argument is a slippery slope to completely neglecting your code style, after all, you know what it does.

This stands opposed to every commit Helix or I have made regarding "enumifying" a set of magic constants.

Furthermore, what if you want to search for all code effecting the shotgun at once? The Unix utility for this is called grep, and you'll usually see it used as a verb. You'll have much more luck grepping for SHOTGUN_WEAPON than "2".


This is an interesting discussion, well worth having, and I have an open mind about it. You make a good point about the search, although it's not quite as bad as you make it out to be (it would take several different searches to round up all the shotgun references, but one could certainly do a lot better than searching for "2").

I don't agree that using constants instead of defined labels necessarily leads one down a slippery slope to completely neglecting code style. Empirically that's just false. I also think that coding at the source level may require different standards. For one thing, the source code could potentially be used for a different Build game. In any case, I regard the weapon numbers differently from, say, tile numbers. I would never use "2000" in the place of "PIGCOP", and not just because of readability -- in theory you could move PIGCOP to a different tile and it would more or less work the same (although there would be some issues because there is hardcoded stuff for tile 2000 in the source!). But putting SHOTGUN_WEAPON on a slot other than 2 would require changing a lot of stuff.
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#2095

For me labels are a huge advantage.

But there will be a difference once dynamicremap is implemented for weapons.

This post has been edited by Fox: 17 October 2017 - 01:01 PM

0

#2096

It's time for me to attempt to make gun-game mode. I need to make a player be limited with only one weapon which changes as the player gets or loses kills. So how do I get amount of kills of a player?
0

User is offline   Danukem 

  • Duke Plus Developer

#2097

View Postthisbecasper, on 17 October 2017 - 07:48 PM, said:

It's time for me to attempt to make gun-game mode. I need to make a player be limited with only one weapon which changes as the player gets or loses kills. So how do I get amount of kills of a player?


Here's your basic kill count: http://wiki.eduke32....i/Actors_killed

If you want a system where the player can lose kills, then you'll need to make your own counter.
0

#2098

View PostTrooper Dan, on 17 October 2017 - 11:05 PM, said:

Here's your basic kill count: http://wiki.eduke32....i/Actors_killed

If you want a system where the player can lose kills, then you'll need to make your own counter.

Sorry, I'm talking multiplayer only - Idk if that's the same counter?
0

#2099

View Postthisbecasper, on 18 October 2017 - 01:35 AM, said:

Sorry, I'm talking multiplayer only - Idk if that's the same counter?

I think I've found what I've been looking for by looking at the pages related to the one you linked, so thanks!
0

#2100

getplayer[THISACTOR].frag gets the players number of frags in a multiplayer game. If you suicide your score decrements by adding one to fraggedself, because the score is the difference between "frag" and "fraggedself". Can't seem to find a structure member that is the score, so how do I make variable that is equal to score? I suppose you can't make it like this: gamevar score ("frag" - "fraggedself") 1...
0

Share this topic:


  • 117 Pages +
  • « First
  • 68
  • 69
  • 70
  • 71
  • 72
  • Last »
  • 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