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

Jump to content

  • 124 Pages +
  • « First
  • 92
  • 93
  • 94
  • 95
  • 96
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

#2784

View Postjimbob, on 19 October 2021 - 02:36 AM, said:

is there an easy way to make an enemy impervious to bullet weapons? i want to program a tank, so obviously i want bullets to do no damage. the hard way would be to add the health taken away back to the actor immediatly, but since there are a few types of bullet weapons it would require too much math. and obviously ifwasweapon shotspark1 { break } wont work as it still detracts damage.

Bullets all share the same SHOTSPARK1 actor if i remember correctly.
HTpicnum checks the ID of the projectile that hit you, so you can get the picnum of the ID.
HTowner gets the id of the enemy that shot at you, so if you need to do some more digging to figure out if it was a bullet, you can see what the enemy picnum was and see if it's an enemy that shoot bullets.

This post has been edited by bullerbullerseven: 19 October 2021 - 07:20 AM

0

User is offline   jimbob 

#2785

there's this bit of code from the wiki page, but that refers to the actor itself, not sure if it works when i refer to the player doing the damage to the actor.
getactor[THISACTOR].htextra TEMP

ifvarg TEMP 0                            // if the actor is set to take some damage from a weapon...
{
  getactor[THISACTOR].htowner TEMP      // gets the owner of the weapon into TEMP
  ifvarvare TEMP THISACTOR              // if the owner of the weapon IS this actor
    setactor[THISACTOR].htextra 0       // set the damage to 0
}

0

User is online   Reaper_Man 

  • Once and Future King

#2786

No, check .htpicnum. All hitscan damage shows up as SHOTSPARK1. You only care about .htowner if you care about who the damage is coming from (IE you want bullet damage to count from some sources but not others)

ife sprite[].htpicnum SHOTSPARK1
    seta .htextra -1


Set this before the "ifhitweapon" call.

That example is interesting, in that they set the damage to 0 instead of -1, since 0 will still trigger "ifhitweapon".

This post has been edited by Reaper_Man: 19 October 2021 - 09:21 AM

1

User is offline   jimbob 

#2787

that seems to work just fine, and much simpler than what i was thinking.
0

User is offline   jimbob 

#2788

for some reason whenever i hit the boss character with a rocket that does a good amount of damage the game hangs with this bit of code and i cant figure out why, i added a check to solve the problem but it does nothing
this bit of code came pretty much straight from the package that was shared here for making a lifebar, i just reworked into an enemy lifebar. the boss has 5000 health. and the code is in event EVENT_DISPLAYREST

ifvare BOSSFIGHT2 1
{
getactor[PANZER].extra temp // get the boss'health
divvar temp 50 // divide the health so the lifebar isnt rediculously long. 
	{   
		ifvarl temp 10 { break } else // if health lower than 10 stop doing this code
		setvar xvar 75 // set starting x coordinate   
		whilevarn temp 0  // loop for each hitpoint       
		{   
		rotatesprite xvar 16 49152 0 199 0 2 16 0 0 xdim ydim // draws HEALTHBAR
		screentext BIGALPHANUM 160 14 32768 0 0 132 0 0 0 0 5 16 1 2 1056768 0 0 xdim ydim
		addvar xvar 2 // move to the right  
		subvar temp 1 // next hitpoint  		

		}
	}

}


hmm, this test it went perfectly, maybe because i move iftempl 10 before the actual code instead of after, maybe luck, maybe its a rounding error that happens when the vehicle gets hit and does an odd number of damage.

speaking of the vehicle, i want it to be unable to move into sectors that have an X amount of height difference, for the player you can use autostep, but i cant find a similar command for actors. if there is non i will just make the actor stayput and map accordingly.

This post has been edited by jimbob: 28 October 2021 - 01:55 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#2789

I don't know if this will help, but a few things in that bothered me. You had some braces doing nothing, and were checking the PANZER var without regard to whether it still contained a valid sprite ID. Typically vars for sprite IDs get set to -1 when the sprite is not in the map.

I'm going to assume this code is in a state and is not directly part of a display event, because if it were then the "break" would cause the rest of the event code to abort as well.


ifvare BOSSFIGHT2 1
ifn PANZER -1
ifge sprite[PANZER].extra 0
{
     getactor[PANZER].extra temp // get the boss' health
     divvar temp 50 // divide the health so the lifebar isnt ridiculously long.
     ifvarl temp 10 break  // if health lower than 10 stop doing this code
     setvar xvar 75 // set starting x coordinate   
     whilevarn temp 0  // loop for each hitpoint       
     { 
          rotatesprite xvar 16 49152 0 199 0 2 16 0 0 xdim ydim // draws HEALTHBAR
          screentext BIGALPHANUM 160 14 32768 0 0 132 0 0 0 0 5 16 1 2 1056768 0 0 xdim ydim
          addvar xvar 2 // move to the right  
          subvar temp 1 // next hitpoint  	
     }	
}


0

User is offline   jimbob 

#2790

the code is actually not in a state, but directly in the event... so that might be one of the problems. i use a similar piece of code for the first bossfight, and if that actor is not in the map, his health wont show and would break.. wich is probably why my bar wasnt showing up properly.

just tested it, remmed the ifvar templ 10 line and it seems to work just fine, will do some aditional testing but so far this seems to be working great, thanks :)
the ifvar templ 10 is redundant anyway with the ifge sprite[PANZER].extra 0 line

This post has been edited by jimbob: 28 October 2021 - 10:18 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#2791

View Postjimbob, on 28 October 2021 - 10:10 AM, said:

the ifvar templ 10 is redundant anyway with the ifge sprite[PANZER].extra 0 line


Not really because even if extra is > 0 that doesn't mean extra/50 is > 0
0

User is offline   jimbob 

#2792

i guess, i'll test some more and if i dont get anymore hangups i'll just leave it remmed.
0

User is offline   Danukem 

  • Duke Plus Developer

#2793

View Postjimbob, on 28 October 2021 - 11:31 AM, said:

i guess, i'll test some more and if i dont get anymore hangups i'll just leave it remmed.


It won't cause a hang because the drawing loop won't even start if temp is 0 after the division. I was just pointing out that there are cases where the break will be executed.
0

User is offline   RPD Guy 

#2794

Hello,

I don't know if someone asked this before, but, is there a way to tint a sector without affecting its containing sprites' pal?

I know that "spritenopal" kinda "solves" this, but I don't want to set every game sprite with this definition.
0

User is offline   Danukem 

  • Duke Plus Developer

#2795

Maybe? On the wiki it says you press N on a sprite to toggle its auto-shading, so there maybe something undocumented for pal. In game, those settings are stored in the htflags bitfield, but that member doesn't seem to be stored in the map. The "flags" member in mapster is for cstat, which is different. However, the "no shade" bit is duplicated in cstat, which I'm guessing they did so that it could be stored in the map file.
0

User is offline   Danukem 

  • Duke Plus Developer

#2796

Since this is the scripting thread, you may want a scripting solution. It's a bit cumbersome, but you could define a new sprite and then put it into the sector where you want the sprites to ignore pal:

define NOPALSPRITE ####
gamevar tempsprite 0 0
gamevar tempvar 0 0

eventloadactor NOPALSPRITE

cstat 32769
headspritesect tempsprite sprite[].sectnum
whilevarn tempsprite -1
{
  geta[tempsprite].htflags tempvar
  orvar tempvar 64
  seta[tempsprite].htflags tempvar
  nextspritesect tempsprite tempsprite
}

enda


I think that will work but I'm not entirely sure because the htflags might get overwritten after map load. If that's the case then the code would need to run later.
0

#2797

If Duke has 1 hp, for example, and is hit by his own projectile in the same tick as an opponent hits him, it's pretty random whether he suicides or the opponent gets the kill. Perhaps, it seems that he mostly suicides. I've tried set it up so that Duke has 1000hp and hits himself every tick with a 1 dmg projectile. Then, when I, an opponent, shoots him with a 2000 dmg projectile, Duke suicides (which is weird IMO).

It seems that all dmg incurred at the same tick is actually accumulated, but htowner and htpicnum and so on contains a "random" value among those that hit Duke in that tick.

I thought I could manipulate some value, e.g. setactor[THISACTOR].htowner some_id_that_is_not_the_actor_itself, but that doesn't seem to have any influence on whether Duke suicides or not.

Same but different: Whenever Duke is hit, the opponent hitting Duke is notified (say, by a hitmarker), but if multiple opponents hit Duke in the same tick, how would I go about notifying all opponents? Atm I'm using htowner, which obviously only holds a single value, so how would I go about this?
0

User is online   Reaper_Man 

  • Once and Future King

#2798

EVENT_DAMAGESPRITE maybe?
1

User is offline   Danukem 

  • Duke Plus Developer

#2799

View PostReaper_Man, on 14 December 2021 - 06:14 PM, said:

EVENT_DAMAGESPRITE maybe?


I'll bet you are right. That event should be triggered every time there is damage, even if it happens to the same sprite multiple times in one tic.

gamevar htowner2 -1 1
gamevar damagetime 0 1
gamevar playerID 0 1

onevent EVENT_DAMAGESPRITE

ife sprite[RETURN].picnum APLAYER
{
  geta[RETURN].yvel playerID
  ife playervar[playerID].damagetime player[playerID].player_par setplayervar[playerID].htowner2 sprite[THISACTOR].owner
  else setplayervar[playerID].htowner2 -1
  setplayervar[playerID].damagetime player[playerID].player_par
}

endevent


I don't normally work with different player IDs since I have only been scripting singleplayer stuff for a long time, but if that code above is correct what it will do is put a second sprite ID into the htowner2 var for the specific player who got damaged by two sprites in the same tic. I think the likelihood of there being a third sprite doing damage in the same tic is pretty low, so having two IDs should be sufficient. Even assuming that works, it won't save how much damage was done by each, so more work would be needed for that feature. However, if one sprite was the same player who got hit and the other sprite is a different player, it would then be easy to always set the htowner to one or the other in that situation, giving credit where it is desired.

EDIT: Also, htowner2 should be cleared back to -1 by the damage handling code that gives credit; otherwise, it stays set until the player is damaged again.

This post has been edited by Danukem: 14 December 2021 - 07:41 PM

2

#2800

That worked, thanks!

Is it possible to make sprites only visible to some of the players in a multiplayer game? I want to show trailing footsteps of players if nightvision is turned on, but I don't want all players to see these footsteps, only those who have nightvision on.
1

#2801

Turns out that by using myconnectindex I can test if getplayer[myconnectindex].heat_on is 1 and draw the footprints accordingly. This means that even if a game contains 3 dukes, it is only when your own duke has goggles turned on that the sprites are drawn - they are in turn not drawn on the screen for other players (unless they also have goggles turned on). Since it is only visual effects that uses myconnectindex it does not cause a desync :)
0

User is offline   Danukem 

  • Duke Plus Developer

#2802

You rediscovered some ancient EDuke knowledge.
0

User is offline   jimbob 

#2803

is it possible to overlay text using screentext during cinematics? particularly .IVF files?

so far i tried using onevent EVENT_CUTSCENE, using IFCUTSCENE cutscene { screentext etc etc } endevent
but it doesnt seem to render, atleast not as an overlay, so before i waste more time on this, i wonder if it is at all possible?

[edit] it seems possible, but using redefinequote makes it hard to pinpoint the exact video file, since im using a custom episode intro video using redefinequote the overlay appears on the 'logo' video file rather than my custom one.

This post has been edited by jimbob: 06 February 2022 - 01:20 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#2804

If screentext works during the cutscene, then I would just try setting a custum gamevar to specific value for that cutscene right before you use the startcutscene command, then have the screentext for that cutscene display depending on the variable -- that way you don't have to worry about IFCUTSCENE and it won't display during the wrong one
0

User is offline   jimbob 

#2805

i'll give that a try
0

User is offline   jimbob 

#2806

the overlay being garbage colors wasnt limited to logo.anm it seems, and it fails to render the actual video, so im canning the idea, but using the vars worked, so thats nice.
0

User is offline   jimbob 

#2807

not sure if there is a Eduke32 suggestions thread, a quick search came up with nothing, but i was working on a random speech system, and i noticed there is a stopallsounds, a stopactorsound command, but no stopallactorsounds command, wich would be very usefull to stop all of the audio the actor is currently playing ( for example make him shup up ) before starting a new soundfile. with a large batch or dedicated audio que's excluding every instance would be a pain in the ass to do. even with as little as 6 pain reactions, you'd have to program a multitude of that. so unless im missing something, and if eduke is still in development something like that would seem very helpfull.

anyway, back to mucking about.
0

User is offline   Danukem 

  • Duke Plus Developer

#2808

View Postjimbob, on 18 February 2022 - 03:35 PM, said:

not sure if there is a Eduke32 suggestions thread, a quick search came up with nothing, but i was working on a random speech system, and i noticed there is a stopallsounds, a stopactorsound command, but no stopallactorsounds command, wich would be very usefull to stop all of the audio the actor is currently playing ( for example make him shup up ) before starting a new soundfile. with a large batch or dedicated audio que's excluding every instance would be a pain in the ass to do. even with as little as 6 pain reactions, you'd have to program a multitude of that. so unless im missing something, and if eduke is still in development something like that would seem very helpfull.

anyway, back to mucking about.


AFAIK there is no way to do that. I have this problem as well. So I end up with code like this:

ifactorsound THISACTOR EDFL_PAIN1 nullop else
ifactorsound THISACTOR EDFL_PAIN2 nullop else
ifactorsound THISACTOR EDFL_PAIN3 nullop else
{
	rand temp 2
	ife temp 0 sound EDFL_PAIN1
	ife temp 1 sound EDFL_PAIN2
	ife temp 2 sound EDFL_PAIN3
}


And believe me I have much worse examples than that, that's just the first one I found on a quick search of my code.
0

User is offline   jimbob 

#2809

i was afraid of that, well time to crack some knuckles and get to work then :o :(
0

User is offline   jimbob 

#2810

is there a way to make 2 sprites "stick" together, think sticky bombs in shadow warrior for instance. and if so, can i get one of them to have a different angle relative to the original sprite? say like a tank hull, and turret, so i can rotate the turret individually while moving in a different direction? in situation 1 it can use a bit of leeway, or wiggleroom but in situation 2 the sprites need to be alligned absolutely perfectly at all times.

This post has been edited by jimbob: 20 March 2022 - 07:14 AM

0

User is offline   dandouglas 

#2811

Is there away to edit/disable individual stats on the bonus/intermission screen (times/kills/secrets)?

Reason being is that I'm using map caching code but I can't get it to retain the correct stats between linked maps (when the nuke button is hit or the player enters an end-level sector, only stats from the specific map it's located in are displayed, not the accumulated total between linked maps).

I've tried studying the AMC Squad map caching code but I can't work out how it's retaining these stats within hubs (something to do with saving arrays I think, but I'm way too inexperienced with CON to work out what).

I know I can disable the bonus/intermission screens entirely, but I don't want to, as I want breaks between certain maps in my mod, and while I've tried custom intermissions using the startscreen command, they're too abrupt and easily skipped by the player (unless I can completely disable player input for a specified amount of time when one of these screens is displayed?) Besides, I'd like to keep the animation of Duke reloading his shotgun.

The only other option I can think of is drawing sprites on bonus/intermission screen using EVENT_DISPLAYBONUSSCREEN to literally conceal the times/kills/secrets popping up, but that seems somewhat clumsy, and the RPG sound effect will still play when each stat is displayed.

Cheers!
0

User is offline   Mark 

#2812

If you decide to go the last route, I used this code which disables sounds you specify only when in a menu screen. Somewhere in the wiki is a list of the possible screens to use this in. In this example I used 1,4,6,8. Hopefully the screens you wish to use it in are available. I put this at the bottom of my game.con file.
// disable menu sounds

state remove_explosion
ifvare RETURN PIPEBOMB_EXPLODE
setvar RETURN -1
ends

state remove_kickhit
ifvare RETURN KICK_HIT
setvar RETURN -1
ends

state remove_lasertrip
ifvare RETURN LASERTRIP_EXPLODE
setvar RETURN -1
ends

onevent EVENT_SOUND
getplayer[THISACTOR].gm temp
getplayer[THISACTOR].palette temp
ifvare temp 6 state remove_explosion state remove_kickhit state remove_lasertrip // ANMs
ifvare temp 4 state remove_explosion state remove_kickhit state remove_lasertrip // title screen

ifvarand temp 1 state remove_explosion state remove_kickhit state remove_lasertrip // menus
ifvarand temp 8 state remove_explosion state remove_kickhit state remove_lasertrip // end-of-level
endevent
0

User is offline   dandouglas 

#2813

Cheers Mark, that's a great shout - I can't find the number which references the bonus screen but I'll keep digging on the wiki. Removing "ifvare temp x" turns off the explosion SFX on the bonus screen, so it's definitely possible somehow!

In the meantime I've knocked up a Dukeless intermission which I'm pretty happy with, hiding the stats but retaining the "press any key to continue" prompt.
0

Share this topic:


  • 124 Pages +
  • « First
  • 92
  • 93
  • 94
  • 95
  • 96
  • 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