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

Jump to content

  • 115 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"

#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 offline   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 offline   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 offline   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 offline   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 offline   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 offline   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 online   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

User is offline   spacekebab 

#2154

The only way I could get CHAIR1 to spawn scrap when hit was to make a new BROKENCHAIR2 actor and point to it via cactor. or change the source code directly in sector.cpp. Is the actor hardcoded or am I just missing something?

This post has been edited by spacekebab: 07 November 2017 - 09:51 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#2155

View Postspacekebab, on 07 November 2017 - 09:51 AM, said:

The only way I could get CHAIR1 to spawn scrap when hit was to make a new BROKENCHAIR2 actor and point to it via cactor. or change the source code directly in sector.cpp. Is the actor hardcoded or am I just missing something?


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.
0

User is offline   CruX 

#2156

is there any way to mass-change the properties of a specific texture used in a map (through con coding) based on the properties it already has? Sector/wall structs really aren't my strong suit so I don't know how complicated this is, but it's stumped me either way. Basically I'm trying to assign a hightile to #199 because it's used as a sky texture a lot.

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

0

User is offline   Danukem 

  • Duke Plus Developer

#2157

View PostCruX, on 15 November 2017 - 12:00 PM, said:

is there any way to mass-change the properties of a specific texture used in a map (through con coding) based on the properties it already has? Sector/wall structs really aren't my strong suit so I don't know how complicated this is, but it's stumped me either way. Basically I'm trying to assign a hightile to #199 because it's used as a sky texture a lot.

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.
1

User is offline   CruX 

#2158

View PostTrooper Dan, on 15 November 2017 - 01:05 PM, said:

Wouldn't it make more sense to use mapster script and just fix the map?


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

0

#2159

Hey guys. I want to achieve something special this time. I want to simulate arming a bomb. So let's say we have a raised sector on a map that looks like a box. I want to have a countdown start when ive been near the bomb and held a key for 2,5 seconds. If the key-press-thingy doesn't work I want something similar to be done in order to get the countdown started (simulating the bomb has been armed). I've thought about using an item on the ground to be a trigger for the countdown, but that doesn't work in my head, because I want to be able to cancel the arming process in the middle of the 2,5 seconds, and if I do that, a new item would have to be placed on the ground and stuff like that. Maybe I could code a sector to have a specifik lotag that trigs some code or something. I honestly don't care about the implementation as long as the arming process works as intended. I should note that it's for multiplayer purposes :-) THANKS IN ADVANCE

This post has been edited by thisbecasper: 24 November 2017 - 03:25 PM

0

#2160

Deleted.

This post has been edited by thisbecasper: 25 November 2017 - 04:01 AM

0

Share this topic:


  • 115 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