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

Jump to content

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

EDuke32 Scripting  "CON coding help"

#2124

 thisbecasper, 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

#2131

Is there a way to have to seperate counters that dont reset eachother upoc resetcounter on one of them? It's because I have a healthregen system, which adds 1 health every 15th code cycle, and at the same time I have some code that adds 1 ammo to the shotgun every 23rd code cycle. There are not written in the same state, but of course the second won't ever get to add ammo to the shotgun.. workaround?
0

User is online   Danukem 

  • Duke Plus Developer

#2132

Just make your own counters using per-player gamevars.
1

#2133

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

Just make your own counters using per-player gamevars.

Oh, yeah of course. Now I finally understand the way add works... I've tried to add something under event_game, and the number shoots into the air, so I was afraid to add something constantly. Got to understand it now, thanks!
0

User is online   Danukem 

  • Duke Plus Developer

#2134

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

Oh, yeah of course. Now I finally understand the way add works... I've tried to add something under event_game, and the number shoots into the air, so I was afraid to add something constantly. Got to understand it now, thanks!


All the code in EVENT_GAME is executed by every single sprite in the game once per tic. So if every sprite increments a per-player var, then of course it will get very high very fast (and more or less randomly). What you have to do is either increment the var in the actor APLAYER code, or if you are going to use EVENT_GAME, then make sure the code is only executed by players (use the condition ifactor APLAYER or something equivalent).
1

#2135

I'm still trying desperately to draw the amount of hp the opponent has to the screen. Just hitting the opponent should be enough to get opponents hp shown, but no luck whatsoever... any alternative suggestions?
0

User is offline   Hendricks266 

  • Weaponized Autism

  #2136

Do you want the HP to stay on screen until you die, or do you want it to time out?

Do you want it to continue to show an updated HP amount if the target takes damage from other sources, or do you want it to show the last known HP amount of the player when you hit them?

What do you want to happen if you hit one player, then hit another player while the first HP is still displaying?

What do you want to happen if you hit more than one player at the same time, such as with anything that has a hitradius?
1

#2137

View PostHendricks266, on 24 October 2017 - 11:39 AM, said:

Do you want the HP to stay on screen until you die, or do you want it to time out?

Do you want it to continue to show an updated HP amount if the target takes damage from other sources, or do you want it to show the last known HP amount of the player when you hit them?

What do you want to happen if you hit one player, then hit another player while the first HP is still displaying?

What do you want to happen if you hit more than one player at the same time, such as with anything that has a hitradius?


Thank you for asking!
1) I want to have the hp bar/or number (its all about getting the opponents .extra really), be displayed for 3 seconds after you've inflicted dmg.

2) Im right inbetween these two... possibly constant updated, so it displays loss of health from other sources.

3) It should only display the "last" person you hit.

4) If you hit two, show random I guess (or the one with the least hp).

And while we are at it, I'm thinking to substitute the amount of hp you've dealt as dmg with a sub-bar of different color. So if the person had 90 hp, and I hit for 37, the bar would show me 90 units - 53 for current hp and 37 for dmg dealt while the bar is showing. Then if I hit again for 10 the bar would still show 90 units... If this idea goes through, I think I'll choose the other option for question 2).

This post has been edited by thisbecasper: 24 October 2017 - 01:59 PM

0

#2138

How come

state healthregen
	addvar healthregencounter 1
	ifvarg healthregencounter 30
	{
		addphealth 1
		setvar healthregencounter 0
	}
ends

state pistolregen
	ifvare pweapon PISTOL_WEAPON
	{
		ifvare currammo 72
		{
			setvar weaponregencounter 0
		}
		else
		{
			addvar weaponregencounter 1
			ifvarg weaponregencounter 14
			{
				addammo PISTOL_WEAPON 1
				setvar weaponregencounter 0
			}
		}
	}
ends

state tripbombregen
	ifvare currtripbombammo 10
	{
		setvar tripbombregencounter 0
	}
	else
	{
		addvar tripbombregencounter 1
		ifvarg tripbombregencounter 250
		{
			addammo TRIPBOMB_WEAPON 1
			setvar tripbombregencounter 0
		}
	}
ends

this work, but if I change
state pistolregen
	ifvare pweapon PISTOL_WEAPON

to
state pistolregen
	ifvare roundweapon PISTOL_WEAPON

where roundweapon is set to a value in EVENT_GAME, it doesn't?

I'm trying to have currentweapon ammo regenerate together with health and tripmine ammo (but if pweapon = tripmine_weapon, it should regenerate a weapon corresponding to roundweapon. You can only have one weapon at all time, and then tripmines as side arms basically). It works with the last change, but then I won't take dmg from the tripmine until I don't have the tripmine_weapon equipped... Basically I can delay dmg from the tripmines if I'm currently having the tripmine weapon in my hands - as soon as I change weapon, the dmg hits me and the screen flashed red and so on. It's like it doesn't like to have 3 active gamevars counters at the same while holding the tripmine time but I really don't know...

This post has been edited by thisbecasper: 25 October 2017 - 03:05 PM

0

User is online   Danukem 

  • Duke Plus Developer

#2139

View Postthisbecasper, on 25 October 2017 - 02:24 PM, said:

where roundweapon is set to a value in EVENT_GAME, it doesn't?


You must be setting it to a different value in EVENT_GAME. Without seeing the code, I can only guess that it is being set to several different values by different sprites, and it ends up being a different value from the one you want.
0

#2140

View PostTrooper Dan, on 25 October 2017 - 07:01 PM, said:

You must be setting it to a different value in EVENT_GAME. Without seeing the code, I can only guess that it is being set to several different values by different sprites, and it ends up being a different value from the one you want.

The roundweapon var is a perplayer var determined by the difference between frag and fraggedself, which are also perplayer vars. If you between 0 and 2 kills your roundweapon is pistol, if you have between 3 and 5 kills your roundweapon is set to the shotgun, so in my head it should work - The counters are working fine, and as they should, but it's the tripmine that wont work properly in action, which is weird, and I can't see the link between using a number to dertermine which weapon to regenerate and the tripmine not working properly..
0

User is online   Danukem 

  • Duke Plus Developer

#2141

Typically, just thinking about a problem is not enough to debug it. If I had a dollar for every time something wasn't working right with my code and the behavior "didn't make sense" I would be able to buy a house. You have to follow the flow of code step by step, starting from where you know it is working correctly and then verify each step after that until you find where it is breaking. Don't forget you can use the addlogvar command to help you.
0

#2142

I HAVE FOUND THE THING THAT CAUSED IT - hallelujah - still doesn't makes sense to me though, but I've found a workaround. Orignally I had made sure the counters were set to 0 if the weapon's ammo amount was at maxammo, so that it wouldn't count to infinity essentially. The problem was that my method took currentammo as a var and and not the currentammo on the roundweapon - long story short -> Weird behavior of the tripmines was caused by counters going wild.

This post has been edited by thisbecasper: 26 October 2017 - 03:20 AM

0

#2143

Is there no way to be able to know how much hp the opponents has, by either hitting or looking at them? - I've tried so many thinks now, do you guys know if it has been achieved before?
0

User is offline   Zaxtor 

#2144

You mean like the condition of the monster etc?
I'm sure there maybe a code somewhere to show the hp number and or displaying above its head.
Or little bar like most modern games have.

My mod for bosses has health bar. (50 lines in bar)
0

User is online   Danukem 

  • Duke Plus Developer

#2145

View Postthisbecasper, on 27 October 2017 - 02:08 PM, said:

do you guys know if it has been achieved before?


Yes. I have this feature in WGR2 for displaying the health bars of bosses on the player's hud. Also in DukePlus, I have an option for displaying a health bar above the head of each enemy. Feel free to borrow whatever code you want, but I don't have time to write a tutorial.

One thing you should realize is that there are many different ways of implementing this type of feature. The health of an actor is always the value of .extra, but you have many choices for displaying it and when to display it. If you are going to show only one enemy's health amount at a time, then there are several conditions you should consider, and some logic in assessing them, including: (1) line of sight to the enemy, (2) distance to the enemy, (3) whether the enemy was the most recent actor to hurt the player, (4) whether you are facing the enemy, even if line of sight is momentarily broken
1

#2146

View PostTrooper Dan, on 27 October 2017 - 07:40 PM, said:

Yes. I have this feature in WGR2 for displaying the health bars of bosses on the player's hud. Also in DukePlus, I have an option for displaying a health bar above the head of each enemy. Feel free to borrow whatever code you want, but I don't have time to write a tutorial.

One thing you should realize is that there are many different ways of implementing this type of feature. The health of an actor is always the value of .extra, but you have many choices for displaying it and when to display it. If you are going to show only one enemy's health amount at a time, then there are several conditions you should consider, and some logic in assessing them, including: (1) line of sight to the enemy, (2) distance to the enemy, (3) whether the enemy was the most recent actor to hurt the player, (4) whether you are facing the enemy, even if line of sight is momentarily broken

I would have no trouble in handling the data once I've got them, It's just a matter of how I can view another aplayer actor's gamevar's value in realtime (once I've got the ID of the player I'm hitting, or whatever) - I'm working on some multiplayer stuff and I'm using the eduke32-oldmp build, idk if that's make a difference. I will try look at your code and see if it works the same way for players, thanks!
0

User is online   Danukem 

  • Duke Plus Developer

#2147

View Postthisbecasper, on 28 October 2017 - 01:40 AM, said:

I would have no trouble in handling the data once I've got them, It's just a matter of how I can view another aplayer actor's gamevar's value in realtime (once I've got the ID of the player I'm hitting, or whatever) - I'm working on some multiplayer stuff and I'm using the eduke32-oldmp build, idk if that's make a difference. I will try look at your code and see if it works the same way for players, thanks!


For damage data, you have to look at the player's sprite, not the player number. The sprite number of a player is the value of player[THISACTOR].i
When you are accessing a player via their player number, but you want information about their sprite, you can grab that sprite ID and then dig into the sprite data.

You could try using this code to populate an array with the player health values:

gamearray playerhealth 8
gamevar temp 0 0
gamevar temp2 0 0

appendevent EVENT_GAME

ifactor APLAYER
{  
     getactor[THISACTOR].yvel temp
     getactor[THISACTOR].extra temp2
     setarray playerhealth[temp] temp2
}

endevent


And then at any point in your code, you can setvarvar <varname> playerhealth[PLAYER#]

Alternatively, you can skip the new array, and at any time use:

getplayer[PLAYER#].i temp
getactor[temp].extra temp2 // where temp2 is the health value

This post has been edited by Trooper Dan: 28 October 2017 - 12:44 PM

1

#2148

Is there somehow a way I can make an item give health above maxplayerhealth like atomic health?
0

User is offline   Zaxtor 

#2149

You can do that.
My mod has an Orb of Health that gives 999 health.
actually it gives 489 hp so if you have let say 510 health, it will rise to 999.
If you have above 510 health you can't use it until you have 510 or less.

You probably can make a portable item that gives like atomic health etc.

This post has been edited by Zaxtor: 03 November 2017 - 03:11 PM

0

User is offline   Hendricks266 

  • Weaponized Autism

  #2150

I think you can use http://wiki.eduke32.com/wiki/I from the player struct to get the player actor, and then modify its .extra directly.
1

User is offline   Mark 

#2151

deleted, made mistake

This post has been edited by Mark.: 04 November 2017 - 03:19 AM

0

#2152

View PostHendricks266, on 03 November 2017 - 08:47 PM, said:

I think you can use http://wiki.eduke32.com/wiki/I from the player struct to get the player actor, and then modify its .extra directly.

I don't know how to write it...

getactor[THISACTOR].extra currenthealth
addvar currenthealth 100
setplayer[I].extra currenthealth


This post has been edited by thisbecasper: 05 November 2017 - 04:41 AM

0

User is offline   Hendricks266 

  • Weaponized Autism

  #2153

getplayer[THISACTOR].i temp
getactor[temp].extra temp2
addvar temp2 100
setactor[temp].extra temp2

1

Share this topic:


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