X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Ft_plats.qc;h=d92a2539d42487fb436bfa19c0c53999170e1bfc;hb=a4185764db2cfb63dfe75c1fa56d55f9ccfd809e;hp=8dac99e41c6079fa50f2aebc4e6026357c399985;hpb=bc51fd3d6308269b5ad770ef62b23fe98ee2cfe1;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/t_plats.qc b/qcsrc/server/t_plats.qc index 8dac99e41..d92a2539d 100644 --- a/qcsrc/server/t_plats.qc +++ b/qcsrc/server/t_plats.qc @@ -331,8 +331,8 @@ void func_rotating_setactive(float astate) { if (astate == ACTIVE_TOGGLE) - { - if(self.active) + { + if(self.active == ACTIVE_ACTIVE) self.active = ACTIVE_NOT; else self.active = ACTIVE_ACTIVE; @@ -340,7 +340,7 @@ void func_rotating_setactive(float astate) else self.active = astate; - if(astate == ACTIVE_NOT) + if(self.active == ACTIVE_NOT) self.avelocity = '0 0 0'; else self.avelocity = self.pos1; @@ -408,19 +408,21 @@ void func_bobbing_controller_think() { local vector v; self.nextthink = time + 0.1; + + if not (self.owner.active == ACTIVE_ACTIVE) + { + self.owner.velocity = '0 0 0'; + return; + } + // calculate sinewave using makevectors makevectors((self.nextthink * self.owner.cnt + self.owner.phase * 360) * '0 1 0'); v = self.owner.destvec + self.owner.movedir * v_forward_y; - // * 10 so it will arrive in 0.1 sec - self.owner.velocity = (v - self.owner.origin) * 10; + if(self.owner.classname == "func_bobbing") // don't brake stuff if the func_bobbing was killtarget'ed + // * 10 so it will arrive in 0.1 sec + self.owner.velocity = (v - self.owner.origin) * 10; }; -void bobbing_blocked() -{ - // no need to duplicate code - generic_plat_blocked(); -} - /*QUAKED spawnfunc_func_bobbing (0 .5 .8) ? X_AXIS Y_AXIS Brush model that moves back and forth on one axis (default Z). speed : how long one cycle takes in seconds (default 4) @@ -447,8 +449,10 @@ void spawnfunc_func_bobbing() // time scale to get degrees self.cnt = 360 / self.speed; + self.active = ACTIVE_ACTIVE; + // damage when blocked - self.blocked = bobbing_blocked; + self.blocked = generic_plat_blocked; if(self.dmg & (!self.message)) self.message = " was squished"; if(self.dmg && (!self.message2)) @@ -483,6 +487,81 @@ void spawnfunc_func_bobbing() // TODO make a reset function for this one }; +.float freq; +void func_pendulum_controller_think() +{ + local float v; + self.nextthink = time + 0.1; + + if not (self.owner.active == ACTIVE_ACTIVE) + { + self.owner.avelocity_x = 0; + return; + } + + // calculate sinewave using makevectors + makevectors((self.nextthink * self.owner.freq + self.owner.phase) * '0 360 0'); + v = self.owner.speed * v_forward_y + self.cnt; + if(self.owner.classname == "func_pendulum") // don't brake stuff if the func_bobbing was killtarget'ed + { + // * 10 so it will arrive in 0.1 sec + self.owner.avelocity_z = (remainder(v - self.owner.angles_z, 360)) * 10; + } +}; + +void spawnfunc_func_pendulum() +{ + local entity controller; + if (self.noise != "") + { + precache_sound(self.noise); + soundto(MSG_INIT, self, CHAN_TRIGGER, self.noise, VOL_BASE, ATTN_IDLE); + } + + self.active = ACTIVE_ACTIVE; + + // keys: angle, speed, phase, noise, freq + + if(!self.speed) + self.speed = 30; + // not initializing self.dmg to 2, to allow damageless pendulum + + if(self.dmg & (!self.message)) + self.message = " was squished"; + if(self.dmg && (!self.message2)) + self.message2 = "was squished by"; + if(self.dmg && (!self.dmgtime)) + self.dmgtime = 0.25; + self.dmgtime2 = time; + + self.blocked = generic_plat_blocked; + + if not(InitMovingBrushTrigger()) + return; + + if(!self.freq) + { + // find pendulum length (same formula as Q3A) + self.freq = 1 / (M_PI * 2) * sqrt(cvar("sv_gravity") / (3 * max(8, fabs(self.mins_z)))); + } + + // copy initial angle + self.cnt = self.angles_z; + + // wait for targets to spawn + controller = spawn(); + controller.classname = "func_pendulum_controller"; + controller.owner = self; + controller.nextthink = time + 1; + controller.think = func_pendulum_controller_think; + self.nextthink = self.ltime + 999999999; + self.think = SUB_Null; + + //self.effects |= EF_LOWPRECISION; + + // TODO make a reset function for this one +}; + // button and multiple button void() button_wait; @@ -551,6 +630,10 @@ void button_use() // dprint(activator.classname); // dprint(" triggered a button\n"); // } + + if not (self.active == ACTIVE_ACTIVE) + return; + self.enemy = activator; button_fire (); }; @@ -640,6 +723,8 @@ void spawnfunc_func_button() if(self.noise != "") precache_sound(self.noise); + self.active = ACTIVE_ACTIVE; + self.pos1 = self.origin; self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip); self.flags |= FL_NOTARGET; @@ -1661,6 +1746,12 @@ void func_fourier_controller_think() float n, i, t; self.nextthink = time + 0.1; + if not (self.owner.active == ACTIVE_ACTIVE) + { + self.owner.velocity = '0 0 0'; + return; + } + n = floor((tokenize_console(self.owner.netname)) / 5); t = self.nextthink * self.owner.cnt + self.owner.phase * 360; @@ -1673,8 +1764,9 @@ void func_fourier_controller_think() v = v + ('1 0 0' * stof(argv(i*5+2)) + '0 1 0' * stof(argv(i*5+3)) + '0 0 1' * stof(argv(i*5+4))) * self.owner.height * v_forward_y; } - // * 10 so it will arrive in 0.1 sec - self.owner.velocity = (v - self.owner.origin) * 10; + if(self.owner.classname == "func_fourier") // don't brake stuff if the func_fourier was killtarget'ed + // * 10 so it will arrive in 0.1 sec + self.owner.velocity = (v - self.owner.origin) * 10; }; void spawnfunc_func_fourier() @@ -1708,6 +1800,8 @@ void spawnfunc_func_fourier() if not(InitMovingBrushTrigger()) return; + self.active = ACTIVE_ACTIVE; + // wait for targets to spawn controller = spawn(); controller.classname = "func_fourier_controller"; @@ -1784,7 +1878,15 @@ vector func_vectormamamam_origin(entity o, float t) void func_vectormamamam_controller_think() { self.nextthink = time + 0.1; - self.owner.velocity = (self.owner.destvec + func_vectormamamam_origin(self.owner, 0.1) - self.owner.origin) * 10; + + if not (self.owner.active == ACTIVE_ACTIVE) + { + self.owner.velocity = '0 0 0'; + return; + } + + if(self.owner.classname == "func_vectormamamam") // don't brake stuff if the func_vectormamamam was killtarget'ed + self.owner.velocity = (self.owner.destvec + func_vectormamamam_origin(self.owner, 0.1) - self.owner.origin) * 10; } void func_vectormamamam_findtarget() @@ -1868,5 +1970,7 @@ void spawnfunc_func_vectormamamam() // Savage: Reduce bandwith, critical on e.g. nexdm02 self.effects |= EF_LOWPRECISION; + self.active = ACTIVE_ACTIVE; + InitializeEntity(self, func_vectormamamam_findtarget, INITPRIO_FINDTARGET); }