From c6c0c1a5a553c66796418b07077465c0c7a89069 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 25 Feb 2021 14:37:37 -0500 Subject: Ionia randomly appears in the water --- res/scripts/hallucination_hot_spring.lua | 7 ++++++- src/script_system.cpp | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/res/scripts/hallucination_hot_spring.lua b/res/scripts/hallucination_hot_spring.lua index 5251ab6..6713e0c 100644 --- a/res/scripts/hallucination_hot_spring.lua +++ b/res/scripts/hallucination_hot_spring.lua @@ -1,7 +1,12 @@ hallucination_hot_spring = {} function hallucination_hot_spring.init() - ShowExpression("water_ionia", "surprise") + if randomChance(3.0/4.0) then + DestroyNamedSprite("water_ionia") + gamestate.ionia_in_water = false + else + gamestate.ionia_in_water = true + end end function hallucination_hot_spring.off_right() diff --git a/src/script_system.cpp b/src/script_system.cpp index d700738..e890dfc 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp @@ -187,6 +187,12 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) { return game_.getMap().getWarpPoint(warp); }); + engine_.set_function( + "randomChance", + [&] (double p) { + return std::bernoulli_distribution(p)(game_.getRng()); + }); + engine_.script_file("../res/scripts/common.lua"); } -- cgit 1.4.1