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

Jump to content

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

EDuke32 Scripting  "CON coding help"

User is offline   Hendricks266 

  • Weaponized Autism

  #2101

This is another example of a case where there is no need to keep your own per-player gamevar. Resist the urge to use those unless you are inventing your own quantity.

gamevar killcount 0 0
gamevar temp 0 0

state getkillcount
    getplayer[THISACTOR].frag killcount
    getplayer[THISACTOR].fraggedself temp
    subvarvar killcount temp
ends


Call state getkillcount before any code section that needs it, and it will populate the killcount variable.
0

User is online   Danukem 

  • Duke Plus Developer

#2102

View PostHendricks266, on 18 October 2017 - 10:31 AM, said:

This is another example of a case where there is no need to keep your own per-player gamevar. Resist the urge to use those unless you are inventing your own quantity.


I think he had come to that same conclusion, if his last post was any indication. When I posted, I had no idea he was working on a multiplayer mod, which is why I thought he might need his own counter.
0

#2103

View PostHendricks266, on 18 October 2017 - 10:31 AM, said:

This is another example of a case where there is no need to keep your own per-player gamevar. Resist the urge to use those unless you are inventing your own quantity.

gamevar killcount 0 0
gamevar temp 0 0

state getkillcount
    getplayer[THISACTOR].frag killcount
    getplayer[THISACTOR].fraggedself temp
    subvarvar killcount temp
ends


Call state getkillcount before any code section that needs it, and it will populate the killcount variable.


This works! I have yet to understand how all of this works... Although I think im slowly understanding bits and pieces, so THANK YOU. Three more questions if I may...: How do I place a sprite or character in the dead center of the screen? Is there a way to make sure a character is drawn in the middle between the crosshair and hud regardless of aspect ratio and resolution? How do I place a quote in a specifik spot on the screen when I have the, let's say, the shotgun equipped (The quote should be displayed as long as the shotgun is equipped)? (It's only the part of being able to draw a quote to the screen that has be troubled)

This post has been edited by thisbecasper: 18 October 2017 - 03:32 PM

0

User is offline   Hendricks266 

  • Weaponized Autism

  #2104

You can do those things in EVENT_DISPLAYREST using the screentext and rotatesprite. If you use rotatesprite at (160, 100) it should be right in the center.

If that sprite will be _part_ of the crosshair, I believe putting that part in EVENT_DISPLAYCROSSHAIR instead will turn it off along with the crosshair, if disabled.
0

#2105

The eduke wiki has been down the hole day. Do you guys know anything about it or have an alternative site to learn how to mod?
0

User is offline   Hendricks266 

  • Weaponized Autism

  #2106

View Postthisbecasper, on 19 October 2017 - 10:42 AM, said:

The eduke wiki has been down the hole day. Do you guys know anything about it or have an alternative site to learn how to mod?

Thanks for letting us know, it's likely a quick fix. You can always try Google Cache or archive.org.
0

User is offline   Kyanos 

#2107

It's on the wayback machine at archive.org
https://web.archive..../wiki/Main_Page
0

User is offline   TerminX 

  • el fundador

  #2108

Fixed.
1

#2109

Holy shit guys. You're better than christmas and birthday combined to me LOL, THANKS!
- How come I can't upvote replies? "You've reached maximum amount of upvotes" it says. (Haven't upvoted anything yet)

This post has been edited by thisbecasper: 19 October 2017 - 12:08 PM

0

User is offline   Hendricks266 

  • Weaponized Autism

  #2110

View Postthisbecasper, on 19 October 2017 - 12:04 PM, said:

- How come I can't upvote replies? "You've reached maximum amount of upvotes" it says. (Haven't upvoted anything yet)

You'll get that permission once you reach 50 posts. You're close.
0

#2111

View PostFox, on 05 August 2009 - 06:38 AM, said:

I am trying to make an heat-seeking weapon... although every time I shoot two times and the first shot kill the enemy, the sprites is deleted and them the second shot has an invalid sprite ID. How does can I check if an ID actually exists as specific sprite?

You still have the code for a heatseeking weapon?? :rolleyes:
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#2112

That's a 8 years old post. I have a code, but it's for a specific use.
0

#2113

View PostFox, on 19 October 2017 - 02:12 PM, said:

That's a 8 years old post. I have a code, but it's for a specific use.

I would still be interested in seeing how one manages to shoot a projectile that follows the closest player or the originally aimed at (if possible), but if you cba, it's all cool :rolleyes:.

Something completely different:
I want to do something to the player (in this example I just set the rpg max ammo to 60), when the player kills another player actor. I thought it would work like this:

gamevar killer 0 1

actor APLAYER ...

(...)

ifdead
  {
    getplayer[THISACTOR].wackedbyactor killer
    setplayer[killer].max_ammo_amount 4 60


Buuuuuuut it doesn't...
0

User is offline   Hendricks266 

  • Weaponized Autism

  #2114

ifdead
{
    getplayer[THISACTOR].wackedbyactor temp
    getactor[temp].picnum temp2
    ifvare temp2 APLAYER
    {
        getactor[temp].yvel temp2
        setplayer[temp2].max_ammo_amount RPG_WEAPON 60
    }

0

#2115

View PostHendricks266, on 19 October 2017 - 04:43 PM, said:

ifdead
{
    getplayer[THISACTOR].wackedbyactor temp
    getactor[temp].picnum temp2
    ifvare temp2 APLAYER
    {
        getactor[temp].yvel temp2
        setplayer[temp2].max_ammo_amount RPG_WEAPON 60
    }



It works, but it was intended to increment different variables so that with each kill, your weapon got stronger or something:

ifdead
  {
    getplayer[THISACTOR].wackedbyactor killer
    getactor[killer].picnum tempkiller
    ifvare tempkiller APLAYER
    {
    	getactor[killer].yvel tempkiller
    	addvar rpgammo 10
    	setplayer[tempkiller].max_ammo_amount RPG_WEAPON rpgammo
    }


Right now I think it perfoms the "addvar rpgammo 10" many many times, because the ifdead maybe works like whiledead also? If I get a kill with this code i get 1410-something maxammo. I only want it to do once everytime a player dies. And how do I alter another players variable? Becuase in fact, I'd want to set the killers maxammo to the originally maxammo plus (the times the killer have gotten a kill) * (10)..

This post has been edited by thisbecasper: 20 October 2017 - 02:17 AM

0

User is online   Danukem 

  • Duke Plus Developer

#2116

Yeah, "ifdead" does work like while dead, so any "ifdead" condition that triggers the ammo bonus should be nested inside an "ifhitweapon" check, to insure that only the killing blow is counted. This means you should make a state that does the bonusing and call it only after appropriate "ifdead" instances.
0

#2117

View PostTrooper Dan, on 20 October 2017 - 10:02 AM, said:

Yeah, "ifdead" does work like while dead, so any "ifdead" condition that triggers the ammo bonus should be nested inside an "ifhitweapon" check, to insure that only the killing blow is counted. This means you should make a state that does the bonusing and call it only after appropriate "ifdead" instances.


I can see the point in making states here, although I simply can't make it to work...

state updatevalue
{
	getplayer[THISACTOR].wackedbyactor killer
    getactor[killer].picnum tempkiller
    ifvare tempkiller APLAYER
    {
    		ifhitweapon
    		{
    			addvar rpgsammo 10
    		}
    		getactor[killer].yvel tempkiller
    		setplayer[tempkiller].max_ammo_amount RPG_WEAPON rpgsammo
    }
}
ends

---

 ifdead
  {
    state updatevalue


I am drawing the rpgsammo through digitalnumberz so I can keep track of it as I'm killing players and dying to players. No matter what it wont increment, and it also just sets the maxammo to whatever the value the variable was declared with in the first place. Actually I'm doubting that I'm using ifhitweapon correct, because when I place the two lines below into the if-statement together with "addvar rpgsammo 10", it wont even set maxammoamount :rolleyes:

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

0

User is offline   Hendricks266 

  • Weaponized Autism

  #2118

The ifhitweapon/ifdead structure should look like this:

state updatevalue
    getplayer[THISACTOR].wackedbyactor killer
    getactor[killer].picnum tempkiller
    ifvare tempkiller APLAYER
    {
                addvar rpgsammo 10
                getactor[killer].yvel tempkiller
                setplayer[tempkiller].max_ammo_amount RPG_WEAPON rpgsammo
    }
ends


ifhitweapon
{
  ifdead
  {
    state updatevalue


If this doesn't work, there may be something that prevents setting max_ammo_amount from working, and in thta case I'll look into it.
0

#2119

View PostHendricks266, on 20 October 2017 - 02:58 PM, said:

The ifhitweapon/ifdead structure should look like this:

state updatevalue
    getplayer[THISACTOR].wackedbyactor killer
    getactor[killer].picnum tempkiller
    ifvare tempkiller APLAYER
    {
                addvar rpgsammo 10
                getactor[killer].yvel tempkiller
                setplayer[tempkiller].max_ammo_amount RPG_WEAPON rpgsammo
    }
ends


ifhitweapon
{
  ifdead
  {
    state updatevalue


If this doesn't work, there may be something that prevents setting max_ammo_amount from working, and in thta case I'll look into it.


Now I've tried what you suggested, and thanks for that btw!, but it still won't work. It sets the maxammo to the variable plus the value you add, in this case 10 - but only once. I'm drawing the value of the var rpgsammo on my screen and it doesn't update when 10 is added. It remains whatever I declare it to. Summing up: After a kill the actual max_ammo_amount and rpgsammo doesn't match, and the max_ammo_amount wont increment on kills past the first one.

This post has been edited by thisbecasper: 20 October 2017 - 04:34 PM

0

User is offline   Hendricks266 

  • Weaponized Autism

  #2120

state updatevalue
    getplayer[THISACTOR].wackedbyactor killer
    getactor[killer].picnum tempkiller
    ifvare tempkiller APLAYER
    {
                getactor[killer].yvel tempkiller
                getplayer[tempkiller].max_ammo_amount RPG_WEAPON temp
                addvar temp 10
                setplayer[tempkiller].max_ammo_amount RPG_WEAPON temp
    }
ends

0

#2121

View PostHendricks266, on 20 October 2017 - 04:44 PM, said:

state updatevalue
    getplayer[THISACTOR].wackedbyactor killer
    getactor[killer].picnum tempkiller
    ifvare tempkiller APLAYER
    {
                getactor[killer].yvel tempkiller
                getplayer[tempkiller].max_ammo_amount RPG_WEAPON temp
                addvar temp 10
                setplayer[tempkiller].max_ammo_amount RPG_WEAPON temp
    }
ends


I only got it to work when put under ifwasweapon RPG - I don't know how to make it work if put under ifhitweapon under ifdead or reverse. Anyway - Something comepletely different: Is it possible to draw an ingame menu with options that perform lines of code when pressed when chosen, and if it is, is it difficult? I'm thinking of an upgrade system, but you'll have to use menu to upgrade the weapons.

This post has been edited by thisbecasper: 21 October 2017 - 08:41 AM

0

#2122

Does somebody know how to get around the instant freeze of the game when the hp goes to -1 in the case of the player getting frozen.

onevent EVENT_DISPLAYREST
  	//Healthbar
  	getactor[THISACTOR].extra health
  	getplayer[THISACTOR].MAX_PLAYER_HEALTH maxhp
  	setvar xvar 0

  	whilevarn maxhp 0
  	{
  		rotatesprite xvar 185 65536 0 3163 0 0 49 0 0 xdim ydim 
    	addvar xvar 1 // move to the right
    	subvar maxhp 1 // next hitpoint
  	}

  	setvar xvar 0
  	setvar yvar 100

  	whilevarn health 0
  	{ 
    	ifvarg health 100
  		{
  			rotatesprite yvar 185 65536 0 3163 0 2 16 0 0 xdim ydim // draws atomic health
   			addvar yvar 1 // move to the right
    		subvar health 1 // next hitpoint
  		}
  		else
  		{
  			rotatesprite xvar 185 65536 0 3163 0 0 16 0 0 xdim ydim // draws regular health
    		addvar xvar 1 // move to the right
    		subvar health 1 // next hitpoint
  		}
   	}
	
endevent


This code crashes the game unfortunately. There has to be fix for this...

Quote

Anyway - Something comepletely different: Is it possible to draw an ingame menu with options that perform lines of code when pressed when chosen, and if it is, is it difficult? I'm thinking of an upgrade system, but you'll have to use menu to upgrade the weapons.

Nvm, think I've found something on it now.

Is there a way to achieve the ID of the player you are hitting, or even better, looking at?

This post has been edited by thisbecasper: 21 October 2017 - 12:43 PM

0

User is offline   Perro Seco 

#2123

View PostTrooper Dan, on 14 October 2017 - 03:22 PM, said:

You could try forcing over_shoulder_on to 1. Normally this would also change the camera position, but since you are already forcing a camera position as well, it might do the job. Don't forget to restore it to the previous value when camera viewing ends. EDIT: To be clear, this isn't necessary the best solution, but I don't remember what is going on with the player sprite that makes it invisible. It might be a tsprite thing.
Thanks a lot for your help, that almost did the trick, but now the player is transparent, just like when F7 view is activated. I can change its cstat, but looks like the game adds the transparency effect over that value...

Also, when playing demos using the cam, I get the "out of sync" warning. Reading in the wiki, looks like this is caused by manipulation of constantly updated gamevars, but the only gamevars I manipulated here were the ones from the above mentioned tutorial. Would that cause a sync problem?
0

#2124

View Postthisbecasper, on 21 October 2017 - 12:20 PM, said:

Does somebody know how to get around the instant freeze of the game when the hp goes to -1 in the case of the player getting frozen.

onevent EVENT_DISPLAYREST
  	//Healthbar
  	getactor[THISACTOR].extra health
  	getplayer[THISACTOR].MAX_PLAYER_HEALTH maxhp
  	setvar xvar 0

  	whilevarn maxhp 0
  	{
  		rotatesprite xvar 185 65536 0 3163 0 0 49 0 0 xdim ydim 
    	addvar xvar 1 // move to the right
    	subvar maxhp 1 // next hitpoint
  	}

  	setvar xvar 0
  	setvar yvar 100

  	whilevarn health 0
  	{ 
    	ifvarg health 100
  		{
  			rotatesprite yvar 185 65536 0 3163 0 2 16 0 0 xdim ydim // draws atomic health
   			addvar yvar 1 // move to the right
    		subvar health 1 // next hitpoint
  		}
  		else
  		{
  			rotatesprite xvar 185 65536 0 3163 0 0 16 0 0 xdim ydim // draws regular health
    		addvar xvar 1 // move to the right
    		subvar health 1 // next hitpoint
  		}
   	}
	
endevent




Fixed.

Now my only questions are: How do you alter another player's gamevar. And is there a way to achieve the ID of the player you are hitting, or even better, looking at?

This post has been edited by thisbecasper: 21 October 2017 - 02:08 PM

0

User is offline   Hendricks266 

  • Weaponized Autism

  #2125

gamevar myvar 0 1

getplayervar[index].myvar
setplayervar[index].myvar
0

#2126

View PostHendricks266, on 22 October 2017 - 12:52 AM, said:

gamevar myvar 0 1

getplayervar[index].myvar
setplayervar[index].myvar


gamevar killer 0 2
gamevar tempkiller 0 2
gamevar temprpg 0 1

state updatevalue
    getplayer[THISACTOR].wackedbyactor killer
    getactor[killer].picnum tempkiller
    ifvare tempkiller APLAYER
    {
                getactor[killer].yvel tempkiller
                getplayervar[tempkiller].temprpg
                addvar temprpg 7
                setplayervar[tempkiller].temprpg
    }
ends    

actor APLAYER MAXPLAYERHEALTH PSTAND 0 0

	getplayer[THISACTOR].max_ammo_amount RPG_WEAPON temprpg


"GAME.CON:3582: error: symbol `setplayervar' is a keyword."
0

User is offline   Mblackwell 

  • Evil Overlord

#2127

gamevar killer 0 2
gamevar tempkiller 0 2
gamevar temprpg 0 1
gamevar temp 0 0

state updatevalue
    getplayer[THISACTOR].wackedbyactor killer
    getactor[killer].picnum tempkiller
    ifvare tempkiller APLAYER
    {
                getactor[killer].yvel tempkiller
                getplayervar[tempkiller].temprpg temp
                addvar temp 7
                setplayervar[tempkiller].temprpg temp
    }
ends    

actor APLAYER MAXPLAYERHEALTH PSTAND 0 0

	getplayer[THISACTOR].max_ammo_amount RPG_WEAPON temprpg

0

#2128

View PostMblackwell, on 22 October 2017 - 09:38 AM, said:

gamevar killer 0 2
gamevar tempkiller 0 2
gamevar temprpg 0 1
gamevar temp 0 0

state updatevalue
    getplayer[THISACTOR].wackedbyactor killer
    getactor[killer].picnum tempkiller
    ifvare tempkiller APLAYER
    {
                getactor[killer].yvel tempkiller
                getplayervar[tempkiller].temprpg temp
                addvar temp 7
                setplayervar[tempkiller].temprpg temp
    }
ends    

actor APLAYER MAXPLAYERHEALTH PSTAND 0 0

	getplayer[THISACTOR].max_ammo_amount RPG_WEAPON temprpg




Now I think I've got it to work finally - thanks guys!

However, I still don't know how to obtain ID of a player unless the player kills you... I want to display damage dealt to the person and/or the health bar of the person they are looking at or last hitted - But I don't know how to get a call to the proper player... Am I missing something obvious here?
0

User is offline   Hendricks266 

  • Weaponized Autism

  #2129

http://wiki.eduke32.com/wiki/htowner

This will give you the sprite id. If the picnum is APLAYER, then you can get the player id from .yvel.
0

#2130

View PostHendricks266, on 22 October 2017 - 01:08 PM, said:

http://wiki.eduke32.com/wiki/htowner

This will give you the sprite id. If the picnum is APLAYER, then you can get the player id from .yvel.

omg thank you - been looking for this for so long. Dumb that I haven't stumpled upon it. Thank you.

onevent EVENT_GAME
{
	getactor[THISACTOR].htowner killer
	ifvare killer APLAYER
	{
		getactor[THISACTOR].extra hp
		getactor[killer].yvel tempkiller
		setplayervar[tempkiller].targethp hp
	}

(...)


If I shoot at someone, targethp won't register - it's 0 all the time.
I've tried writing it under actor APLAYER, and as a state, no luck.

This post has been edited by thisbecasper: 22 October 2017 - 01:46 PM

0

Share this topic:


  • 115 Pages +
  • « First
  • 69
  • 70
  • 71
  • 72
  • 73
  • 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