Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * HL rotating things
- *
- * from QuakeLife by avirox
- *
- * Pros: Simpler and use less models
- * Cons: Engine and map compiler must support (origin brushes)
- * Possible solution: Set the origin some other way
- * It's messy though - Quake wasn't made for this
- *
- */
- // for now only doors, gb
- void() rot_crush =
- {
- //dprint ("plat_crush\n");
- T_Damage (other, self, self, 1000, DTH_WORLD_SQUISH, FALSE, 1);
- };
- // DOOR_START_OPEN 1
- float DOOR_REVERSE = 2;
- // DOOR_DONT_LINK 4
- // DOOR_GOLD_KEY 8
- // DOOR_SILVER_KEY 16
- // TOGGLE 32
- float DOOR_X_AXIS = 64;
- float DOOR_Y_AXIS = 128;
- /*QUAKED rotate_door (0 .5 .8) ? START_OPEN DOOR_REVERSE DOOR_DONT_LINK GOLD_KEY SILVER_KEY TOGGLE DOOR_X_AXIS DOOR_Y_AXIS
- if two doors touch, they are assumed to be connected and operate as a unit.
- TOGGLE causes the door to wait in both the start and end states for a trigger event.
- START_OPEN causes the door to move to its destination when spawned, and operate in reverse. It is used to temporarily or permanently close off an area when triggered (not usefull for touch or takedamage doors).
- Key doors are allways wait -1.
- "target" must target an info_null or info_rotate with matching targetname, which marks the center of rotation
- "linkname" rotating doors must be linked manually; give linked doors the same linkname (string)
- "message" is printed when the door is touched if it is a trigger door and it hasn't been fired yet
- "distance" amount in degrees to rotate
- "targetname" if set, no touch field will be spawned and a remote button or trigger field activates the door.
- "health" if set, door must be shot open
- "speed" movement speed (100 default)
- "wait" wait before returning (3 default, -1 = never return)
- "lip" lip remaining at end of move (8 default)
- "dmg" damage to inflict when blocked (2 default)
- "noise1" overrides the stopping sound if sounds 0
- "noise2" overrides the moving sound if sounds 0
- "sounds"
- 0) no sound
- 1) stone
- 2) base
- 3) stone chain
- 4) screechy metal
- */
- // avirox, Urre, LordHavoc, Baker, gb
- void() rotate_door =
- {
- /* local entity ent;
- ent = find( world, targetname, self.target);
- */
- if (!self.target) // gb
- objerror ("rotate_door without target\n");
- if (world.worldtype == 0)
- {
- precache_sound ("doors/medtry.wav");
- precache_sound ("doors/meduse.wav");
- self.noise3 = "doors/medtry.wav";
- self.noise4 = "doors/meduse.wav";
- }
- else if (world.worldtype == 1)
- {
- precache_sound ("doors/runetry.wav");
- precache_sound ("doors/runeuse.wav");
- self.noise3 = "doors/runetry.wav";
- self.noise4 = "doors/runeuse.wav";
- }
- else if (world.worldtype == 2)
- {
- precache_sound ("doors/basetry.wav");
- precache_sound ("doors/baseuse.wav");
- self.noise3 = "doors/basetry.wav";
- self.noise4 = "doors/baseuse.wav";
- }
- else
- {
- dprint ("no worldtype set!\n");
- }
- if (self.sounds == 0)
- {
- if (!self.noise1) // gb, stopping sound
- self.noise1 = "misc/null.wav";
- if (!self.noise2) // gb, moving sound
- self.noise2 = "misc/null.wav";
- precache_sound (self.noise1);
- precache_sound (self.noise2);
- }
- if (self.sounds == 1)
- {
- precache_sound ("doors/drclos4.wav");
- precache_sound ("doors/doormv1.wav");
- self.noise1 = "doors/drclos4.wav";
- self.noise2 = "doors/doormv1.wav";
- }
- if (self.sounds == 2)
- {
- precache_sound ("doors/hydro1.wav");
- precache_sound ("doors/hydro2.wav");
- self.noise2 = "doors/hydro1.wav";
- self.noise1 = "doors/hydro2.wav";
- }
- if (self.sounds == 3)
- {
- precache_sound ("doors/stndr1.wav");
- precache_sound ("doors/stndr2.wav");
- self.noise2 = "doors/stndr1.wav";
- self.noise1 = "doors/stndr2.wav";
- }
- if (self.sounds == 4)
- {
- precache_sound ("doors/ddoor1.wav");
- precache_sound ("doors/ddoor2.wav");
- self.noise1 = "doors/ddoor2.wav";
- self.noise2 = "doors/ddoor1.wav";
- }
- if (self.spawnflags & DOOR_X_AXIS)
- self.movedir_z = 1.0;
- else if (self.spawnflags & DOOR_Y_AXIS)
- self.movedir_x = 1.0;
- else // Z_AXIS
- self.movedir_y = 1.0;
- // check for reverse rotation
- if (self.spawnflags & DOOR_REVERSE)
- self.movedir = '0 0 0' - self.movedir;
- // if (world.model == "maps/e1m2rq.bsp")
- // self.effects = 8192;
- self.max_health = self.health;
- self.solid = SOLID_BSP;
- self.movetype = MOVETYPE_PUSH; // gb
- setorigin (self, self.origin); // self.origin
- setmodel (self, self.model);
- self.classname = "door_rotating";
- if (!self.linkname)
- self.linkname = string_null;
- self.blocked = door_blocked;
- self.use = door_use;
- if (self.spawnflags & DOOR_SILVER_KEY)
- self.items = IT_KEY1;
- if (self.spawnflags & DOOR_GOLD_KEY)
- self.items = IT_KEY2;
- if (!self.speed)
- self.speed = 100;
- if (!self.wait)
- self.wait = 3;
- if (!self.lip)
- self.lip = 8;
- if (!self.dmg)
- self.dmg = 2;
- // self.pos1 = self.origin;
- // self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip);
- self.pos1 = self.angles;
- self.pos2 = self.angles + self.movedir * self.distance;
- // DOOR_START_OPEN is to allow an entity to be lighted in the closed position
- // but spawn in the open position
- if (self.spawnflags & DOOR_START_OPEN) // fixed this, gb
- {
- self.pos2 = self.angles;
- self.pos1 = self.angles - self.movedir * self.distance;
- self.angles = self.angles + self.movedir * self.distance;
- // setorigin (self, self.pos1);
- }
- self.state = STATE_BOTTOM;
- if (self.health)
- {
- self.takedamage = DAMAGE_YES;
- self.nobleed = TRUE;
- self.th_die = door_killed;
- }
- if (self.items)
- self.wait = -1;
- //if (!(self.spawnflags & 256)) // use only - but use is touch in quake anyways lol
- self.touch = door_touch;
- if (self.targetname) { // Door is locked if it must be triggered
- self.touch = SUB_Null;
- self.th_die = SUB_Null;
- }
- // LinkDoors can't be done until all of the doors have been spawned, so
- // the sizes can be detected properly.
- if (!(self.spawnflags & 4))
- self.spawnflags = self.spawnflags | 4; // so we DONT link doors
- self.think = LinkDoors;
- self.nextthink = self.ltime + 0.1;
- };
- /*
- * gb - another rotating bmodel using origin brushes / origin vector - for testing purposes
- * this is from the quakesrc.org avelocity engine / qc tutorial
- * and should work in conjunction with avirox' engine avelocity tutorial
- * or any engine that supports avelocity (angle velocity)
- *
- */
- float STATE_WAITING = 0;
- float STATE_SPINNING = 1;
- // gb
- void() accelerator_think =
- {
- local float accel_factor;
- if (self.is_female) // backwards
- {
- if (self.cnt >= self.is_female) // reached top speed?
- {
- self.think = SUB_Remove;
- self.nextthink = time + 0.1;
- dprint("removing accelerator\n");
- return;
- }
- accel_factor = self.is_female / self.delay / 10;
- }
- else
- {
- if (self.cnt >= self.speed) // reached top speed?
- {
- self.think = SUB_Remove;
- self.nextthink = time + 0.1;
- dprint("removing accelerator\n");
- return;
- }
- accel_factor = self.speed / self.delay / 10; // 10 FPS; delay 10 = 100 frames
- }
- self.cnt = self.cnt + accel_factor; // keep count
- if (self.wait == 4) // lol
- {
- if (self.is_female) // backwards?
- self.owner.avelocity_z = self.owner.avelocity_z - accel_factor;
- else
- self.owner.avelocity_z = self.owner.avelocity_z + accel_factor;
- }
- else if (self.wait == 8) // yup, save globals
- {
- if (self.is_female) // backwards?
- self.owner.avelocity_x = self.owner.avelocity_x - accel_factor;
- else
- self.owner.avelocity_x = self.owner.avelocity_x + accel_factor;
- }
- else
- {
- if (self.is_female) // backwards?
- self.owner.avelocity_y = self.owner.avelocity_y - accel_factor;
- else
- self.owner.avelocity_y = self.owner.avelocity_y + accel_factor;
- }
- self.nextthink = time + 0.1; // accelerate every frame
- };
- // gb
- void() decelerator_think =
- {
- local float accel_factor;
- if (self.owner.avelocity == '0 0 0') // make very sure it stopped completely
- {
- self.think = SUB_Remove;
- self.nextthink = time + 0.1;
- dprint("removing decelerator\n");
- return;
- }
- if (self.is_female) // backwards
- accel_factor = self.is_female / self.delay / 10;
- else
- accel_factor = self.speed / self.delay / 10; // 10 FPS; delay 10 = 100 frames
- if (self.wait == 4) // lol
- {
- if (self.owner.avelocity_z < 10 && self.owner.avelocity_z > -10) // have to account for both - might be reverse
- self.owner.avelocity_z = 0; // make sure it doesn't go the other direction
- else if (self.is_female) // backwards
- self.owner.avelocity_z = self.owner.avelocity_z + accel_factor;
- else
- self.owner.avelocity_z = self.owner.avelocity_z - accel_factor;
- }
- else if (self.wait == 8) // yup, save globals
- {
- if (self.owner.avelocity_x < 10 && self.owner.avelocity_x > -10)
- self.owner.avelocity_x = 0;
- else if (self.is_female) // backwards
- self.owner.avelocity_x = self.owner.avelocity_x + accel_factor;
- else
- self.owner.avelocity_x = self.owner.avelocity_x - accel_factor;
- }
- else
- {
- if (self.owner.avelocity_y < 10 && self.owner.avelocity_y > -10)
- self.owner.avelocity_y = 0;
- else if (self.is_female) // backwards
- self.owner.avelocity_y = self.owner.avelocity_y + accel_factor;
- else
- self.owner.avelocity_y = self.owner.avelocity_y - accel_factor;
- }
- self.nextthink = time + 0.1; // accelerate every frame
- };
- // gb
- void() rotate_continuous_use =
- {
- local entity e; // we're dumb, so use a helper
- if (self.state == STATE_SPINNING) // gb, already spinning, got toggled off - stop moving
- {
- if (self.spawnflags & 4)
- {
- if (self.delay > 0) // shall I decelerate?
- {
- e = spawn();
- e.owner = self;
- e.delay = self.delay;
- e.speed = self.speed;
- e.is_female = self.is_female; // backwards?
- e.wait = 4; // lol
- e.think = decelerator_think;
- e.nextthink = time + 0.1;
- dprint ("decelerator spawned\n");
- //return;
- }
- else // nope, just go for it
- {
- self.avelocity_z = 0;
- }
- }
- else if (self.spawnflags & 8)
- {
- if (self.delay > 0) // shall I decelerate?
- {
- e = spawn();
- e.owner = self;
- e.delay = self.delay;
- e.speed = self.speed;
- e.is_female = self.is_female; // backwards?
- e.wait = 8; // lol
- e.think = decelerator_think;
- e.nextthink = time + 0.1;
- dprint("decelerator spawned\n");
- //return;
- }
- else // nope, just go for it
- {
- self.avelocity_x = 0;
- }
- }
- else
- {
- if (self.delay > 0) // shall I decelerate?
- {
- e = spawn();
- e.owner = self;
- e.delay = self.delay;
- e.speed = self.speed;
- e.is_female = self.is_female; // backwards?
- // no wait
- e.think = decelerator_think;
- e.nextthink = time + 0.1;
- dprint("decelerator spawned\n");
- //return;
- }
- else // nope, just go for it
- {
- self.avelocity_y = 0;
- }
- }
- self.state = STATE_WAITING; // possibly let the helper set this once stopped
- }
- else // STATE_WAITING // gb, got toggled on - start spinning
- {
- if (self.spawnflags & 4)
- {
- self.avelocity_x = 0;
- self.avelocity_y = 0;
- self.avelocity_z = 0; // null it out
- if (self.delay > 0) // shall I accelerate?
- {
- e = spawn();
- e.owner = self;
- e.delay = self.delay;
- e.speed = self.speed;
- e.is_female = self.is_female; // backwards?
- e.wait = 4; // lol
- e.think = accelerator_think;
- e.nextthink = time + 0.1;
- dprint ("accelerator spawned\n");
- //return;
- }
- else // nope, just go for it
- {
- self.avelocity_z = self.speed;
- }
- }
- else if (self.spawnflags & 8)
- {
- self.avelocity_z = 0;
- self.avelocity_y = 0;
- self.avelocity_x = 0; // null it out
- if (self.delay > 0) // shall I accelerate?
- {
- e = spawn();
- e.owner = self;
- e.delay = self.delay;
- e.speed = self.speed;
- e.is_female = self.is_female; // backwards?
- e.wait = 8; // lol
- e.think = accelerator_think;
- e.nextthink = time + 0.1;
- dprint("accelerator spawned\n");
- //return;
- }
- else // nope, just go for it
- {
- self.avelocity_x = self.speed;
- }
- }
- else
- {
- self.avelocity_z = 0;
- self.avelocity_x = 0;
- self.avelocity_y = 0; // null it out
- if (self.delay > 0) // shall I accelerate?
- {
- e = spawn();
- e.owner = self;
- e.delay = self.delay;
- e.speed = self.speed;
- e.is_female = self.is_female; // backwards?
- // no wait
- e.think = accelerator_think;
- e.nextthink = time + 0.1;
- dprint("accelerator spawned\n");
- //return;
- }
- else // nope, just go for it
- {
- self.avelocity_y = self.speed;
- }
- }
- self.state = STATE_SPINNING; // possibly let the helper set this once fully spun up
- self.think = SUB_Null;
- self.nextthink = self.ltime + 9999999;
- }
- };
- /*QUAKED rotate_continuous (0 .5 .8) ? x REVERSE Z_AXIS X_AXIS x x NONSOLID
- RMQ Origin-rotating bmodel - experimental
- "targetname" if set, waits for trigger and can be toggled on/off
- "speed" nominal rotating speed (100 default)
- "delay" if set, duration of acceleration / deceleration
- "target" must target an info_null, which marks the center of rotation
- */
- // gb
- void() rotate_continuous =
- {
- if (!self.target)
- objerror ("rotate_continuous without target\n");
- self.solid = SOLID_BSP;
- self.movetype = MOVETYPE_PUSH;
- //self.think = SUB_Null;
- setorigin (self, self.origin);
- setmodel (self, self.model);
- self.classname = "rotate_continuous";
- setsize (self, self.mins, self.maxs);
- if (!self.speed)
- self.speed = 100;
- if (self.spawnflags & 2) // reverse direction
- {
- self.is_female = self.speed; // yeah
- self.speed = 0 - self.speed;
- }
- if (self.spawnflags & 64) // not solid
- self.solid = SOLID_NOT;
- if (!self.targetname)
- {
- self.state = STATE_WAITING;
- rotate_continuous_use();
- }
- else
- {
- self.state = STATE_WAITING;
- self.use = rotate_continuous_use;
- }
- self.blocked = rot_crush;
- };
- void() rotate_continuous_model = //ijed, gb A model instead of being a brush entity
- {
- if ((self.mdl) || (self.model))
- {
- if (self.mdl)
- {
- precache_model (self.mdl);
- self.model = self.mdl;
- }
- precache_model (self.model);
- setmodel (self, self.model);
- }
- else
- {
- dprint ("null rotate_continuous_model at: ");
- dprint (vtos (self.origin));
- dprint ("\n");
- }
- rotate_continuous();
- };
- // still more rotating crap, this time by urre
- // must target something to get its origin
- /*
- void () rotate_obejct =
- {
- setorigin (self, self.origin);
- setmodel (self, self.model);
- setsize (self, self.mins, self.maxs);
- self.classname = self.netname;
- if (self.classname == "func_rotating_door")
- func_rotating_door();
- else if (self.classname == "func_rotating_banana")
- func-rotating_banana();
- };
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement