EDuke32 Scripting "CON coding help"
#2125 Posted 22 October 2017 - 12:52 AM
getplayervar[index].myvar
setplayervar[index].myvar
#2126 Posted 22 October 2017 - 07:44 AM
Hendricks266, on 22 October 2017 - 12:52 AM, said:
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."
#2127 Posted 22 October 2017 - 09:38 AM
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
#2128 Posted 22 October 2017 - 11:25 AM
Mblackwell, 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?
#2129 Posted 22 October 2017 - 01:08 PM
This will give you the sprite id. If the picnum is APLAYER, then you can get the player id from .yvel.
#2130 Posted 22 October 2017 - 01:12 PM
Hendricks266, on 22 October 2017 - 01:08 PM, said:
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
#2131 Posted 22 October 2017 - 10:09 PM
#2133 Posted 23 October 2017 - 01:35 AM
Trooper Dan, on 22 October 2017 - 11:22 PM, 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!
#2134 Posted 23 October 2017 - 02:03 AM
thisbecasper, on 23 October 2017 - 01:35 AM, said:
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).
#2135 Posted 24 October 2017 - 11:24 AM
#2136 Posted 24 October 2017 - 11:39 AM
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?
#2137 Posted 24 October 2017 - 01:23 PM
Hendricks266, on 24 October 2017 - 11:39 AM, said:
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
#2138 Posted 25 October 2017 - 02:24 PM
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
#2139 Posted 25 October 2017 - 07:01 PM
thisbecasper, on 25 October 2017 - 02:24 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.
#2140 Posted 26 October 2017 - 12:56 AM
Trooper Dan, on 25 October 2017 - 07:01 PM, said:
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..
#2141 Posted 26 October 2017 - 01:09 AM
#2142 Posted 26 October 2017 - 02:38 AM
This post has been edited by thisbecasper: 26 October 2017 - 03:20 AM
#2143 Posted 27 October 2017 - 02:08 PM
#2144 Posted 27 October 2017 - 02:18 PM
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)
#2145 Posted 27 October 2017 - 07:40 PM
thisbecasper, on 27 October 2017 - 02:08 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
#2146 Posted 28 October 2017 - 01:40 AM
Trooper Dan, on 27 October 2017 - 07:40 PM, said:
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!
#2147 Posted 28 October 2017 - 12:34 PM
thisbecasper, on 28 October 2017 - 01:40 AM, said:
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
#2148 Posted 03 November 2017 - 02:16 PM
#2149 Posted 03 November 2017 - 03:10 PM
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
#2150 Posted 03 November 2017 - 08:47 PM
#2151 Posted 04 November 2017 - 03:18 AM
This post has been edited by Mark.: 04 November 2017 - 03:19 AM
#2152 Posted 05 November 2017 - 04:40 AM
Hendricks266, on 03 November 2017 - 08:47 PM, said:
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
#2153 Posted 05 November 2017 - 10:34 AM
getplayer[THISACTOR].i temp getactor[temp].extra temp2 addvar temp2 100 setactor[temp].extra temp2
#2154 Posted 07 November 2017 - 09:51 AM
This post has been edited by spacekebab: 07 November 2017 - 09:51 AM

Help
Duke4.net
DNF #1
Duke 3D #1


