]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator_physical_weapons.qc
Move the physical weapon code to the new mutator
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_physical_weapons.qc
index a95017750693fc5430f4c3556980355e5e3ca436..2ec984c89c09819a9f31279a8f6cb671e23aa668 100644 (file)
@@ -1,13 +1,45 @@
+void thrown_wep_ode_think()
+{
+       self.nextthink = time;
+       if(!self.owner.modelindex)
+               remove(self); // the real weapon is gone, remove this
+}
+
 MUTATOR_HOOKFUNCTION(item_spawning)
 {
-       dprint("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
+       if(!autocvar_physics_ode)
+               return FALSE;
+       if(self.classname != "droppedweapon")
+               return FALSE;
+
+       // make the dropped weapon physical
+       entity wep;
+       wep = spawn();
+       setsize(wep, self.mins, self.maxs);
+       setorigin(wep, self.origin);
+       wep.angles = self.angles;
+       wep.velocity = self.velocity;
+
+       wep.classname = "droppedweapon2";
+       wep.owner = self;
+       wep.solid = SOLID_CORPSE;
+       wep.movetype = MOVETYPE_PHYSICS;
+       wep.takedamage = DAMAGE_AIM;
+       wep.damageforcescale = autocvar_g_ode_weapons_damageforcescale;
+
+       wep.think = thrown_wep_ode_think;
+       wep.nextthink = time;
+
+       self.effects |= EF_NOMODELFLAGS; // disable the spinning
+       self.movetype = MOVETYPE_FOLLOW;
+       self.aiment = wep;
 
-       return 0;
+       return FALSE;
 }
 
 MUTATOR_DEFINITION(mutator_physical_weapons)
 {
        MUTATOR_HOOK(Item_Spawn, item_spawning, CBC_ORDER_ANY);
 
-       return 0;
+       return FALSE;
 }