Duke4.net Forums: Duke Comes Back to Life Without Resetting the Map. - Duke4.net Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Duke Comes Back to Life Without Resetting the Map.

User is offline   HELLMOUSE 

#1

Has anyone ever given Duke the ability to pop back to the beginning sector after death and not reset the map? It is not like in Bio Shock where there is a special chamber but just the "brown arrow" sector. I'm trying to just move Duke without resetting everything in the map.

I've created an actor by using the spinning green Duke head and have that record its sector number. That sector number is loaded into a gamevar. In the Duke dead code after "quote 13" and "ifhitspace" I've tried to set Duke's "cursectnum" to that gamevar but it has no effect. I've obviously commented out the "resetplayer" command. So far it looks like there are 4 spots in the "APLAYER" code that control what happens when Duke dies and when the user hits "space" or whatever the interact key is.

I also used the event of "EVEN_KILLIT" with the "killit" command as a way to force the game to move Duke to where I want. That still didn't work.

Does anyone have any advice on this?
1

User is offline   HELLMOUSE 

#2

I figured out how to place Duke at the beginning of the map without resetting it. I'll make a save inventory state latter so it isn't reset. Gamevars are saved while in the same map unless you reset them, but the game had some trouble remembering which track it was on. I fixed that problem. The only problem is Duke sometimes becomes temporarily invincible after death. There are two ways to work around that, either load a saved game or start shooting at an enemy. I'm not sure why it does that. I have some code of what I have so far.

This is what loads the map and starts the proper music track again. Looking at the Wiki, "loadmapstate" should be placed into the EVENT_ENTERLEVEL so the map loads where you intended. The "REM_MUS" state remembers the music track when Duke died. These two gamevars are global temporary ones used with the DMP.
onevent EVENT_ENTERLEVEL
  loadmapstate // this is needed here
  setuserdef[].music_episode MUSIC_E 
  setuserdef[].music_level MUSIC_L
  starttrackslot MUSIC_E MUSIC_L 
endevent

state REM_MUS   // in case Duke dies
  getuserdef[].music_episode MUSIC_E 
  getuserdef[].music_level MUSIC_L  
ends



This is how I save the map. If there is no saved game, then Duke is sent back to the beginning of the map without it being reset. Duke's inventory is reset back to all 0's but I'll fix that latter. If there is a saved game and "Y" is hit, it will load that saved game. If "N" is hit, then Duke is sent back but the map is not reset. That all seems to be working fine. I began to experiment to figure out why Duke becomes invincible. I thought it may have had something to do with "resetactioncount" and "resetcount" but those commands had no effect.
    ifaction PLYINGDEAD
    {
      ifactioncount 3
        move PSTOPED
      quote 13
      ifhitspace
      {
        action PSTAND
        state REM_MUS // remember the music track
        savemapstate // save the map
        resetplayer
      }
      break
    }

0

User is offline   Mark 

#3

nevermind

This post has been edited by Mark: 12 September 2020 - 08:28 AM

0

User is offline   HELLMOUSE 

#4

View PostMark, on 12 September 2020 - 08:27 AM, said:

nevermind

I never saw what you neverminded about.

I think I have it narrowed down. It seems to only be fixed when Duke fires at an enemy with a bullet or shot weapon.


Something else that I noticed. Duke's shield always sets back to 0 if health is 0 and I can't seem to find a command that sounds like it saves Duke's stats. I've just made his shield be set to 32 if killed. I have a gamevar called WASDUKEKILLED because EVENT_RESETPLAYER will run that code even when he starts fresh at the next level. Putting "setvar RETURN -1" inside EVENT_RESETINVENTORY and EVENT_RESETWEAPONS has no effect. Looks like I'll be doing it manually.

This post has been edited by HELLMOUSE: 12 September 2020 - 12:58 PM

0

User is offline   Mark 

#5

What I posted was maybe duke is asleep which might explain unkillable and when you fire he wakes. A few minutes later I changed it to nevermind.

This post has been edited by Mark: 12 September 2020 - 01:18 PM

1

User is offline   Danukem 

  • Duke Plus Developer

#6

I thought about posting something helpful earlier, but tbh you make too many threads and I feel like this is another case of someone trying to run before they learn how to walk. I will say this: why would you think that just setting the sector without even setting coordinates could possibly reset the player's position?
1

User is offline   HELLMOUSE 

#7

View PostDanukem, on 12 September 2020 - 01:18 PM, said:

I thought about posting something helpful earlier, but tbh you make too many threads and I feel like this is another case of someone trying to run before they learn how to walk.

Do you think I should have a free hosted forum instead of filling up the Forum?



View PostDanukem, on 12 September 2020 - 01:18 PM, said:

I will say this: why would you think that just setting the sector without even setting coordinates could possibly reset the player's position?

Thanks for the hint the only problem is Duke gets stuck and doesn't move at the starting point.

Attached File  Duke Move.TXT (471bytes)
Number of downloads: 181


Here is my approach with saving and loading the map (savemapstate and loadmapstate).
Two problems:
Duke is invincible until you shoot a bullet weapon at an enemy, and for some reason, occasionally, one of Duke's ammo is set back to the max or loses the weapon. This happens if he dies with it full, comes back, uses it all up, and then immediately exits the level. On the next level, the weapon is full or he doesn't have it. It only seems to happen with the Devastator.

Attached File  Save and Load map.TXT (2.86K)
Number of downloads: 186
0

User is offline   Danukem 

  • Duke Plus Developer

#8

View PostHELLMOUSE, on 12 September 2020 - 08:55 PM, said:

Do you think I should have a free hosted forum instead of filling up the Forum?


No, I think you should just pick a thread, like that CON coding problems one that firefly started or that earlier one I started a long time ago about CON scripting.

As for the problem that started this thread, you need to save the player's starting coordinates in gamevars, then reset the player to those coordinates by setting the posx posy posz members of the player (in addition to setting sector). Also set the player's strength and action and dead_flag...basically set all the things needed to make the player alive and well again.
1

User is offline   HELLMOUSE 

#9

Thanks for the help so far. I do have a textfile with the coordinates being changed somewhere above (Duke Move Text). The below is improved thanks to your guidance. The only problem left is Duke needs to fire at an enemy to "wake-up" again if he is going to take damage. I've experimented with "statnum" and "httimetosleep" but it didn't solve the problem.

Attached File  RESPAWNDUKE.TXT (1.07K)
Number of downloads: 184
0

User is offline   HELLMOUSE 

#10

Updated actor, DUKESTART and state, RESPAWNDUKE.
I fixed the invincibility problem a while ago and forgot to post it.
Attached File  RESPAWNDUKE2.TXT (1.91K)
Number of downloads: 175

Updated actor, APLAYER in case the player wants to play without the respawning ability, or forgets to add it in the map.
Attached File  SAMPLE_APLAYER.TXT (501bytes)
Number of downloads: 173

This post has been edited by HELLMOUSE: 14 December 2020 - 02:52 PM

0

Share this topic:


Page 1 of 1
  • 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