]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Object materials. They influence what sounds are generated when the object impacts...
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Wed, 26 Oct 2011 13:39:18 +0000 (16:39 +0300)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Wed, 26 Oct 2011 13:39:18 +0000 (16:39 +0300)
defaultXonotic.cfg
qcsrc/menu/xonotic/dialog_sandboxtools.c
qcsrc/server/mutators/sandbox.qc

index d220f7ba404c25c3ecd8c99e0e4c0a2500fe1580..03a31b899c21428220ce10ff9c481b913629760f 100644 (file)
@@ -557,6 +557,7 @@ seta menu_sandbox_edit_frame 0
 seta menu_sandbox_edit_scale 1
 seta menu_sandbox_edit_physics 1
 seta menu_sandbox_edit_force 1
+seta menu_sandbox_edit_material 0
 
 alias menu_showsandboxtools "menu_cmd directmenu SandboxTools"
 bind f7 menu_showsandboxtools
index 39cb997682b28c7733cc62c653e5abfb7886f0c8..301ca92d3d6c815540dc4d16f3b87134c02bacbf 100644 (file)
@@ -47,13 +47,19 @@ void XonoticSandboxToolsDialog_fill(entity me)
        me.TR(me);
        me.TD(me, 1, 2, e = makeXonoticTextLabel(0, _("Physical object properties:")));
        me.TR(me);
-               me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Set scale:"), '0 0 0', "sandbox edit_object scale $menu_sandbox_edit_scale", 0));
-               me.TD(me, 1, 1.5, e = makeXonoticSlider(0.5, 2, 0.05, "menu_sandbox_edit_scale"));
+               me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Set material:"), '0 0 0', "sandbox edit_object material $menu_sandbox_edit_material", 0));
+               me.TD(me, 1, 1.5, e = makeXonoticTextSlider("menu_sandbox_edit_material"));
+                       e.addValue(e, _("metal"), "0");
+                       e.addValue(e, _("stone"), "1");
+                       e.addValue(e, _("wood"), "2");
+                       e.configureXonoticTextSliderValues(e);
                me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Set physics:"), '0 0 0', "sandbox edit_object physics $menu_sandbox_edit_physics", 0));
                me.TD(me, 1, 0.5, e = makeXonoticRadioButton(1, "menu_sandbox_edit_physics", "0", _("Static")));
                me.TD(me, 1, 0.5, e = makeXonoticRadioButton(1, "menu_sandbox_edit_physics", "1", _("Movable")));
                me.TD(me, 1, 0.5, e = makeXonoticRadioButton(1, "menu_sandbox_edit_physics", "2", _("Physical")));
        me.TR(me);
+               me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Set scale:"), '0 0 0', "sandbox edit_object scale $menu_sandbox_edit_scale", 0));
+               me.TD(me, 1, 1.5, e = makeXonoticSlider(0.5, 2, 0.05, "menu_sandbox_edit_scale"));
                me.TD(me, 1, 0.5, makeXonoticCommandButton(_("Set force:"), '0 0 0', "sandbox edit_object force $menu_sandbox_edit_force", 0));
                me.TD(me, 1, 1.5, e = makeXonoticSlider(0, 10, 0.5, "menu_sandbox_edit_force"));
 
index 30e486895a851903848fa7c2e332c0bdc6b2897f..9c0f0e70480d49701780d46cd1c73dc1061607e9 100644 (file)
@@ -1,4 +1,9 @@
 .string object_clipboard;
+.float material;
+
+const float MATERIAL_METAL = 0;
+const float MATERIAL_STONE = 1;
+const float MATERIAL_WOOD = 2;
 
 entity sandbox_EditObject_Get()
 {
@@ -22,6 +27,18 @@ void sandbox_EditObject_Scale(entity e, float f)
        }
 }
 
+void sandbox_Object_Touch()
+{
+       switch(self.material)
+       {
+               case MATERIAL_METAL:
+                       sound(self, CH_TRIGGER, strcat("object/impact_metal_", ftos(ceil(random() * 5)) , ".ogg"), VOL_BASE, ATTN_NORM);
+                       break;
+               default:
+                       break;
+       }
+}
+
 entity sandbox_SpawnObject()
 {
        // spawn a new object with default properties
@@ -36,6 +53,9 @@ entity sandbox_SpawnObject()
        e.movetype = MOVETYPE_TOSS;
        e.frame = 0;
        e.skin = 0;
+       e.material = MATERIAL_METAL;
+
+       e.touch = sandbox_Object_Touch;
 
        // set origin and direction based on player position and view angle
        makevectors(self.v_angle);
@@ -79,7 +99,8 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                                print_to(self, "^3frame value ^7- object animation frame, for self-animated models");
                                print_to(self, "^3scale value ^7- changes object scale. 0.5 is half size and 2 is double size");
                                print_to(self, "^3physics value ^7- object physics, 0 = static, 1 = movable, 2 = physical");
-                               print_to(self, "^force value ^7- amount of force applied to objects that are shot");
+                               print_to(self, "^3force value ^7- amount of force applied to objects that are shot");
+                               print_to(self, "^3material value ^7- sets the material of the object. Valid materials are: 0 (metal), 1 (stone), 2 (wood)");
                                print_to(self, "^7The ^1drag object ^7key can be used to grab and carry objects. Players can only grab their own objects");
                                return TRUE;
 
@@ -170,6 +191,7 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                                        self.object_clipboard = strcat(self.object_clipboard, ftos(e.scale), " ");
                                        self.object_clipboard = strcat(self.object_clipboard, ftos(e.movetype), " ");
                                        self.object_clipboard = strcat(self.object_clipboard, ftos(e.damageforcescale), " ");
+                                       self.object_clipboard = strcat(self.object_clipboard, ftos(e.material), " ");
 
                                        self.object_clipboard = strzone(self.object_clipboard);
                                        print_to(self, "Object copied to clipboard");
@@ -202,6 +224,7 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                                sandbox_EditObject_Scale(e, stof(argv(6)));
                                e.movetype = stof(argv(7));
                                e.damageforcescale = stof(argv(8));
+                               e.material = stof(argv(9));
 
                                print_to(self, "Object pasted");
                                if(autocvar_g_sandbox_info)
@@ -259,6 +282,9 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                                                case "force":
                                                        e.damageforcescale = stof(argv(3));
                                                        break;
+                                               case "material":
+                                                       e.material = stof(argv(3));
+                                                       break;
                                                default:
                                                        print_to(self, "WARNING: Invalid object property. For usage information, type 'sandbox help'");
                                                        break;
@@ -326,5 +352,15 @@ MUTATOR_DEFINITION(sandbox)
        MUTATOR_HOOK(PlayerPreThink, sandbox_PlayerPreThink, CBC_ORDER_ANY);
        MUTATOR_HOOK(ClientDisconnect, sandbox_ClientDisconnect, CBC_ORDER_ANY);
 
+       MUTATOR_ONADD
+       {
+               float i;
+               for (i = 1; i <= 5; i++)
+               {
+                       precache_sound(strcat("objects/impact_metal_", ftos(i), ".ogg"));
+               }
+       }
+
        return FALSE;
 }
+