
EDuke32 Scripting "CON coding help"
#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
#2155 Posted 07 November 2017 - 01:42 PM
spacekebab, on 07 November 2017 - 09:51 AM, said:
It's hardcoded. You can tell by searching GAME.CON that there is no actor script for it. But what you could do is declare it as an actor, and then make it run state breakobject or something similar. You may have to force it to statnum 1 though.
#2156 Posted 15 November 2017 - 12:00 PM
Problem is that it's also used for a lot of other things where the hightile would look out of place, so I got the idea to only assign it based on a generally unused pallet in the DEF file, then change the texture's pallet via con based on certain conditions (eg if it's being used as a sky texture on a paralaxed ceiling). The code I wrote works, but not really. It's all dependent on the player, so the sky's pallet ONLY changes when the player enters that sector which makes enough sense, but for obvious reasons i can't have it work that way. I'm not sure how to make that change happen independent of the player though.
This post has been edited by CruX: 15 November 2017 - 12:12 PM
#2157 Posted 15 November 2017 - 01:05 PM
CruX, on 15 November 2017 - 12:00 PM, said:
Problem is that it's also used for a lot of other things where the hightile would look out of place, so I got the idea to only assign it based on a generally unused pallet in the DEF file, then change the texture's pallet via con based on certain conditions (eg if it's being used as a sky texture on a paralaxed ceiling). The code I wrote works, but not really. It's all dependent on the player, so the sky's pallet ONLY changes when the player enters that sector which makes enough sense, but for obvious reasons i can't have it work that way. I'm not sure how to make that change happen independent of the player though.
Wouldn't it make more sense to use mapster script and just fix the map?
If you want to do it via CON, you could use code like this:
onevent EVENT_ENTERLEVEL set temp 0 whilevarvarn temp NUMSECTORS { ife sector[temp].ceilingpicnum 199 ifvarand sector[temp].ceilingstat 1 setsector[temp].ceilingpicnum MYHIGHTILECEILING add temp 1 } endevent
That code doesn't do anything with palettes, but you can easily add a condition that checks ceilingpal, or you could change ceilingpal instead of changing ceilingpicnum.
#2158 Posted 15 November 2017 - 01:30 PM
Trooper Dan, on 15 November 2017 - 01:05 PM, said:
Maybe? I'm not with familiar mapster script, just working within the boundaries of things I (vaguely) know. Might have to look into it sometime. Either way, I tweaked that code to switch pallets instead of picnums and it worked without a hitch. Thanks!
This post has been edited by CruX: 15 November 2017 - 01:33 PM
#2159 Posted 24 November 2017 - 03:24 PM
This post has been edited by thisbecasper: 24 November 2017 - 03:25 PM
#2160 Posted 25 November 2017 - 03:42 AM
This post has been edited by thisbecasper: 25 November 2017 - 04:01 AM