// **** all of this is above actor APLAYER **** gamevar WASDUKEKILLED 0 0 gamearray DUKE_WEAPONS 12 // index 0 to 11 gamearray DUKE_AMMO 12 // index 0 to 11 state SAVEDUKEINV setvar INDEX 0 // just in case something else used this gamevar whilevarl INDEX 12 // stops at 12 but never does it for 12 { getplayer[].gotweapon INDEX DUKE_STAT // checks to see what weapons Duke has and puts 1 or 0 into DUKE_STAT setarray DUKE_WEAPONS[INDEX] DUKE_STAT // puts value in DUKE_STAT into the array, DUKE_WEAPONS addvar INDEX 1 // increments the array index and loop } setvar INDEX 0 // clears back to 0 whilevarl INDEX 12 { getplayer[].ammo_amount INDEX DUKE_STAT // same but with the ammo_amount array and puts setarray DUKE_AMMO[INDEX] DUKE_STAT // it into an array, DUKE_AMMO addvar INDEX 1 } setvar INDEX 0 ends state LOADDUKEINV // set Duke's ammo and weapons (so far) setplayer[].shield_amount 64 // can't really do anything else setvar INDEX 0 whilevarl INDEX 12 { setplayer[].gotweapon INDEX DUKE_WEAPONS[INDEX] // set Duke's weapons using the array, DUKE_WEAPONS setplayer[].ammo_amount INDEX DUKE_AMMO[INDEX] // set Duke's ammo using the array, DUKE_AMMO addvar INDEX 1 // increments the array index and loop } setvar INDEX 0 ends onevent EVENT_RESETPLAYER // when reentering the map this sets Duke's weapons and ammo (so far - no access yet or items ) // resetactioncount // resetcount ifvare WASDUKEKILLED 1 { state LOADDUKEINV setvar WASDUKEKILLED 0 } endevent state REM_MUS // in case Duke dies getuserdef[].music_episode MUSIC_E // puts episode # into global gamevar, MUSIC_E getuserdef[].music_level MUSIC_L // puts level # into global gamevar, MUSIC_L ends onevent EVENT_ENTERLEVEL loadmapstate // if there is no saved map then this does not happen setuserdef[].music_episode MUSIC_E // set music - thanks Danukem setuserdef[].music_level MUSIC_L // set music - thanks Danukem starttrackslot MUSIC_E MUSIC_L // start the track again endevent // **** under actor APLAYER **** // this is 1 out of 4 parts of code that are similar ifaction PLYINGDEAD { ifactioncount 3 move PSTOPED quote 13 ifhitspace { action PSTAND // spawn DUKELYINGDEAD setvar WASDUKEKILLED 1 // this is so the LOADDUKEINV state only triggers when Duke dies state SAVEDUKEINV // saves Duke's weapons and ammo state REM_MUS // saves what musci track is playing savemapstate // saves sprites and active sectors resetplayer // sets player back to start point } break }