Page 1 of 1
Duke Comes Back to Life Without Resetting the Map.
#1 Posted 07 September 2020 - 01:18 AM
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?
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?
#2 Posted 12 September 2020 - 07:43 AM
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.
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.
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 }
#3 Posted 12 September 2020 - 08:27 AM
nevermind
This post has been edited by Mark: 12 September 2020 - 08:28 AM
#4 Posted 12 September 2020 - 10:39 AM
Mark, 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
#5 Posted 12 September 2020 - 01:15 PM
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
#6 Posted 12 September 2020 - 01:18 PM
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?
#7 Posted 12 September 2020 - 08:55 PM
Danukem, 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?
Danukem, 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.
Duke Move.TXT (471bytes)
Number of downloads: 184
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.
Save and Load map.TXT (2.86K)
Number of downloads: 191
#8 Posted 12 September 2020 - 10:17 PM
HELLMOUSE, 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.
#9 Posted 13 September 2020 - 01:38 PM
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.
RESPAWNDUKE.TXT (1.07K)
Number of downloads: 186
RESPAWNDUKE.TXT (1.07K)
Number of downloads: 186
#10 Posted 14 December 2020 - 02:46 PM
Updated actor, DUKESTART and state, RESPAWNDUKE.
I fixed the invincibility problem a while ago and forgot to post it.
RESPAWNDUKE2.TXT (1.91K)
Number of downloads: 177
Updated actor, APLAYER in case the player wants to play without the respawning ability, or forgets to add it in the map.
SAMPLE_APLAYER.TXT (501bytes)
Number of downloads: 173
I fixed the invincibility problem a while ago and forgot to post it.
RESPAWNDUKE2.TXT (1.91K)
Number of downloads: 177
Updated actor, APLAYER in case the player wants to play without the respawning ability, or forgets to add it in the map.
SAMPLE_APLAYER.TXT (501bytes)
Number of downloads: 173
This post has been edited by HELLMOUSE: 14 December 2020 - 02:52 PM
Share this topic:
Page 1 of 1