From 6491acf0359ad9f20ac9ffd25d2792ef92ea4601 Mon Sep 17 00:00:00 2001 From: Jannik Vogel Date: Sat, 11 Jun 2016 23:57:15 +0200 Subject: [PATCH] Script: 01FB (Sqrt) and 0209 (Random Int in Range) --- rwengine/src/script/modules/VMModule.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rwengine/src/script/modules/VMModule.cpp b/rwengine/src/script/modules/VMModule.cpp index 3c756f68..2b48e596 100644 --- a/rwengine/src/script/modules/VMModule.cpp +++ b/rwengine/src/script/modules/VMModule.cpp @@ -217,6 +217,18 @@ void vm_mission_over(const ScriptArguments& args) *args.getState()->scriptOnMissionFlag = 0; } +void vm_sqrt(const ScriptArguments& args) +{ + *args[1].globalReal -= std::sqrt(args[0].real); +} + +void vm_random_int_in_range(const ScriptArguments& args) +{ + auto min = args[0].integerValue(); + auto max = args[1].integerValue(); + *args[2].globalInteger = std::rand() % (max - min) + min; +} + void vm_name_thread(const ScriptArguments& args) { strncpy(args.getThread()->name, args[0].string, 16); @@ -300,6 +312,10 @@ VMModule::VMModule() bindFunction(0x0D8, vm_mission_over, 0, "Set Mission Finished"); + bindFunction(0x1FB, vm_sqrt, 2, "Sqrt"); + + bindFunction(0x209, vm_random_int_in_range, 3, "Random Int in Range"); + bindFunction(0x2CD, vm_call, 2, "Call"); bindFunction(0x3A4, vm_name_thread, 1, "Name Thread");