Reworked Thunderstorm scripting
authorChristoph Sommer <mail@christoph-sommer.de>
Thu, 13 Jul 2006 00:44:58 +0000 (00:44 +0000)
committerChristoph Sommer <mail@christoph-sommer.de>
Thu, 13 Jul 2006 00:44:58 +0000 (00:44 +0000)
SVN-Revision: 3995

data/levels/world2/ghostly.stl
src/object/thunderstorm.cpp
src/object/thunderstorm.hpp
src/scripting/thunderstorm.hpp

index 17a6194..49e0b2a 100644 (file)
     )
     (scripttrigger
       (script "Tux.deactivate();
-play_sound(\"sounds/brick.wav\");
-Effect.fade_in(0.2);
-wait(0.1);
-play_sound(\"sounds/brick.wav\");
-Effect.fade_in(0.2);
-wait(0.2);
-play_sound(\"sounds/brick.wav\");
-Effect.fade_in(0.2);
+play_music(\"music/ghostforest.ogg\");
 wait(1);
-play_sound(\"sounds/brick.wav\");
-wait(0.2);
-play_sound(\"sounds/brick.wav\");
-Effect.fade_in(0.2);
-wait(0.1);
-play_sound(\"sounds/brick.wav\");
-Effect.fade_out(0.5);
+thunder1.lightning();
 wait(1);
+thunder1.lightning();
+wait(0.33);
+thunder1.lightning();
 play_sound(\"sounds/warp.wav\");
 Tux.activate();
 Level.spawn(\"ghostforest\", \"main\");
@@ -97,6 +87,10 @@ Level.spawn(\"ghostforest\", \"main\");
       (x 2016)
       (y 0)
     )
+    (thunderstorm
+      (name "thunder1")
+      (running #f)
+    )
   )
   (sector
     (name "ghostforest")
@@ -204,23 +198,11 @@ Level.spawn(\"ghostforest\", \"main\");
     )
     (scripttrigger
       (script "Tux.deactivate();
-play_sound(\"sounds/brick.wav\");
-Effect.fade_in(0.2);
-wait(0.1);
-play_sound(\"sounds/brick.wav\");
-Effect.fade_in(0.2);
-wait(0.2);
-play_sound(\"sounds/brick.wav\");
-Effect.fade_in(0.2);
-wait(1);
-play_sound(\"sounds/brick.wav\");
-wait(0.2);
-play_sound(\"sounds/brick.wav\");
-Effect.fade_in(0.2);
-wait(0.1);
-play_sound(\"sounds/brick.wav\");
-Effect.fade_out(0.5);
-wait(1);
+thunder2.lightning();
+wait(0.66);
+thunder2.thunder();
+wait(0.3);
+thunder2.lightning();
 play_sound(\"sounds/warp.wav\");
 Tux.activate();
 Level.spawn(\"main\", \"back\");
@@ -231,5 +213,9 @@ Level.spawn(\"main\", \"back\");
       (x 6848)
       (y 0)
     )
+    (thunderstorm
+      (name "thunder2")
+      (running #f)
+    )
   )
 )
index 5a9cb36..1aec362 100644 (file)
@@ -91,7 +91,7 @@ void
 Thunderstorm::expose(HSQUIRRELVM vm, SQInteger table_idx)
 {
   if (name == "") return;
-  Scripting::Thunderstorm* interface = static_cast<Scripting::Thunderstorm*>(this);
+  Scripting::Thunderstorm* interface = new Scripting::Thunderstorm(this);
   expose_object(vm, table_idx, interface, name, true);
 }
 
index 804312f..77f8f68 100644 (file)
@@ -29,7 +29,7 @@
 /**
  * Thunderstorm scriptable GameObject; plays thunder, lightning and electrifies water at regular interval
  */
-class Thunderstorm : public GameObject, public Scripting::Thunderstorm, public ScriptInterface
+class Thunderstorm : public GameObject, public ScriptInterface
 {
 public:
     Thunderstorm(const lisp::Lisp& reader);
index 79e350b..24a4d2e 100644 (file)
 #ifndef __SCRIPTING_THUNDERSTORM_H__
 #define __SCRIPTING_THUNDERSTORM_H__
 
+#ifndef SCRIPTING_API
+class Thunderstorm;
+typedef Thunderstorm _Thunderstorm;
+#endif
+
 namespace Scripting
 {
 
@@ -27,41 +32,43 @@ class Thunderstorm
 {
 public:
 #ifndef SCRIPTING_API
-  virtual ~Thunderstorm()
-  {}
+  Thunderstorm(_Thunderstorm* thunderstorm);
+  ~Thunderstorm();
 #endif
 
     /**
      * Start playing thunder and lightning at configured interval
      */
-    virtual void start() = 0;
+    void start();
     
     /**
      * Stop playing thunder and lightning at configured interval
      */
-    virtual void stop() = 0;
+    void stop();
 
     /**
      * Play thunder
      */
-    virtual void thunder() = 0;
+    void thunder();
 
     /**
      * Play lightning, i.e. call flash() and electrify()
      */
-    virtual void lightning() = 0;
+    void lightning();
 
     /**
      * Display a nice flash
      */
-    virtual void flash() = 0;
+    void flash();
 
     /**
      * Electrify water throughout the whole sector for a short time
      */
-    virtual void electrify() = 0;
-
+    void electrify();
 
+#ifndef SCRIPTING_API
+  _Thunderstorm* thunderstorm;
+#endif
 };
 
 }