From 131e8ae37809ef25da7c325a74e31564800f655f Mon Sep 17 00:00:00 2001 From: kimden <23140380+kimden@users.noreply.github.com> Date: Mon, 26 May 2025 21:33:35 +0400 Subject: [PATCH] Add Kart::explode(id) to scriptengine --- src/scriptengine/script_kart.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/scriptengine/script_kart.cpp b/src/scriptengine/script_kart.cpp index 89a08939d9a..b36d28b1562 100644 --- a/src/scriptengine/script_kart.cpp +++ b/src/scriptengine/script_kart.cpp @@ -18,6 +18,7 @@ #include "script_kart.hpp" +#include "karts/explosion_animation.hpp" #include "karts/kart.hpp" #include "karts/kart_model.hpp" #include "karts/kart_properties.hpp" @@ -49,7 +50,21 @@ namespace Scripting { AbstractKart* kart = World::getWorld()->getKart(idKart); kart->setSquash(time, 0.5); //0.5 * max speed is new max for squashed duration - } + } // squash + //--------------------------------------------------------------------- + + /** Explodes the specified kart */ + void explode(int idKart) + { + AbstractKart* kart = World::getWorld()->getKart(idKart); + + ExplosionAnimation::create(kart); + if (kart->getKartAnimation() != NULL) + { + World::getWorld()->kartHit(idKart); + } + } // explode + //--------------------------------------------------------------------- /** Teleports the kart to the specified Vec3 location */ void teleport(int idKart, SimpleVec3* position) @@ -163,6 +178,10 @@ namespace Scripting r = engine->RegisterGlobalFunction("void squash(int id, float time)", mp ? WRAP_FN(squash) : asFUNCTION(squash), call_conv); assert(r >= 0); + + r = engine->RegisterGlobalFunction("void explode(int id)", + mp ? WRAP_FN(explode) : asFUNCTION(explode), + call_conv); assert(r >= 0); r = engine->RegisterGlobalFunction("void teleport(int id, const Vec3 &in)", mp ? WRAP_FN(teleport) : asFUNCTION(teleport),