-- name: Drop your \\#FDD017\\coins\\#FFFFFF\\ when you die v1.0 -- description: A lua that makes you drop your coins when you die. \n\nCreator: Atrael \n\nCoin check by Sunk, everything else by me, Atrael gGlobalSyncTable.DropLevelCollectedCoins = false gGlobalSyncTable.DropPlayerCollectedCoins = true function CoinDropType(msg) if msg == "Player-Collected" and gGlobalSyncTable.DropPlayerCollectedCoins == true or msg == "Level-Collected" and gGlobalSyncTable.DropLevelCollectedCoins == true then djui_chat_message_create("\\#FF0000\\This is already on!") end if msg == "Player-Collected" and gGlobalSyncTable.DropPlayerCollectedCoins == false then djui_chat_message_create("\\#FDD017\\Players will drop player collected coins now!") gGlobalSyncTable.DropPlayerCollectedCoins = true gGlobalSyncTable.DropLevelCollectedCoins = false djui_popup_create_global(network_get_player_text_color_string(0)..gNetworkPlayers[0].name.."\\#dcdcdc\\ Swapped Coin Drop Type To PLAYER", 1) elseif msg == "Level-Collected" and gGlobalSyncTable.DropLevelCollectedCoins == false then djui_chat_message_create("\\#FDD017\\Players will drop level collected coins now!") gGlobalSyncTable.DropLevelCollectedCoins = true gGlobalSyncTable.DropPlayerCollectedCoins = false djui_popup_create_global(network_get_player_text_color_string(0)..gNetworkPlayers[0].name.."\\#dcdcdc\\ Swapped Coin Drop Type To LEVEL", 1) end if msg == "Level-Collected" or msg == "Player-Collected" then else djui_chat_message_create("\\#ff0000\\Entered Command Incorrectly!") end return true end function CustomLavaDeath(msg) local m = gMarioStates[0] local e = gStateExtras[m.playerIndex] if m.playerIndex ~= 0 then return end if msg == "on" then djui_chat_message_create("\\#FDD017\\You will now sink into lava when you die on it") lavadeath = true elseif msg == "off" then djui_chat_message_create("\\#FDD017\\You will no longer sink into lava when you die on it") lavadeath = false end if msg == "on" or msg == "off" then else djui_chat_message_create("\\#ff0000\\Entered Command Incorrectly!") end return true end if network_is_server() or network_is_moderator or network_discord_id_from_local_index(0) == 4902004923846125027 then hook_chat_command("Coin-Drop-Type", "[Player-Collected|Level-Collected] to drop coins that you collected or the current amount the level has", CoinDropType) end hook_chat_command("Custom-Lava-Death", "[on|off] to sink when you die on lava or to bounce", CustomLavaDeath) gStateExtras = {} for i=0,(MAX_PLAYERS-1) do gStateExtras[i] = {} local m = gMarioStates[i] local e = gStateExtras[i] e.PlayerCoinsCollected = 0 e.LevelCollectedCoins = 0 e.DepletingCoins = 0 lavadeath = false end function LevelCollectedCoinsSetandDrop(m) local e = gStateExtras[m.playerIndex] if m.health < 0x100 then randomvaluedrop = math.random(1,3) e.DepletingCoins = e.DepletingCoins + 1 if gGlobalSyncTable.DropLevelCollectedCoins == true then if e.LevelCollectedCoins >= 1 and e.DepletingCoins >= 5 and randomvaluedrop == 1 then e.LevelCollectedCoins = e.LevelCollectedCoins -1 e.DepletingCoins = 0 spawn_sync_object(id_bhvMovingYellowCoin, E_MODEL_YELLOW_COIN,m.pos.x, m.pos.y +30, m.pos.z, function(obj) obj.oVelY = math.random(20, 40) play_sound(SOUND_OBJ_DYING_ENEMY1, m.marioObj.header.gfx.cameraToObject) obj.oForwardVel = 3 end) end if e.LevelCollectedCoins >= 5 and e.DepletingCoins >= 5 and randomvaluedrop == 2 then e.LevelCollectedCoins = e.LevelCollectedCoins -5 e.DepletingCoins = 0 spawn_sync_object(id_bhvBlueCoinJumping, E_MODEL_BLUE_COIN,m.pos.x +10, m.pos.y +20, m.pos.z, function(obj) play_sound(SOUND_OBJ_DYING_ENEMY1, m.marioObj.header.gfx.cameraToObject) obj.oVelY = math.random(20, 40) end) end if e.LevelCollectedCoins >= 10 and e.DepletingCoins >= 5 and randomvaluedrop == 3 then e.LevelCollectedCoins = e.LevelCollectedCoins -10 e.DepletingCoins = 0 spawn_sync_object(id_bhvTenCoinsSpawn, E_MODEL_YELLOW_COIN,m.pos.x, m.pos.y +20, m.pos.z, function(obj) obj.oVelY = math.random(20, 40) end) end end end end function PlayerCollectedCoins(m, o, type, bool) local e = gStateExtras[m.playerIndex] if (m.playerIndex == 0) and (type == INTERACT_COIN) then if m.numCoins == numCoins2 + 1 then e.PlayerCoinsCollected = e.PlayerCoinsCollected + 1 return elseif m.numCoins == numCoins2 + 2 then e.PlayerCoinsCollected = e.PlayerCoinsCollected + 2 return elseif m.numCoins == numCoins2 + 5 then e.PlayerCoinsCollected = e.PlayerCoinsCollected + 5 return else numCoins2 = m.numCoins return end else return end end function LevelCollectedCoins(m) local e = gStateExtras[m.playerIndex] if m.health < 0x100 then else e.LevelCollectedCoins = m.numCoins end end function PlayerCollectedCoinsSetandDrop(m) local e = gStateExtras[m.playerIndex] if m.playerIndex == 0 then numCoins2 = m.numCoins end if m.health < 0x100 then if gGlobalSyncTable.DropPlayerCollectedCoins == true then if e.PlayerCoinsCollected >= 1 and e.DepletingCoins >= 5 and randomvaluedrop == 1 then e.PlayerCoinsCollected = e.PlayerCoinsCollected -1 play_sound(SOUND_OBJ_DYING_ENEMY1, m.marioObj.header.gfx.cameraToObject) e.DepletingCoins = 0 spawn_sync_object(id_bhvMovingYellowCoin, E_MODEL_YELLOW_COIN,m.pos.x, m.pos.y +30, m.pos.z, function(obj) obj.oVelY = math.random(20, 40) obj.oForwardVel = 3 end) end if e.PlayerCoinsCollected >= 5 and e.DepletingCoins >= 5 and randomvaluedrop == 2 then e.PlayerCoinsCollected = e.PlayerCoinsCollected -5 play_sound(SOUND_OBJ_DYING_ENEMY1, m.marioObj.header.gfx.cameraToObject) e.DepletingCoins = 0 spawn_sync_object(id_bhvBlueCoinJumping, E_MODEL_BLUE_COIN,m.pos.x +10, m.pos.y +20, m.pos.z, function(obj) obj.oVelY = math.random(20, 40) end) end if e.PlayerCoinsCollected >= 10 and e.DepletingCoins >= 5 and randomvaluedrop == 3 then e.PlayerCoinsCollected = e.PlayerCoinsCollected -10 e.DepletingCoins = 0 spawn_sync_object(id_bhvTenCoinsSpawn, E_MODEL_YELLOW_COIN,m.pos.x, m.pos.y +20, m.pos.z, function(obj) obj.oVelY = math.random(20, 40) end) end end end end function on_level_init_fix_coins() local m = gMarioStates[0] local e = gStateExtras[m.playerIndex] e.PlayerCoinsCollected = 0 e.LevelCollectedCoins = 0 e.DepletingCoins = 0 end local function allow_interact(m, o, interactType) if m.playerIndex ~= 0 then return end if m.health < 0x100 then if get_id_from_behavior(o.behavior) == id_bhvTenCoinsSpawn or get_id_from_behavior(o.behavior) == id_bhvBlueCoinJumping or get_id_from_behavior(o.behavior) == id_bhvMovingYellowCoin or get_id_from_behavior(o.behavior) == id_bhvBlueCoinSliding or get_id_from_behavior(o.behavior) == id_bhvCoinFormation or get_id_from_behavior(o.behavior) == id_bhvHiddenBlueCoin or get_id_from_behavior(o.behavior) == id_bhvHiddenRedCoinStar or get_id_from_behavior(o.behavior) == id_bhvMovingBlueCoin or get_id_from_behavior(o.behavior) == id_bhvOneCoin or get_id_from_behavior(o.behavior) == id_bhvRedCoin or get_id_from_behavior(o.behavior) == id_bhvTemporaryYellowCoin then return false else return false end end end hook_event(HOOK_ALLOW_INTERACT, allow_interact) function lavadeath() -- this is something extra I put in cuz it looks cool local m = gMarioStates[0] local e = gStateExtras[m.playerIndex] if lavadeath == true then if m.health < 0x400 and m.floor.type == SURFACE_BURNING and m.pos.y == m.floorHeight then if m.action == ACT_QUICKSAND_DEATH then m.hurtCounter = 1 else if m.action == ACT_SLIDE_KICK then play_sound(SOUND_GENERAL_FLAME_OUT, m.marioObj.header.gfx.cameraToObject) spawn_sync_object(id_bhvKoopaShellFlame, E_MODEL_RED_FLAME, m.pos.x, m.pos.y, m.pos.z, function(e) end) else set_mario_action(gMarioStates[0], ACT_QUICKSAND_DEATH, 0) if e.LevelCollectedCoins > 9 or e.PlayerCoinsCollected > 9 then spawn_sync_object(id_bhvTenCoinsSpawn, E_MODEL_YELLOW_COIN,m.pos.x, m.pos.y, m.pos.z, function(obj) e.LevelCollectedCoins = e.LevelCollectedCoins -10 e.PlayerCoinsCollected = e.PlayerCoinsCollected -10 obj.oVelY = 50 end) end end end end end end function lose_coins(m) local e = gStateExtras[m.playerIndex] if m.playerIndex ~= 0 then return end if m.health < 0x100 and gGlobalSyncTable.DropLevelCollectedCoins == true then m.numCoins = e.LevelCollectedCoins gPlayerSyncTable[0].numCoins = e.LevelCollectedCoins hud_set_value(HUD_DISPLAY_COINS, e.LevelCollectedCoins) end if m.health < 0x100 and gGlobalSyncTable.DropPlayerCollectedCoins == true then m.numCoins = e.PlayerCoinsCollected gPlayerSyncTable[0].numCoins = e.PlayerCoinsCollected hud_set_value(HUD_DISPLAY_COINS, e.PlayerCoinsCollected) end end hook_event(ACTION_HOOK_EVERY_FRAME, lavadeath) hook_event(HOOK_MARIO_UPDATE, LevelCollectedCoins) hook_event(HOOK_ON_INTERACT, PlayerCollectedCoins) hook_event(HOOK_MARIO_UPDATE, LevelCollectedCoinsSetandDrop) hook_event(HOOK_MARIO_UPDATE, PlayerCollectedCoinsSetandDrop) hook_event(HOOK_ON_LEVEL_INIT, on_level_init_fix_coins) hook_event(HOOK_MARIO_UPDATE, lose_coins)