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

Jump to content

  • 124 Pages +
  • « First
  • 118
  • 119
  • 120
  • 121
  • 122
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

User is offline   Danukem 

  • Duke Plus Developer

#3563

If you are trying to make a radar display, it has been done.
0

User is offline   Danukem 

  • Duke Plus Developer

#3564

in my radar code, I'm mainly using rotatepoint to do the heavy lifting, with some getincangle and basic var and array manipulation
0

User is online   VGames 

  • Extra Crispy

#3565

View PostDanukem, on 31 October 2024 - 11:09 AM, said:

in my radar code, I'm mainly using rotatepoint to do the heavy lifting, with some getincangle and basic var and array manipulation


I want a way to see enemy positions through walls. Like the railgun on Red Faction.
0

User is offline   Reaper_Man 

  • Once and Future King

#3566

That's a big pain in the ass and involves math translating game coords to screen space coords. I do this exact thing in AWOL to display the AI Bot's stats over their heads while on screen. Take a look at awol_ui.con around the middle of the file, the "botui_xxx" statements handles it. In the "// AI Bot status display" section. There becomes a pretty big vertical desync the closer the actor is to the top or bottom of the player's screen or view, I'm pretty sure because of precision issues with the horiz property. As always, please credit Shotspark and/or AWOL if you pull any of the code wholesale.
1

User is online   VGames 

  • Extra Crispy

#3567

View PostReaper_Man, on 01 November 2024 - 02:12 PM, said:

That's a big pain in the ass and involves math translating game coords to screen space coords. I do this exact thing in AWOL to display the AI Bot's stats over their heads while on screen. Take a look at awol_ui.con around the middle of the file, the "botui_xxx" statements handles it. In the "// AI Bot status display" section. There becomes a pretty big vertical desync the closer the actor is to the top or bottom of the player's screen or view, I'm pretty sure because of precision issues with the horiz property. As always, please credit Shotspark and/or AWOL if you pull any of the code wholesale.


Hey, thanks a lot for the heads up. I'll credit Shotspark and AWOL no matter what if this helps me. I'll check it out ASAP. How do you open the GRP for AWOL? Nothing I have opens it. I normally use GRPViewer.

This post has been edited by VGames: 01 November 2024 - 03:05 PM

0

User is online   VGames 

  • Extra Crispy

#3568

Nevermind just figured it out
0

User is online   VGames 

  • Extra Crispy

#3569

What's a good way to wake enemies up when the player is within a certain range without having to go into every one of their individual sets of code and add the scripts to call on one of their AI statements specific to them? I considered giving them a little bit of damage to wake them up but if there was a better way to start their ai as if they actually saw the player, I'd like to use that instead.

This post has been edited by VGames: 03 November 2024 - 09:16 AM

0

User is offline   Reaper_Man 

  • Once and Future King

#3570

Actors go asleep in 2 ways, changing their statnum and the .httimetosleep property. You can check their .picnum to see if it matches the enemy tile ID, and then check if their statnum is set to STAT_ZOMBIEACTOR and if so set them back to STAT_ACTOR. This will turn them back into regular actors running code. Actors turn into Zombies when their "sleep time" counter exceeds 32767 (and other conditions like being too far away). So you probably want to set the .httimetosleep back to 0 when you force them out of the Zombie state to prevent them from instantly falling asleep again.
1

User is online   VGames 

  • Extra Crispy

#3571

View PostReaper_Man, on 03 November 2024 - 09:48 AM, said:

Actors go asleep in 2 ways, changing their statnum and the .httimetosleep property. You can check their .picnum to see if it matches the enemy tile ID, and then check if their statnum is set to STAT_ZOMBIEACTOR and if so set them back to STAT_ACTOR. This will turn them back into regular actors running code. Actors turn into Zombies when their "sleep time" counter exceeds 32767 (and other conditions like being too far away). So you probably want to set the .httimetosleep back to 0 when you force them out of the Zombie state to prevent them from instantly falling asleep again.


Cool man. That explains a lot.

By the way I ended up using the code from AWOL like you said to set up targeting reticles that pop up on enemies when they are on the other side of walls. It works pretty dang good thanks to you, so thanks for allowing me to use some code from AWOL. However, I noticed that when enemies are higher than me, such as a Liztroop flying, the targets are much higher than the actual enemy position on my screen. Were these health stats that appear above the bots in AWOL not setup to accommodate flying bots or bots that were higher than you because the bots in AWOL don't ever fly around or go up above you often? Can this be fixed? It's not a huge deal for me since you can only see enemies on the other side of a wall that you're somewhat close to and enemies aren't necessarily in the air or higher than you anyways while using this see through walls mechanic. I was just wanted to fix it if it was possible just in case.
0

User is offline   Reaper_Man 

  • Once and Future King

#3572

Like I said, the vertical desync. If the problem is because of precision issues with .horiz, then I don't know if the problem can be solved. Otherwise it's an issue in the math calculating the Z-difference, I'd look at that code section first. I don't think it's a screen drawing precision issue but you could rule it out using the ROTATESPRITE_FULL16 flag (and changing the screen drawing values accordingly)
0

User is online   VGames 

  • Extra Crispy

#3573

View PostReaper_Man, on 03 November 2024 - 07:10 PM, said:

Like I said, the vertical desync. If the problem is because of precision issues with .horiz, then I don't know if the problem can be solved. Otherwise it's an issue in the math calculating the Z-difference, I'd look at that code section first. I don't think it's a screen drawing precision issue but you could rule it out using the ROTATESPRITE_FULL16 flag (and changing the screen drawing values accordingly)

Ok I’ll check that out. Like I said it’s not a huge deal since the enemies that will be painted with these target icons will more than likely be on the floor and close by in the next room anyways. So no big deal. You’ve provided lots of help regardless. Thanks again.

This post has been edited by VGames: 04 November 2024 - 06:28 AM

0

#3574

I had a couple questions involving changing the chaingun cannon to something more akin to the plasma rifle from the LameDuke beta. Is it possible, through CON editing or something more advanced, to:

-Edit the muzzle flash of the chaingun? I see there's a sprite for the chaingun muzzle flash, but it seems to be rendered three times, roughly around where each of the chaingun's barrels are. I've seen some classic total conversions just blank out the sprites for this flash, but I would like to keep it, just color it blue and only have it shown once about where the plasma rifle's barrel is.

-Animate the chaingun ammo pickup? I'm trying to make a mod that doesn't interfere with anything already in place (so you could still play the original levels, just with the new player character and weapons). The default chaingun ammo sprite isn't animated, but the plasma rifle battery pickup is, so I basically wanted to put in a simple CON script that would have the battery pickup (the first frame of which would replace the original box of ammo) jump to the new ART tiles for a couple frames and then come back to the original one. That way the pickup would be animated but all the original chaingun ammo pickups in the original maps don't need new sprites set. I know there's a way to set animations in the ARTs themselves, but those assume the frames are all right next to each other.
0

User is offline   Danukem 

  • Duke Plus Developer

#3575

If you are making a mod with a new character and weapons, you'll need to learn a ton of stuff and it won't be easy, although there are many released mods that already do that and you can look at for examples of how to do things. My advice is just accept from the start that you will need to make your own chaingun with its own sprites, its own ammo actor, its own separate display code, etc. Trying to piggyback on the hardcoded chaingun will limit you severely and if your mod "doesn't interfere with anything already in place" then hacking the chaingun for your new weapon seems like a nonstarter anyway.

Certainly there are a lot of things that are impossible to do in EDuke32, but there's also a huge amount of possibilities. In general I don't think its very useful to ask whether something is possible, because then some smartass such as myself might simply say "yes" and that doesn't put you any farther forward. What you want to know is expert opinions on the best way to accomplish your goals.
0

User is offline   eniojr 

#3576

I'm having trouble to create new interactive buttons. I tried looking some mods, tried to replicate the code, like Memories Mod, but with no results. I just want to create a new button with 2 new textures (off and on). I also tried keycard buttons and new keycards, but also without results.
0

User is offline   Danukem 

  • Duke Plus Developer

#3577

Why do you need new buttons? You could just put your new textures on the existing button tile numbers.
0

User is offline   eniojr 

#3578

View PostDanukem, on 27 November 2024 - 11:32 PM, said:

Why do you need new buttons? You could just put your new textures on the existing button tile numbers.


This is too meh for me... I just want new variations of buttons in the game and keep the existing ones. Some mods did that, but I couldn't replicate that.

I got codes from Memories mod which appears to have at least to funcional textures for a button... One off and another on, in a way they could behave like any other buttons in the game.

These are the codes I found so far related to 2 of the textures of the mod:


//////////MEMOGAME.CON

define BADSWITCH 3935



//////////MEMEXTRA.CON

action ABADSWITCH1 0 0 0 0 2
action ABADSWITCH2 1 0 0 0 2
actor BADSWITCH sleeptime -1
ifaction 0 action ABADSWITCH1
ifaction ABADSWITCH1 
{
ifcansee ifhitspace ifpdistg 1500 setvar PRESS_VAR 2
ifpdistl 1500 ifvare PRESS_VAR 0 ifcansee ifp pfacing ifhitspace 
{
sound NEWBUTTON operateactivators 9892 myconnectindex setvar PRESS_VAR 2 action ABADSWITCH2
}
}
enda


The textures for the button are 3935 (off) and 3936 (on).

I tried to make a new button following this pattern, but failed, like this:

action ALAMEBUTTON1 0 0 0 0 2
action ALAMEBUTTON2 1 0 0 0 2
actor LAMEBUTTON sleeptime -1
ifaction 0 action ALAMEBUTTON1
ifaction ALAMEBUTTON1 
{
ifcansee ifhitspace ifpdistg 1500 setvar PRESS_VAR 2
ifpdistl 1500 ifvare PRESS_VAR 0 ifcansee ifp pfacing ifhitspace 
{
sound SWITCH_ON operateactivators 9892 myconnectindex setvar PRESS_VAR 2 action ABADSWITCH2
}
}
enda


I also have this code, but the button fails to interact with the lotag activator (I put 100 in the map), and doesn't work either, same for the code above:

//LAMEBUTTON

define LAMEBUTTON_STATE_OFF    0
define LAMEBUTTON_STATE_ON     1
define LAMEBUTTON_STATE_LOCKED 2

gamevar LAMEBUTTON_STATE    0

// Estado principal do LAMEBUTTON Toggle
state LAMEBUTTON_TOGGLE
    ifvare LAMEBUTTON_STATE LAMEBUTTON_STATE_OFF
        setvar LAMEBUTTON_STATE LAMEBUTTON_STATE_ON
        cstat 1             
        return
    
    setvar LAMEBUTTON_STATE LAMEBUTTON_STATE_OFF
    cstat 257            
ends

// Evento de uso do LAMEBUTTON
onevent EVENT_USE
    ifspritepal LAMEBUTTON_STATE_LOCKED
        quote 1             
        return
    
    state LAMEBUTTON_TOGGLE
endevent


I made a definition for the tile LAMEBUTTON in DEFS.CON.




Also, I tried to add other colors to ACCESSCARD and ACCESSSWITCH1 and ACCESSSWITCH2, but I have no clue how to do that.

So I tried to add a new keycard (ACCESSCARD2) and a new switch (ACCESSSWITCH3) as actors, like what was done in Memories, but I also failed.


Here are the codes in Memories mod I found so far related to accesscards and accessswitches:

actor ACCESSCARD

ifspawnedby APLAYER { spritepal 21
getplayer[THISACTOR].posx TEMP
setactor[THISACTOR].x TEMP
getplayer[THISACTOR].posy TEMP
setactor[THISACTOR].y TEMP
getplayer[THISACTOR].cursectnum TEMP
setactor[THISACTOR].sectnum TEMP
getplayer[THISACTOR].posz TEMP
setactor[THISACTOR].z TEMP
}

ifspawnedby SPAWNER_SPRITE cstat 0
  fall
  ifspawnedby ITEMBAG spritepal 23
  ifspawnedby SPAWNER_SPRITE spritepal 21
  ifmove RESPAWN_ACTOR_FLAG
    state respawnit
  else
    ifp pshrunk nullop
    else
      ifp palive
        ifpdistl RETRIEVEDISTANCE
          ifcount 6
            ifcanseetarget
      {
        ifpinventory GET_ACCESS 0
          break
        addinventory GET_ACCESS 1
        quote 43
		ifspritepal 23 ifvare FORGET 1 setvar SHOWYOURSELF 1
        state getcode
      }
enda

actor NEWACCESSCARD
  fall
      ifp palive
        ifpdistl RETRIEVEDISTANCE
          ifcount 6
            ifcanseetarget
      {
        setvar GHOSTCARD 1
        quote 177
        state getcode
      }
enda


actor NEWACCESSCARD2
  fall
ifaction 0 { cstat 32768
ifvarg NEWGOD 0 action ZERO }

ifaction ZERO {
cstat 0
      ifp palive
        ifpdistl RETRIEVEDISTANCE
          ifcount 6
            ifcanseetarget
      {
stopsound WAR_AMBIENCE1 
stopsound WAR_AMBIENCE2  
stopsound WAR_AMBIENCE3
stopsound WAR_AMBIENCE4 
        setvar MOLDYCARD 1
		setvar NEWGOD 2
        quote 250
		setvar NEWGOD 4
        state getcode
      }
	  
	  }
enda


actor NEWACCESSCARD3
 // fall
  
    ifaction 0
	ifp palive
        ifpdistl RETRIEVEDISTANCE
          ifcount 6
            ifcanseetarget
      {
        setvar BLOODCARD 1
		operateactivators 1027 myconnectindex
        quote 295
        palfrom 18 63
	cstat 32768
	globalsound DUKE_GET
	action ZERO
      }
	  
	ifaction ZERO ifactioncount 35 { setvar OPERATE 182  killit }
enda


action ANEWACCESSSWITCH1 0 0 0 0 2
action ANEWACCESSSWITCH2 1 0 0 0 2
actor NEWACCESSSWITCH sleeptime -1
ifaction 0 action ANEWACCESSSWITCH1
ifaction ANEWACCESSSWITCH1 {
ifcansee ifhitspace ifpdistg 1500 setvar PRESS_VAR 2
ifpdistl 1500 ifvare PRESS_VAR 0 ifcansee ifp pfacing ifhitspace {
ifvare GHOSTCARD 0 { quote 178 setvar PRESS_VAR 2 } else
ifvare GHOSTCARD 1 { operateactivators 118 myconnectindex setvar PRESS_VAR 2 setvar GHOSTCARD 0 sound MONITOR_ACTIVE2 lockplayer 20 tip action ANEWACCESSSWITCH2 }
}

}

ifaction ANEWACCESSSWITCH2 {
ifrnd 128 setactor[THISACTOR].shade 15 else setactor[THISACTOR].shade 12
}

enda


action ANEWACCESSSWITCH20 0 0 0 0 2
action ANEWACCESSSWITCH21 0 0 0 0 2
action ANEWACCESSSWITCH22 0 0 0 0 2
actor NEWACCESSSWITCH2 sleeptime -1
ifaction 0 { cstat 32768 ifvare OPERATE 832 action ANEWACCESSSWITCH20 }

ifaction ANEWACCESSSWITCH20 {
cstat 80
ifcansee ifpdistl 1700 { setvar OPERATE 833 action ANEWACCESSSWITCH21 }
}

ifaction ANEWACCESSSWITCH21 {
cstat 80
ifcansee ifhitspace ifpdistg 1500 setvar PRESS_VAR 2
ifpdistl 1500 ifvare PRESS_VAR 0 ifcansee ifp pfacing ifhitspace {
ifvare MOLDYCARD 0 { quote 249 setvar PRESS_VAR 2 } else
ifvare MOLDYCARD 1 { tip operateactivators 2265 myconnectindex setvar PRESS_VAR 2 setvar MOLDYCARD 2 sound MONITOR_ACTIVE2 lockplayer 20 action ANEWACCESSSWITCH22 }
}

}

ifaction ANEWACCESSSWITCH22 {
ifrnd 128 setactor[THISACTOR].shade 15 else setactor[THISACTOR].shade 12
ifactioncount 4 cstat 82
ifactioncount 8 cstat 594
ifactioncount 12 killit
}

enda


actor NEWACCESSSWITCH3 sleeptime -1
ifaction 0 ifpdistl 4000 action ANEWACCESSSWITCH1
ifaction ANEWACCESSSWITCH1 {
ifpdistg 4000 action 0
ifcansee ifhitspace ifpdistg 1500 setvar PRESS_VAR 2
ifpdistl 1500 ifvare PRESS_VAR 0 ifcansee ifp pfacing ifhitspace {
ifvare BLOODCARD 0 { quote 296 setvar PRESS_VAR 2 } else
ifvare BLOODCARD 1 { operateactivators 838 myconnectindex setvar PRESS_VAR 2 setvar BLOODCARD 0 
tip globalsound BLOODSWITCH lockplayer 20 palfrom 24 63 action ANEWACCESSSWITCH2 }
}

}

enda



I tried to replicate that in the extra tiles I made, adapting to the name, but I failed. Is there something missing here? I made definitions for the tiles ACCESSCARD2 and ACCESSSWITCH3 in DEFS.CON.

Here's an example:

actor ACCESSCARD2
  fall
      ifp palive
        ifpdistl RETRIEVEDISTANCE
          ifcount 6
            ifcanseetarget
      {
        setvar ACCESSCARD2 1
        quote 1010
        state getcode
      }
enda

action AACCESSSWITCH3 0 0 0 0 2
actor ACCESSSWITCH3 sleeptime -1
ifaction 0 { cstat 32768 ifvare OPERATE 832 action ACCESSSWITCH3 
}
}


Or there's something missing here, or this is more complicated than I thought.

There's Nuclear Showdown mod, but that mod is old and based on an older version of Eduke32, so the codes are not more compatible.

Note: I couldn't upload the TILES.ART from Memories mod because they are too big!


I'm just trying to "expand" the game. :D
0

User is offline   Reaper_Man 

  • Once and Future King

#3579

The problem with wholesale copying code from other mods without actually understanding what those things are doing, is you don't know why they aren't working when you just change some names around.

Also taking code from Memories is probably a bad idea because so much of that mod is misdirection. None of those buttons are doing button-y things, and why they aren't (and what they ARE doing) is so specific to that mod.

In the most simple terms, "a switch" just triggers Activators and Masterswitches via operateactivators and operatemasterswitches. Maybe operatesectors too, I'd have to go look. So if you just want a switch to do switch things, that's what "doing switch things" means. That may not be what you need or want them to do though, because they also technically do a lot of other work like triggering game quotes and automatically playing sounds.
2

User is offline   eniojr 

#3580

Quote

OThe problem with wholesale copying code from other mods without actually understanding what those things are doing, is you don't know why they aren't working when you just change some names around.

Also taking code from Memories is probably a bad idea because so much of that mod is misdirection. None of those buttons are doing button-y things, and why they aren't (and what they ARE doing) is so specific to that mod.

In the most simple terms, "a switch" just triggers Activators and Masterswitches via operateactivators and operatemasterswitches. Maybe operatesectors too, I'd have to go look. So if you just want a switch to do switch things, that's what "doing switch things" means. That may not be what you need or want them to do though, because they also technically do a lot of other work like triggering game quotes and automatically playing sounds.


Ok, thank's for the hint. I'll try to use operateactivators, operatemasterswitches and operatesectors. Maybe to create a switch you have to make a very specific script, but I still can't fugure out exactly, but I'll try.

I'm also trying to make additional keycards to the game, by creating new items, but that seems even more complex.

I saw somewhere that in order to add new possible colors for existing keycards and accessswitches, you have to change the source code. There was a mod that did add new colors for that, but I don't know if it was by .CON or by changing the source code.

My idea is that if a mod made something using .CON only and that worked, then it's possible to implement in the game in an individual way for other purposes.

For example, if I want to make an addon for a mod for personal use (what i'm doing right now) or create a new mod, then it's possible to somehow replicate things from other mods. Modders usually do that.
0

User is offline   Danukem 

  • Duke Plus Developer

#3581

If your new buttons are actors, and you intend to make or modify other actors, then learning the CON fundamentals of action, move and other basic commands is worthwhile and perhaps even necessary. You should be able to open up the GAME.CON from the Atomic edition, look at the code for some arbitrary actor and be able to understand what it's doing. You should also be able to create your own actor from scratch that does simple things that could be done in the original game like display certain frames of animation for certain amounts of time when interacted with (just one example). If you had that basic amount of proficiency, then knowing that operateactivators, operatemasterswitches and operaterespawns are things you would want a working button to do would already give you enough to easily code the actor without any further help. [Er...I suppose you would probably get stuck on not knowing EVENT_LOADACTOR but you could still make it work without that]. Copying and pasting code you don't understand and then struggling to modify the pasted code with extremely limited knowledge is very inefficient. It's also unappealing for those of us who do understand it: it comes off as "help me take" rather than "help me learn".
0

User is offline   eniojr 

#3582

Finally, I managed to make a new custom button in the game. Here is the script:


/////////////////NEW SWITCHES

gamevar LOTAGSAVED 0 2
gamevar HITAGSAVED 0 2
action ONE 1

state CUSTOMSWITCH
ifpdistl 1548
 ifp palive
  ifp pfacing
   ifcansee
    ifhitspace
     ifcount 13
      {
      sound SWITCH_ON
      ifvare HITAGSAVED 0 { ifactor LAMEBUTTON sound SWITCH_ON} else { soundvar HITAGSAVED }
      ifaction 0 { action ONE } else ifaction ONE { action 0 }
      operateactivators LOTAGSAVED THISACTOR
      operaterespawns LOTAGSAVED
      operatemasterswitches LOTAGSAVED
      resetcount
      }
	else ifactor LAMEBUTTON
	ifhitweapon
	ifcount 13
	{
	strength 1
	cstator 256
      ifvare HITAGSAVED 0 { ifactor LAMEBUTTON sound SWITCH_ON } else { soundvar HITAGSAVED }
      ifaction 0 { action ONE } else ifaction ONE { action 0 }
      operateactivators LOTAGSAVED THISACTOR
      operaterespawns LOTAGSAVED
      operatemasterswitches LOTAGSAVED
      resetcount
	}
ends


useractor notenemy LAMEBUTTON
cstator 256
state CUSTOMSWITCH
enda

eventloadactor 10445
{
    getactor[THISACTOR].hitag HITAGSAVED
    getactor[THISACTOR].lotag LOTAGSAVED
    setactor[THISACTOR].hitag 0
    setactor[THISACTOR].lotag 0
}
enda


With this, I can now use it as a base to create all the other custom buttons in my maps. It was based on a mod's script. It took me several hours to make a functional script, but here it is, in case anyone wants to use this code as a base to create a functional button, related to the use of lotags and hitags. It is not enough to just create an actor, there has to be something that allows this actor to interact with sector activation functions. I took advantage of some tips about operateactivators, operaterespawns and operatemasterswitches and then I ended up discovering them in the mod, and then I incorporated them into the script and bingo, it finally worked. The next step now is to add new custom access cards, in addition to custom access switches, something I've already done and it worked, and which I'll show you next.


/////////////////NEW KEYCARD

gamevar ACCESSKEY2 0 1

gamevar TEMP 0 2
gamevar TEMP2 0 2
gamevar TEMP3 0 2
gamevar TEMP4 0 2
gamevar TEMP5 0 2
gamevar TEMP6 0 2
gamevar TEMP7 0 2
gamevar LOTAGSAVED 0 2
gamevar HITAGSAVED 0 2
gamevar CUSTOMKEYCARDPOS 0
gamevar CKEYCARDPAL 0 0
gamevar CKEYCARDTILE 0 0
gamevar ACCESSKEY2 0 1
gamevar ZERO 0 2
gamevar ANIMATIONACTIVE 0
gamevar ANIMTIMER 0

define DOUBLESIZE 131072
define NORMALSIZE 65536
define HALFSIZE 32768
define QUARTERSIZE 16384
define ANIMDELAY 16

define EVENT_GETACCESSCARD 100
define EVENT_USESWITCH 13
define EVENT_DISPLAYCROSSHAIR 9
define EVENT_DISPLAYROOMS 6
define EVENT_ACTIVATESWITCH 8

action ONE 1
action LOCKED 0
action UNLOCKING 0
action UNLOCKED 1

state DISPLAYGREYKEY
    rotatesprite 261 31 QUARTERSIZE 0 15175 0 4 545 ZERO ZERO xdim ydim
    rotatesprite 260 30 QUARTERSIZE 0 15175 0 12 512 ZERO ZERO xdim ydim
ends

state DISPLAYGREENKEY
    rotatesprite 251 21 QUARTERSIZE 0 15175 0 4 545 ZERO ZERO xdim ydim
    rotatesprite 250 20 QUARTERSIZE 0 15175 0 11 512 ZERO ZERO xdim ydim
ends

state DISPLAYBROWNKEY
    rotatesprite 241 11 QUARTERSIZE 0 15175 0 4 545 ZERO ZERO xdim ydim
    rotatesprite 240 10 QUARTERSIZE 0 15175 0 15 512 ZERO ZERO xdim ydim
ends

eventloadactor ACCESSCARD2
    setactor[THISACTOR].xrepeat 28
    setactor[THISACTOR].yrepeat 28
enda

useractor notenemy ACCESSCARD2
    ifp pshrunk nullop
    else
    ifp palive
        ifpdistl RETRIEVEDISTANCE
        ifcount 6
        ifcanseetarget
        { 
            ifspritepal 12 
            { 
                ifvarand ACCESSKEY2 1 { break } 
                else 
                {
                    addvar ACCESSKEY2 1  
                    quote 1013  // "GREY ACCESS CARD ACQUIRED"
                }
            } 
            else
            ifspritepal 11 
            { 
                ifvarand ACCESSKEY2 2 { break } 
                else 
                {
                    addvar ACCESSKEY2 2  
                    quote 1014  // "GREEN ACCESS CARD ACQUIRED"
                }
            } 
            else
            ifspritepal 15 
            { 
                ifvarand ACCESSKEY2 4 { break } 
                else 
                {
                    addvar ACCESSKEY2 4  
                    quote 1015  // "BROWN ACCESS CARD ACQUIRED"
                }
            }
            globalsound DUKE_GET
            quote 43
            palfrom 16 0 32
            killit 
        }
enda

onevent EVENT_DISPLAYCROSSHAIR
    ifvarand ACCESSKEY2 1 { state DISPLAYGREYKEY }   
    ifvarand ACCESSKEY2 2 { state DISPLAYGREENKEY } 
    ifvarand ACCESSKEY2 4 { state DISPLAYBROWNKEY }  
endevent


/////////////////NEW ACCESSSWITCH

eventloadactor ACCESSSWITCH3
{
    espawn 2568  
    getactor[THISACTOR].pal TEMP  
    setactor[RETURN].pal TEMP  
    getactor[THISACTOR].hitag HITAGSAVED  
    getactor[THISACTOR].lotag LOTAGSAVED  
    setactor[THISACTOR].hitag 0  
    setactor[THISACTOR].lotag 0  
}
enda

state checkcounterpart2
    setvar TEMP 0
    whilevarn TEMP 16384
    {
        getactor[TEMP].statnum TEMP4
        ifvarn TEMP4 1024
        {
            getactor[TEMP].picnum TEMP2
            ifvare TEMP2 ACCESSSWITCH3
            {
                getactorvar[TEMP].LOTAGSAVED TEMP3
                ifvarvare LOTAGSAVED TEMP3 { setactor[TEMP].picnum 15177 }
            }
        }
        addvar TEMP 1
    }
ends

state CUSTOMACCESSSWITCH
    ifaction 0 { action LOCKED }

    ifpdistl 1024 ifhitspace ifaction LOCKED 
    {
        getactor[THISACTOR].pal TEMP

        ifvare TEMP 11
        {
            ifvarand ACCESSKEY2 2
            {
                quote 1016  // "GREEN ACCESS CARD GRANTED"
                state checkcounterpart2
                sound SWITCH_ON

                setvar CUSTOMKEYCARDPOS 1

                operateactivators LOTAGSAVED THISACTOR
                operaterespawns LOTAGSAVED
                operatemasterswitches LOTAGSAVED
                action UNLOCKED
                subvar ACCESSKEY2 2
            }
            else { quote 1013 }  // "GREEN ACCESS CARD REQUIRED"
        }
        else ifvare TEMP 12
        {
            ifvarand ACCESSKEY2 1
            {
                quote 1017  // "GREY ACCESS CARD GRANTED"
                state checkcounterpart2
                sound SWITCH_ON

                setvar CUSTOMKEYCARDPOS 1

                operateactivators LOTAGSAVED THISACTOR
                operaterespawns LOTAGSAVED
                operatemasterswitches LOTAGSAVED
                action UNLOCKED
                subvar ACCESSKEY2 1
            }
            else { quote 1014 }  // "GREY ACCESS CARD REQUIRED"
        }
        else ifvare TEMP 15
        {
            ifvarand ACCESSKEY2 4
            {
                quote 1018  // "BROWN ACCESS CARD GRANTED"
                state checkcounterpart2
                sound SWITCH_ON

                setvar CUSTOMKEYCARDPOS 1

                operateactivators LOTAGSAVED THISACTOR
                operaterespawns LOTAGSAVED
                operatemasterswitches LOTAGSAVED
                action UNLOCKED
                subvar ACCESSKEY2 4
            }
            else { quote 1015 }  // "BROWN ACCESS CARD REQUIRED"
        }
    }
ends

useractor notenemy ACCESSSWITCH3
    state CUSTOMACCESSSWITCH
enda


Here is the code I used to make functional cards and switches. And not only that, but I also used different palettes, for green (11), gray (12) and brown (15). I got this code from Nuclear Showndown, so I already had the basis, but I still lacked knowledge about the codes and parameters. In this case, I had to do a lot of trial and error with the help of artificial intelligence (Claude 3.5 Sonnet and GPT 4), because it was too difficult for me to understand how to assemble the code alone. On several occasions, the AI ​​made mistakes, but on other occasions I was the one who made the mistakes while assembling the script. This way, I ended up learning better how to create custom cards as well as customizable card switches. Because of so much trial and error and code research, I ended up getting a better understanding of the syntax and how scripts should be constructed, although I'm still not an expert in this. After all, game programming has become a new thing for me recently.

Also, based on Nuclear Showndown, I managed to make the icons of the cards I pick up appear on the HUD, more or less like they do in the mod. But I only did it for the extra colors, and not for the ones that are already in the game originally.

For those who need a script to create new cards and switches, here it is for newbies in .CON programming who need this. One day, when I've already managed to create several things using codes, maybe I'll create a topic just for this.

Ok, now that the cards and switches are working normally on my map, as well as the icons of the cards acquired in the HUD, all that's left is to deal with the animation, the one when the player activates a switch and Duke Nukem's hand appears holding a card and then the hand without the card. I spent over a day trying to deal with this, with partial success.


/////////////////NEW CARD ANIMATIONS

onevent EVENT_DISPLAYCROSSHAIR
    ifvarn CUSTOMKEYCARDPOS 0
    {
        addvar ANIMTIMER 256
        ifvarn ANIMTIMER 512
        {
            setvar ANIMTIMER 0
            switch CUSTOMKEYCARDPOS
                case 0: break
                case 1:
                    rotatesprite 160 134 NORMALSIZE 1024 HANDHOLDINGACCESS 0 0 260 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 2:
                    rotatesprite 160 134 NORMALSIZE 1024 HANDHOLDINGACCESS 0 0 260 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 3:
                    rotatesprite 160 134 NORMALSIZE 1024 HANDHOLDINGACCESS 0 0 260 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 4:
                    rotatesprite 160 134 NORMALSIZE 1024 HANDHOLDINGACCESS 0 0 260 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 5:
                    rotatesprite 160 134 NORMALSIZE 1024 HANDHOLDINGACCESS 0 0 260 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 6:
                    rotatesprite 160 134 NORMALSIZE 1024 HANDHOLDINGACCESS 0 0 260 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 7:
                    rotatesprite 160 134 NORMALSIZE 1024 HANDHOLDINGACCESS 0 0 260 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 8:
                    rotatesprite 160 134 NORMALSIZE 1024 HANDHOLDINGACCESS 0 0 260 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 9:
                    rotatesprite 160 134 NORMALSIZE 1024 HANDHOLDINGACCESS 0 0 260 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 10:
                    rotatesprite 160 134 NORMALSIZE 1024 HANDHOLDINGACCESS 0 0 260 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 11:
                    rotatesprite 160 134 NORMALSIZE 1024 HANDHOLDINGACCESS 0 0 260 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 12:
                    rotatesprite 160 134 NORMALSIZE 1024 HANDHOLDINGACCESS 0 0 260 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 13:
                    rotatesprite 160 134 NORMALSIZE 0 2563 0 0 0 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 14:
                    rotatesprite 160 134 NORMALSIZE 0 2563 0 0 0 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 15:
                    rotatesprite 160 134 NORMALSIZE 0 2563 0 0 0 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 16:
                    rotatesprite 160 134 NORMALSIZE 0 2563 0 0 0 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 17:
                    rotatesprite 120 134 NORMALSIZE 0 2564 0 0 0 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 18:
                    rotatesprite 120 134 NORMALSIZE 0 2564 0 0 0 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 19:
                    rotatesprite 120 134 NORMALSIZE 0 2564 0 0 0 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 20:
                    rotatesprite 120 134 NORMALSIZE 0 2564 0 0 0 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 21:
                    rotatesprite 80 134 NORMALSIZE 0 2565 0 0 0 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 22:
                    rotatesprite 80 134 NORMALSIZE 0 2565 0 0 0 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 23:
                    rotatesprite 80 134 NORMALSIZE 0 2565 0 0 0 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 24:
                    rotatesprite 80 134 NORMALSIZE 0 2565 0 0 0 0 0 xdim ydim
                    setvar CUSTOMKEYCARDPOS 0
                    setvar ANIMATIONACTIVE 0
                    break
            endswitch
        }
    }
endevent

onevent EVENT_ACTIVATESWITCH
    ifvare ANIMATIONACTIVE 0
    {
        setvar CUSTOMKEYCARDPOS 1
        setvar ANIMATIONACTIVE 1
    }
endevent


The animation involves several repeated lines, since if I put only one animation line for each texture and color, it will appear very fast in the animation, while the original in the game is slower and smoother between animations.

Now this is the part where I'm having trouble. I'm starting to understand this rotatesprite thing and its parameters, after countless trials and errors using flags. HANDHOLDINGACCESS (texture 2568) was more complicated, because the original texture is in a horizontally inverted position in relation to what appears in the animation, so I had to use a flag and change the sprite angle value. Then I was able to straighten it, like in the game's animation. Then, since there are other textures in the animation in the game, I also had to use those (textures 2563, 2564 and 2565) for the texture of the hand without the card. Since in this case the textures are already in the right position in relation to the animation in the game, I didn't need to change the angle. If you test the animation script, you'll notice that the animation is very similar to the original in the game. There's just one little problem. I've tried several times to use flags to put the texture behind the status bar, but I can't do it through flags, not even by setting the specific pure value for it.

I'm also not sure if "setvar CUSTOMKEYCARDPOS 1" is correct in the switch and animation script so that the animation responds according to the specific color for accesscard and acessswitch.

And this is where I need help. Then all that's left is to establish a set of independent animations for each card color (green, gray and brown).

If I can do this or if someone can help me with this, I'll have achieved everything I need regarding cards, switches and card animations.
0

User is offline   Danukem 

  • Duke Plus Developer

#3583

That's way too much to read. Glancing at the rotatesprite commands, I see that pal is 0 in all cases though so I don't see how you could display different colored cards with that.
0

User is offline   eniojr 

#3584

The main problem for now is related to the layers. I just can't make the animation happen behind the status bar, like that one in the game. It happens in front of the status bar.

I'm trying here about the pal thing, but the layer thing I just don't have a hint on how to solve that.

This post has been edited by eniojr: 02 December 2024 - 07:54 AM

0

User is offline   eniojr 

#3585

Here is a shortened version of the animation script, for easier reading:

onevent EVENT_DISPLAYCROSSHAIR
    ifvarn CUSTOMKEYCARDPOS 0
    {
        addvar ANIMTIMER 256
        ifvarn ANIMTIMER 512
        {
            setvar ANIMTIMER 0
            switch CUSTOMKEYCARDPOS
                case 0: break
                case 1:
                    rotatesprite 160 134 NORMALSIZE 1024 HANDHOLDINGACCESS 0 0 260 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 2:
                    rotatesprite 160 134 NORMALSIZE 0 2563 0 0 0 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 3:
                    rotatesprite 120 134 NORMALSIZE 0 2564 0 0 0 0 0 xdim ydim
                    addvar CUSTOMKEYCARDPOS 1
                    break
                case 4:
                    rotatesprite 80 134 NORMALSIZE 0 2565 0 0 0 0 0 xdim ydim
                    setvar CUSTOMKEYCARDPOS 0
                    setvar ANIMATIONACTIVE 0
                    break
            endswitch
        }
    }
endevent

onevent EVENT_ACTIVATESWITCH
    ifvare ANIMATIONACTIVE 0
    {
        setvar CUSTOMKEYCARDPOS 1
        setvar ANIMATIONACTIVE 1
    }
endevent

0

User is offline   Danukem 

  • Duke Plus Developer

#3586

View Posteniojr, on 02 December 2024 - 07:54 AM, said:

The main problem for now is related to the layers. I just can't make the animation happen behind the status bar, like that one in the game. It happens in front of the status bar.

I'm trying here about the pal thing, but the layer thing I just don't have a hint on how to solve that.


Try doing the drawing in EVENT_DISPLAYWEAPON. Also I presume you already have a way of making sure the weapon isn't being drawn at the same time.
0

User is offline   eniojr 

#3587

No, I haven't explored any code related to weapons yet, as I don't plan on creating or modifying weapons in the game. Dealing with weapons is even more complex.
0

User is offline   Danukem 

  • Duke Plus Developer

#3588

You don't understand what I meant but I guess the custom card code that James wrote utilizes access_incs in the player struct so the weapon display is already disabled.
0

User is online   VGames 

  • Extra Crispy

#3589

When using EVENT_DAMAGEWALL how do you check to see if the wall was damaged by RADIUSDAMAGE from an explosion and it wasn't from a bullet or some other projectile?
0

User is offline   Reaper_Man 

  • Once and Future King

#3590

https://wiki.eduke32...VENT_DAMAGEWALL

Two ways really: Check for the value of userdef[].return 1 and if it's anything other than -1, that means it was radius damage.

Or, check sprite[RETURN].htpicnum for the specific weapon name/tile ID for what you want to match against. This would basically be an equivalent of "ifwasweapon".

The first method is probably more reliable, but the second method would let you check specifically for RADIUSDAMAGE as a defined attack, rather than all types of radius damage.

This post has been edited by Reaper_Man: 06 December 2024 - 01:58 PM

1

User is online   VGames 

  • Extra Crispy

#3591

Ok that makes perfect sense. I was getting confused by the userdef.return stuff. Thanks a lot. I'll give it a shot.
0

User is offline   Reaper_Man 

  • Once and Future King

#3592

In this instance, return is a userdef property. It's also an array, so to access different array indices you use the second value (in this case "1"). There's not too many properties that are exposed arrays, htg_t is the main one that know of and use a lot.
1

Share this topic:


  • 124 Pages +
  • « First
  • 118
  • 119
  • 120
  • 121
  • 122
  • 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