diff --git a/quakec/basemod/.cvsignore b/quakec/basemod/.cvsignore new file mode 100644 index 000000000..fe4dd0181 --- /dev/null +++ b/quakec/basemod/.cvsignore @@ -0,0 +1,8 @@ +fteprogs.lno +fteqcc.exe +progs.dat +progs.lno +qc.asm +qwprogs.dat +qwprogs.lno +fteprogs.dat \ No newline at end of file diff --git a/quakec/basemod/basemod.txt b/quakec/basemod/basemod.txt new file mode 100644 index 000000000..eac5c3cb8 --- /dev/null +++ b/quakec/basemod/basemod.txt @@ -0,0 +1,32 @@ +Incomplete - +Triggered kills (explobox, etc) + +Done - +Cleanup warnings +Fix QW bugs +Heal decay (over maxhealth) +INTEGER mod +Nailgun frame seperation +Body queue change +Suicide timer limit +Suicide backpack/quad/ring drop +Condense bprint, sprint, centerprints +te_explode sprite + +Todo - +Track oldbutton presses +Samelevel 4 (exit acts as a spawnpoint teleporter) +Don't use newmis/spawn projectiles in front +Fix weird deathmatch modes, cvar checking +sv_gravity change? +Advanced heal decay (only decay health that the megahealth added?) +Effects system, NQ/QW cross compatibility +Object-oriented?/Unionize? +Add monsters back? +H2 ents? +HL ents? +Q3 ents? +Decal system based on visibility from players? +Clean up backpack pickup prints? +CSQC? +Rogue/hipnotic weapons/monsters? diff --git a/quakec/basemod/buttons.qc b/quakec/basemod/buttons.qc new file mode 100644 index 000000000..190d98dab --- /dev/null +++ b/quakec/basemod/buttons.qc @@ -0,0 +1,138 @@ +// button and multiple button + +void() button_wait; +void() button_return; + +void() button_wait = +{ + self.state = STATE_TOP; + self.nextthink = self.ltime + self.wait; + self.think = button_return; + activator = self.enemy; + SUB_UseTargets(); + self.frame = 1; // use alternate textures +}; + +void() button_done = +{ + self.state = STATE_BOTTOM; +}; + +void() button_return = +{ + self.state = STATE_DOWN; + SUB_CalcMove (self.pos1, self.speed, button_done); + self.frame = 0; // use normal textures + if (self.health) + self.takedamage = DAMAGE_YES; // can be shot again +}; + + +void() button_blocked = +{ // do nothing, just don't ome all the way back out +}; + + +void() button_fire = +{ + if (self.state == STATE_UP || self.state == STATE_TOP) + return; + + sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM); + + self.state = STATE_UP; + SUB_CalcMove (self.pos2, self.speed, button_wait); +}; + + +void() button_use = +{ + self.enemy = activator; + button_fire (); +}; + +void() button_touch = +{ + if (other.classname != "player") + return; + self.enemy = other; + button_fire (); +}; + +void() button_killed = +{ + self.enemy = damage_attacker; + self.health = self.max_health; + self.takedamage = DAMAGE_NO; // wil be reset upon return + button_fire (); +}; + + +/*QUAKED func_button (0 .5 .8) ? +When a button is touched, it moves some distance in the direction of it's angle, triggers all of it's targets, waits some time, then returns to it's original position where it can be triggered again. + +"angle" determines the opening direction +"target" all entities with a matching targetname will be used +"speed" override the default 40 speed +"wait" override the default 1 second wait (-1 = never return) +"lip" override the default 4 pixel lip remaining at end of move +"health" if set, the button must be killed instead of touched +"sounds" +0) steam metal +1) wooden clunk +2) metallic click +3) in-out +*/ +void() func_button = +{ + switch (self.sounds) + { + case 0: + precache_sound ("buttons/airbut1.wav"); + self.noise = "buttons/airbut1.wav"; + break; + case 1: + precache_sound ("buttons/switch21.wav"); + self.noise = "buttons/switch21.wav"; + break; + case 2: + precache_sound ("buttons/switch02.wav"); + self.noise = "buttons/switch02.wav"; + break; + case 3: + precache_sound ("buttons/switch04.wav"); + self.noise = "buttons/switch04.wav"; + break; + } + + SetMovedir (); + + self.movetype = MOVETYPE_PUSH; + self.solid = SOLID_BSP; + setmodel (self, self.model); + + self.blocked = button_blocked; + self.use = button_use; + + if (self.health) + { + self.max_health = self.health; + self.th_die = button_killed; + self.takedamage = DAMAGE_YES; + } + else + self.touch = button_touch; + + if (!self.speed) + self.speed = 40; + if (!self.wait) + self.wait = 1; + if (!self.lip) + self.lip = 4; + + self.state = STATE_BOTTOM; + + self.pos1 = self.origin; + self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip); +}; + diff --git a/quakec/basemod/client.qc b/quakec/basemod/client.qc new file mode 100644 index 000000000..0df3e67fa --- /dev/null +++ b/quakec/basemod/client.qc @@ -0,0 +1,1268 @@ + +// prototypes +void () W_WeaponFrame; +void() W_SetCurrentAmmo; +void() player_pain; +void() player_stand1; +void (vector org) spawn_tfog; +void (vector org, entity death_owner) spawn_tdeath; + +float modelindex_eyes, modelindex_player; + +/* +============================================================================= + + LEVEL CHANGING / INTERMISSION + +============================================================================= +*/ + +string nextmap; + +/*QUAKED info_intermission (1 0.5 0.5) (-16 -16 -16) (16 16 16) +This is the camera point for the intermission. +Use mangle instead of angle, so you can set pitch or roll as well as yaw. 'pitch roll yaw' +*/ +void() info_intermission = +{ + self.angles = self.mangle; // so C can get at it +}; + + + +void() SetChangeParms = +{ + if (self.health <= 0) + { + SetNewParms (); + return; + } + +// remove items + self.items = self.items - (self.items & + (IT_KEY1 | IT_KEY2 | IT_INVISIBILITY | IT_INVULNERABILITY | IT_SUIT | IT_QUAD) ); + +// cap super health + if (self.health > 100) + self.health = 100; + if (self.health < 50) + self.health = 50; + parm1 = self.items; + parm2 = self.health; + parm3 = self.armorvalue; + if (self.ammo_shells < 25) + parm4 = 25; + else + parm4 = self.ammo_shells; + parm5 = self.ammo_nails; + parm6 = self.ammo_rockets; + parm7 = self.ammo_cells; + parm8 = self.weapon; + parm9 = self.armortype; +}; + +void() SetNewParms = +{ + parm1 = IT_SHOTGUN | IT_AXE; + parm2 = 100; + parm3 = 0; + parm4 = 25; + parm5 = 0; + parm6 = 0; + parm7 = 0; + parm8 = 1; + parm9 = 0; +}; + +void() DecodeLevelParms = +{ + if (serverflags) + { + if (world.model == "maps/start.bsp") + SetNewParms (); // take away all stuff on starting new episode + } + + self.items = parm1; + self.health = parm2; + self.armorvalue = parm3; + self.ammo_shells = parm4; + self.ammo_nails = parm5; + self.ammo_rockets = parm6; + self.ammo_cells = parm7; + self.weapon = parm8; + self.armortype = parm9; +}; + +/* +============ +FindIntermission + +Returns the entity to view from +============ +*/ +entity() FindIntermission = +{ + local entity spot; + local float cyc; + +// look for info_intermission first + spot = find (world, classname, "info_intermission"); + if (spot) + { // pick a random one + cyc = random() * 4; + while (cyc > 1) + { + spot = find (spot, classname, "info_intermission"); + if (!spot) + spot = find (spot, classname, "info_intermission"); + cyc = cyc - 1; + } + return spot; + } + +// then look for the start position + spot = find (world, classname, "info_player_start"); + if (spot) + return spot; + + objerror ("FindIntermission: no spot"); + return world; // remove warning +}; + + +void() GotoNextMap = +{ + local string newmap; + +//ZOID: 12-13-96, samelevel is overloaded, only 1 works for same level + + if (cvar("samelevel") == 1) // if samelevel is set, stay on same level + changelevel (mapname); + else { + // configurable map lists, see if the current map exists as a + // serverinfo/localinfo var + newmap = stringserverinfokey(mapname); + if (newmap != "") + changelevel (newmap); + else + changelevel (nextmap); + } +}; + + + +/* +============ +IntermissionThink + +When the player presses attack or jump, change to the next level +============ +*/ +void() IntermissionThink = +{ + if (time < intermission_exittime) + return; + + if (!self.button0 && !self.button1 && !self.button2) + return; + + GotoNextMap (); +}; + +/* +============ +execute_changelevel + +The global "nextmap" has been set previously. +Take the players to the intermission spot +============ +*/ +void() execute_changelevel = +{ + local entity pos; + + intermission_running = 1; + +// enforce a wait time before allowing changelevel + if (deathmatch) + intermission_exittime = time + 5; + else + intermission_exittime = time + 2; + + pos = FindIntermission (); + +// play intermission music + WriteByte (MSG_ALL, SVC_CDTRACK); + WriteByte (MSG_ALL, 3); +#ifdef NETQUAKE + WriteByte (MSG_ALL, 3); + + pos = FindIntermission (); + + other = find (world, classname, "player"); + while (other != world) + { + other.view_ofs = '0 0 0'; + other.angles = other.v_angle = pos.mangle; + other.fixangle = TRUE; // turn this way immediately + other.nextthink = time + 0.5; + other.takedamage = DAMAGE_NO; + other.solid = SOLID_NOT; + other.movetype = MOVETYPE_NONE; + other.modelindex = 0; + setorigin (other, pos.origin); + other = find (other, classname, "player"); + } + + WriteByte (MSG_ALL, SVC_INTERMISSION); +#else + WriteByte (MSG_ALL, SVC_INTERMISSION); + WriteCoord (MSG_ALL, pos.origin_x); + WriteCoord (MSG_ALL, pos.origin_y); + WriteCoord (MSG_ALL, pos.origin_z); + WriteAngle (MSG_ALL, pos.mangle_x); + WriteAngle (MSG_ALL, pos.mangle_y); + WriteAngle (MSG_ALL, pos.mangle_z); + + other = find (world, classname, "player"); + while (other != world) + { + other.takedamage = DAMAGE_NO; + other.solid = SOLID_NOT; + other.movetype = MOVETYPE_NONE; + other.modelindex = 0; + other = find (other, classname, "player"); + } +#endif +}; + + +void() changelevel_touch = +{ + if (other.classname != "player") + return; + +// if "noexit" is set, blow up the player trying to leave +//ZOID, 12-13-96, noexit isn't supported in QW. Overload samelevel +// if ((cvar("noexit") == 1) || ((cvar("noexit") == 2) && (mapname != "start"))) + if ((cvar("samelevel") == 2) || ((cvar("samelevel") == 3) && (mapname != "start"))) + { + T_Damage (other, self, self, 50000, MOD_EXIT); + return; + } + + bprint2 (PRINT_HIGH, other.netname, " exited the level\n"); + + nextmap = self.map; + + SUB_UseTargets (); + + self.touch = SUB_Null; + +// we can't move people right now, because touch functions are called +// in the middle of C movement code, so set a think time to do it + self.think = execute_changelevel; + self.nextthink = time + 0.1; +}; + +/*QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION +When the player touches this, he gets sent to the map listed in the "map" variable. Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission spot and display stats. +*/ +void() trigger_changelevel = +{ + if (!self.map) + objerror ("chagnelevel trigger doesn't have map"); + + InitTrigger (); + self.touch = changelevel_touch; +}; + + +/* +============================================================================= + + PLAYER GAME EDGE FUNCTIONS + +============================================================================= +*/ + +void() set_suicide_frame; + +// create a deadbody ent that is removed over time +void(entity ent) CopyToDeadbody = +{ + local entity deadbody; + + deadbody = spawn(); + deadbody.angles = ent.angles; + deadbody.model = ent.model; + deadbody.modelindex = ent.modelindex; + deadbody.frame = ent.frame; + deadbody.colormap = ent.colormap; + deadbody.movetype = ent.movetype; + deadbody.velocity = ent.velocity; + deadbody.flags = 0; + setorigin (deadbody, ent.origin); + setsize (deadbody, ent.mins, ent.maxs); + + deadbody.think = SUB_Remove; + deadbody.nextthink = time + 30; +}; + +// called by ClientKill and DeadThink +void() respawn = +{ + // make a copy of the dead body for appearances sake + CopyToDeadbody (self); + // set default spawn parms + SetNewParms (); + // respawn + PutClientInServer (); +}; + + +/* +============ +ClientKill + +Player entered the suicide command +============ +*/ +void() PlayerDropStuff; + +void() ClientKill = +{ + if (intermission_running) + return; + + if (self.suicide_time > time) + return; + + bprint2 (PRINT_MEDIUM, self.netname, " suicides\n"); + PlayerDropStuff (); + set_suicide_frame (); + self.modelindex = modelindex_player; + logfrag (self, self); + self.frags = self.frags - 2; // extra penalty + respawn (); +}; + +float(vector v) CheckSpawnPoint = +{ + return FALSE; +}; + +/* +============ +SelectSpawnPoint + +Returns the entity to spawn at +============ +*/ +entity() SelectSpawnPoint = +{ + local entity spot, thing; + local float numspots, totalspots; + local float pcount; + local entity spots; + + numspots = 0; + totalspots = 0; + +// choose a info_player_deathmatch point + +// ok, find all spots that don't have players nearby + + spots = world; + spot = find (world, classname, "info_player_deathmatch"); + while (spot) + { + totalspots = totalspots + 1; + + thing=findradius(spot.origin, 84); + pcount=0; + while (thing) + { + if (thing.classname == "player") + pcount=pcount + 1; + thing=thing.chain; + } + if (pcount == 0) { + spot.goalentity = spots; + spots = spot; + numspots = numspots + 1; + } + + // Get the next spot in the chain + spot = find (spot, classname, "info_player_deathmatch"); + } + totalspots=totalspots - 1; + if (!numspots) { + // ack, they are all full, just pick one at random +// bprint (PRINT_HIGH, "Ackk! All spots are full. Selecting random spawn spot\n"); + totalspots = rint((random() * totalspots)); + spot = find (world, classname, "info_player_deathmatch"); + while (totalspots > 0) { + totalspots = totalspots - 1; + spot = find (spot, classname, "info_player_deathmatch"); + } + return spot; + } + +// We now have the number of spots available on the map in numspots + + // Generate a random number between 1 and numspots + + numspots = numspots - 1; + + numspots = rint((random() * numspots ) ); + + spot = spots; + while (numspots > 0) { + spot = spot.goalentity; + numspots = numspots - 1; + } + return spot; + +}; +void() DecodeLevelParms; +void() PlayerDie; + +/* +=========== +ValidateUser + + +============ +*/ +/* +float(entity e) ValidateUser = +{ + + local string s; + local string userclan; + local float rank, rankmin, rankmax; + +// +// if the server has set "clan1" and "clan2", then it +// is a clan match that will allow only those two clans in +// + s = serverinfo("clan1"); + if (s) + { + userclan = masterinfo(e,"clan"); + if (s == userclan) + return true; + s = serverinfo("clan2"); + if (s == userclan) + return true; + return false; + } + +// +// if the server has set "rankmin" and/or "rankmax" then +// the users rank must be between those two values +// + s = masterinfo (e, "rank"); + rank = stof (s); + + s = serverinfo("rankmin"); + if (s) + { + rankmin = stof (s); + if (rank < rankmin) + return false; + } + s = serverinfo("rankmax"); + if (s) + { + rankmax = stof (s); + if (rankmax < rank) + return false; + } + + return true; +}; +*/ + +/* +=========== +PutClientInServer + +called each time a player enters a new level +============ +*/ +void() PutClientInServer = +{ + dprint("putclientinserver called\n"); + local entity spot; + + self.classname = "player"; + self.health = 100; + self.takedamage = DAMAGE_AIM; + self.solid = SOLID_SLIDEBOX; + self.movetype = MOVETYPE_WALK; + self.show_hostile = 0; + self.max_health = 100; + self.flags = FL_CLIENT; + self.air_finished = time + 12; + self.dmg = 2; // initial water damage + self.super_damage_finished = 0; + self.radsuit_finished = 0; + self.invisible_finished = 0; + self.invincible_finished = 0; + self.effects = 0; + self.invincible_time = 0; + self.suicide_time = time + 3; + + DecodeLevelParms (); + + W_SetCurrentAmmo (); + + self.attack_finished = time; + self.th_pain = player_pain; + self.th_die = PlayerDie; + + self.deadflag = DEAD_NO; + + spot = SelectSpawnPoint (); + + self.origin = spot.origin + '0 0 1'; + self.angles = spot.angles; + self.fixangle = TRUE; // turn this way immediately + +// oh, this is a hack! + setmodel (self, "progs/eyes.mdl"); + modelindex_eyes = self.modelindex; + + setmodel (self, "progs/player.mdl"); + modelindex_player = self.modelindex; + + setsize (self, VEC_HULL_MIN, VEC_HULL_MAX); + + self.view_ofs = '0 0 22'; + +// Mod - Xian (May.20.97) +// Bug where player would have velocity from their last kill + + self.velocity = '0 0 0'; + + player_stand1 (); + + makevectors(self.angles); + spawn_tfog (self.origin + v_forward*20); + + spawn_tdeath (self.origin, self); + + // Set Rocket Jump Modifiers + rj = numberserverinfokey("rj"); + + if (deathmatch == 4) + { + self.ammo_shells = 0; + if (numberserverinfokey("axe") == 0) + { + self.ammo_nails = 255; + self.ammo_shells = 255; + self.ammo_rockets = 255; + self.ammo_cells = 255; + self.items |= IT_NAILGUN + | IT_SUPER_NAILGUN + | IT_SUPER_SHOTGUN + | IT_ROCKET_LAUNCHER + | IT_LIGHTNING; + } + self.items |= IT_ARMOR3 | IT_INVULNERABILITY; + self.items = self.items - (self.items & (IT_ARMOR1 | IT_ARMOR2)); + self.armorvalue = 200; + self.armortype = 0.8; + self.health = 250; + self.invincible_time = 1; + self.invincible_finished = time + 3; + } + + if (deathmatch == 5) + { + self.ammo_nails = 80; + self.ammo_shells = 30; + self.ammo_rockets = 10; + self.ammo_cells = 30; + self.items |= IT_NAILGUN + | IT_SUPER_NAILGUN + | IT_SUPER_SHOTGUN + | IT_ROCKET_LAUNCHER + | IT_GRENADE_LAUNCHER + | IT_LIGHTNING + | IT_ARMOR3 + | IT_INVULNERABILITY; + self.items = self.items - (self.items & (IT_ARMOR1 | IT_ARMOR2)); + self.armorvalue = 200; + self.armortype = 0.8; + self.health = 200; + self.invincible_time = 1; + self.invincible_finished = time + 3; + } + +}; + + +/* +============================================================================= + + QUAKED FUNCTIONS + +============================================================================= +*/ + + +/*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 24) +The normal starting point for a level. +*/ +void() info_player_start = +{ +}; + + +/*QUAKED info_player_start2 (1 0 0) (-16 -16 -24) (16 16 24) +Only used on start map for the return point from an episode. +*/ +void() info_player_start2 = +{ +}; + +/*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 24) +potential spawning position for deathmatch games +*/ +void() info_player_deathmatch = +{ +}; + +/*QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 24) +potential spawning position for coop games +*/ +void() info_player_coop = +{ +}; + +/* +=============================================================================== + +RULES + +=============================================================================== +*/ + +/* +go to the next level for deathmatch +*/ +void() NextLevel = +{ + local entity o; + + if (nextmap != "") + return; // already done + + if (mapname == "start") + { + if (!cvar("registered")) + { + mapname = "e1m1"; + } + else if (!(serverflags & 1)) + { + mapname = "e1m1"; + serverflags = serverflags | 1; + } + else if (!(serverflags & 2)) + { + mapname = "e2m1"; + serverflags = serverflags | 2; + } + else if (!(serverflags & 4)) + { + mapname = "e3m1"; + serverflags = serverflags | 4; + } + else if (!(serverflags & 8)) + { + mapname = "e4m1"; + serverflags = serverflags - 7; + } + + o = spawn(); + o.map = mapname; + } + else + { + // find a trigger changelevel + o = find(world, classname, "trigger_changelevel"); + if (!o || mapname == "start") + { // go back to same map if no trigger_changelevel + o = spawn(); + o.map = mapname; + } + } + + nextmap = o.map; + + if (o.nextthink < time) + { + o.think = execute_changelevel; + o.nextthink = time + 0.1; + } +}; + +/* +============ +CheckRules + +Exit deathmatch games upon conditions +============ +*/ +void() CheckRules = +{ + if (deathmatch && timelimit && time >= timelimit) + NextLevel (); + + if (deathmatch && fraglimit && self.frags >= fraglimit) + NextLevel (); +}; + +//============================================================================ + +void() PlayerDeathThink = +{ + local float forward; + + if ((self.flags & FL_ONGROUND)) + { + forward = vlen (self.velocity); + forward = forward - 20; + if (forward <= 0) + self.velocity = '0 0 0'; + else + self.velocity = forward * normalize(self.velocity); + } + +// wait for all buttons released + if (self.deadflag == DEAD_DEAD) + { + if (self.button2 || self.button1 || self.button0) + return; + self.deadflag = DEAD_RESPAWNABLE; + return; + } + +// wait for any button down + if (!self.button2 && !self.button1 && !self.button0) + return; + + self.button0 = 0; + self.button1 = 0; + self.button2 = 0; + respawn(); +}; + + +void() PlayerJump = +{ + if (self.flags & FL_WATERJUMP) + return; + + if (self.waterlevel >= 2) + { +// play swiming sound + if (self.swim_flag < time) + { + self.swim_flag = time + 1; + if (random() < 0.5) + sound (self, CHAN_BODY, "misc/water1.wav", 1, ATTN_NORM); + else + sound (self, CHAN_BODY, "misc/water2.wav", 1, ATTN_NORM); + } + + return; + } + + if (!(self.flags & FL_ONGROUND)) + return; + + if ( !(self.flags & FL_JUMPRELEASED) ) + return; // don't pogo stick + + self.flags = self.flags - (self.flags & FL_JUMPRELEASED); + self.button2 = 0; + +// player jumping sound + sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM); +#ifdef NETQUAKE + self.flags = self.flags - FL_ONGROUND; + self.velocity_z = self.velocity_z + 270; +#endif +}; + + +/* +=========== +WaterMove + +============ +*/ +.float dmgtime; + +void() WaterMove = +{ +//dprint (ftos(self.waterlevel)); + if (self.movetype == MOVETYPE_NOCLIP) + return; + if (self.health < 0) + return; + + if (self.waterlevel != 3) + { + if (self.air_finished < time) + sound (self, CHAN_VOICE, "player/gasp2.wav", 1, ATTN_NORM); + else if (self.air_finished < time + 9) + sound (self, CHAN_VOICE, "player/gasp1.wav", 1, ATTN_NORM); + self.air_finished = time + 12; + self.dmg = 2; + } + else if (self.air_finished < time) + { // drown! + if (self.pain_finished < time) + { + self.dmg = self.dmg + 2; + if (self.dmg > 15) + self.dmg = 10; + T_Damage (self, world, world, self.dmg, MOD_DROWN); + self.pain_finished = time + 1; + } + } + + if (!self.waterlevel) + { + if (self.flags & FL_INWATER) + { + // play leave water sound + sound (self, CHAN_BODY, "misc/outwater.wav", 1, ATTN_NORM); + self.flags = self.flags - FL_INWATER; + } + return; + } + + if (self.watertype == CONTENT_LAVA) + { // do damage + if (self.dmgtime < time) + { + if (self.radsuit_finished > time) + self.dmgtime = time + 1; + else + self.dmgtime = time + 0.2; + + T_Damage (self, world, world, 10*self.waterlevel, MOD_LAVA); + } + } + else if (self.watertype == CONTENT_SLIME) + { // do damage + if (self.dmgtime < time && self.radsuit_finished < time) + { + self.dmgtime = time + 1; + T_Damage (self, world, world, 4*self.waterlevel, MOD_SLIME); + } + } + + if ( !(self.flags & FL_INWATER) ) + { + +// player enter water sound + + if (self.watertype == CONTENT_LAVA) + sound (self, CHAN_BODY, "player/inlava.wav", 1, ATTN_NORM); + if (self.watertype == CONTENT_WATER) + sound (self, CHAN_BODY, "player/inh2o.wav", 1, ATTN_NORM); + if (self.watertype == CONTENT_SLIME) + sound (self, CHAN_BODY, "player/slimbrn2.wav", 1, ATTN_NORM); + + self.flags = self.flags + FL_INWATER; + self.dmgtime = 0; + } +}; + +void() CheckWaterJump = +{ + local vector start, end; + +// check for a jump-out-of-water + makevectors (self.angles); + start = self.origin; + start_z = start_z + 8; + v_forward_z = 0; + normalize(v_forward); + end = start + v_forward*24; + traceline (start, end, TRUE, self); + if (trace_fraction < 1) + { // solid at waist + start_z = start_z + self.maxs_z - 8; + end = start + v_forward*24; + self.movedir = trace_plane_normal * -50; + traceline (start, end, TRUE, self); + if (trace_fraction == 1) + { // open at eye level + self.flags = self.flags | FL_WATERJUMP; + self.velocity_z = 225; + self.flags = self.flags - (self.flags & FL_JUMPRELEASED); + self.teleport_time = time + 2; // safety net + return; + } + } +}; + +/* +================ +PlayerPreThink + +Called every frame before physics are run +================ +*/ +void() PlayerPreThink = +{ + if (intermission_running) + { + IntermissionThink (); // otherwise a button could be missed between + return; // the think tics + } + +// if intermission is running what is the point of this? +// if (self.view_ofs == '0 0 0') +// return; + + makevectors (self.v_angle); // is this still used + + CheckRules (); + WaterMove (); +/* + if (self.waterlevel == 2) + CheckWaterJump (); +*/ + + if (self.deadflag >= DEAD_DEAD) + { + PlayerDeathThink (); + return; + } + + if (self.deadflag == DEAD_DYING) + return; // dying, so do nothing + + if (self.button2) + PlayerJump (); + else + self.flags = self.flags | FL_JUMPRELEASED; + + if(time > self.attack_finished && self.currentammo == 0 && self.weapon != IT_AXE) + { + self.weapon = W_BestWeapon (); + W_SetCurrentAmmo (); + } +}; + +/* +================ +CheckPowerups + +Check for turning off powerups +================ +*/ +void() CheckPowerups = +{ + if (self.health <= 0) + return; + +// invisibility + if (self.invisible_finished) + { +// sound and screen flash when items starts to run out + if (self.invisible_sound < time) + { + sound (self, CHAN_AUTO, "items/inv3.wav", 0.5, ATTN_IDLE); + self.invisible_sound = time + ((random() * 3) + 1); + } + + + if (self.invisible_finished < time + 3) + { + if (self.invisible_time == 1) + { + sprint1 (self, PRINT_HIGH, "Ring of Shadows magic is fading\n"); + stuffcmd (self, "bf\n"); + sound (self, CHAN_AUTO, "items/inv2.wav", 1, ATTN_NORM); + self.invisible_time = time + 1; + } + + if (self.invisible_time < time) + { + self.invisible_time = time + 1; + stuffcmd (self, "bf\n"); + } + } + + if (self.invisible_finished < time) + { // just stopped + self.items = self.items - IT_INVISIBILITY; + self.invisible_finished = 0; + self.invisible_time = 0; + } + + // use the eyes + self.frame = 0; + self.modelindex = modelindex_eyes; + } + else + self.modelindex = modelindex_player; // don't use eyes + +// invincibility + if (self.invincible_finished) + { +// sound and screen flash when items starts to run out + if (self.invincible_finished < time + 3) + { + if (self.invincible_time == 1) + { + sprint1 (self, PRINT_HIGH, "Protection is almost burned out\n"); + stuffcmd (self, "bf\n"); + sound (self, CHAN_AUTO, "items/protect2.wav", 1, ATTN_NORM); + self.invincible_time = time + 1; + } + + if (self.invincible_time < time) + { + self.invincible_time = time + 1; + stuffcmd (self, "bf\n"); + } + } + + if (self.invincible_finished < time) + { // just stopped + self.items = self.items - IT_INVULNERABILITY; + self.invincible_time = 0; + self.invincible_finished = 0; + } + if (self.invincible_finished > time) + self.effects = self.effects | ef_pent; + else + self.effects = self.effects - (self.effects & ef_pent); + } + +// super damage + if (self.super_damage_finished) + { + +// sound and screen flash when items starts to run out + + if (self.super_damage_finished < time + 3) + { + if (self.super_time == 1) + { + if (deathmatch == 4) + sprint1 (self, PRINT_HIGH, "OctaPower is wearing off\n"); + else + sprint1 (self, PRINT_HIGH, "Quad Damage is wearing off\n"); + stuffcmd (self, "bf\n"); + sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM); + self.super_time = time + 1; + } + + if (self.super_time < time) + { + self.super_time = time + 1; + stuffcmd (self, "bf\n"); + } + } + + if (self.super_damage_finished < time) + { // just stopped + self.items = self.items - IT_QUAD; + if (deathmatch == 4) + { + self.ammo_cells = 255; + self.armorvalue = 1; + self.armortype = 0.8; + self.health = 100; + } + self.super_damage_finished = 0; + self.super_time = 0; + } + if (self.super_damage_finished > time) + self.effects = self.effects | ef_quad; + else + self.effects = self.effects - (self.effects & ef_quad); + } + +// suit + if (self.radsuit_finished) + { + self.air_finished = time + 12; // don't drown + +// sound and screen flash when items starts to run out + if (self.radsuit_finished < time + 3) + { + if (self.rad_time == 1) + { + sprint1 (self, PRINT_HIGH, "Air supply in Biosuit expiring\n"); + stuffcmd (self, "bf\n"); + sound (self, CHAN_AUTO, "items/suit2.wav", 1, ATTN_NORM); + self.rad_time = time + 1; + } + + if (self.rad_time < time) + { + self.rad_time = time + 1; + stuffcmd (self, "bf\n"); + } + } + + if (self.radsuit_finished < time) + { // just stopped + self.items = self.items - IT_SUIT; + self.rad_time = 0; + self.radsuit_finished = 0; + } + } + +}; + + +/* +================ +PlayerPostThink + +Called every frame after physics are run +================ +*/ +void() PlayerPostThink = +{ +//dprint ("post think\n"); + if (intermission_running) + return; +// if (self.view_ofs == '0 0 0') +// return; + if (self.deadflag) + return; + +// check to see if player landed and play landing sound + if ((self.jump_flag < -300) && (self.flags & FL_ONGROUND) ) + { + if (self.watertype == CONTENT_WATER) + sound (self, CHAN_BODY, "player/h2ojump.wav", 1, ATTN_NORM); + else if (self.jump_flag < -650) + { + T_Damage (self, world, world, 5, MOD_FALL); + sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM); + } + else + sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM); + } + + self.jump_flag = self.velocity_z; + + CheckPowerups (); + + W_WeaponFrame (); + + // decay health + if (self.healdecay < time) + { + if (self.health > self.max_health) + self.health = self.health - 1; + self.healdecay = time + 1; + } +}; + + +/* +=========== +ClientConnect + +called when a player connects to a server +============ +*/ +void() ClientConnect = +{ + bprint2 (PRINT_HIGH, self.netname, " entered the game\n"); + +// a client connecting during an intermission can cause problems + if (intermission_running) + GotoNextMap (); +}; + + +/* +=========== +ClientDisconnect + +called when a player disconnects from a server +============ +*/ +void() ClientDisconnect = +{ + // let everyone else know + bprint4 (PRINT_HIGH, self.netname, " left the game with ", ftos(self.frags), " frags\n"); + sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE); + set_suicide_frame (); +}; + +/* +=========== +ClientObituary + +called when a player dies +============ +*/ +float(entity targ, entity attacker) OnSameTeam; + +void(entity targ, entity attacker, INTEGER mod) ClientObituary = +{ + if (attacker.classname == "player") + { + if (attacker == targ) + { + SuicideMessage(targ.netname, mod); + targ.frags = targ.frags - 1; + logfrag(targ, targ); + return; + } // else if anything else + + if (OnSameTeam(targ, attacker)) + { + TeamKillMessage(targ.netname, attacker.netname, mod); + logfrag(attacker, attacker); + attacker.frags = attacker.frags - 1; + return; + } + + KillMessage(targ.netname, attacker.netname, mod); + if (targ.classname == "player") + { + attacker.frags = attacker.frags + 1; + logfrag(attacker, targ); + } + return; + } // else if attacker != player + + if (attacker.netname == "") + { + WorldKillMessage(targ.netname, mod); + if (targ.classname == "player") + { + targ.frags = targ.frags - 1; + logfrag(targ, targ); + } + return; + } + + // monster kill, but still consider it a suicide for score purposes + KillMessage(targ.netname, attacker.netname, mod); + targ.frags = targ.frags - 1; + logfrag(targ, targ); +}; + diff --git a/quakec/basemod/combat.qc b/quakec/basemod/combat.qc new file mode 100644 index 000000000..e2662c664 --- /dev/null +++ b/quakec/basemod/combat.qc @@ -0,0 +1,325 @@ + +void() T_MissileTouch; +void() info_player_start; +void(entity targ, entity attacker, INTEGER mod) ClientObituary; +void(entity inflictor, entity attacker, float damage, entity ignore, INTEGER mod) T_RadiusDamage; + +/*SERVER +void() monster_death_use; +*/ + +//============================================================================ + +/* +============ +CanDamage + +Returns true if the inflictor can directly damage the target. Used for +explosions and melee attacks. +============ +*/ +float(entity targ, entity inflictor) CanDamage = +{ +// bmodels need special checking because their origin is 0,0,0 + if (targ.movetype == MOVETYPE_PUSH) + { + traceline(inflictor.origin, 0.5 * (targ.absmin + targ.absmax), TRUE, self); + if (trace_fraction == 1) + return TRUE; + if (trace_ent == targ) + return TRUE; + return FALSE; + } + + traceline(inflictor.origin, targ.origin, TRUE, self); + if (trace_fraction == 1) + return TRUE; + traceline(inflictor.origin, targ.origin + '15 15 0', TRUE, self); + if (trace_fraction == 1) + return TRUE; + traceline(inflictor.origin, targ.origin + '-15 -15 0', TRUE, self); + if (trace_fraction == 1) + return TRUE; + traceline(inflictor.origin, targ.origin + '-15 15 0', TRUE, self); + if (trace_fraction == 1) + return TRUE; + traceline(inflictor.origin, targ.origin + '15 -15 0', TRUE, self); + if (trace_fraction == 1) + return TRUE; + + return FALSE; +}; + + +/* +============ +Killed +============ +*/ +void(entity targ, entity attacker, INTEGER mod) Killed = +{ + local entity oself; + + oself = self; + self = targ; + + if (self.health < -99) + self.health = -99; // don't let sbar look bad if a player + + self.enemy = attacker; + + if (self.movetype == MOVETYPE_PUSH || self.movetype == MOVETYPE_NONE) + { // doors, triggers, etc + self.th_die (); + self = oself; + return; + } + +// bump the monster counter + if (self.flags & FL_MONSTER) + { + killed_monsters = killed_monsters + 1; + WriteByte (MSG_ALL, SVC_KILLEDMONSTER); + } + + ClientObituary(self, attacker, mod); + + self.takedamage = DAMAGE_NO; + self.touch = SUB_Null; + self.effects = 0; + +/*SERVER + monster_death_use(); +*/ + self.th_die (); + + self = oself; +}; + +/* +OnSameTeam +*/ +float(entity targ, entity attacker) OnSameTeam = +{ +#ifndef NETQUAKE + local string targteam; + local string attackerteam; +#endif + + if (attacker == targ) + return TRUE; + + if (targ.classname != "player" || attacker.classname != "player") + return FALSE; + + if (teamplay == 0) + return FALSE; + +#ifdef NETQUAKE +// NQ team check + if (!targ.team) + return FALSE; + + if (targ.team == attacker.team) + return TRUE; +#else +// QW team check + targteam = stringclientinfokey(targ, "team"); + attackerteam = stringclientinfokey(attacker, "team"); + + if (targteam == "") + return FALSE; + + if (targteam == attackerteam) + return TRUE; +#endif + + return FALSE; +}; + +/* +DisallowFriendlyFire +*/ +float(entity targ, entity attacker, INTEGER mod) DisallowFriendlyFire = +{ + if (targ == attacker && teamplay != 1) + return FALSE; + + if (OnSameTeam(targ, attacker) && (teamplay == 1 || teamplay == 3)) + return TRUE; + + return FALSE; +}; + +/* +============ +T_Damage + +The damage is coming from inflictor, but get mad at attacker +This should be the only function that ever reduces health. +============ +*/ +void(entity targ, entity inflictor, entity attacker, float damage, INTEGER mod) T_Damage= +{ + local vector dir; + local entity oldself; + local float save; + local float take; + + if (!targ.takedamage) + return; + +// used by buttons and triggers to set activator for target firing + damage_attacker = attacker; + +// set mod + damage_mod = mod; + +// check for quad damage powerup on the attacker + if (attacker.super_damage_finished > time && inflictor.classname != "door") + if (deathmatch == 4) + damage = damage * 8; + else + damage = damage * 4; + +// save damage based on the target's armor level + + save = ceil(targ.armortype*damage); + if (save >= targ.armorvalue) + { + save = targ.armorvalue; + targ.armortype = 0; // lost all armor + targ.items = targ.items - (targ.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)); + } + + targ.armorvalue = targ.armorvalue - save; + take = ceil(damage-save); + +// add to the damage total for clients, which will be sent as a single +// message at the end of the frame +// FIXME: remove after combining shotgun blasts? + if (targ.flags & FL_CLIENT) + { + targ.dmg_take = targ.dmg_take + take; + targ.dmg_save = targ.dmg_save + save; + targ.dmg_inflictor = inflictor; + } + + damage_inflictor = inflictor; + + +// figure momentum add + if ( (inflictor != world) && (targ.movetype == MOVETYPE_WALK) ) + { + dir = targ.origin - (inflictor.absmin + inflictor.absmax) * 0.5; + dir = normalize(dir); + // Set kickback for smaller weapons +//Zoid -- use normal NQ kickback +// // Read: only if it's not yourself doing the damage +// if ( (damage < 60) & ((attacker.classname == "player") & (targ.classname == "player")) & ( attacker.netname != targ.netname)) +// targ.velocity = targ.velocity + dir * damage * 11; +// else + // Otherwise, these rules apply to rockets and grenades + // for blast velocity + targ.velocity = targ.velocity + dir * damage * 8; + + // Rocket Jump modifiers + if ( (rj > 1) & ((attacker.classname == "player") & (targ.classname == "player")) & ( attacker == targ)) + targ.velocity = targ.velocity + dir * damage * rj; + + } + + + +// check for godmode or invincibility + if (targ.flags & FL_GODMODE) + return; + if (targ.invincible_finished >= time) + { + if (self.invincible_sound < time) + { + sound (targ, CHAN_ITEM, "items/protect3.wav", 1, ATTN_NORM); + self.invincible_sound = time + 2; + } + return; + } + +// team play damage avoidance + if (DisallowFriendlyFire(targ, attacker, mod)) + return; + +// do the damage + targ.health = targ.health - take; + + if (targ.health <= 0) + { + Killed (targ, attacker, mod); + return; + } + +// react to the damage + oldself = self; + self = targ; + +/*SERVER + if ( (self.flags & FL_MONSTER) && attacker != world) + { + // get mad unless of the same class (except for soldiers) + if (self != attacker && attacker != self.enemy) + { + if ( (self.classname != attacker.classname) + || (self.classname == "monster_army" ) ) + { + if (self.enemy.classname == "player") + self.oldenemy = self.enemy; + self.enemy = attacker; + FoundTarget (); + } + } + } +*/ + if (self.th_pain) + { + self.th_pain (attacker, take); + } + + self = oldself; +}; + +/* +============ +T_RadiusDamage +============ +*/ +void(entity inflictor, entity attacker, float damage, entity ignore, INTEGER mod) T_RadiusDamage = +{ + local float points; + local entity head; + local vector org; + + head = findradius(inflictor.origin, damage+40); + + while (head) + { + if (head != ignore) + { + if (head.takedamage) + { + org = head.origin + (head.mins + head.maxs)*0.5; + points = 0.5*vlen (inflictor.origin - org); + if (points < 0) + points = 0; + points = damage - points; + + if (head == attacker) + points = points * 0.5; + if (points > 0) + { + if (CanDamage (head, inflictor)) + T_Damage (head, inflictor, attacker, points, mod); + } + } + } + head = head.chain; + } +}; diff --git a/quakec/basemod/defs.qc b/quakec/basemod/defs.qc new file mode 100644 index 000000000..93fdb7ea9 --- /dev/null +++ b/quakec/basemod/defs.qc @@ -0,0 +1,782 @@ + +// uncomment based on desired compile +// #define NETQUAKE +// #define FTE + +#ifdef FTE +#pragma target fte +#pragma PROGS_DAT fteprogs.dat +// use real ints +#define INTEGER int +#else + +// if netquake, use progs.dat file name +#ifdef NETQUAKE +#pragma PROGS_DAT progs.dat +#endif + +#define INTEGER float +#endif + + +#define FALSE 0 +#define TRUE 1 + +/* +============================================================================== + + SOURCE FOR GLOBALVARS_T C STRUCTURE + +============================================================================== +*/ + +// +// system globals +// +entity self; +entity other; +entity world; +float time; +float frametime; + +#ifndef NETQUAKE +entity newmis; // if this is set, the entity that just + // run created a new missile that should + // be simulated immediately +#endif + +float force_retouch; // force all entities to touch triggers + // next frame. this is needed because + // non-moving things don't normally scan + // for triggers, and when a trigger is + // created (like a teleport trigger), it + // needs to catch everything. + // decremented each frame, so set to 2 + // to guarantee everything is touched +string mapname; + +#ifdef NETQUAKE +float deathmatch; +float coop; +float teamplay; +#endif + +float serverflags; // propagated from level to level, used to + // keep track of completed episodes + +float total_secrets; +float total_monsters; + +float found_secrets; // number of secrets found +float killed_monsters; // number of monsters killed + + +// spawnparms are used to encode information about clients across server +// level changes +float parm1, parm2, parm3, parm4, parm5, parm6, parm7, parm8, parm9, parm10, parm11, parm12, parm13, parm14, parm15, parm16; + +// +// global variables set by built in functions +// +vector v_forward, v_up, v_right; // set by makevectors() + +// set by traceline / tracebox +float trace_allsolid; +float trace_startsolid; +float trace_fraction; +vector trace_endpos; +vector trace_plane_normal; +float trace_plane_dist; +entity trace_ent; +float trace_inopen; +float trace_inwater; + +entity msg_entity; // destination of single entity writes + +// +// required prog functions +// +void() main; // only for testing + +void() StartFrame; + +void() PlayerPreThink; +void() PlayerPostThink; + +void() ClientKill; +void() ClientConnect; +void() PutClientInServer; // call after setting the parm1... parms +void() ClientDisconnect; + +void() SetNewParms; // called when a client first connects to + // a server. sets parms so they can be + // saved off for restarts + +void() SetChangeParms; // call to set parms for self so they can + // be saved for a level transition + + +//================================================ +void end_sys_globals; // flag for structure dumping +//================================================ + +/* +============================================================================== + + SOURCE FOR ENTVARS_T C STRUCTURE + +============================================================================== +*/ + +// +// system fields (*** = do not set in prog code, maintained by C code) +// +.float modelindex; // *** model index in the precached list +.vector absmin, absmax; // *** origin + mins / maxs + +.float ltime; // local time for entity +#ifndef NETQUAKE +.float lastruntime; // *** to allow entities to run out of sequence +#endif + +.float movetype; +.float solid; + +.vector origin; // *** +.vector oldorigin; // *** +.vector velocity; +.vector angles; +.vector avelocity; + +#ifdef NETQUAKE +.vector punchangle; +#endif + +.string classname; // spawn function +.string model; +.float frame; +.float skin; +.float effects; + +.vector mins, maxs; // bounding box extents reletive to origin +.vector size; // maxs - mins + +.void() touch; +.void() use; +.void() think; +.void() blocked; // for doors or plats, called when can't push other + +.float nextthink; +.entity groundentity; + + + +// stats +.float health; +.float frags; +.float weapon; // one of the IT_SHOTGUN, etc flags +.string weaponmodel; +.float weaponframe; +.float currentammo; +.float ammo_shells, ammo_nails, ammo_rockets, ammo_cells; + +.float items; // bit flags + +.float takedamage; +.entity chain; +.float deadflag; + +.vector view_ofs; // add to origin to get eye point + + +.float button0; // fire +.float button1; // use +.float button2; // jump + +.float impulse; // weapon changes + +.float fixangle; +.vector v_angle; // view / targeting angle for players + +#ifdef NETQUAKE +.float idealpitch; +#endif + +.string netname; + +.entity enemy; + +.float flags; + +.float colormap; +.float team; + +.float max_health; // players maximum health is stored here + +.float teleport_time; // don't back up + +.float armortype; // save this fraction of incoming damage +.float armorvalue; + +.float waterlevel; // 0 = not in, 1 = feet, 2 = wast, 3 = eyes +.float watertype; // a contents value + +.float ideal_yaw; +.float yaw_speed; + +.entity aiment; + +.entity goalentity; // a movetarget or an enemy + +.float spawnflags; + +.string target; +.string targetname; + +// damage is accumulated through a frame. and sent as one single +// message, so the super shotgun doesn't generate huge messages +.float dmg_take; +.float dmg_save; +.entity dmg_inflictor; + +.entity owner; // who launched a missile +.vector movedir; // mostly for doors, but also used for waterjump + +.string message; // trigger messages + +.float sounds; // either a cd track number or sound number + +.string noise, noise1, noise2, noise3; // contains names of wavs to play + +//================================================ +void end_sys_fields; // flag for structure dumping +//================================================ + +/* +============================================================================== + + VARS NOT REFERENCED BY C CODE + +============================================================================== +*/ + + +// +// constants +// + +// edict.flags +#define FL_FLY 1 +#define FL_SWIM 2 +#define FL_CLIENT 8 // set for all client edicts +#define FL_INWATER 16 // for enter / leave water splash +#define FL_MONSTER 32 +#define FL_GODMODE 64 // player cheat +#define FL_NOTARGET 128 // player cheat +#define FL_ITEM 256 // extra wide size for bonus items +#define FL_ONGROUND 512 // standing on something +#define FL_PARTIALGROUND 1024 // not all corners are valid +#define FL_WATERJUMP 2048 // player jumping out of water +#define FL_JUMPRELEASED 4096 // for jump debouncing + +// edict.movetype values +#define MOVETYPE_NONE 0 // never moves +#define MOVETYPE_WALK 3 // players only +#define MOVETYPE_STEP 4 // discrete, not real time unless fall +#define MOVETYPE_FLY 5 +#define MOVETYPE_TOSS 6 +#define MOVETYPE_PUSH 7 // no clip to world, push and crush +#define MOVETYPE_NOCLIP 8 +#define MOVETYPE_FLYMISSILE 9 // fly with extra size against monsters +#define MOVETYPE_BOUNCE 10 +#define MOVETYPE_BOUNCEMISSILE 11 // bounce with extra size + +// edict.solid values +#define SOLID_NOT 0 // no interaction with other objects +#define SOLID_TRIGGER 1 // touch on edge, but not blocking +#define SOLID_BBOX 2 // touch on edge, block +#define SOLID_SLIDEBOX 3 // touch on edge, but not an onground +#define SOLID_BSP 4 // bsp clip, touch on edge, block + +// range values +/* +float RANGE_MELEE = 0; +float RANGE_NEAR = 1; +float RANGE_MID = 2; +float RANGE_FAR = 3; +*/ + +// deadflag values +#define DEAD_NO 0 +#define DEAD_DYING 1 +#define DEAD_DEAD 2 +#define DEAD_RESPAWNABLE 3 + +// takedamage values +#define DAMAGE_NO 0 +#define DAMAGE_YES 1 +#define DAMAGE_AIM 2 + +// items +float IT_AXE = 4096; +float IT_SHOTGUN = 1; +float IT_SUPER_SHOTGUN = 2; +float IT_NAILGUN = 4; +float IT_SUPER_NAILGUN = 8; +float IT_GRENADE_LAUNCHER = 16; +float IT_ROCKET_LAUNCHER = 32; +float IT_LIGHTNING = 64; +float IT_EXTRA_WEAPON = 128; + +float IT_SHELLS = 256; +float IT_NAILS = 512; +float IT_ROCKETS = 1024; +float IT_CELLS = 2048; + +float IT_ARMOR1 = 8192; +float IT_ARMOR2 = 16384; +float IT_ARMOR3 = 32768; +float IT_SUPERHEALTH = 65536; + +float IT_KEY1 = 131072; +float IT_KEY2 = 262144; + +float IT_INVISIBILITY = 524288; +float IT_INVULNERABILITY = 1048576; +float IT_SUIT = 2097152; +float IT_QUAD = 4194304; + +// point content values + +float CONTENT_EMPTY = -1; +float CONTENT_SOLID = -2; +float CONTENT_WATER = -3; +float CONTENT_SLIME = -4; +float CONTENT_LAVA = -5; +float CONTENT_SKY = -6; + +float STATE_TOP = 0; +float STATE_BOTTOM = 1; +float STATE_UP = 2; +float STATE_DOWN = 3; + +vector VEC_ORIGIN = '0 0 0'; +vector VEC_HULL_MIN = '-16 -16 -24'; +vector VEC_HULL_MAX = '16 16 32'; + +vector VEC_HULL2_MIN = '-32 -32 -24'; +vector VEC_HULL2_MAX = '32 32 64'; + +// protocol bytes +float SVC_TEMPENTITY = 23; +float SVC_KILLEDMONSTER = 27; +float SVC_FOUNDSECRET = 28; +float SVC_INTERMISSION = 30; +float SVC_FINALE = 31; +float SVC_CDTRACK = 32; +float SVC_SELLSCREEN = 33; +float SVC_SMALLKICK = 34; +float SVC_BIGKICK = 35; +float SVC_MUZZLEFLASH = 39; + + +float TE_SPIKE = 0; +float TE_SUPERSPIKE = 1; +float TE_GUNSHOT = 2; +float TE_EXPLOSION = 3; +float TE_TAREXPLOSION = 4; +float TE_LIGHTNING1 = 5; +float TE_LIGHTNING2 = 6; +float TE_WIZSPIKE = 7; +float TE_KNIGHTSPIKE = 8; +float TE_LIGHTNING3 = 9; +float TE_LAVASPLASH = 10; +float TE_TELEPORT = 11; +float TE_BLOOD = 12; +float TE_LIGHTNINGBLOOD = 13; + +// sound channels +// channel 0 never willingly overrides +// other channels (1-7) allways override a playing sound on that channel +#define CHAN_AUTO 0 +#define CHAN_WEAPON 1 +#define CHAN_VOICE 2 +#define CHAN_ITEM 3 +#define CHAN_BODY 4 +// chan_no_phs_add is defined in engine.qc + +#define ATTN_NONE 0.0 // no volume fall off due to range +#define ATTN_NORM 1.0 // small volume fall off (1000 range) +#define ATTN_IDLE 2.0 // medium volume fall off (500 range) +#define ATTN_STATIC 3.0 // large volume fall oof (333 range) + +// entity effects + +//float EF_BRIGHTFIELD = 1; +float EF_MUZZLEFLASH = 2; +float EF_BRIGHTLIGHT = 4; +float EF_DIMLIGHT = 8; +float EF_FLAG1 = 16; +float EF_FLAG2 = 32; +// GLQuakeWorld Stuff +// float EF_BLUE = 64; // Blue Globe effect for Quad +// float EF_RED = 128; // Red Globe effect for Pentagram +// messages +#define MSG_BROADCAST 0 // unreliable to all +#define MSG_ONE 1 // reliable to one (msg_entity) +#define MSG_ALL 2 // reliable to all +#define MSG_INIT 3 // write to the init string +#define MSG_MULTICAST 4 // for multicast() call + +// message levels +#define PRINT_LOW 0 +#define PRINT_MEDIUM 1 +#define PRINT_HIGH 2 +#define PRINT_CHAT 3 + +// multicast sets +float MULTICAST_ALL = 0; // every client +float MULTICAST_PHS = 1; // within hearing +float MULTICAST_PVS = 2; // within sight +float MULTICAST_ALL_R = 3; // every client, reliable +float MULTICAST_PHS_R = 4; // within hearing, reliable +float MULTICAST_PVS_R = 5; // within sight, reliable + + + + +//================================================ + +// +// globals +// +// float movedist; + +string string_null; // null string, nothing should be held here +float empty_float; + +entity activator; // the entity that activated a trigger or brush + +entity damage_attacker; // set by T_Damage +entity damage_inflictor; // set by T_Damage +INTEGER damage_mod; // set by T_Damage + + +float framecount; + +// +// cvars checked each frame +// +float timelimit; +float fraglimit; +float rj; + +#ifndef NETQUAKE +// these variables are not a part of QW's system fields +float deathmatch; +float coop; +float teamplay; +#endif + +float skill; + +//================================================ + +// +// world fields (FIXME: make globals) +// +.string wad; +.string map; +.float worldtype; // 0=medieval 1=metal 2=base +#define WT_MEDIEVAL 0 +#define WT_METAL 1 +#define WT_BASE 2 + +//================================================ + +.string killtarget; + +// +// quakeed fields +// +.float light_lev; // not used by game, but parsed by light util +.float style; + + +// +// monster ai +// +.void(entity attacker, float damage) th_pain; +.void() th_die; +.void() th_stand; + +.void() th_walk; +.void() th_run; +.void() th_missile; +.void() th_melee; + +/* +.entity oldenemy; + +.float search_time; +.float attack_state; + +float AS_STRAIGHT = 1; +float AS_SLIDING = 2; +float AS_MELEE = 3; +float AS_MISSILE = 4; +*/ + +.float speed; + +// +// player only fields +// +.float voided; +.float walkframe; + +// Zoid Additions +.float maxspeed; // Used to set Maxspeed on a player +.float gravity; // Gravity Multiplier (0 to 1.0) + +.float attack_finished; +.float pain_finished; + +.float invincible_finished; +.float invisible_finished; +.float super_damage_finished; +.float radsuit_finished; + +.float invincible_time, invincible_sound; +.float invisible_time, invisible_sound; +.float super_time, super_sound; +.float rad_time; + +.float jump_flag; // player jump flag +.float swim_flag; // player swimming sound flag +.float air_finished; // when time > air_finished, start drowning + +// +// object stuff +// +.vector mangle; // angle at start + +// +// doors, etc +// +.vector dest, dest1, dest2; +// .float wait, see unions +// .float delay, see unions +.entity trigger_field; // door's trigger entity +.string noise4; + +// +// doors +// +.float dmg; // damage done by door when hit + +// +// misc +// +.float cnt; // misc flag + +// +// plats / doors / buttons +// +.float lip; +.float state; +.vector pos1, pos2; // top and bottom positions +.float height; + +// +// sounds +// + +// heal stuff +#define H_ROTTEN 1 +#define H_MEGA 2 + +// intermission +float intermission_running; +float intermission_exittime; + +#ifdef NETQUAKE +entity newmis; +#endif + +// unions +// DO NOT MIX UNION TYPES LIKE I AM DOING +.union { + struct { // fields used with triggers/doors/plats + float delay; // time from activation to firing + float wait; // time from firing to restarting + float t_length; // override length to move sideways + float t_width; // override length to move upwards/downwards + void() think1; // used with SUB_CalcMove + vector finaldest; // used with SUB_CalcMove + vector finalangle;// used with SUB_CalcMove + float count; // for counting triggers + }; + struct { // fields used with players + float weaponframe_time; // weapon frame advance time + float suicide_time; // time to allow suicide after spawn + float healdecay; // time when health will decay + float show_hostile; // used to alert monsters + float lsound_time; // used for lightning sound playback + float fly_sound; // used with trigger_push and maintaining wind sound + }; + struct { // fields used with bubbles spawned from drowning + float bubble_count; // keeps track of the number of bubbles + }; + struct { // fields used with items + float healamount; // amount healed with health item + float healtype; // type of health with health item + string mdl; // model used with SUB_regen + float ammo_count; // ammo amount + }; + struct { // fields used with monsters + float pausetime; // time to pause for monsters + entity movetarget; // target entity to move to + }; + // fields used with ambient sounds? + /* + struct { + float waitmin; + float waitmax; + float distance; + float volume; + }; + */ +}; + +//=========================================================================== + + +// +// builtin functions +// + +void(vector ang) makevectors = #1; // sets v_forward, etc globals +void(entity e, vector o) setorigin = #2; +void(entity e, string m) setmodel = #3; // set movetype and solid first +void(entity e, vector min, vector max) setsize = #4; +// #5 was removed +void() break = #6; +float() random = #7; // returns 0 - 1 +void(entity e, float chan, string samp, float vol, float atten) sound = #8; +vector(vector v) normalize = #9; +void(string e) error = #10; +void(string e) objerror = #11; +float(vector v) vlen = #12; +float(vector v) vectoyaw = #13; +entity() spawn = #14; +void(entity e) remove = #15; + +// sets trace_* globals +// nomonsters can be: +// An entity will also be ignored for testing if forent == test, +// forent->owner == test, or test->owner == forent +// a forent of world is ignored +void(vector v1, vector v2, float nomonsters, entity forent) traceline = #16; + +entity() checkclient = #17; // returns a client to look for +entity(entity start, .string fld, string match) find = #18; +string(string s) precache_sound = #19; +string(string s) precache_model = #20; +void(entity client, string s)stuffcmd = #21; +entity(vector org, float rad) findradius = #22; +// bprint moved to engine.qc +// sprint moved to engine.qc +void(string s) dprint = #25; +string(float f) ftos = #26; +string(vector v) vtos = #27; +void() coredump = #28; // prints all edicts +void() traceon = #29; // turns statment trace on +void() traceoff = #30; +void(entity e) eprint = #31; // prints an entire edict +float(float yaw, float dist) walkmove = #32; // returns TRUE or FALSE +// #33 was removed +float() droptofloor= #34; // TRUE if landed on floor +void(float style, string value) lightstyle = #35; +float(float v) rint = #36; // round to nearest int +float(float v) floor = #37; // largest integer <= v +float(float v) ceil = #38; // smallest integer >= v +// #39 was removed +float(entity e) checkbottom = #40; // true if self is on ground +float(vector v) pointcontents = #41; // returns a CONTENT_* +// #42 was removed +float(float f) fabs = #43; +vector(entity e, float speed) aim = #44; // returns the shooting vector +// cvar moved to engine.qc +void(string s) localcmd = #46; // put string into local que +entity(entity e) nextent = #47; // for looping through all ents +// #48 was removed +void() ChangeYaw = #49; // turn towards self.ideal_yaw + // at self.yaw_speed +// #50 was removed +vector(vector v) vectoangles = #51; + +// +// direct client message generation +// +void(float to, float f) WriteByte = #52; +void(float to, float f) WriteChar = #53; +void(float to, float f) WriteShort = #54; +void(float to, float f) WriteLong = #55; +void(float to, float f) WriteCoord = #56; +void(float to, float f) WriteAngle = #57; +void(float to, string s) WriteString = #58; +void(float to, entity s) WriteEntity = #59; + +// several removed + +void(float step) movetogoal = #67; + +string(string s) precache_file = #68; // no effect except for -copy +void(entity e) makestatic = #69; +void(string s) changelevel = #70; + +//#71 was removed + +void(string var, string val) cvar_set = #72; // sets cvar.value + +void(entity client, string s) centerprint = #73; // sprint, but in middle + +void(vector pos, string samp, float vol, float atten) ambientsound = #74; + +string(string s) precache_model2 = #75; // registered version only +string(string s) precache_sound2 = #76; // registered version only +string(string s) precache_file2 = #77; // registered version only + +void(entity e) setspawnparms = #78; // set parm1... to the + // values at level start + // for coop respawn +// logfrag moved to engine.qc +// infokey moved to engine.qc +// stof moved to engine.qc + +//============================================================================ + +// +// subs.qc +// +void(vector tdest, float tspeed, void() func) SUB_CalcMove; +void(entity ent, vector tdest, float tspeed, void() func) SUB_CalcMoveEnt; +void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove; +void() SUB_CalcMoveDone; +void() SUB_CalcAngleMoveDone; +void() SUB_Null; +void() SUB_UseTargets; +void() SUB_Remove; + +// +// combat.qc +// +void(entity targ, entity inflictor, entity attacker, float damage, INTEGER mod) T_Damage; + + +float (entity e, float healamount, float ignore) T_Heal; // health function + +float(entity targ, entity inflictor) CanDamage; + + diff --git a/quakec/basemod/doors.qc b/quakec/basemod/doors.qc new file mode 100644 index 000000000..9f05c65ea --- /dev/null +++ b/quakec/basemod/doors.qc @@ -0,0 +1,770 @@ + +float DOOR_START_OPEN = 1; +float DOOR_DONT_LINK = 4; +float DOOR_GOLD_KEY = 8; +float DOOR_SILVER_KEY = 16; +float DOOR_TOGGLE = 32; + +/* + +Doors are similar to buttons, but can spawn a fat trigger field around them +to open without a touch, and they link together to form simultanious +double/quad doors. + +Door.owner is the master door. If there is only one door, it points to itself. +If multiple doors, all will point to a single one. + +Door.enemy chains from the master door through all doors linked in the chain. + +*/ + +/* +============================================================================= + +THINK FUNCTIONS + +============================================================================= +*/ + +void() door_go_down; +void() door_go_up; + +void() door_blocked = +{ + T_Damage (other, self, self.goalentity, self.dmg, MOD_SQUISH); + +// if a door has a negative wait, it would never come back if blocked, +// so let it just squash the object to death real fast + if (self.wait >= 0) + { + if (self.state == STATE_DOWN) + door_go_up (); + else + door_go_down (); + } +}; + + +void() door_hit_top = +{ + sound (self, chan_no_phs_add|CHAN_VOICE, self.noise1, 1, ATTN_NORM); + self.state = STATE_TOP; + if (self.spawnflags & DOOR_TOGGLE) + return; // don't come down automatically + self.think = door_go_down; + self.nextthink = self.ltime + self.wait; +}; + +void() door_hit_bottom = +{ + sound (self, chan_no_phs_add|CHAN_VOICE, self.noise1, 1, ATTN_NORM); + self.state = STATE_BOTTOM; +}; + +void() door_go_down = +{ + sound (self, CHAN_VOICE, self.noise2, 1, ATTN_NORM); + if (self.max_health) + { + self.takedamage = DAMAGE_YES; + self.health = self.max_health; + } + + self.state = STATE_DOWN; + SUB_CalcMove (self.pos1, self.speed, door_hit_bottom); +}; + +void() door_go_up = +{ + if (self.state == STATE_UP) + return; // allready going up + + if (self.state == STATE_TOP) + { // reset top wait time + self.nextthink = self.ltime + self.wait; + return; + } + + sound (self, CHAN_VOICE, self.noise2, 1, ATTN_NORM); + self.state = STATE_UP; + SUB_CalcMove (self.pos2, self.speed, door_hit_top); + + SUB_UseTargets(); +}; + + +/* +============================================================================= + +ACTIVATION FUNCTIONS + +============================================================================= +*/ + +void() door_fire = +{ + local entity oself; + local entity starte; + + if (self.owner != self) + objerror ("door_fire: self.owner != self"); + +// play use key sound + + if (self.items) + sound (self, CHAN_ITEM, self.noise4, 1, ATTN_NORM); + + self.message = string_null; // no more message + oself = self; + + if (self.spawnflags & DOOR_TOGGLE) + { + if (self.state == STATE_UP || self.state == STATE_TOP) + { + starte = self; + do + { + door_go_down (); + self = self.enemy; + } while ( (self != starte) && (self != world) ); + self = oself; + return; + } + } + +// trigger all paired doors + starte = self; + + do + { + self.goalentity = activator; // Who fired us + door_go_up (); + self = self.enemy; + } while ( (self != starte) && (self != world) ); + self = oself; +}; + + +void() door_use = +{ + local entity oself; + + self.message = ""; // door message are for touch only + self.owner.message = ""; + self.enemy.message = ""; + + oself = self; + self = self.owner; + door_fire (); + self = oself; +}; + + +void() door_trigger_touch = +{ + if (other.health <= 0) + return; + + if (time < self.attack_finished) + return; + self.attack_finished = time + 1; + + activator = other; + + self = self.owner; + door_use (); +}; + + +void() door_killed = +{ + local entity oself; + + oself = self; + self = self.owner; + self.health = self.max_health; + self.takedamage = DAMAGE_NO; // wil be reset upon return + door_use (); + self = oself; +}; + + +/* +================ +door_touch + +Prints messages and opens key doors +================ +*/ +void() door_touch = +{ + if (other.classname != "player") + return; + if (self.owner.attack_finished > time) + return; + + self.owner.attack_finished = time + 2; + + if (self.owner.message != "") + { + centerprint (other, self.owner.message); + sound (other, CHAN_VOICE, "misc/talk.wav", 1, ATTN_NORM); + } + +// key door stuff + if (!self.items) + return; + +// FIXME: blink key on player's status bar + if ( (self.items & other.items) != self.items ) + { + if (self.owner.items == IT_KEY1) + { + switch (world.worldtype) + { + case WT_MEDIEVAL: + centerprint (other, "You need the silver key"); + break; + case WT_METAL: + centerprint (other, "You need the silver runekey"); + break; + case WT_BASE: + centerprint (other, "You need the silver keycard"); + break; + } + } + else + { + switch (world.worldtype) + { + case WT_MEDIEVAL: + centerprint (other, "You need the gold key"); + break; + case WT_METAL: + centerprint (other, "You need the gold runekey"); + break; + case WT_BASE: + centerprint (other, "You need the gold keycard"); + break; + } + } + + sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM); + return; + } + + other.items = other.items - self.items; + self.touch = SUB_Null; + if (self.enemy) + self.enemy.touch = SUB_Null; // get paired door + door_use (); +}; + +/* +============================================================================= + +SPAWNING FUNCTIONS + +============================================================================= +*/ + + +entity(vector fmins, vector fmaxs) spawn_field = +{ + local entity trigger; + local vector t1, t2; + + trigger = spawn(); + trigger.movetype = MOVETYPE_NONE; + trigger.solid = SOLID_TRIGGER; + trigger.owner = self; + trigger.touch = door_trigger_touch; + + t1 = fmins; + t2 = fmaxs; + setsize (trigger, t1 - '60 60 8', t2 + '60 60 8'); + return (trigger); +}; + + +float (entity e1, entity e2) EntitiesTouching = +{ + if (e1.mins_x > e2.maxs_x) + return FALSE; + if (e1.mins_y > e2.maxs_y) + return FALSE; + if (e1.mins_z > e2.maxs_z) + return FALSE; + if (e1.maxs_x < e2.mins_x) + return FALSE; + if (e1.maxs_y < e2.mins_y) + return FALSE; + if (e1.maxs_z < e2.mins_z) + return FALSE; + return TRUE; +}; + + +/* +============= +LinkDoors + + +============= +*/ +void() LinkDoors = +{ + local entity t, starte; + local vector cmins, cmaxs; + + if (self.enemy) + return; // already linked by another door + if (self.spawnflags & 4) + { + self.owner = self.enemy = self; + return; // don't want to link this door + } + + cmins = self.mins; + cmaxs = self.maxs; + + starte = self; + t = self; + + do + { + self.owner = starte; // master door + + if (self.health) + starte.health = self.health; + if (self.targetname) + starte.targetname = self.targetname; + if (self.message != "") + starte.message = self.message; + + t = find (t, classname, self.classname); + if (!t) + { + self.enemy = starte; // make the chain a loop + + // shootable, fired, or key doors just needed the owner/enemy links, + // they don't spawn a field + + self = self.owner; + + if (self.health) + return; + if (self.targetname) + return; + if (self.items) + return; + + self.owner.trigger_field = spawn_field(cmins, cmaxs); + + return; + } + + if (EntitiesTouching(self,t)) + { + if (t.enemy) + objerror ("cross connected doors"); + + self.enemy = t; + self = t; + + if (t.mins_x < cmins_x) + cmins_x = t.mins_x; + if (t.mins_y < cmins_y) + cmins_y = t.mins_y; + if (t.mins_z < cmins_z) + cmins_z = t.mins_z; + if (t.maxs_x > cmaxs_x) + cmaxs_x = t.maxs_x; + if (t.maxs_y > cmaxs_y) + cmaxs_y = t.maxs_y; + if (t.maxs_z > cmaxs_z) + cmaxs_z = t.maxs_z; + } + } while (1 ); + +}; + + +/*QUAKED func_door (0 .5 .8) ? START_OPEN x DOOR_DONT_LINK GOLD_KEY SILVER_KEY TOGGLE +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. + +"message" is printed when the door is touched if it is a trigger door and it hasn't been fired yet +"angle" determines the opening direction +"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) +"sounds" +0) no sound +1) stone +2) base +3) stone chain +4) screechy metal +*/ + +void() func_door = +{ + switch (world.worldtype) + { + case WT_MEDIEVAL: + precache_sound ("doors/medtry.wav"); + precache_sound ("doors/meduse.wav"); + self.noise3 = "doors/medtry.wav"; + self.noise4 = "doors/meduse.wav"; + break; + case WT_METAL: + precache_sound ("doors/runetry.wav"); + precache_sound ("doors/runeuse.wav"); + self.noise3 = "doors/runetry.wav"; + self.noise4 = "doors/runeuse.wav"; + break; + case WT_BASE: + precache_sound ("doors/basetry.wav"); + precache_sound ("doors/baseuse.wav"); + self.noise3 = "doors/basetry.wav"; + self.noise4 = "doors/baseuse.wav"; + break; + default: + dprint ("no worldtype set!\n"); + } + + switch (self.sounds) + { + case 0: + precache_sound ("misc/null.wav"); + precache_sound ("misc/null.wav"); + self.noise1 = "misc/null.wav"; + self.noise2 = "misc/null.wav"; + break; + case 1: + precache_sound ("doors/drclos4.wav"); + precache_sound ("doors/doormv1.wav"); + self.noise1 = "doors/drclos4.wav"; + self.noise2 = "doors/doormv1.wav"; + break; + case 2: + precache_sound ("doors/hydro1.wav"); + precache_sound ("doors/hydro2.wav"); + self.noise2 = "doors/hydro1.wav"; + self.noise1 = "doors/hydro2.wav"; + break; + case 3: + precache_sound ("doors/stndr1.wav"); + precache_sound ("doors/stndr2.wav"); + self.noise2 = "doors/stndr1.wav"; + self.noise1 = "doors/stndr2.wav"; + break; + case 4: + precache_sound ("doors/ddoor1.wav"); + precache_sound ("doors/ddoor2.wav"); + self.noise1 = "doors/ddoor2.wav"; + self.noise2 = "doors/ddoor1.wav"; + break; + } + + SetMovedir (); + + self.max_health = self.health; + self.solid = SOLID_BSP; + self.movetype = MOVETYPE_PUSH; + setorigin (self, self.origin); + setmodel (self, self.model); + self.classname = "door"; + + 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); + +// 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) + { + setorigin (self, self.pos2); + self.pos2 = self.pos1; + self.pos1 = self.origin; + } + + self.state = STATE_BOTTOM; + + if (self.health) + { + self.takedamage = DAMAGE_YES; + self.th_die = door_killed; + } + + if (self.items) + self.wait = -1; + + self.touch = door_touch; + +// LinkDoors can't be done until all of the doors have been spawned, so +// the sizes can be detected properly. + self.think = LinkDoors; + self.nextthink = self.ltime + 0.1; +}; + +/* +============================================================================= + +SECRET DOORS + +============================================================================= +*/ + +void() fd_secret_move1; +void() fd_secret_move2; +void() fd_secret_move3; +void() fd_secret_move4; +void() fd_secret_move5; +void() fd_secret_move6; +void() fd_secret_done; + +float SECRET_OPEN_ONCE = 1; // stays open +float SECRET_1ST_LEFT = 2; // 1st move is left of arrow +float SECRET_1ST_DOWN = 4; // 1st move is down from arrow +float SECRET_NO_SHOOT = 8; // only opened by trigger +float SECRET_YES_SHOOT = 16; // shootable even if targeted + + +void () fd_secret_use = +{ + local float temp; + + self.health = 10000; + + // exit if still moving around... + if (self.origin != self.oldorigin) + return; + + self.message = string_null; // no more message + + SUB_UseTargets(); // fire all targets / killtargets + + if (!(self.spawnflags & SECRET_NO_SHOOT)) + { + self.th_pain = SUB_Null; + self.takedamage = DAMAGE_NO; + } + self.velocity = '0 0 0'; + + // Make a sound, wait a little... + + sound(self, CHAN_VOICE, self.noise1, 1, ATTN_NORM); + self.nextthink = self.ltime + 0.1; + + temp = 1 - (self.spawnflags & SECRET_1ST_LEFT); // 1 or -1 + makevectors(self.mangle); + + if (!self.t_width) + { + if (self.spawnflags & SECRET_1ST_DOWN) + self.t_width = fabs(v_up * self.size); + else + self.t_width = fabs(v_right * self.size); + } + + if (!self.t_length) + self.t_length = fabs(v_forward * self.size); + + if (self.spawnflags & SECRET_1ST_DOWN) + self.dest1 = self.origin - v_up * self.t_width; + else + self.dest1 = self.origin + v_right * (self.t_width * temp); + + self.dest2 = self.dest1 + v_forward * self.t_length; + SUB_CalcMove(self.dest1, self.speed, fd_secret_move1); + sound(self, CHAN_VOICE, self.noise2, 1, ATTN_NORM); +}; + +// Wait after first movement... +void () fd_secret_move1 = +{ + self.nextthink = self.ltime + 1.0; + self.think = fd_secret_move2; + sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM); +}; + +// Start moving sideways w/sound... +void () fd_secret_move2 = +{ + sound(self, CHAN_VOICE, self.noise2, 1, ATTN_NORM); + SUB_CalcMove(self.dest2, self.speed, fd_secret_move3); +}; + +// Wait here until time to go back... +void () fd_secret_move3 = +{ + sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM); + if (!(self.spawnflags & SECRET_OPEN_ONCE)) + { + self.nextthink = self.ltime + self.wait; + self.think = fd_secret_move4; + } +}; + +// Move backward... +void () fd_secret_move4 = +{ + sound(self, CHAN_VOICE, self.noise2, 1, ATTN_NORM); + SUB_CalcMove(self.dest1, self.speed, fd_secret_move5); +}; + +// Wait 1 second... +void () fd_secret_move5 = +{ + self.nextthink = self.ltime + 1.0; + self.think = fd_secret_move6; + sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM); +}; + +void () fd_secret_move6 = +{ + sound(self, CHAN_VOICE, self.noise2, 1, ATTN_NORM); + SUB_CalcMove(self.oldorigin, self.speed, fd_secret_done); +}; + +void () fd_secret_done = +{ + if (!self.targetname || self.spawnflags&SECRET_YES_SHOOT) + { + self.health = 10000; + self.takedamage = DAMAGE_YES; + self.th_pain = fd_secret_use; + self.th_die = fd_secret_use; + } + sound(self, chan_no_phs_add|CHAN_VOICE, self.noise3, 1, ATTN_NORM); +}; + +void () secret_blocked = +{ + if (time < self.attack_finished) + return; + self.attack_finished = time + 0.5; + T_Damage (other, self, self, self.dmg, MOD_SQUISH); +}; + +/* +================ +secret_touch + +Prints messages +================ +*/ +void() secret_touch = +{ + if (other.classname != "player") + return; + if (self.attack_finished > time) + return; + + self.attack_finished = time + 2; + + if (self.message) + { + centerprint (other, self.message); + sound (other, CHAN_BODY, "misc/talk.wav", 1, ATTN_NORM); + } +}; + + +/*QUAKED func_door_secret (0 .5 .8) ? open_once 1st_left 1st_down no_shoot always_shoot +Basic secret door. Slides back, then to the side. Angle determines direction. +wait = # of seconds before coming back +1st_left = 1st move is left of arrow +1st_down = 1st move is down from arrow +always_shoot = even if targeted, keep shootable +t_width = override WIDTH to move back (or height if going down) +t_length = override LENGTH to move sideways +"dmg" damage to inflict when blocked (2 default) + +If a secret door has a targetname, it will only be opened by it's botton or trigger, not by damage. +"sounds" +1) medieval +2) metal +3) base +*/ + +void () func_door_secret = +{ + switch (self.sounds) + { + case 0: + case 3: + precache_sound ("doors/basesec1.wav"); + precache_sound ("doors/basesec2.wav"); + self.noise2 = "doors/basesec1.wav"; + self.noise1 = "doors/basesec2.wav"; + self.noise3 = "doors/basesec2.wav"; + break; + case 1: + precache_sound ("doors/latch2.wav"); + precache_sound ("doors/winch2.wav"); + precache_sound ("doors/drclos4.wav"); + self.noise1 = "doors/latch2.wav"; + self.noise2 = "doors/winch2.wav"; + self.noise3 = "doors/drclos4.wav"; + break; + case 2: + precache_sound ("doors/airdoor1.wav"); + precache_sound ("doors/airdoor2.wav"); + self.noise2 = "doors/airdoor1.wav"; + self.noise1 = "doors/airdoor2.wav"; + self.noise3 = "doors/airdoor2.wav"; + break; + } + + if (!self.dmg) + self.dmg = 2; + + // Magic formula... + self.mangle = self.angles; + self.angles = '0 0 0'; + self.solid = SOLID_BSP; + self.movetype = MOVETYPE_PUSH; + self.classname = "door"; + setmodel (self, self.model); + setorigin (self, self.origin); + + self.touch = secret_touch; + self.blocked = secret_blocked; + self.speed = 50; + self.use = fd_secret_use; + if ( !self.targetname || self.spawnflags&SECRET_YES_SHOOT) + { + self.health = 10000; + self.takedamage = DAMAGE_YES; + self.th_pain = fd_secret_use; + } + self.oldorigin = self.origin; + if (!self.wait) + self.wait = 5; // 5 seconds before closing +}; diff --git a/quakec/basemod/effects.qc b/quakec/basemod/effects.qc new file mode 100644 index 000000000..2b2f32ee5 --- /dev/null +++ b/quakec/basemod/effects.qc @@ -0,0 +1,307 @@ + +// Effects code (EFF) -- + +// TE effects/muzzleflash/messages + +// modular efs +var float ef_red = 0; // used for glow on pent item +var float ef_pent = EF_DIMLIGHT; // used for pent effect on player +var float ef_blue = 0; // used for glow on quad +var float ef_quad = EF_DIMLIGHT; // used for quad effect on player + +/* +================ +SpawnBlood +================ +*/ +void(vector org, float damage) _SpawnBlood_TEBlood = +{ + te_blood(org, '0 0 0', damage*2); +}; + +void(vector org, float damage) _SpawnBlood = +{ +#ifdef NETQUAKE + particle (org, '0 0 0', 73, damage*2); +#else + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_BLOOD); + WriteByte (MSG_MULTICAST, damage); + WriteCoord (MSG_MULTICAST, org_x); + WriteCoord (MSG_MULTICAST, org_y); + WriteCoord (MSG_MULTICAST, org_z); + multicast (org, MULTICAST_PVS); +#endif +}; + +#ifdef NETQUAKE +void() s_explode6 = [5, SUB_Remove] {}; +void() s_explode5 = [4, s_explode6] {}; +void() s_explode4 = [3, s_explode5] {}; +void() s_explode3 = [2, s_explode4] {}; +void() s_explode2 = [1, s_explode3] {}; +void() s_explode1 = [0, s_explode2] {}; + +void(vector org) CreateExplosion = +{ + local entity s; + + s = self; // save old self + + self = spawn(); + + self.movetype = MOVETYPE_NONE; + self.velocity = '0 0 0'; + self.touch = SUB_Null; + setmodel (self, "progs/s_explod.spr"); + setorigin (self, org); + self.solid = SOLID_NOT; + s_explode1 (); + + self = s; // restore old self +}; +#endif + +void(vector org) _TE_explosion = +{ +#ifdef NETQUAKE + WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); + WriteByte (MSG_BROADCAST, TE_EXPLOSION); + WriteCoord (MSG_BROADCAST, org_x); + WriteCoord (MSG_BROADCAST, org_y); + WriteCoord (MSG_BROADCAST, org_z); + CreateExplosion(org); +#else + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_EXPLOSION); + WriteCoord (MSG_MULTICAST, org_x); + WriteCoord (MSG_MULTICAST, org_y); + WriteCoord (MSG_MULTICAST, org_z); + multicast (org, MULTICAST_PHS); +#endif +}; + +void(vector org) _TE_gunshot = +{ +#ifdef NETQUAKE + WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); + WriteByte (MSG_BROADCAST, TE_GUNSHOT); + WriteCoord (MSG_BROADCAST, org_x); + WriteCoord (MSG_BROADCAST, org_y); + WriteCoord (MSG_BROADCAST, org_z); +#else + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_GUNSHOT); + WriteByte (MSG_MULTICAST, 3); + WriteCoord (MSG_MULTICAST, org_x); + WriteCoord (MSG_MULTICAST, org_y); + WriteCoord (MSG_MULTICAST, org_z); + multicast (org, MULTICAST_PVS); +#endif +}; + +void(vector org) _TE_spike = +{ +#ifdef NETQUAKE + WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); + WriteByte (MSG_BROADCAST, TE_SPIKE); + WriteCoord (MSG_BROADCAST, org_x); + WriteCoord (MSG_BROADCAST, org_y); + WriteCoord (MSG_BROADCAST, org_z); +#else + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_SPIKE); + WriteCoord (MSG_MULTICAST, org_x); + WriteCoord (MSG_MULTICAST, org_y); + WriteCoord (MSG_MULTICAST, org_z); + multicast (org, MULTICAST_PHS); +#endif +}; + +void(vector org) _TE_knightspike = +{ +#ifdef NETQUAKE + WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); + WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE); + WriteCoord (MSG_BROADCAST, org_x); + WriteCoord (MSG_BROADCAST, org_y); + WriteCoord (MSG_BROADCAST, org_z); +#else + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_KNIGHTSPIKE); + WriteCoord (MSG_MULTICAST, org_x); + WriteCoord (MSG_MULTICAST, org_y); + WriteCoord (MSG_MULTICAST, org_z); + multicast (org, MULTICAST_PHS); +#endif +}; + +void(vector org) _TE_wizspike = +{ +#ifdef NETQUAKE + WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); + WriteByte (MSG_BROADCAST, TE_WIZSPIKE); + WriteCoord (MSG_BROADCAST, org_x); + WriteCoord (MSG_BROADCAST, org_y); + WriteCoord (MSG_BROADCAST, org_z); +#else + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_WIZSPIKE); + WriteCoord (MSG_MULTICAST, org_x); + WriteCoord (MSG_MULTICAST, org_y); + WriteCoord (MSG_MULTICAST, org_z); + multicast (org, MULTICAST_PHS); +#endif +}; + +void(vector org) _TE_superspike = +{ +#ifdef NETQUAKE + WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); + WriteByte (MSG_BROADCAST, TE_SUPERSPIKE); + WriteCoord (MSG_BROADCAST, org_x); + WriteCoord (MSG_BROADCAST, org_y); + WriteCoord (MSG_BROADCAST, org_z); +#else + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_SUPERSPIKE); + WriteCoord (MSG_MULTICAST, org_x); + WriteCoord (MSG_MULTICAST, org_y); + WriteCoord (MSG_MULTICAST, org_z); + multicast (org, MULTICAST_PHS); +#endif +}; + +void(vector org) _TE_teleport = +{ +#ifdef NETQUAKE + WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); + WriteByte (MSG_BROADCAST, TE_TELEPORT); + WriteCoord (MSG_BROADCAST, org_x); + WriteCoord (MSG_BROADCAST, org_y); + WriteCoord (MSG_BROADCAST, org_z); +#else + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_TELEPORT); + WriteCoord (MSG_MULTICAST, org_x); + WriteCoord (MSG_MULTICAST, org_y); + WriteCoord (MSG_MULTICAST, org_z); + multicast (org, MULTICAST_PHS); +#endif +}; + +void(entity ent, vector start, vector end) _TE_lightning2 = +{ +#ifdef NETQUAKE + WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); + WriteByte (MSG_BROADCAST, TE_LIGHTNING2); + WriteEntity (MSG_BROADCAST, ent); + WriteCoord (MSG_BROADCAST, start_x); + WriteCoord (MSG_BROADCAST, start_y); + WriteCoord (MSG_BROADCAST, start_z); + WriteCoord (MSG_BROADCAST, end_x); + WriteCoord (MSG_BROADCAST, end_y); + WriteCoord (MSG_BROADCAST, end_z); +#else + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_LIGHTNING2); + WriteEntity (MSG_MULTICAST, ent); + WriteCoord (MSG_MULTICAST, start_x); + WriteCoord (MSG_MULTICAST, start_y); + WriteCoord (MSG_MULTICAST, start_z); + WriteCoord (MSG_MULTICAST, end_x); + WriteCoord (MSG_MULTICAST, end_y); + WriteCoord (MSG_MULTICAST, end_z); + multicast (start, MULTICAST_PHS); +#endif +}; + +void(vector org) TE_lightningblood = +{ +#ifdef NETQUAKE + particle(org, '0 0 100', 225, 120); +#else + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_LIGHTNINGBLOOD); + WriteCoord (MSG_MULTICAST, org_x); + WriteCoord (MSG_MULTICAST, org_y); + WriteCoord (MSG_MULTICAST, org_z); + multicast (org, MULTICAST_PVS); +#endif +}; + +// view kicks +void(entity ent) VK_smallkick = +{ +#ifdef NETQUAKE + self.punchangle_x = -2; +#else + msg_entity = ent; + WriteByte (MSG_ONE, SVC_SMALLKICK); +#endif +} + +void(entity ent) VK_bigkick = +{ +#ifdef NETQUAKE + self.punchangle_x = -4; +#else + msg_entity = ent; + WriteByte (MSG_ONE, SVC_BIGKICK); +#endif +} + +// muzzle flash +void() muzzleflash = +{ +#ifdef NETQUAKE + self.effects |= EF_MUZZLEFLASH; +#else + WriteByte (MSG_MULTICAST, SVC_MUZZLEFLASH); + WriteEntity (MSG_MULTICAST, self); + multicast (self.origin, MULTICAST_PVS); +#endif +}; + +// function pointers for TE calls +var void(vector org, float damage) SpawnBlood = _SpawnBlood; +var void(vector org) TE_explosion = _TE_explosion; +var void(vector org) TE_gunshot = _TE_gunshot; +var void(vector org) TE_spike = _TE_spike; +var void(vector org) TE_knightspike = _TE_knightspike; +var void(vector org) TE_wizspike = _TE_wizspike; +var void(vector org) TE_superspike = _TE_superspike; +var void(vector org) TE_teleport = _TE_teleport; +var void(entity ent, vector start, vector end) TE_lightning2 = _TE_lightning2; + +// set effects function, takes function pointers and assigns them based on detected builtins +void() EFF_SetEffects = +{ + if (eng_support & ENG_EFRED) + { + ef_pent = 128; + ef_red = 128; + } + + if (eng_support & ENG_EFBLUE) + { + ef_blue = 64; + ef_quad = 64; + } + + if (eng_support & ENG_TEBUILTINS) + { + // use TE_ builtins instead + TE_explosion = _te_explosion; + TE_gunshot = _te_gunshot; + TE_spike = _te_spike; + TE_knightspike = _te_knightspike; + TE_wizspike = _te_wizspike; + TE_superspike = _te_superspike; + TE_teleport = _te_teleport; + TE_lightning2 = _te_lightning2; + } + + if (eng_support & ENG_TEBLOOD) + SpawnBlood = _SpawnBlood_TEBlood; // use TE_Blood builtin instead +}; diff --git a/quakec/basemod/engine.qc b/quakec/basemod/engine.qc new file mode 100644 index 000000000..120ddee8b --- /dev/null +++ b/quakec/basemod/engine.qc @@ -0,0 +1,153 @@ + +// Engine support code (ENG) -- +// Checks to see what extensions are supported by current running engine and +// has wrappers for builtins based on engine (other than EF_/messages/TE_ effects) + +var float chan_no_phs_add = 0; + +INTEGER eng_support; +#define ENG_STOF 0x01 +#define ENG_CVARSTRING 0x02 +#define ENG_TEBUILTINS 0x04 +#define ENG_TEBLOOD 0x08 +#define ENG_EFRED 0x10 +#define ENG_EFBLUE 0x20 + +// prototypes +void() EFF_SetEffects; + +// builtins +float(string s) cvar = #45; +void(vector o, vector d, float color, float count) particle = #48; // NQ only +void(entity killer, entity killee) _logfrag = #79; // QW only +string(entity e, string key) _infokey = #80; // QW only +void(vector where, float set) multicast = #82; // QW only +float(string s) checkextension = #99; // QSG extension +void(vector org, vector velocity, float howmany) te_blood = #405; // DP_TE_BLOOD +void(vector org) _te_gunshot = #418; // DP_TE_STANDARDEFFECTBUILTINS +void(vector org) _te_spike = #419; // DP_TE_STANDARDEFFECTBUILTINS +void(vector org) _te_superspike = #420; // DP_TE_STANDARDEFFECTBUILTINS +void(vector org) _te_explosion = #421; // DP_TE_STANDARDEFFECTBUILTINS +void(vector org) _te_tarexplosion = #422; // DP_TE_STANDARDEFFECTBUILTINS +void(vector org) _te_wizspike = #423; // DP_TE_STANDARDEFFECTBUILTINS +void(vector org) _te_knightspike = #424; // DP_TE_STANDARDEFFECTBUILTINS +void(vector org) _te_lavasplash = #425; // DP_TE_STANDARDEFFECTBUILTINS +void(vector org) _te_teleport = #426; // DP_TE_STANDARDEFFECTBUILTINS +void(vector org, float color, float colorlength) _te_explosion2 = #427; // DP_TE_STANDARDEFFECTBUILTINS +void(entity own, vector start, vector end) _te_lightning1 = #428; // DP_TE_STANDARDEFFECTBUILTINS +void(entity own, vector start, vector end) _te_lightning2 = #429; // DP_TE_STANDARDEFFECTBUILTINS +void(entity own, vector start, vector end) _te_lightning3 = #430; // DP_TE_STANDARDEFFECTBUILTINS +void(entity own, vector start, vector end) _te_beam = #431; // DP_TE_STANDARDEFFECTBUILTINS +string(string s) cvar_string = #448; // DP_CVAR_STRING + +// wrappers +// print wrapper +#ifdef NETQUAKE +void(...) _bprint = #23; // NQ +void(entity client, ...) _sprint = #24; // NQ +#define bprint1(l,a) _bprint(a) +#define bprint2(l,a,b) _bprint(a,b) +#define bprint3(l,a,b,c) _bprint(a,b,c) +#define bprint4(l,a,b,c,d) _bprint(a,b,c,d) +#define bprint5(l,a,b,c,d,e) _bprint(a,b,c,d,e) +#define bprint6(l,a,b,c,d,e,f) _bprint(a,b,c,d,e,f) +#define bprint7(l,a,b,c,d,e,f,g) _bprint(a,b,c,d,e,f,g) + +#define sprint1(t,l,a) _sprint(t,a) +#define sprint2(t,l,a,b) _sprint(t,a,b) +#define sprint3(t,l,a,b,c) _sprint(t,a,b,c) +#define sprint4(t,l,a,b,c,d) _sprint(t,a,b,c,d) +#define sprint5(t,l,a,b,c,d,e) _sprint(t,a,b,c,d,e) +#define sprint6(t,l,a,b,c,d,e,f) _sprint(t,a,b,c,d,e,f) +#else +void(float level, ...) _bprint = #23; // QW +void(entity client, float level, ...) _sprint = #24; // QW +#define bprint1(l,a) _bprint(l,a) +#define bprint2(l,a,b) _bprint(l,a,b) +#define bprint3(l,a,b,c) _bprint(l,a,b,c) +#define bprint4(l,a,b,c,d) _bprint(l,a,b,c,d) +#define bprint5(l,a,b,c,d,e) _bprint(l,a,b,c,d,e) +#define bprint6(l,a,b,c,d,e,f) _bprint(l,a,b,c,d,e,f) +#define bprint7(l,a,b,c,d,e,f,g) _bprint(l,a,b,c,d,e,f,g) + +#define sprint1(t,l,a) _sprint(t,l,a) +#define sprint2(t,l,a,b) _sprint(t,l,a,b) +#define sprint3(t,l,a,b,c) _sprint(t,l,a,b,c) +#define sprint4(t,l,a,b,c,d) _sprint(t,l,a,b,c,d) +#define sprint5(t,l,a,b,c,d,e) _sprint(t,l,a,b,c,d,e) +#define sprint6(t,l,a,b,c,d,e,f) _sprint(t,l,a,b,c,d,e,f) +#endif + +// logfrag wrapper +#ifdef NETQUAKE +// empty define to strip logfrag out +#define logfrag(x,y) +#else +#define logfrag(x,y) _logfrag(x,y) +#endif + +// stof +float(string s) _stof = #81; +float(string s) _stofdummy = +{ + return 0; +} + +var float(string s) stof = _stofdummy; + +// infokey wrapper +#ifdef NETQUAKE +#define numberserverinfokey(x) cvar(x) +string(string cv) stringserverinfokey = +{ + if (eng_support & ENG_CVARSTRING) + return cvar_string(cv); + + return ""; +} + +#define numberclientinfokey(x,y) 0 +#define stringclientinfokey(x,y) "" +#else +#define numberserverinfokey(x) stof(_infokey(world,x)) +#define stringserverinfokey(x) _infokey(world,x) +#define numberclientinfokey(x,y) stof(_infokey(x,y)) +#define stringclientinfokey(x,y) _infokey(x,y) +#endif + +// engine check routine +void() ENG_Check = +{ +#ifndef NETQUAKE + eng_support = ENG_STOF | ENG_EFRED | ENG_EFBLUE; + chan_no_phs_add = 8; +#endif + + if (!cvar("pr_checkextension")) + return; // no extensions supported + + if (checkextension("FRIK_FILE")) + eng_support |= ENG_STOF; + + if (checkextension("DP_CVAR_STRING")) + eng_support |= ENG_CVARSTRING; + + if (checkextension("DP_TE_STANDARDEFFECTBUILTINS")) + eng_support |= ENG_TEBUILTINS; + + if (checkextension("DP_TE_BLOOD")) + eng_support |= ENG_TEBLOOD; + + if (checkextension("DP_EF_RED")) + eng_support |= ENG_EFRED; + + if (checkextension("DP_EF_BLUE")) + eng_support |= ENG_EFBLUE; + + // check and set stof extension + if (eng_support & ENG_STOF) + stof = _stof; + + EFF_SetEffects(); +}; + diff --git a/quakec/basemod/items.qc b/quakec/basemod/items.qc new file mode 100644 index 000000000..f2816cd8a --- /dev/null +++ b/quakec/basemod/items.qc @@ -0,0 +1,1559 @@ +void() W_SetCurrentAmmo; +/* ALL LIGHTS SHOULD BE 0 1 0 IN COLOR ALL OTHER ITEMS SHOULD +BE .8 .3 .4 IN COLOR */ + + +void() SUB_regen = +{ + self.model = self.mdl; // restore original model + self.solid = SOLID_TRIGGER; // allow it to be touched again + sound (self, CHAN_VOICE, "items/itembk2.wav", 1, ATTN_NORM); // play respawn sound + setorigin (self, self.origin); +}; + + + +/*QUAKED noclass (0 0 0) (-8 -8 -8) (8 8 8) +prints a warning message when spawned +*/ +void() noclass = +{ + dprint ("noclass spawned at"); + dprint (vtos(self.origin)); + dprint ("\n"); + remove (self); +}; + +// names of weapons function +string(float weap) I_WeaponName = +{ + switch (weap) + { + case IT_AXE: + return "Axe"; + case IT_SHOTGUN: + return "Shotgun"; + case IT_SUPER_SHOTGUN: + return "Double-barrelled Shotgun"; + case IT_NAILGUN: + return "Nailgun"; + case IT_SUPER_NAILGUN: + return "Super Nailgun"; + case IT_GRENADE_LAUNCHER: + return "Grenade Launcher"; + case IT_ROCKET_LAUNCHER: + return "Rocket Launcher"; + case IT_LIGHTNING: + return "Thunderbolt"; + } + + return ""; +} + +void() q_touch; + +void() q_touch = +{ + local string s, t; + + if (other.classname != "player") + return; + if (other.health <= 0) + return; + + self.mdl = self.model; + + sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + self.solid = SOLID_NOT; + other.items = other.items | IT_QUAD; + self.model = string_null; + if (deathmatch == 4) + { + other.armortype = 0; + other.armorvalue = 0; + other.ammo_cells = 0; + } + +// do the apropriate action + other.super_time = 1; + other.super_damage_finished = self.cnt; + + s=ftos(rint(other.super_damage_finished - time)); + t = " recovered a Quad with "; + if (deathmatch == 4) + t = " recovered an OctaPower with "; + + bprint4 (PRINT_LOW, other.netname, t, s, " seconds remaining!\n"); + + activator = other; + SUB_UseTargets(); // fire all targets / killtargets +}; + + +void(float timeleft) DropQuad = +{ + local entity item; + + item = spawn(); + item.origin = self.origin; + + item.velocity_z = 300; + item.velocity_x = -100 + (random() * 200); + item.velocity_y = -100 + (random() * 200); + + item.flags = FL_ITEM; + item.solid = SOLID_TRIGGER; + item.movetype = MOVETYPE_TOSS; + item.noise = "items/damage.wav"; + setmodel (item, "progs/quaddama.mdl"); + setsize (item, '-16 -16 -24', '16 16 32'); + item.cnt = time + timeleft; + item.touch = q_touch; + item.nextthink = time + timeleft; // remove it with the time left on it + item.think = SUB_Remove; +}; + + +void() r_touch; + +void() r_touch = +{ +local string s; + + if (other.classname != "player") + return; + if (other.health <= 0) + return; + + self.mdl = self.model; + + sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + self.solid = SOLID_NOT; + other.items = other.items | IT_INVISIBILITY; + self.model = string_null; + +// do the apropriate action + other.invisible_time = 1; + other.invisible_finished = self.cnt; + s=ftos(rint(other.invisible_finished - time)); + bprint4 (PRINT_LOW, other.netname, " recovered a Ring with ", s, " seconds remaining!\n"); + + + activator = other; + SUB_UseTargets(); // fire all targets / killtargets +}; + + +void(float timeleft) DropRing = +{ + local entity item; + + item = spawn(); + item.origin = self.origin; + + item.velocity_z = 300; + item.velocity_x = -100 + (random() * 200); + item.velocity_y = -100 + (random() * 200); + + item.flags = FL_ITEM; + item.solid = SOLID_TRIGGER; + item.movetype = MOVETYPE_TOSS; + item.noise = "items/inv1.wav"; + setmodel (item, "progs/invisibl.mdl"); + setsize (item, '-16 -16 -24', '16 16 32'); + item.cnt = time + timeleft; + item.touch = r_touch; + item.nextthink = time + timeleft; // remove after 30 seconds + item.think = SUB_Remove; +}; + +/* +============ +PlaceItem + +plants the object on the floor +============ +*/ +void() PlaceItem = +{ + local float oldz; + + self.mdl = self.model; // so it can be restored on respawn + self.flags = FL_ITEM; // make extra wide + self.solid = SOLID_TRIGGER; + self.movetype = MOVETYPE_TOSS; + self.velocity = '0 0 0'; + self.origin_z = self.origin_z + 6; + oldz = self.origin_z; + if (!droptofloor()) + { + dprint ("Bonus item fell out of level at "); + dprint (vtos(self.origin)); + dprint ("\n"); + remove(self); + return; + } +}; + +/* +============ +StartItem + +Sets the clipping size and plants the object on the floor +============ +*/ +void() StartItem = +{ + self.nextthink = time + 0.2; // items start after other solids + self.think = PlaceItem; +}; + +/* +========================================================================= + +HEALTH BOX + +========================================================================= +*/ +// +// T_Heal: add health to an entity, limiting health to max_health +// "ignore" will ignore max_health limit +// +float (entity e, float hamount, float ignore) T_Heal = +{ + if (e.health <= 0) + return 0; + if ((!ignore) && (e.health >= other.max_health)) + return 0; + hamount = ceil(hamount); + + e.health = e.health + hamount; + if ((!ignore) && (e.health >= other.max_health)) + e.health = other.max_health; + + + if (e.health > e.max_health + 150) + e.health = e.max_health + 150; + + e.healdecay = time + 5; + return 1; +}; + +/*QUAKED item_health (.3 .3 1) (0 0 0) (32 32 32) rotten megahealth +Health box. Normally gives 25 points. +Rotten box heals 5-10 points, +megahealth will add 100 health, then +rot you down to your maximum health limit, +one point per second. +*/ + +void() health_touch; + +void() item_health = +{ + self.touch = health_touch; + + if (self.spawnflags & H_ROTTEN) + { + precache_model("maps/b_bh10.bsp"); + + precache_sound("items/r_item1.wav"); + setmodel(self, "maps/b_bh10.bsp"); + self.noise = "items/r_item1.wav"; + self.healamount = 15; + self.healtype = 0; + } + else + if (self.spawnflags & H_MEGA) + { + precache_model("maps/b_bh100.bsp"); + precache_sound("items/r_item2.wav"); + setmodel(self, "maps/b_bh100.bsp"); + self.noise = "items/r_item2.wav"; + self.healamount = 100; + self.healtype = 2; + } + else + { + precache_model("maps/b_bh25.bsp"); + precache_sound("items/health1.wav"); + setmodel(self, "maps/b_bh25.bsp"); + self.noise = "items/health1.wav"; + self.healamount = 25; + self.healtype = 1; + } + setsize (self, '0 0 0', '32 32 56'); + StartItem (); +}; + + +void() health_touch = +{ + local string s; + + if (deathmatch == 4) + if (other.invincible_time > time) + return; + + if (other.classname != "player") + return; + + if (self.healtype == H_MEGA) // Megahealth? Ignore max_health... + { + if (other.health >= other.max_health + 150) + return; + if (!T_Heal(other, self.healamount, 1)) + return; + } + else + { + if (!T_Heal(other, self.healamount, 0)) + return; + } + + s = ftos(self.healamount); + sprint3(other, PRINT_LOW, "You receive ", s, " health\n"); + +// health touch sound + sound(other, CHAN_ITEM, self.noise, 1, ATTN_NORM); + + stuffcmd (other, "bf\n"); + + self.model = string_null; + self.solid = SOLID_NOT; + + // Megahealth = rot down the player's super health + if (deathmatch == 1) // deathmatch 2 is the silly old rules + { + if (self.healtype == 2) + self.nextthink = time + 45; + else + self.nextthink = time + 20; + self.think = SUB_regen; + } + + activator = other; + SUB_UseTargets(); // fire all targets / killtargets +}; + +/* +=============================================================================== + +ARMOR + +=============================================================================== +*/ + +void() armor_touch; + +void() armor_touch = +{ + local float type, value, bit; + + if (other.health <= 0) + return; + if (other.classname != "player") + return; + + if (deathmatch == 4) + + if (other.invincible_time > 0) + return; + + switch (self.classname) + { + case "item_armor1": + type = 0.3; + value = 100; + bit = IT_ARMOR1; + break; + case "item_armor2": + type = 0.6; + value = 150; + bit = IT_ARMOR2; + break; + case "item_armorInv": + type = 0.8; + value = 200; + bit = IT_ARMOR3; + break; + } + + if (other.armortype*other.armorvalue >= type*value) + return; + + other.armortype = type; + other.armorvalue = value; + other.items = other.items - (other.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + bit; + + self.solid = SOLID_NOT; + self.model = string_null; + if (deathmatch != 2) + self.nextthink = time + 20; + self.think = SUB_regen; + + sprint1(other, PRINT_LOW, "You got armor\n"); +// armor touch sound + sound(other, CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + + activator = other; + SUB_UseTargets(); // fire all targets / killtargets +}; + + +/*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32) +*/ + +void() item_armor1 = +{ + self.touch = armor_touch; + precache_model ("progs/armor.mdl"); + setmodel (self, "progs/armor.mdl"); + self.skin = 0; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); +}; + +/*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32) +*/ + +void() item_armor2 = +{ + self.touch = armor_touch; + precache_model ("progs/armor.mdl"); + setmodel (self, "progs/armor.mdl"); + self.skin = 1; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); +}; + +/*QUAKED item_armorInv (0 .5 .8) (-16 -16 0) (16 16 32) +*/ + +void() item_armorInv = +{ + self.touch = armor_touch; + precache_model ("progs/armor.mdl"); + setmodel (self, "progs/armor.mdl"); + self.skin = 2; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); +}; + +/* +=============================================================================== + +WEAPONS + +=============================================================================== +*/ + +void() bound_other_ammo = +{ + if (other.ammo_shells > 100) + other.ammo_shells = 100; + if (other.ammo_nails > 200) + other.ammo_nails = 200; + if (other.ammo_rockets > 100) + other.ammo_rockets = 100; + if (other.ammo_cells > 100) + other.ammo_cells = 100; +}; + + +float(float w) RankForWeapon = +{ + if (w == IT_LIGHTNING) + return 1; + if (w == IT_ROCKET_LAUNCHER) + return 2; + if (w == IT_SUPER_NAILGUN) + return 3; + if (w == IT_GRENADE_LAUNCHER) + return 4; + if (w == IT_SUPER_SHOTGUN) + return 5; + if (w == IT_NAILGUN) + return 6; + return 7; +}; + +float (float w) WeaponCode = +{ + if (w == IT_SUPER_SHOTGUN) + return 3; + if (w == IT_NAILGUN) + return 4; + if (w == IT_SUPER_NAILGUN) + return 5; + if (w == IT_GRENADE_LAUNCHER) + return 6; + if (w == IT_ROCKET_LAUNCHER) + return 7; + if (w == IT_LIGHTNING) + return 8; + return 1; +}; + +/* +============= +Deathmatch_Weapon + +Deathmatch weapon change rules for picking up a weapon + +.float ammo_shells, ammo_nails, ammo_rockets, ammo_cells; +============= +*/ +void(float old, float new) Deathmatch_Weapon = +{ + local float or, nr; + +// change self.weapon if desired + or = RankForWeapon (self.weapon); + nr = RankForWeapon (new); + + if ( nr == IT_LIGHTNING && self.waterlevel > 1 ) + return; + + if ( nr < or ) + self.weapon = new; +}; + +/* +============= +weapon_touch +============= +*/ +float() W_BestWeapon; + +void() weapon_touch = +{ + local float new, old; + local float leave; + local entity stemp; + + // For client weapon_switch + local float w_switch; + + if (!(other.flags & FL_CLIENT)) + return; + + w_switch = numberclientinfokey(other,"w_switch"); + if (w_switch == 0) + w_switch = 8; + + if (deathmatch == 2 || deathmatch == 3 || deathmatch == 5) + leave = 1; + else + leave = 0; + + // check if we have the weapon already + if (leave && (other.items & self.weapon)) + return; + new = self.weapon; + + // add ammo here + switch (new) + { + case IT_SUPER_SHOTGUN: + other.ammo_shells = other.ammo_shells + 5; + break; + case IT_NAILGUN: + case IT_SUPER_NAILGUN: + other.ammo_nails = other.ammo_nails + 30; + break; + case IT_GRENADE_LAUNCHER: + case IT_ROCKET_LAUNCHER: + other.ammo_rockets = other.ammo_rockets + 5; + break; + case IT_LIGHTNING: + other.ammo_cells = other.ammo_cells + 15; + break; + } + + sprint3 (other, PRINT_LOW, "You got the ", I_WeaponName(new), "\n"); +// weapon touch sound + sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + + bound_other_ammo (); + +// change to the weapon + old = other.items; + other.items = other.items | new; + + stemp = self; + self = other; + + if ( WeaponCode(new) <= w_switch ) + { + if (self.flags & FL_INWATER) + { + if (new != IT_LIGHTNING) + { + Deathmatch_Weapon (old, new); + } + } + else + { + Deathmatch_Weapon (old, new); + } + } + + W_SetCurrentAmmo(); + + self = stemp; + + if (leave) + return; + + if (deathmatch!=3 || deathmatch !=5) + { + // remove it in single player, or setup for respawning in deathmatch + self.model = string_null; + self.solid = SOLID_NOT; + if (deathmatch != 2) + self.nextthink = time + 30; + self.think = SUB_regen; + } + activator = other; + SUB_UseTargets(); // fire all targets / killtargets +}; + + +/*QUAKED weapon_supershotgun (0 .5 .8) (-16 -16 0) (16 16 32) +*/ + +void() weapon_supershotgun = +{ + if (deathmatch <= 3) + { + precache_model ("progs/g_shot.mdl"); + setmodel (self, "progs/g_shot.mdl"); + self.weapon = IT_SUPER_SHOTGUN; + self.touch = weapon_touch; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); + } + else + remove(self); +}; + +/*QUAKED weapon_nailgun (0 .5 .8) (-16 -16 0) (16 16 32) +*/ + +void() weapon_nailgun = +{ + if (deathmatch <= 3) + { + precache_model ("progs/g_nail.mdl"); + setmodel (self, "progs/g_nail.mdl"); + self.weapon = IT_NAILGUN; + self.touch = weapon_touch; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); + } + else + remove(self); +}; + +/*QUAKED weapon_supernailgun (0 .5 .8) (-16 -16 0) (16 16 32) +*/ + +void() weapon_supernailgun = +{ + if (deathmatch <= 3) + { + precache_model ("progs/g_nail2.mdl"); + setmodel (self, "progs/g_nail2.mdl"); + self.weapon = IT_SUPER_NAILGUN; + self.touch = weapon_touch; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); + } + else + remove(self); +}; + +/*QUAKED weapon_grenadelauncher (0 .5 .8) (-16 -16 0) (16 16 32) +*/ + +void() weapon_grenadelauncher = +{ + if (deathmatch <= 3) + { + precache_model ("progs/g_rock.mdl"); + setmodel (self, "progs/g_rock.mdl"); + self.weapon = IT_GRENADE_LAUNCHER; + self.touch = weapon_touch; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); + } + else + remove(self); +}; + +/*QUAKED weapon_rocketlauncher (0 .5 .8) (-16 -16 0) (16 16 32) +*/ + +void() weapon_rocketlauncher = +{ + if (deathmatch <= 3) + { + precache_model ("progs/g_rock2.mdl"); + setmodel (self, "progs/g_rock2.mdl"); + self.weapon = IT_ROCKET_LAUNCHER; + self.touch = weapon_touch; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); + } + else + remove(self); +}; + + +/*QUAKED weapon_lightning (0 .5 .8) (-16 -16 0) (16 16 32) +*/ + +void() weapon_lightning = +{ + if (deathmatch <= 3) + { + precache_model ("progs/g_light.mdl"); + setmodel (self, "progs/g_light.mdl"); + self.weapon = IT_LIGHTNING; + self.touch = weapon_touch; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); + } + else + remove(self); +}; + + +/* +=============================================================================== + +AMMO + +=============================================================================== +*/ + +void() ammo_touch = +{ +local entity stemp; +local float best; + + if (other.classname != "player") + return; + if (other.health <= 0) + return; + +// if the player was using his best weapon, change up to the new one if better + stemp = self; + self = other; + best = W_BestWeapon(); + self = stemp; + + + switch (self.weapon) + { + case 1: // shotgun + if (other.ammo_shells >= 100) + return; + other.ammo_shells = other.ammo_shells + self.ammo_count; + break; + case 2: // spikes + if (other.ammo_nails >= 200) + return; + other.ammo_nails = other.ammo_nails + self.ammo_count; + break; + case 3: // rockets + if (other.ammo_rockets >= 100) + return; + other.ammo_rockets = other.ammo_rockets + self.ammo_count; + break; + case 4: // cells + if (other.ammo_cells >= 100) + return; + other.ammo_cells = other.ammo_cells + self.ammo_count; + break; + } + + bound_other_ammo (); + + sprint3 (other, PRINT_LOW, "You got the ", self.netname, "\n"); +// ammo touch sound + sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + +// change to a better weapon if appropriate + + stemp = self; + self = other; + + if ( self.weapon == best ) + self.weapon = W_BestWeapon(); + +// if changed current ammo, update it + W_SetCurrentAmmo(); + self = stemp; + +// remove it in single player, or setup for respawning in deathmatch + self.model = string_null; + self.solid = SOLID_NOT; + if (deathmatch != 2) + self.nextthink = time + 30; + +// Xian -- If playing in DM 3.0 mode, halve the time ammo respawns + + if (deathmatch == 3 || deathmatch == 5) + self.nextthink = time + 15; + + self.think = SUB_regen; + + activator = other; + SUB_UseTargets(); // fire all targets / killtargets +}; + + + + +float WEAPON_BIG2 = 1; + +/*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) big +*/ + +void() item_shells = +{ + if (deathmatch == 4) + { + remove(self); + return; + } + + self.touch = ammo_touch; + + if (self.spawnflags & WEAPON_BIG2) + { + precache_model ("maps/b_shell1.bsp"); + setmodel (self, "maps/b_shell1.bsp"); + self.ammo_count = 40; + } + else + { + precache_model ("maps/b_shell0.bsp"); + setmodel (self, "maps/b_shell0.bsp"); + self.ammo_count = 20; + } + self.weapon = 1; + self.netname = "shells"; + setsize (self, '0 0 0', '32 32 56'); + StartItem (); +}; + +/*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) big +*/ + +void() item_spikes = +{ + if (deathmatch == 4) + { + remove(self); + return; + } + + self.touch = ammo_touch; + + if (self.spawnflags & WEAPON_BIG2) + { + precache_model ("maps/b_nail1.bsp"); + setmodel (self, "maps/b_nail1.bsp"); + self.ammo_count = 50; + } + else + { + precache_model ("maps/b_nail0.bsp"); + setmodel (self, "maps/b_nail0.bsp"); + self.ammo_count = 25; + } + self.weapon = 2; + self.netname = "nails"; + setsize (self, '0 0 0', '32 32 56'); + StartItem (); + +}; + +/*QUAKED item_rockets (0 .5 .8) (0 0 0) (32 32 32) big +*/ + +void() item_rockets = +{ + if (deathmatch == 4) + { + remove(self); + return; + } + + self.touch = ammo_touch; + + if (self.spawnflags & WEAPON_BIG2) + { + precache_model ("maps/b_rock1.bsp"); + setmodel (self, "maps/b_rock1.bsp"); + self.ammo_count = 10; + } + else + { + precache_model ("maps/b_rock0.bsp"); + setmodel (self, "maps/b_rock0.bsp"); + self.ammo_count = 5; + } + self.weapon = 3; + self.netname = "rockets"; + setsize (self, '0 0 0', '32 32 56'); + StartItem (); + +}; + + +/*QUAKED item_cells (0 .5 .8) (0 0 0) (32 32 32) big +*/ + +void() item_cells = +{ + if (deathmatch == 4) + { + remove(self); + return; + } + + self.touch = ammo_touch; + + if (self.spawnflags & WEAPON_BIG2) + { + precache_model ("maps/b_batt1.bsp"); + setmodel (self, "maps/b_batt1.bsp"); + self.ammo_count = 12; + } + else + { + precache_model ("maps/b_batt0.bsp"); + setmodel (self, "maps/b_batt0.bsp"); + self.ammo_count = 6; + } + self.weapon = 4; + self.netname = "cells"; + setsize (self, '0 0 0', '32 32 56'); + StartItem (); + +}; + + +/*QUAKED item_weapon (0 .5 .8) (0 0 0) (32 32 32) shotgun rocket spikes big +DO NOT USE THIS!!!! IT WILL BE REMOVED! +*/ + +float WEAPON_SHOTGUN = 1; +float WEAPON_ROCKET = 2; +float WEAPON_SPIKES = 4; +float WEAPON_MASK = 7; +float WEAPON_BIG = 8; +void() item_weapon = +{ + local float weap; + + weap = self.spawnflags & WEAPON_MASK; + self.touch = ammo_touch; + + self.spawnflags = 0; + if (self.spawnflags & WEAPON_BIG) + + self.spawnflags |= WEAPON_BIG2; + + switch (weap) + { + case WEAPON_SHOTGUN: + self.classname = "item_shells"; + item_shells(); + return; + case WEAPON_SPIKES: + self.classname = "item_spikes"; + item_spikes(); + return; + case WEAPON_ROCKET: + self.classname = "item_rockets"; + item_rockets(); + } +}; + + +/* +=============================================================================== + +KEYS + +=============================================================================== +*/ + +void() key_touch = +{ + if (other.classname != "player") + return; + if (other.health <= 0) + return; + if (other.items & self.items) + return; + + sprint3 (other, PRINT_LOW, "You got the ", self.netname, "\n"); + + sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + other.items = other.items | self.items; + + self.solid = SOLID_NOT; + self.model = string_null; + + activator = other; + SUB_UseTargets(); // fire all targets / killtargets +}; + + +void() key_setsounds = +{ + switch (world.worldtype) + { + case WT_MEDIEVAL: + precache_sound ("misc/medkey.wav"); + self.noise = "misc/medkey.wav"; + break; + case WT_METAL: + precache_sound ("misc/runekey.wav"); + self.noise = "misc/runekey.wav"; + break; + case WT_BASE: + precache_sound2 ("misc/basekey.wav"); + self.noise = "misc/basekey.wav"; + break; + } +}; + +/*QUAKED item_key1 (0 .5 .8) (-16 -16 -24) (16 16 32) +SILVER key +In order for keys to work +you MUST set your maps +worldtype to one of the +following: +0: medieval +1: metal +2: base +*/ + +void() item_key1 = +{ + if (deathmatch) + { + remove(self); + return; + } + + switch (world.worldtype) + { + case WT_MEDIEVAL: + precache_model ("progs/w_s_key.mdl"); + setmodel (self, "progs/w_s_key.mdl"); + self.netname = "silver key"; + break; + case WT_METAL: + precache_model ("progs/m_s_key.mdl"); + setmodel (self, "progs/m_s_key.mdl"); + self.netname = "silver runekey"; + break; + case WT_BASE: + precache_model2 ("progs/b_s_key.mdl"); + setmodel (self, "progs/b_s_key.mdl"); + self.netname = "silver keycard"; + break; + } + + key_setsounds(); + self.touch = key_touch; + self.items = IT_KEY1; + setsize (self, '-16 -16 -24', '16 16 32'); + StartItem (); +}; + +/*QUAKED item_key2 (0 .5 .8) (-16 -16 -24) (16 16 32) +GOLD key +In order for keys to work +you MUST set your maps +worldtype to one of the +following: +0: medieval +1: metal +2: base +*/ + +void() item_key2 = +{ + if (deathmatch) + { + remove(self); + return; + } + + switch (world.worldtype) + { + case WT_MEDIEVAL: + precache_model ("progs/w_g_key.mdl"); + setmodel (self, "progs/w_g_key.mdl"); + self.netname = "gold key"; + break; + case WT_METAL: + precache_model ("progs/m_g_key.mdl"); + setmodel (self, "progs/m_g_key.mdl"); + self.netname = "gold runekey"; + break; + case WT_BASE: + precache_model2 ("progs/b_g_key.mdl"); + setmodel (self, "progs/b_g_key.mdl"); + self.netname = "gold keycard"; + break; + } + key_setsounds(); + self.touch = key_touch; + self.items = IT_KEY2; + setsize (self, '-16 -16 -24', '16 16 32'); + StartItem (); +}; + + + +/* +=============================================================================== + +END OF LEVEL RUNES + +=============================================================================== +*/ + +void() sigil_touch = +{ + if (other.classname != "player") + return; + if (other.health <= 0) + return; + + centerprint (other, "You got the rune!"); + + sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + self.solid = SOLID_NOT; + self.model = string_null; + serverflags = serverflags | (self.spawnflags & 15); + self.classname = ""; // so rune doors won't find it + + activator = other; + SUB_UseTargets(); // fire all targets / killtargets +}; + + +/*QUAKED item_sigil (0 .5 .8) (-16 -16 -24) (16 16 32) E1 E2 E3 E4 +End of level sigil, pick up to end episode and return to jrstart. +*/ + +void() item_sigil = +{ + if (deathmatch) + { + remove(self); + return; + } + + if (!self.spawnflags) + objerror ("no spawnflags"); + + precache_sound ("misc/runekey.wav"); + self.noise = "misc/runekey.wav"; + + switch (self.spawnflags) + { + case 1: + precache_model ("progs/end1.mdl"); + setmodel (self, "progs/end1.mdl"); + break; + case 2: + precache_model2 ("progs/end2.mdl"); + setmodel (self, "progs/end2.mdl"); + break; + case 4: + precache_model2 ("progs/end3.mdl"); + setmodel (self, "progs/end3.mdl"); + break; + case 8: + precache_model2 ("progs/end4.mdl"); + setmodel (self, "progs/end4.mdl"); + break; + } + + self.touch = sigil_touch; + setsize (self, '-16 -16 -24', '16 16 32'); + StartItem (); +}; + +/* +=============================================================================== + +POWERUPS + +=============================================================================== +*/ + +void() powerup_touch; + + +void() powerup_touch = +{ + if (other.classname != "player") + return; + if (other.health <= 0) + return; + + sprint3 (other, PRINT_LOW, "You got the ", self.netname, "\n"); + + self.mdl = self.model; + + if ((self.classname == "item_artifact_invulnerability") || + (self.classname == "item_artifact_invisibility")) + self.nextthink = time + 60*5; + else + self.nextthink = time + 60; + + self.think = SUB_regen; + + sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + self.solid = SOLID_NOT; + other.items = other.items | self.items; + self.model = string_null; + +// do the apropriate action + switch (self.items) + { + case IT_SUIT: + other.rad_time = 1; + other.radsuit_finished = time + 30; + break; + case IT_INVULNERABILITY: + other.invincible_time = 1; + other.invincible_finished = time + 30; + break; + case IT_INVISIBILITY: + other.invisible_time = 1; + other.invisible_finished = time + 30; + break; + case IT_QUAD: + if (deathmatch == 4) + { + other.armortype = 0; + other.armorvalue = 0; + other.ammo_cells = 0; + } + other.super_time = 1; + other.super_damage_finished = time + 30; + break; + } + + activator = other; + SUB_UseTargets(); // fire all targets / killtargets +}; + + + +/*QUAKED item_artifact_invulnerability (0 .5 .8) (-16 -16 -24) (16 16 32) +Player is invulnerable for 30 seconds +*/ +void() item_artifact_invulnerability = +{ + self.touch = powerup_touch; + + precache_model ("progs/invulner.mdl"); + precache_sound ("items/protect.wav"); + precache_sound ("items/protect2.wav"); + precache_sound ("items/protect3.wav"); + self.noise = "items/protect.wav"; + setmodel (self, "progs/invulner.mdl"); + self.netname = "Pentagram of Protection"; + self.effects = self.effects | ef_red; + self.items = IT_INVULNERABILITY; + setsize (self, '-16 -16 -24', '16 16 32'); + StartItem (); +}; + +/*QUAKED item_artifact_envirosuit (0 .5 .8) (-16 -16 -24) (16 16 32) +Player takes no damage from water or slime for 30 seconds +*/ +void() item_artifact_envirosuit = +{ + self.touch = powerup_touch; + + precache_model ("progs/suit.mdl"); + precache_sound ("items/suit.wav"); + precache_sound ("items/suit2.wav"); + self.noise = "items/suit.wav"; + setmodel (self, "progs/suit.mdl"); + self.netname = "Biosuit"; + self.items = IT_SUIT; + setsize (self, '-16 -16 -24', '16 16 32'); + StartItem (); +}; + + +/*QUAKED item_artifact_invisibility (0 .5 .8) (-16 -16 -24) (16 16 32) +Player is invisible for 30 seconds +*/ +void() item_artifact_invisibility = +{ + self.touch = powerup_touch; + + precache_model ("progs/invisibl.mdl"); + precache_sound ("items/inv1.wav"); + precache_sound ("items/inv2.wav"); + precache_sound ("items/inv3.wav"); + self.noise = "items/inv1.wav"; + setmodel (self, "progs/invisibl.mdl"); + self.netname = "Ring of Shadows"; + self.items = IT_INVISIBILITY; + setsize (self, '-16 -16 -24', '16 16 32'); + StartItem (); +}; + + +/*QUAKED item_artifact_super_damage (0 .5 .8) (-16 -16 -24) (16 16 32) +The next attack from the player will do 4x damage +*/ +void() item_artifact_super_damage = +{ + self.touch = powerup_touch; + + precache_model ("progs/quaddama.mdl"); + precache_sound ("items/damage.wav"); + precache_sound ("items/damage2.wav"); + precache_sound ("items/damage3.wav"); + self.noise = "items/damage.wav"; + setmodel (self, "progs/quaddama.mdl"); + if (deathmatch == 4) + self.netname = "OctaPower"; + else + self.netname = "Quad Damage"; + self.items = IT_QUAD; + self.effects = self.effects | ef_blue; + setsize (self, '-16 -16 -24', '16 16 32'); + StartItem (); +}; + + + +/* +=============================================================================== + +PLAYER BACKPACKS + +=============================================================================== +*/ + +void() BackpackTouch = +{ + local string s; + local float best, old, new; + local entity stemp; + local float acount; + local float b_switch; + + if (deathmatch == 4) + if (other.invincible_time > 0) + return; + + b_switch = numberclientinfokey(other,"b_switch"); + if (b_switch == 0) + b_switch = 8; + + if (other.classname != "player") + return; + if (other.health <= 0) + return; + + acount = 0; + if (deathmatch == 4) + { + other.health = other.health + 10; + sprint1 (other, PRINT_LOW, "You get 10 additional health\n"); + if ((other.health > 250) && (other.health < 300)) + sound (other, CHAN_ITEM, "items/protect3.wav", 1, ATTN_NORM); + else + sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + remove(self); + + if (other.health >299) + { + if (other.invincible_time != 1) + { + other.invincible_time = 1; + other.invincible_finished = time + 30; + other.items = other.items | IT_INVULNERABILITY; + + other.super_time = 1; + other.super_damage_finished = time + 30; + other.items = other.items | IT_QUAD; + + other.ammo_cells = 0; + + + sound (other, CHAN_VOICE, "boss1/sight1.wav", 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + bprint2 (PRINT_HIGH, other.netname, " attains bonus powers!!!\n"); + } + } + self = other; + return; + } + + sprint1 (other, PRINT_LOW, "You get "); + + if ((other.items & self.items) == 0) + { + acount = 1; + sprint2 (other, PRINT_LOW, "the ", I_WeaponName(self.items)); + } + +// if the player was using his best weapon, change up to the new one if better + stemp = self; + self = other; + best = W_BestWeapon(); + self = stemp; + +// change weapons + other.ammo_shells = other.ammo_shells + self.ammo_shells; + other.ammo_nails = other.ammo_nails + self.ammo_nails; + other.ammo_rockets = other.ammo_rockets + self.ammo_rockets; + other.ammo_cells = other.ammo_cells + self.ammo_cells; + + new = self.items; + if (!new) + new = other.weapon; + old = other.items; + other.items = other.items | self.items; + + bound_other_ammo (); + + if (self.ammo_shells) + { + s = ftos(self.ammo_shells); + if (acount) + sprint3(other, PRINT_LOW, ". ", s, " shells"); + else + sprint2(other, PRINT_LOW, s, " shells"); + acount = 1; + } + if (self.ammo_nails) + { + s = ftos(self.ammo_nails); + if (acount) + sprint3(other, PRINT_LOW, ". ", s, " nails"); + else + sprint2(other, PRINT_LOW, s, " nails"); + acount = 1; + } + if (self.ammo_rockets) + { + s = ftos(self.ammo_rockets); + if (acount) + sprint3(other, PRINT_LOW, ". ", s, " rockets"); + else + sprint2(other, PRINT_LOW, s, " rockets"); + acount = 1; + } + if (self.ammo_cells) + { + s = ftos(self.ammo_cells); + if (acount) + sprint3(other, PRINT_LOW, ". ", s, " cells"); + else + sprint2(other, PRINT_LOW, s, " cells"); + acount = 1; + } + + if ( (deathmatch==3 || deathmatch == 5) & ( (WeaponCode(new)==6) || (WeaponCode(new)==7) ) & (other.ammo_rockets < 5) ) + other.ammo_rockets = 5; + + sprint1 (other, PRINT_LOW, "\n"); +// backpack touch sound + sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + + remove(self); + self = other; + +// change to the weapon + + + if ( WeaponCode(new) <= b_switch ) + { + if (self.flags & FL_INWATER) + { + if (new != IT_LIGHTNING) + { + Deathmatch_Weapon (old, new); + } + } + else + { + Deathmatch_Weapon (old, new); + } + } + + W_SetCurrentAmmo (); +}; + +/* +=============== +DropBackpack +=============== +*/ +void() DropBackpack = +{ + local entity item; + + if (!(self.ammo_shells + self.ammo_nails + self.ammo_rockets + self.ammo_cells)) + return; // nothing in it + + item = spawn(); + item.origin = self.origin - '0 0 24'; + + item.items = self.weapon; + + item.ammo_shells = self.ammo_shells; + item.ammo_nails = self.ammo_nails; + item.ammo_rockets = self.ammo_rockets; + item.ammo_cells = self.ammo_cells; + + item.velocity_z = 300; + item.velocity_x = -100 + (random() * 200); + item.velocity_y = -100 + (random() * 200); + + item.flags = FL_ITEM; + item.solid = SOLID_TRIGGER; + item.movetype = MOVETYPE_TOSS; + setmodel (item, "progs/backpack.mdl"); + setsize (item, '-16 -16 0', '16 16 56'); + item.touch = BackpackTouch; + + item.nextthink = time + 120; // remove after 2 minutes + item.think = SUB_Remove; +}; + + diff --git a/quakec/basemod/misc.qc b/quakec/basemod/misc.qc new file mode 100644 index 000000000..e1d6e5a21 --- /dev/null +++ b/quakec/basemod/misc.qc @@ -0,0 +1,678 @@ + +/*QUAKED info_null (0 0.5 0) (-4 -4 -4) (4 4 4) +Used as a positional target for spotlights, etc. +*/ +void() info_null = +{ + remove(self); +}; + +/*QUAKED info_notnull (0 0.5 0) (-4 -4 -4) (4 4 4) +Used as a positional target for lightning. +*/ +void() info_notnull = +{ +}; + +//============================================================================ + +float START_OFF = 1; + +void() light_use = +{ + if (self.spawnflags & START_OFF) + { + lightstyle(self.style, "m"); + self.spawnflags = self.spawnflags - START_OFF; + } + else + { + lightstyle(self.style, "a"); + self.spawnflags = self.spawnflags | START_OFF; + } +}; + +/*QUAKED light (0 1 0) (-8 -8 -8) (8 8 8) START_OFF +Non-displayed light. +Default light value is 300 +Default style is 0 +If targeted, it will toggle between on or off. +*/ +void() light = +{ + if (!self.targetname) + { // inert light + remove(self); + return; + } + + if (self.style >= 32) + { + self.use = light_use; + if (self.spawnflags & START_OFF) + lightstyle(self.style, "a"); + else + lightstyle(self.style, "m"); + } +}; + +/*QUAKED light_fluoro (0 1 0) (-8 -8 -8) (8 8 8) START_OFF +Non-displayed light. +Default light value is 300 +Default style is 0 +If targeted, it will toggle between on or off. +Makes steady fluorescent humming sound +*/ +void() light_fluoro = +{ + if (self.style >= 32) + { + self.use = light_use; + if (self.spawnflags & START_OFF) + lightstyle(self.style, "a"); + else + lightstyle(self.style, "m"); + } + + precache_sound ("ambience/fl_hum1.wav"); + ambientsound (self.origin, "ambience/fl_hum1.wav", 0.5, ATTN_STATIC); +}; + +/*QUAKED light_fluorospark (0 1 0) (-8 -8 -8) (8 8 8) +Non-displayed light. +Default light value is 300 +Default style is 10 +Makes sparking, broken fluorescent sound +*/ +void() light_fluorospark = +{ + if (!self.style) + self.style = 10; + + precache_sound ("ambience/buzz1.wav"); + ambientsound (self.origin, "ambience/buzz1.wav", 0.5, ATTN_STATIC); +}; + +/*QUAKED light_globe (0 1 0) (-8 -8 -8) (8 8 8) +Sphere globe light. +Default light value is 300 +Default style is 0 +*/ +void() light_globe = +{ + precache_model ("progs/s_light.spr"); + setmodel (self, "progs/s_light.spr"); + makestatic (self); +}; + +void() FireAmbient = +{ + precache_sound ("ambience/fire1.wav"); +// attenuate fast + ambientsound (self.origin, "ambience/fire1.wav", 0.5, ATTN_STATIC); +}; + +/*QUAKED light_torch_small_walltorch (0 .5 0) (-10 -10 -20) (10 10 20) +Short wall torch +Default light value is 200 +Default style is 0 +*/ +void() light_torch_small_walltorch = +{ + precache_model ("progs/flame.mdl"); + setmodel (self, "progs/flame.mdl"); + FireAmbient (); + makestatic (self); +}; + +/*QUAKED light_flame_large_yellow (0 1 0) (-10 -10 -12) (12 12 18) +Large yellow flame ball +*/ +void() light_flame_large_yellow = +{ + precache_model ("progs/flame2.mdl"); + setmodel (self, "progs/flame2.mdl"); + self.frame = 1; + FireAmbient (); + makestatic (self); +}; + +/*QUAKED light_flame_small_yellow (0 1 0) (-8 -8 -8) (8 8 8) START_OFF +Small yellow flame ball +*/ +void() light_flame_small_yellow = +{ + precache_model ("progs/flame2.mdl"); + setmodel (self, "progs/flame2.mdl"); + FireAmbient (); + makestatic (self); +}; + +/*QUAKED light_flame_small_white (0 1 0) (-10 -10 -40) (10 10 40) START_OFF +Small white flame ball +*/ +void() light_flame_small_white = +{ + precache_model ("progs/flame2.mdl"); + setmodel (self, "progs/flame2.mdl"); + FireAmbient (); + makestatic (self); +}; + +//============================================================================ + + +/*QUAKED misc_fireball (0 .5 .8) (-8 -8 -8) (8 8 8) +Lava Balls +*/ + +void() fire_fly; +void() fire_touch; +void() misc_fireball = +{ + + precache_model ("progs/lavaball.mdl"); + self.classname = "fireball"; + self.nextthink = time + 0.1 + (random() * 4.9); + self.think = fire_fly; + if (!self.speed) + self.speed = 1000; +}; + +void() fire_fly = +{ +local entity fireball; + + fireball = spawn(); + fireball.solid = SOLID_TRIGGER; + fireball.movetype = MOVETYPE_TOSS; + fireball.velocity = '0 0 1000'; + fireball.velocity_x = (random() * 100) - 50; + fireball.velocity_y = (random() * 100) - 50; + fireball.velocity_z = self.speed + (random() * 200); + fireball.classname = "fireball"; + setmodel (fireball, "progs/lavaball.mdl"); + setsize (fireball, '0 0 0', '0 0 0'); + setorigin (fireball, self.origin); + fireball.nextthink = time + 5; + fireball.think = SUB_Remove; + fireball.touch = fire_touch; + + self.nextthink = time + (random() * 5) + 3; + self.think = fire_fly; +}; + + +void() fire_touch = +{ + T_Damage (other, world, world, 20, MOD_FIREBALL); + remove(self); +}; + +//============================================================================ + + +void() barrel_explode = +{ + self.takedamage = DAMAGE_NO; + self.classname = "explo_box"; + // did say self.owner, self.enemy should be set by Killed function + T_RadiusDamage (self, self.enemy, 160, self, MOD_EXPLOBOX); + TE_explosion(self.origin + '0 0 32'); + remove (self); +}; + + + +/*QUAKED misc_explobox (0 .5 .8) (0 0 0) (32 32 64) +TESTING THING +*/ + +void() misc_explobox = +{ + local float oldz; + + self.solid = SOLID_BBOX; + self.movetype = MOVETYPE_NONE; + precache_model ("maps/b_explob.bsp"); + setmodel (self, "maps/b_explob.bsp"); + setsize (self, '0 0 0', '32 32 64'); + precache_sound ("weapons/r_exp3.wav"); + self.health = 20; + self.th_die = barrel_explode; + self.takedamage = DAMAGE_AIM; + + self.origin_z = self.origin_z + 2; + oldz = self.origin_z; + droptofloor(); + if (oldz - self.origin_z > 250) + { + dprint ("item fell out of level at "); + dprint (vtos(self.origin)); + dprint ("\n"); + remove(self); + } +}; + + + + +/*QUAKED misc_explobox2 (0 .5 .8) (0 0 0) (32 32 64) +Smaller exploding box, REGISTERED ONLY +*/ + +void() misc_explobox2 = +{ + local float oldz; + + self.solid = SOLID_BBOX; + self.movetype = MOVETYPE_NONE; + precache_model2 ("maps/b_exbox2.bsp"); + setmodel (self, "maps/b_exbox2.bsp"); + setsize (self, '0 0 0', '32 32 32'); + precache_sound ("weapons/r_exp3.wav"); + self.health = 20; + self.th_die = barrel_explode; + self.takedamage = DAMAGE_AIM; + + self.origin_z = self.origin_z + 2; + oldz = self.origin_z; + droptofloor(); + if (oldz - self.origin_z > 250) + { + dprint ("item fell out of level at "); + dprint (vtos(self.origin)); + dprint ("\n"); + remove(self); + } +}; + +//============================================================================ + +float SPAWNFLAG_SUPERSPIKE = 1; +float SPAWNFLAG_LASER = 2; + +void() Laser_Touch = +{ + local vector org; + + if (other == self.owner) + return; // don't explode on owner + + if (pointcontents(self.origin) == CONTENT_SKY) + { + remove(self); + return; + } + + sound (self, CHAN_WEAPON, "enforcer/enfstop.wav", 1, ATTN_STATIC); + org = self.origin - 8*normalize(self.velocity); + + if (other.health) + { + SpawnBlood (org, 15); + T_Damage (other, self, self.owner, 15, MOD_LASER); + } + else + { + TE_gunshot(org); + } + + remove(self); +}; + +void(vector org, vector vec) LaunchLaser = +{ + if (self.classname == "monster_enforcer") + sound (self, CHAN_WEAPON, "enforcer/enfire.wav", 1, ATTN_NORM); + + vec = normalize(vec); + + newmis = spawn(); + newmis.owner = self; + newmis.movetype = MOVETYPE_FLY; + newmis.solid = SOLID_BBOX; + newmis.effects = EF_DIMLIGHT; + + setmodel (newmis, "progs/laser.mdl"); + setsize (newmis, '0 0 0', '0 0 0'); + + setorigin (newmis, org); + + newmis.velocity = vec * 600; + newmis.angles = vectoangles(newmis.velocity); + + newmis.nextthink = time + 5; + newmis.think = SUB_Remove; + newmis.touch = Laser_Touch; +}; + +void() spikeshooter_use = +{ + if (self.spawnflags & SPAWNFLAG_LASER) + { + sound (self, CHAN_VOICE, "enforcer/enfire.wav", 1, ATTN_NORM); + LaunchLaser (self.origin, self.movedir); + } + else + { + sound (self, CHAN_VOICE, "weapons/spike2.wav", 1, ATTN_NORM); + launch_spike (self.origin, self.movedir); + newmis.velocity = self.movedir * 500; + if (self.spawnflags & SPAWNFLAG_SUPERSPIKE) + newmis.touch = superspike_touch; + } +}; + +void() shooter_think = +{ + spikeshooter_use (); + self.nextthink = time + self.wait; + newmis.velocity = self.movedir * 500; +}; + + +/*QUAKED trap_spikeshooter (0 .5 .8) (-8 -8 -8) (8 8 8) superspike laser +When triggered, fires a spike in the direction set in QuakeEd. +Laser is only for REGISTERED. +*/ + +void() trap_spikeshooter = +{ + SetMovedir (); + self.use = spikeshooter_use; + if (self.spawnflags & SPAWNFLAG_LASER) + { + precache_model2 ("progs/laser.mdl"); + + precache_sound2 ("enforcer/enfire.wav"); + precache_sound2 ("enforcer/enfstop.wav"); + } + else + precache_sound ("weapons/spike2.wav"); +}; + + +/*QUAKED trap_shooter (0 .5 .8) (-8 -8 -8) (8 8 8) superspike laser +Continuously fires spikes. +"wait" time between spike (1.0 default) +"nextthink" delay before firing first spike, so multiple shooters can be stagered. +*/ +void() trap_shooter = +{ + trap_spikeshooter (); + + if (self.wait == 0) + self.wait = 1; + self.nextthink = self.nextthink + self.wait + self.ltime; + self.think = shooter_think; +}; + + + +/* +=============================================================================== + + +=============================================================================== +*/ + + +void() make_bubbles; +void() bubble_remove; +void() bubble_bob; + +/*QUAKED air_bubbles (0 .5 .8) (-8 -8 -8) (8 8 8) + +testing air bubbles +*/ + +void() air_bubbles = +{ + remove (self); +}; + +void() make_bubbles = +{ +local entity bubble; + + bubble = spawn(); + setmodel (bubble, "progs/s_bubble.spr"); + setorigin (bubble, self.origin); + bubble.movetype = MOVETYPE_NOCLIP; + bubble.solid = SOLID_NOT; + bubble.velocity = '0 0 15'; + bubble.nextthink = time + 0.5; + bubble.think = bubble_bob; + bubble.touch = bubble_remove; + bubble.classname = "bubble"; + bubble.frame = 0; + bubble.cnt = 0; + setsize (bubble, '-8 -8 -8', '8 8 8'); + self.nextthink = time + random() + 0.5; + self.think = make_bubbles; +}; + +void() bubble_split = +{ +local entity bubble; + bubble = spawn(); + setmodel (bubble, "progs/s_bubble.spr"); + setorigin (bubble, self.origin); + bubble.movetype = MOVETYPE_NOCLIP; + bubble.solid = SOLID_NOT; + bubble.velocity = self.velocity; + bubble.nextthink = time + 0.5; + bubble.think = bubble_bob; + bubble.touch = bubble_remove; + bubble.classname = "bubble"; + bubble.frame = 1; + bubble.cnt = 10; + setsize (bubble, '-8 -8 -8', '8 8 8'); + self.frame = 1; + self.cnt = 10; + if (self.waterlevel != 3) + remove (self); +}; + +void() bubble_remove = +{ + if (other.classname == self.classname) + { +// dprint ("bump"); + return; + } + remove(self); +}; + +void() bubble_bob = +{ +local float rnd1, rnd2, rnd3; + + self.cnt = self.cnt + 1; + if (self.cnt == 4) + bubble_split(); + if (self.cnt == 20) + remove(self); + + rnd1 = self.velocity_x + (-10 + (random() * 20)); + rnd2 = self.velocity_y + (-10 + (random() * 20)); + rnd3 = self.velocity_z + 10 + random() * 10; + + if (rnd1 > 10) + rnd1 = 5; + if (rnd1 < -10) + rnd1 = -5; + + if (rnd2 > 10) + rnd2 = 5; + if (rnd2 < -10) + rnd2 = -5; + + if (rnd3 < 10) + rnd3 = 15; + if (rnd3 > 30) + rnd3 = 25; + + self.velocity_x = rnd1; + self.velocity_y = rnd2; + self.velocity_z = rnd3; + + self.nextthink = time + 0.5; + self.think = bubble_bob; +}; + +/*~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~> +~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~*/ + +/*QUAKED viewthing (0 .5 .8) (-8 -8 -8) (8 8 8) + +Just for the debugging level. Don't use +*/ + +void() viewthing = + +{ + self.movetype = MOVETYPE_NONE; + self.solid = SOLID_NOT; + precache_model ("progs/player.mdl"); + setmodel (self, "progs/player.mdl"); +}; + + +/* +============================================================================== + +SIMPLE BMODELS + +============================================================================== +*/ + +void() func_wall_use = +{ // change to alternate textures + self.frame = 1 - self.frame; +}; + +/*QUAKED func_wall (0 .5 .8) ? +This is just a solid wall if not inhibitted +*/ +void() func_wall = +{ + self.angles = '0 0 0'; + self.movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything + self.solid = SOLID_BSP; + self.use = func_wall_use; + setmodel (self, self.model); +}; + + +/*QUAKED func_illusionary (0 .5 .8) ? +A simple entity that looks solid but lets you walk through it. +*/ +void() func_illusionary = + +{ + self.angles = '0 0 0'; + self.movetype = MOVETYPE_NONE; + self.solid = SOLID_NOT; + setmodel (self, self.model); + makestatic (self); +}; + +/*QUAKED func_episodegate (0 .5 .8) ? E1 E2 E3 E4 +This bmodel will appear if the episode has allready been completed, so players can't reenter it. +*/ +void() func_episodegate = + +{ + if (!(serverflags & self.spawnflags)) + return; // can still enter episode + + self.angles = '0 0 0'; + self.movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything + self.solid = SOLID_BSP; + self.use = func_wall_use; + setmodel (self, self.model); +}; + +/*QUAKED func_bossgate (0 .5 .8) ? +This bmodel appears unless players have all of the episode sigils. +*/ +void() func_bossgate = + +{ + if ( (serverflags & 15) == 15) + return; // all episodes completed + self.angles = '0 0 0'; + self.movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything + self.solid = SOLID_BSP; + self.use = func_wall_use; + setmodel (self, self.model); +}; + +//============================================================================ +/*QUAKED ambient_suck_wind (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) +*/ +void() ambient_suck_wind = +{ + precache_sound ("ambience/suck1.wav"); + ambientsound (self.origin, "ambience/suck1.wav", 1, ATTN_STATIC); +}; + +/*QUAKED ambient_drone (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) +*/ +void() ambient_drone = +{ + precache_sound ("ambience/drone6.wav"); + ambientsound (self.origin, "ambience/drone6.wav", 0.5, ATTN_STATIC); +}; + +/*QUAKED ambient_flouro_buzz (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) +*/ +void() ambient_flouro_buzz = +{ + precache_sound ("ambience/buzz1.wav"); + ambientsound (self.origin, "ambience/buzz1.wav", 1, ATTN_STATIC); +}; +/*QUAKED ambient_drip (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) +*/ +void() ambient_drip = +{ + precache_sound ("ambience/drip1.wav"); + ambientsound (self.origin, "ambience/drip1.wav", 0.5, ATTN_STATIC); +}; +/*QUAKED ambient_comp_hum (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) +*/ +void() ambient_comp_hum = +{ + precache_sound ("ambience/comp1.wav"); + ambientsound (self.origin, "ambience/comp1.wav", 1, ATTN_STATIC); +}; +/*QUAKED ambient_thunder (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) +*/ +void() ambient_thunder = +{ + precache_sound ("ambience/thunder1.wav"); + ambientsound (self.origin, "ambience/thunder1.wav", 0.5, ATTN_STATIC); +}; +/*QUAKED ambient_light_buzz (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) +*/ +void() ambient_light_buzz = +{ + precache_sound ("ambience/fl_hum1.wav"); + ambientsound (self.origin, "ambience/fl_hum1.wav", 0.5, ATTN_STATIC); +}; +/*QUAKED ambient_swamp1 (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) +*/ +void() ambient_swamp1 = +{ + precache_sound ("ambience/swamp1.wav"); + ambientsound (self.origin, "ambience/swamp1.wav", 0.5, ATTN_STATIC); +}; +/*QUAKED ambient_swamp2 (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) +*/ +void() ambient_swamp2 = +{ + precache_sound ("ambience/swamp2.wav"); + ambientsound (self.origin, "ambience/swamp2.wav", 0.5, ATTN_STATIC); +}; diff --git a/quakec/basemod/models.qc b/quakec/basemod/models.qc new file mode 100644 index 000000000..56f474d56 --- /dev/null +++ b/quakec/basemod/models.qc @@ -0,0 +1,585 @@ + +/* +=============================================================================== + +WORLD WEAPONS + +=============================================================================== +*/ + +$modelname g_shot +$cd /raid/quake/id1/models/g_shot +$origin 0 0 -24 +$flags 8 // client side rotate +$base base +$skin skin +$frame shot1 + + +$modelname g_nail +$cd /raid/quake/id1/models/g_nail +$flags 8 // client side rotate +$origin 0 0 -24 +$base base +$skin skin +$frame shot1 + + +$modelname g_nail2 +$cd /raid/quake/id1/models/g_nail2 +$flags 8 // client side rotate +$origin 0 0 -24 +$base base +$skin skin +$frame shot2 + + +$modelname g_rock +$cd /raid/quake/id1/models/g_rock +$flags 8 // client side rotate +$origin 0 0 -24 +$base base +$skin skin +$frame shot1 + + +$modelname g_rock2 +$cd /raid/quake/id1/models/g_rock2 +$flags 8 // client side rotate +$origin 0 0 -24 +$base base +$skin skin +$frame shot1 + +$modelname g_light +$cd /raid/quake/id1/models/g_light +$flags 8 // client side rotate +$origin 0 0 -24 +$base base +$skin skin +$frame shot1 + +/* +=============================================================================== + +VIEW WEAPONS + +=============================================================================== +*/ + +$modelname v_axe +$cd /raid/quake/id1/models/v_axe +$origin 0 5 54 +$base base +$skin skin +$frame frame1 frame2 frame3 frame4 frame5 frame6 frame7 frame8 frame9 + + +$modelname v_shot +$cd /raid/quake/id1/models/v_shot +$origin 0 0 54 +$base base +$skin skin +$frame shot1 shot2 shot3 shot4 shot5 shot6 shot7 + + +$modelname v_shot2 +$cd /raid/quake/id1/models/v_shot2 +$origin 0 0 56 +$base base +$skin skin +$frame shot1 shot2 shot3 shot4 shot5 shot6 shot7 + + +$modelname v_rock2 +$cd /raid/quake/id1/models/v_rock2 +$origin 0 0 54 +$base base +$skin skin +$frame shot1 shot2 shot3 shot4 shot5 shot6 shot6 + + +$modelname v_rock +$cd /raid/quake/id1/models/v_rock +$origin 0 0 54 +$base base +$skin skin +$frame shot1 shot2 shot3 shot4 shot5 shot6 shot7 + + +$modelname v_nail2 +$cd /raid/quake/id1/models/v_nail2 +$origin 0 0 54 +$base base +$skin skin +$frame shot1 shot2 shot3 shot4 shot5 shot6 shot7 shot8 shot9 + + +$modelname v_nail +$cd /raid/quake/id1/models/v_nail +$origin 0 0 54 +$base base +$skin skin +$frame shot1 shot2 shot3 shot4 shot5 shot6 shot7 shot8 shot9 + +$modelname v_light +$cd /raid/quake/id1/models/v_light +$origin 0 0 54 +$base base +$skin skin +$frame shot1 shot2 shot3 shot4 shot5 + + +/* +=============================================================================== + +ITEMS + +=============================================================================== +*/ + +$modelname w_g_key +$cd /raid/quake/id1/models/w_g_key +$flags 8 // client side rotate +$base base +$skin skin +$frame frame1 + +$modelname w_s_key +$cd /raid/quake/id1/models/w_s_key +$flags 8 // client side rotate +$base base +$skin skin +$frame frame1 + +$modelname m_g_key +$cd /raid/quake/id1/models/m_g_key +$flags 8 // client side rotate +$base base +$skin skin +$frame frame1 + +$modelname m_s_key +$cd /raid/quake/id1/models/m_s_key +$flags 8 // client side rotate +$base base +$skin skin +$frame frame1 + +$modelname b_g_key +$cd /raid/quake/id1/models/b_g_key +$flags 8 // client side rotate +$base base +$skin skin +$frame frame1 + +$modelname b_s_key +$cd /raid/quake/id1/models/b_s_key +$flags 8 // client side rotate +$base base +$skin skin +$frame frame1 + + +$modelname quaddama +$cd /raid/quake/id1/models/quaddama +$flags 8 // client side rotate +$base base +$skin skin +$frame frame1 + +$modelname invisibl +$cd /raid/quake/id1/models/invisibl +$flags 8 // client side rotate +$base base +$skin skin +$frame frame1 + +$modelname invulner +$flags 8 // client side rotate +$cd /raid/quake/id1/models/invulner +$base base +$skin skin +$frame frame1 + +//modelname jetpack +//cd /raid/quake/id1/models/jetpack +//flags 8 // client side rotate +//base base +//skin skin +//frame frame1 + +$modelname cube +$cd /raid/quake/id1/models/cube +$flags 8 // client side rotate +$base base +$skin skin +$frame frame1 + +$modelname suit +$cd /raid/quake/id1/models/suit +$flags 8 // client side rotate +$base base +$skin skin +$frame frame1 + +$modelname boots +$cd /raid/quake/id1/models/boots +$flags 8 // client side rotate +$base base +$skin skin +$frame frame1 + +$modelname end1 +$cd /raid/quake/id1/models/end1 +$flags 8 // client side rotate +$base base +$skin skin +$frame frame1 + +$modelname end2 +$cd /raid/quake/id1/models/end2 +$flags 8 // client side rotate +$base base +$skin skin +$frame frame1 + +$modelname end3 +$cd /raid/quake/id1/models/end3 +$flags 8 // client side rotate +$base base +$skin skin +$frame frame1 + +$modelname end4 +$cd /raid/quake/id1/models/end4 +$flags 8 // client side rotate +$base base +$skin skin +$frame frame1 + + +/* +=============================================================================== + +GIBS + +=============================================================================== +*/ + +$modelname gib1 +$cd /raid/quake/id1/models/gib1 +$flags 4 // EF_GIB +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + + +// torso +$modelname gib2 +$cd /raid/quake/id1/models/gib2 +$flags 4 // EF_GIB +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +$modelname gib3 +$cd /raid/quake/id1/models/gib3 +$flags 4 // EF_GIB +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + + +// heads + +$modelname h_player +$cd /raid/quake/id1/models/h_player +$flags 4 // EF_GIB +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +$modelname h_dog +$cd /raid/quake/id1/models/h_dog +$flags 4 // EF_GIB +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +$modelname h_mega +$cd /raid/quake/id1/models/h_mega +$flags 4 // EF_GIB +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +$modelname h_guard +$cd /raid/quake/id1/models/h_guard +$flags 4 // EF_GIB +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +$modelname h_wizard +$cd /raid/quake/id1/models/h_wizard +$flags 4 // EF_GIB +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +$modelname h_knight +$cd /raid/quake/id1/models/h_knight +$flags 4 // EF_GIB +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +$modelname h_hellkn +$cd /raid/quake/id1/models/h_hellkn +$flags 4 // EF_GIB +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +$modelname h_zombie +$cd /raid/quake/id1/models/h_zombie +$flags 4 // EF_GIB +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +$modelname h_shams +$cd /raid/quake/id1/models/h_shams +$flags 4 // EF_GIB +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +$modelname h_shal +$cd /raid/quake/id1/models/h_shal +$flags 4 // EF_GIB +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +$modelname h_ogre +$cd /raid/quake/id1/models/h_ogre +$flags 4 // EF_GIB +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +$modelname h_demon +$cd /raid/quake/id1/models/h_demon +$flags 4 // EF_GIB +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +/* +=============================================================================== + +MISC + +=============================================================================== +*/ + +$modelname armor +$cd /raid/quake/id1/models/armor +$flags 8 // client side rotate +$origin 0 0 -8 +$base base +$skin skin +$skin skin2 +$skin skin3 +$frame armor + +$modelname s_light // shambler lightning ready +$cd /raid/quake/id1/models/s_light +$origin 0 0 24 +$base base +$skin skin +$frame frame1 frame2 frame3 + +$modelname bolt3 // lightning towar bolts +$cd /raid/quake/id1/models/bolt2 +$origin 0 0 0 +$base base +$scale 4 +$skin skin +$frame light + +$modelname bolt2 +$cd /raid/quake/id1/models/bolt2 +$origin 0 0 0 +$base base +$skin skin +$frame light + +$modelname bolt +$cd /raid/quake/id1/models/bolt +$origin 0 0 0 +$base light +$skin light +$frame light + +$modelname laser +$cd /raid/quake/id1/models/laser +$base base +$skin skin +$scale 2 +$frame frame1 + +$modelname flame // with torch +$cd /raid/quake/id1/models/flame +$origin 0 0 12 +$base base +$skin skin +$framegroupstart +$frame flame1 0.1 +$frame flame2 0.1 +$frame flame3 0.1 +$frame flame4 0.1 +$frame flame5 0.1 +$frame flame6 0.1 +$framegroupend + +$modelname flame2 // standing flame, no torch +$cd /raid/quake/id1/models/flame2 +$origin 0 0 12 +$base base +$skin skin +$framegroupstart +$frame flame1 0.1 +$frame flame2 0.1 +$frame flame3 0.1 +$frame flame4 0.1 +$frame flame5 0.1 +$frame flame6 0.1 +$framegroupend +$framegroupstart +$frame flameb1 +$frame flameb2 +$frame flameb3 +$frame flameb4 +$frame flameb5 +$frame flameb6 +$frame flameb7 +$frame flameb8 +$frame flameb9 +$frame flameb10 +$frame flameb11 +$framegroupend + +$modelname zom_gib +$cd /raid/quake/id1/models/zom_gib +$flags 32 // EF_ZOMGIB +$base base +$skin skin +$frame frame1 + +$modelname eyes +$cd /raid/quake/id1/models/eyes +$origin 0 0 -24 +$base base +$skin skin +$frame frame1 + +$modelname spike +$cd /raid/quake/id1/models/spike +$origin 0 0 0 +$base spike +$skin skin +$frame spike + +$modelname s_spike +$cd /raid/quake/id1/models/s_spike +$origin 0 0 0 +$base spike +$skin skin +$frame spike + +$modelname v_spike +$cd /raid/quake/id1/models/v_spike +$flags 128 // EF_TRACER3 +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +$modelname w_spike +$cd /raid/quake/id1/models/w_spike +$flags 16 // EF_TRACER +$origin 0 0 0 +$base base +$skin skin +$framegroupstart +$frame frame1 0.1 +$frame frame2 0.1 +$frame frame3 0.1 +$frame frame4 0.1 +$framegroupend + +$modelname k_spike +$cd /raid/quake/id1/models/k_spike +$flags 64 // EF_TRACER2 +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +$modelname backpack +$cd /raid/quake/id1/models/backpack +$flags 8 // EF_ROTATE +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +$modelname grenade +$cd /raid/quake/id1/models/grenade2 +$flags 2 // EF_GRENADE +$origin 0 0 0 +$base base +$skin skin +$frame grenade + +$modelname missile +$cd /raid/quake/id1/models/missile +$flags 1 // EF_ROCKET +$origin 0 0 0 +$base base +$skin skin +$frame missile + +$modelname lavaball +$cd /raid/quake/id1/models/lavaball +$flags 1 // EF_ROCKET +$origin 0 0 0 +$base base +$skin skin +$frame frame1 + +$modelname teleport +$cd /raid/quake/id1/models/teleport +$origin 0 0 24 +$base base +$skin skin +$frame frame1 + diff --git a/quakec/basemod/obituary.qc b/quakec/basemod/obituary.qc new file mode 100644 index 000000000..e40c5800f --- /dev/null +++ b/quakec/basemod/obituary.qc @@ -0,0 +1,285 @@ +// client death messages +#define MOD_NONE 0 +#define MOD_AXE 1 +#define MOD_SHOTGUN 2 +#define MOD_SUPERSHOTGUN 3 +#define MOD_SPIKE 4 +#define MOD_SUPERSPIKE 5 +#define MOD_GRENADE 6 +#define MOD_ROCKET 8 +#define MOD_ROCKETRADIUS 9 +#define MOD_SHAFT 10 +#define MOD_SHAFTWATER 11 +#define MOD_SHAFTSLIME 12 +#define MOD_SHAFTLAVA 13 +#define MOD_TELEFRAG 14 +#define MOD_TELEFRAGDEFLECT 15 +#define MOD_SQUISH 16 +#define MOD_DROWN 17 +#define MOD_SLIME 18 +#define MOD_LAVA 19 +#define MOD_EXPLOBOX 20 +#define MOD_FALL 21 +#define MOD_FIREBALL 22 +#define MOD_EXIT 23 +#define MOD_LASER 24 +#define MOD_SELFWATER 25 +#define MOD_HURT 26 + +void(string targ, INTEGER mod) SuicideMessage = +{ + string s, t, u; + + s = ""; + t = ""; + u = ""; + + switch (mod) + { + case MOD_GRENADE: + s = targ; + t = " tries to put the pin back in"; + break; + case MOD_SHAFTWATER: + s = targ; + t = " discharges into the water."; + break; + case MOD_SHAFTSLIME: + s = targ; + t = " discharges into the slime"; + break; + case MOD_SHAFTLAVA: + s = targ; + t = " discharges into the lava"; + break; + case MOD_TELEFRAGDEFLECT: + s = "Satan's power deflects "; + t = targ; + u = "'s telefrag"; + break; + case MOD_SELFWATER: + s = targ; + t = " electrocutes himself."; + break; + case MOD_EXPLOBOX: + s = targ; + t = " blew himself up"; + break; + default: + s = targ; + t = " becomes bored with life"; + } + + bprint4(PRINT_MEDIUM, s, t, u, "\n"); +} + +void(string targ, string attacker, INTEGER mod) KillMessage = +{ + string s, t, u, v, w; + + s = ""; + t = ""; + u = ""; + v = ""; + w = ""; + + switch (mod) + { + case MOD_AXE: + s = targ; + t = " was ax-murdered by "; + u = attacker; + break; + case MOD_SHOTGUN: + s = targ; + t = " chewed on "; + u = attacker; + v = "'s boomstick"; + break; + case MOD_SUPERSHOTGUN: + s = targ; + t = " ate two loads of "; + u = attacker; + v = "'s buckshot"; + break; + case MOD_SPIKE: + s = targ; + t = " was nailed by "; + u = attacker; + break; + case MOD_SUPERSPIKE: + s = targ; + t = " was punctured by "; + u = attacker; + break; + case MOD_GRENADE: + s = targ; + t = " eats "; + u = attacker; + v = "'s pineapple"; + break; + case MOD_ROCKET: + case MOD_ROCKETRADIUS: + s = targ; + t = " rides "; + u = attacker; + v = "'s rocket"; + break; + case MOD_SHAFT: + s = targ; + t = " accepts "; + u = attacker; + v = "'s shaft"; + break; + case MOD_SHAFTWATER: + case MOD_SHAFTSLIME: + case MOD_SHAFTLAVA: + s = targ; + t = " accepts "; + u = attacker; + v = "'s discharge"; + break; + case MOD_TELEFRAG: + s = targ; + t = " was telefragged by "; + u = attacker; + break; + case MOD_TELEFRAGDEFLECT: + s = targ; + t = " was telefragged by "; + u = attacker; + v = "'s Satan's power"; + break; + case MOD_SQUISH: + s = attacker; + t = " squishes "; + u = targ; + break; + case MOD_EXPLOBOX: + s = targ; + t = " was blown up by "; + u = attacker; + break; + default: + s = targ; + t = " was killed by "; + u = attacker; + } + + bprint6(PRINT_MEDIUM, s, t, u, v, w, "\n"); +} + +void(string targ, string attacker, INTEGER mod) TeamKillMessage = +{ + string s, t, u, v, w; + float rnum; + + s = ""; + t = ""; + u = ""; + v = ""; + w = ""; + + switch (mod) + { + case MOD_SQUISH: + s = attacker; + t = " squishes teammate "; + u = targ; + break; + default: + rnum = random(); + + s = attacker; + + if (rnum < 0.25) + t = " mows down teammate "; + else if (rnum < 0.5) + { + t = " checks his glasses and sees "; + v = " dead"; + } + else if (rnum < 0.75) + { + t = " frags "; + v = " for the other team"; + } + else + t = " loses his friend "; + + u = targ; + } + + bprint6(PRINT_MEDIUM, s, t, u, v, w, "\n"); +} + +void(string targ, INTEGER mod) WorldKillMessage = +{ + string s, t, u; + + s = ""; + t = ""; + u = ""; + + switch (mod) + { + case MOD_SPIKE: + case MOD_SUPERSPIKE: + s = targ; + t = " was spiked"; + break; + case MOD_SQUISH: + s = targ; + t = " was squished"; + break; + case MOD_DROWN: + s = targ; + + if (random() < 0.5) + t = " sleeps with the fishes"; + else + t = " sucks it down"; + break; + case MOD_SLIME: + s = targ; + + if (random() < 0.5) + t = " gulped a load of slime"; + else + t = " can't exist on slime alone"; + break; + case MOD_LAVA: + s = targ; + + if (random() < 0.5) + t = " turned into hot slag"; + else + t = " visits the Volcano God"; + break; + case MOD_EXPLOBOX: + s = targ; + t = " blew up"; + break; + case MOD_FALL: + s = targ; + t = " fell to his death"; + break; + case MOD_FIREBALL: + s = targ; + t = " ate a lavaball"; + break; + case MOD_EXIT: + s = targ; + t = " tried to leave"; + break; + case MOD_LASER: + s = targ; + t = " was zapped"; + break; + default: + s = targ; + t = " died"; + } + + bprint4(PRINT_MEDIUM, s, t, u, "\n"); +} \ No newline at end of file diff --git a/quakec/basemod/plats.qc b/quakec/basemod/plats.qc new file mode 100644 index 000000000..f66623182 --- /dev/null +++ b/quakec/basemod/plats.qc @@ -0,0 +1,363 @@ + + +void() plat_center_touch; +void() plat_outside_touch; +void() plat_trigger_use; +void() plat_go_up; +void() plat_go_down; +void() plat_crush; +float PLAT_LOW_TRIGGER = 1; + +void() plat_spawn_inside_trigger = +{ + local entity trigger; + local vector tmin, tmax; + +// +// middle trigger +// + trigger = spawn(); + trigger.touch = plat_center_touch; + trigger.movetype = MOVETYPE_NONE; + trigger.solid = SOLID_TRIGGER; + trigger.enemy = self; + + tmin = self.mins + '25 25 0'; + tmax = self.maxs - '25 25 -8'; + tmin_z = tmax_z - (self.pos1_z - self.pos2_z + 8); + if (self.spawnflags & PLAT_LOW_TRIGGER) + tmax_z = tmin_z + 8; + + if (self.size_x <= 50) + { + tmin_x = (self.mins_x + self.maxs_x) / 2; + tmax_x = tmin_x + 1; + } + if (self.size_y <= 50) + { + tmin_y = (self.mins_y + self.maxs_y) / 2; + tmax_y = tmin_y + 1; + } + + setsize (trigger, tmin, tmax); +}; + +void() plat_hit_top = +{ + sound (self, chan_no_phs_add|CHAN_VOICE, self.noise1, 1, ATTN_NORM); + self.state = STATE_TOP; + self.think = plat_go_down; + self.nextthink = self.ltime + 3; +}; + +void() plat_hit_bottom = +{ + sound (self, chan_no_phs_add|CHAN_VOICE, self.noise1, 1, ATTN_NORM); + self.state = STATE_BOTTOM; +}; + +void() plat_go_down = +{ + sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM); + self.state = STATE_DOWN; + SUB_CalcMove (self.pos2, self.speed, plat_hit_bottom); +}; + +void() plat_go_up = +{ + sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM); + self.state = STATE_UP; + SUB_CalcMove (self.pos1, self.speed, plat_hit_top); +}; + +void() plat_center_touch = +{ + if (other.classname != "player") + return; + + if (other.health <= 0) + return; + + self = self.enemy; + if (self.state == STATE_BOTTOM) + plat_go_up (); + else if (self.state == STATE_TOP) + self.nextthink = self.ltime + 1; // delay going down +}; + +void() plat_outside_touch = +{ + if (other.classname != "player") + return; + + if (other.health <= 0) + return; + +//dprint ("plat_outside_touch\n"); + self = self.enemy; + if (self.state == STATE_TOP) + plat_go_down (); +}; + +void() plat_trigger_use = +{ + if (self.think) + return; // allready activated + plat_go_down(); +}; + + +void() plat_crush = +{ +//dprint ("plat_crush\n"); + + T_Damage (other, self, self, 1, MOD_SQUISH); + + if (self.state == STATE_UP) + plat_go_down (); + else if (self.state == STATE_DOWN) + plat_go_up (); + else + objerror ("plat_crush: bad self.state\n"); +}; + +void() plat_use = +{ + self.use = SUB_Null; + if (self.state != STATE_UP) + objerror ("plat_use: not in up state"); + plat_go_down(); +}; + + +/*QUAKED func_plat (0 .5 .8) ? PLAT_LOW_TRIGGER +speed default 150 + +Plats are always drawn in the extended position, so they will light correctly. + +If the plat is the target of another trigger or button, it will start out disabled in the extended position until it is trigger, when it will lower and become a normal plat. + +If the "height" key is set, that will determine the amount the plat moves, instead of being implicitly determined by the model's height. +Set "sounds" to one of the following: +1) base fast +2) chain slow +*/ + + +void() func_plat = + +{ + + if (!self.t_length) + self.t_length = 80; + if (!self.t_width) + self.t_width = 10; + + if (self.sounds == 0) + self.sounds = 2; +// FIX THIS TO LOAD A GENERIC PLAT SOUND + + if (self.sounds == 1) + { + precache_sound ("plats/plat1.wav"); + precache_sound ("plats/plat2.wav"); + self.noise = "plats/plat1.wav"; + self.noise1 = "plats/plat2.wav"; + } + else if (self.sounds == 2) + { + precache_sound ("plats/medplat1.wav"); + precache_sound ("plats/medplat2.wav"); + self.noise = "plats/medplat1.wav"; + self.noise1 = "plats/medplat2.wav"; + } + + + self.mangle = self.angles; + self.angles = '0 0 0'; + + self.classname = "plat"; + self.solid = SOLID_BSP; + self.movetype = MOVETYPE_PUSH; + setorigin (self, self.origin); + setmodel (self, self.model); + setsize (self, self.mins , self.maxs); + + self.blocked = plat_crush; + if (!self.speed) + self.speed = 150; + +// pos1 is the top position, pos2 is the bottom + self.pos1 = self.origin; + self.pos2 = self.origin; + if (self.height) + self.pos2_z = self.origin_z - self.height; + else + self.pos2_z = self.origin_z - self.size_z + 8; + + self.use = plat_trigger_use; + + plat_spawn_inside_trigger (); // the "start moving" trigger + + if (self.targetname) + { + self.state = STATE_UP; + self.use = plat_use; + } + else + { + setorigin (self, self.pos2); + self.state = STATE_BOTTOM; + } +}; + +//============================================================================ + +void() train_next; +void() func_train_find; + +void() train_blocked = +{ + if (time < self.attack_finished) + return; + self.attack_finished = time + 0.5; + T_Damage (other, self, self, self.dmg, MOD_SQUISH); +}; + +void() train_use = +{ + if (self.think != func_train_find) + return; // already activated + train_next(); +}; + +void() train_wait = +{ + if (self.wait) + { + self.nextthink = self.ltime + self.wait; + sound (self, chan_no_phs_add|CHAN_VOICE, self.noise, 1, ATTN_NORM); + } + else + self.nextthink = self.ltime + 0.1; + + self.think = train_next; +}; + +void() train_next = +{ + local entity targ; + + targ = find (world, targetname, self.target); + self.target = targ.target; + if (!self.target) + objerror ("train_next: no next target"); + if (targ.wait) + self.wait = targ.wait; + else + self.wait = 0; + sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM); + SUB_CalcMove (targ.origin - self.mins, self.speed, train_wait); +}; + +void() func_train_find = + +{ + local entity targ; + + targ = find (world, targetname, self.target); + self.target = targ.target; + setorigin (self, targ.origin - self.mins); + if (!self.targetname) + { // not triggered, so start immediately + self.nextthink = self.ltime + 0.1; + self.think = train_next; + } +}; + +/*QUAKED func_train (0 .5 .8) ? +Trains are moving platforms that players can ride. +The targets origin specifies the min point of the train at each corner. +The train spawns at the first target it is pointing at. +If the train is the target of a button or trigger, it will not begin moving until activated. +speed default 100 +dmg default 2 +sounds +1) ratchet metal + +*/ +void() func_train = +{ + if (!self.speed) + self.speed = 100; + if (!self.target) + objerror ("func_train without a target"); + if (!self.dmg) + self.dmg = 2; + + if (self.sounds == 0) + { + self.noise = ("misc/null.wav"); + precache_sound ("misc/null.wav"); + self.noise1 = ("misc/null.wav"); + precache_sound ("misc/null.wav"); + } + + if (self.sounds == 1) + { + self.noise = ("plats/train2.wav"); + precache_sound ("plats/train2.wav"); + self.noise1 = ("plats/train1.wav"); + precache_sound ("plats/train1.wav"); + } + + self.cnt = 1; + self.solid = SOLID_BSP; + self.movetype = MOVETYPE_PUSH; + self.blocked = train_blocked; + self.use = train_use; + self.classname = "train"; + + setmodel (self, self.model); + setsize (self, self.mins , self.maxs); + setorigin (self, self.origin); + +// start trains on the second frame, to make sure their targets have had +// a chance to spawn + self.nextthink = self.ltime + 0.1; + self.think = func_train_find; +}; + +/*QUAKED misc_teleporttrain (0 .5 .8) (-8 -8 -8) (8 8 8) +This is used for the final bos +*/ +void() misc_teleporttrain = +{ + if (!self.speed) + self.speed = 100; + if (!self.target) + objerror ("func_train without a target"); + + self.cnt = 1; + self.solid = SOLID_NOT; + self.movetype = MOVETYPE_PUSH; + self.blocked = train_blocked; + self.use = train_use; + self.avelocity = '100 200 300'; + + self.noise = ("misc/null.wav"); + precache_sound ("misc/null.wav"); + self.noise1 = ("misc/null.wav"); + precache_sound ("misc/null.wav"); + + precache_model2 ("progs/teleport.mdl"); + setmodel (self, "progs/teleport.mdl"); + setsize (self, self.mins , self.maxs); + setorigin (self, self.origin); + +// start trains on the second frame, to make sure their targets have had +// a chance to spawn + self.nextthink = self.ltime + 0.1; + self.think = func_train_find; +}; + diff --git a/quakec/basemod/player.qc b/quakec/basemod/player.qc new file mode 100644 index 000000000..95471d18a --- /dev/null +++ b/quakec/basemod/player.qc @@ -0,0 +1,638 @@ + +void() bubble_bob; + +/* +============================================================================== + +PLAYER + +============================================================================== +*/ + +$cd /raid/quake/id1/models/player_4 +$origin 0 -6 24 +$base base +$skin skin + +// +// running +// +$frame axrun1 axrun2 axrun3 axrun4 axrun5 axrun6 + +$frame rockrun1 rockrun2 rockrun3 rockrun4 rockrun5 rockrun6 + +// +// standing +// +$frame stand1 stand2 stand3 stand4 stand5 + +$frame axstnd1 axstnd2 axstnd3 axstnd4 axstnd5 axstnd6 +$frame axstnd7 axstnd8 axstnd9 axstnd10 axstnd11 axstnd12 + + +// +// pain +// +$frame axpain1 axpain2 axpain3 axpain4 axpain5 axpain6 + +$frame pain1 pain2 pain3 pain4 pain5 pain6 + + +// +// death +// + +$frame axdeth1 axdeth2 axdeth3 axdeth4 axdeth5 axdeth6 +$frame axdeth7 axdeth8 axdeth9 + +$frame deatha1 deatha2 deatha3 deatha4 deatha5 deatha6 deatha7 deatha8 +$frame deatha9 deatha10 deatha11 + +$frame deathb1 deathb2 deathb3 deathb4 deathb5 deathb6 deathb7 deathb8 +$frame deathb9 + +$frame deathc1 deathc2 deathc3 deathc4 deathc5 deathc6 deathc7 deathc8 +$frame deathc9 deathc10 deathc11 deathc12 deathc13 deathc14 deathc15 + +$frame deathd1 deathd2 deathd3 deathd4 deathd5 deathd6 deathd7 +$frame deathd8 deathd9 + +$frame deathe1 deathe2 deathe3 deathe4 deathe5 deathe6 deathe7 +$frame deathe8 deathe9 + +// +// attacks +// +$frame nailatt1 nailatt2 + +$frame light1 light2 + +$frame rockatt1 rockatt2 rockatt3 rockatt4 rockatt5 rockatt6 + +$frame shotatt1 shotatt2 shotatt3 shotatt4 shotatt5 shotatt6 + +$frame axatt1 axatt2 axatt3 axatt4 axatt5 axatt6 + +$frame axattb1 axattb2 axattb3 axattb4 axattb5 axattb6 + +$frame axattc1 axattc2 axattc3 axattc4 axattc5 axattc6 + +$frame axattd1 axattd2 axattd3 axattd4 axattd5 axattd6 + + +/* +============================================================================== +PLAYER +============================================================================== +*/ + +void() player_run; + +void() player_stand1 =[ $axstnd1, player_stand1 ] +{ + if (self.velocity_x || self.velocity_y) + { + self.walkframe=0; + player_run(); + return; + } + + if (self.weapon == IT_AXE) + { + if (self.walkframe >= 12) + self.walkframe = 0; + self.frame = $axstnd1 + self.walkframe; + } + else + { + if (self.walkframe >= 5) + self.walkframe = 0; + self.frame = $stand1 + self.walkframe; + } + self.walkframe = self.walkframe + 1; +}; + +void() player_run =[ $rockrun1, player_run ] +{ + if (!self.velocity_x && !self.velocity_y) + { + self.walkframe=0; + player_stand1(); + return; + } + + if (self.weapon == IT_AXE) + { + if (self.walkframe == 6) + self.walkframe = 0; + self.frame = $axrun1 + self.walkframe; + } + else + { + if (self.walkframe == 6) + self.walkframe = 0; + self.frame = self.frame + self.walkframe; + } + self.walkframe = self.walkframe + 1; +}; + +void() player_shot1 = [$shotatt1, player_shot2 ] {}; +void() player_shot2 = [$shotatt2, player_shot3 ] {}; +void() player_shot3 = [$shotatt3, player_shot4 ] {}; +void() player_shot4 = [$shotatt4, player_shot5 ] {}; +void() player_shot5 = [$shotatt5, player_shot6 ] {}; +void() player_shot6 = [$shotatt6, player_run ] {}; + +void() player_axe1 = [$axatt1, player_axe2 ] {}; +void() player_axe2 = [$axatt2, player_axe3 ] {}; +void() player_axe3 = [$axatt3, player_axe4 ] {W_FireAxe();}; +void() player_axe4 = [$axatt4, player_run ] {}; + +void() player_axeb1 = [$axattb1, player_axeb2 ] {}; +void() player_axeb2 = [$axattb2, player_axeb3 ] {}; +void() player_axeb3 = [$axattb3, player_axeb4 ] {W_FireAxe();}; +void() player_axeb4 = [$axattb4, player_run ] {}; + +void() player_axec1 = [$axattc1, player_axec2 ] {}; +void() player_axec2 = [$axattc2, player_axec3 ] {}; +void() player_axec3 = [$axattc3, player_axec4 ] {W_FireAxe();}; +void() player_axec4 = [$axattc4, player_run ] {}; + +void() player_axed1 = [$axattd1, player_axed2 ] {}; +void() player_axed2 = [$axattd2, player_axed3 ] {}; +void() player_axed3 = [$axattd3, player_axed4 ] {W_FireAxe();}; +void() player_axed4 = [$axattd4, player_run ] {}; + + +//============================================================================ + +void() player_nail1 =[$nailatt1, player_nail2 ] +{ + if (!self.button0 || intermission_running || self.impulse) + {player_run ();return;} +}; +void() player_nail2 =[$nailatt2, player_nail1 ] +{ + if (!self.button0 || intermission_running || self.impulse) + {player_run ();return;} +}; + +//============================================================================ + +void() player_light1 =[$light1, player_light2 ] +{ + if (!self.button0 || intermission_running) + {player_run ();return;} +}; +void() player_light2 =[$light2, player_light1 ] +{ + if (!self.button0 || intermission_running) + {player_run ();return;} +}; + +//============================================================================ + + +void() player_rocket1 =[$rockatt1, player_rocket2 ] {}; +void() player_rocket2 =[$rockatt2, player_rocket3 ] {}; +void() player_rocket3 =[$rockatt3, player_rocket4 ] {}; +void() player_rocket4 =[$rockatt4, player_rocket5 ] {}; +void() player_rocket5 =[$rockatt5, player_rocket6 ] {}; +void() player_rocket6 =[$rockatt6, player_run ] {}; +void(float num_bubbles) DeathBubbles; + +void() PainSound = +{ + local float rs; + local string s; + + if (self.health < 0) + return; + + if (self.pain_finished > time) + return; + + // change pain sound depending on means of death + switch (damage_mod) + { + case MOD_TELEFRAG: + case MOD_TELEFRAGDEFLECT: + sound (self, CHAN_VOICE, "player/teledth1.wav", 1, ATTN_NONE); + return; + case MOD_DROWN: + DeathBubbles(1); + if (random() > 0.5) + sound (self, CHAN_VOICE, "player/drown1.wav", 1, ATTN_NORM); + else + sound (self, CHAN_VOICE, "player/drown2.wav", 1, ATTN_NORM); + return; + case MOD_SLIME: + // FIX ME: put in some steam here + if (self.waterlevel == 3) + DeathBubbles(1); + case MOD_LAVA: + if (random() > 0.5) + sound (self, CHAN_VOICE, "player/lburn1.wav", 1, ATTN_NORM); + else + sound (self, CHAN_VOICE, "player/lburn2.wav", 1, ATTN_NORM); + return; + case MOD_AXE: + sound (self, CHAN_VOICE, "player/axhit1.wav", 1, ATTN_NORM); + self.pain_finished = time + 0.5; + return; + default: + rs = random(); + + s = "player/pain6.wav"; + if (rs < 0.166) + s = "player/pain1.wav"; + else if (rs < 0.333) + s = "player/pain2.wav"; + else if (rs < 0.5) + s = "player/pain3.wav"; + else if (rs < 0.667) + s = "player/pain4.wav"; + else if (rs < 0.833) + s = "player/pain5.wav"; + + sound (self, CHAN_VOICE, s, 1, ATTN_NORM); + return; + } +}; + +void() player_pain1 = [ $pain1, player_pain2 ] {PainSound();}; +void() player_pain2 = [ $pain2, player_pain3 ] {}; +void() player_pain3 = [ $pain3, player_pain4 ] {}; +void() player_pain4 = [ $pain4, player_pain5 ] {}; +void() player_pain5 = [ $pain5, player_pain6 ] {}; +void() player_pain6 = [ $pain6, player_run ] {}; + +void() player_axpain1 = [ $axpain1, player_axpain2 ] {PainSound();}; +void() player_axpain2 = [ $axpain2, player_axpain3 ] {}; +void() player_axpain3 = [ $axpain3, player_axpain4 ] {}; +void() player_axpain4 = [ $axpain4, player_axpain5 ] {}; +void() player_axpain5 = [ $axpain5, player_axpain6 ] {}; +void() player_axpain6 = [ $axpain6, player_run ] {}; + +void() player_pain = +{ + if (self.weaponframe) + return; + + if (self.invisible_finished > time) + return; // eyes don't have pain frames + + if (self.weapon == IT_AXE) + player_axpain1 (); + else + player_pain1 (); +}; + +void() player_diea1; +void() player_dieb1; +void() player_diec1; +void() player_died1; +void() player_diee1; +void() player_die_ax1; + +void() DeathBubblesSpawn = +{ +local entity bubble; + if (self.owner.waterlevel != 3) + { + remove(self); + return; + } + bubble = spawn(); + setmodel (bubble, "progs/s_bubble.spr"); + setorigin (bubble, self.owner.origin + '0 0 24'); + bubble.movetype = MOVETYPE_NOCLIP; + bubble.solid = SOLID_NOT; + bubble.velocity = '0 0 15'; + bubble.nextthink = time + 0.5; + bubble.think = bubble_bob; + bubble.classname = "bubble"; + bubble.frame = 0; + bubble.cnt = 0; + setsize (bubble, '-8 -8 -8', '8 8 8'); + self.nextthink = time + 0.1; + self.think = DeathBubblesSpawn; + self.air_finished = self.air_finished + 1; + if (self.air_finished >= self.bubble_count) + remove(self); +}; + +void(float num_bubbles) DeathBubbles = +{ +local entity bubble_spawner; + + bubble_spawner = spawn(); + setorigin (bubble_spawner, self.origin); + bubble_spawner.movetype = MOVETYPE_NONE; + bubble_spawner.solid = SOLID_NOT; + bubble_spawner.nextthink = time + 0.1; + bubble_spawner.think = DeathBubblesSpawn; + bubble_spawner.air_finished = 0; + bubble_spawner.owner = self; + bubble_spawner.bubble_count = num_bubbles; +}; + + +void() DeathSound = +{ +local float rs; + + // water death sounds + if (self.waterlevel == 3) + { + DeathBubbles(5); + sound (self, CHAN_VOICE, "player/h2odeath.wav", 1, ATTN_NONE); + return; + } + + rs = rint ((random() * 4) + 1); + if (rs == 1) + self.noise = "player/death1.wav"; + if (rs == 2) + self.noise = "player/death2.wav"; + if (rs == 3) + self.noise = "player/death3.wav"; + if (rs == 4) + self.noise = "player/death4.wav"; + if (rs == 5) + self.noise = "player/death5.wav"; + + sound (self, CHAN_VOICE, self.noise, 1, ATTN_NONE); + return; +}; + + +void() PlayerDead = +{ + self.nextthink = -1; +// allow respawn after a certain time + self.deadflag = DEAD_DEAD; +}; + +vector(float dm) VelocityForDamage = +{ + local vector v; + + if (vlen(damage_inflictor.velocity)>0) + { + v = 0.5 * damage_inflictor.velocity; + v = v + (25 * normalize(self.origin-damage_inflictor.origin)); + v_z = 100 + 240 * random(); + v_x = v_x + (200 * crandom()); + v_y = v_y + (200 * crandom()); + //dprint ("Velocity gib\n"); + } + else + { + v_x = 100 * crandom(); + v_y = 100 * crandom(); + v_z = 200 + 100 * random(); + } + + //v_x = 100 * crandom(); + //v_y = 100 * crandom(); + //v_z = 200 + 100 * random(); + + if (dm > -50) + { + // dprint ("level 1\n"); + v = v * 0.7; + } + else if (dm > -200) + { + // dprint ("level 3\n"); + v = v * 2; + } + else + v = v * 10; + + return v; +}; + +void(string gibname, float dm) ThrowGib = +{ + local entity new; + + new = spawn(); + new.origin = self.origin; + setmodel (new, gibname); + setsize (new, '0 0 0', '0 0 0'); + new.velocity = VelocityForDamage (dm); + new.movetype = MOVETYPE_BOUNCE; + new.solid = SOLID_NOT; + new.avelocity_x = random()*600; + new.avelocity_y = random()*600; + new.avelocity_z = random()*600; + new.think = SUB_Remove; + new.ltime = time; + new.nextthink = time + 10 + random()*10; + new.frame = 0; + new.flags = 0; +}; + +void(string gibname, float dm) ThrowHead = +{ + setmodel (self, gibname); + self.frame = 0; + self.nextthink = -1; + self.movetype = MOVETYPE_BOUNCE; + self.takedamage = DAMAGE_NO; + self.solid = SOLID_NOT; + self.view_ofs = '0 0 8'; + setsize (self, '-16 -16 0', '16 16 56'); + self.velocity = VelocityForDamage (dm); + self.origin_z = self.origin_z - 24; + self.flags = self.flags - (self.flags & FL_ONGROUND); + self.avelocity = crandom() * '0 600 0'; +}; + + +void() GibPlayer = +{ + ThrowHead ("progs/h_player.mdl", self.health); + ThrowGib ("progs/gib1.mdl", self.health); + ThrowGib ("progs/gib2.mdl", self.health); + ThrowGib ("progs/gib3.mdl", self.health); + + self.deadflag = DEAD_DEAD; + + if (damage_attacker.classname == "teledeath") + { + sound (self, CHAN_VOICE, "player/teledth1.wav", 1, ATTN_NONE); + return; + } + + if (random() < 0.5) + sound (self, CHAN_VOICE, "player/gib.wav", 1, ATTN_NONE); + else + sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NONE); +}; + +void() PlayerDropStuff = +{ + local string s, t; + + if (numberserverinfokey("dq") != 0) + { + if (self.super_damage_finished > time) + { + DropQuad (self.super_damage_finished - time); + s = ftos(rint(self.super_damage_finished - time)); + t = " lost a quad with "; + if (deathmatch == 4) + t = " lost an OctaPower with "; + bprint4 (PRINT_LOW, self.netname, t, s, " seconds remaining\n"); + } + } + + if (numberserverinfokey("dr") != 0) + { + if (self.invisible_finished > time) + { + s = ftos(rint(self.invisible_finished - time)); + bprint4 (PRINT_LOW, self.netname, " lost a ring with ", s, " seconds remaining\n"); + DropRing (self.invisible_finished - time); + } + } + + DropBackpack(); +} + +void() PlayerDie = +{ + local float i; + self.items = self.items - (self.items & IT_INVISIBILITY); + + PlayerDropStuff(); + + self.invisible_finished = 0; // don't die as eyes + self.invincible_finished = 0; + self.super_damage_finished = 0; + self.radsuit_finished = 0; + self.modelindex = modelindex_player; // don't use eyes + + self.weaponmodel=""; + self.view_ofs = '0 0 -8'; + self.deadflag = DEAD_DYING; + self.solid = SOLID_NOT; + self.flags = self.flags - (self.flags & FL_ONGROUND); + self.movetype = MOVETYPE_TOSS; + if (self.velocity_z < 10) + self.velocity_z = self.velocity_z + random()*300; + + if (self.health < -40) + { + GibPlayer (); + return; + } + + DeathSound(); + + self.angles_x = 0; + self.angles_z = 0; + + if (self.weapon == IT_AXE) + { + player_die_ax1 (); + return; + } + + i = random(); + + if (i < 0.2) + player_diea1(); + else if (i < 0.4) + player_dieb1(); + else if (i < 0.6) + player_diec1(); + else if (i < 0.8) + player_died1(); + else + player_diee1(); + +}; + +void() set_suicide_frame = +{ // used by klill command and diconnect command + if (self.model != "progs/player.mdl") + return; // allready gibbed + self.frame = $deatha11; + self.solid = SOLID_NOT; + self.movetype = MOVETYPE_TOSS; + self.deadflag = DEAD_DEAD; + self.nextthink = -1; +}; + + +void() player_diea1 = [ $deatha1, player_diea2 ] {}; +void() player_diea2 = [ $deatha2, player_diea3 ] {}; +void() player_diea3 = [ $deatha3, player_diea4 ] {}; +void() player_diea4 = [ $deatha4, player_diea5 ] {}; +void() player_diea5 = [ $deatha5, player_diea6 ] {}; +void() player_diea6 = [ $deatha6, player_diea7 ] {}; +void() player_diea7 = [ $deatha7, player_diea8 ] {}; +void() player_diea8 = [ $deatha8, player_diea9 ] {}; +void() player_diea9 = [ $deatha9, player_diea10 ] {}; +void() player_diea10 = [ $deatha10, player_diea11 ] {}; +void() player_diea11 = [ $deatha11, player_diea11 ] {PlayerDead();}; + +void() player_dieb1 = [ $deathb1, player_dieb2 ] {}; +void() player_dieb2 = [ $deathb2, player_dieb3 ] {}; +void() player_dieb3 = [ $deathb3, player_dieb4 ] {}; +void() player_dieb4 = [ $deathb4, player_dieb5 ] {}; +void() player_dieb5 = [ $deathb5, player_dieb6 ] {}; +void() player_dieb6 = [ $deathb6, player_dieb7 ] {}; +void() player_dieb7 = [ $deathb7, player_dieb8 ] {}; +void() player_dieb8 = [ $deathb8, player_dieb9 ] {}; +void() player_dieb9 = [ $deathb9, player_dieb9 ] {PlayerDead();}; + +void() player_diec1 = [ $deathc1, player_diec2 ] {}; +void() player_diec2 = [ $deathc2, player_diec3 ] {}; +void() player_diec3 = [ $deathc3, player_diec4 ] {}; +void() player_diec4 = [ $deathc4, player_diec5 ] {}; +void() player_diec5 = [ $deathc5, player_diec6 ] {}; +void() player_diec6 = [ $deathc6, player_diec7 ] {}; +void() player_diec7 = [ $deathc7, player_diec8 ] {}; +void() player_diec8 = [ $deathc8, player_diec9 ] {}; +void() player_diec9 = [ $deathc9, player_diec10 ] {}; +void() player_diec10 = [ $deathc10, player_diec11 ] {}; +void() player_diec11 = [ $deathc11, player_diec12 ] {}; +void() player_diec12 = [ $deathc12, player_diec13 ] {}; +void() player_diec13 = [ $deathc13, player_diec14 ] {}; +void() player_diec14 = [ $deathc14, player_diec15 ] {}; +void() player_diec15 = [ $deathc15, player_diec15 ] {PlayerDead();}; + +void() player_died1 = [ $deathd1, player_died2 ] {}; +void() player_died2 = [ $deathd2, player_died3 ] {}; +void() player_died3 = [ $deathd3, player_died4 ] {}; +void() player_died4 = [ $deathd4, player_died5 ] {}; +void() player_died5 = [ $deathd5, player_died6 ] {}; +void() player_died6 = [ $deathd6, player_died7 ] {}; +void() player_died7 = [ $deathd7, player_died8 ] {}; +void() player_died8 = [ $deathd8, player_died9 ] {}; +void() player_died9 = [ $deathd9, player_died9 ] {PlayerDead();}; + +void() player_diee1 = [ $deathe1, player_diee2 ] {}; +void() player_diee2 = [ $deathe2, player_diee3 ] {}; +void() player_diee3 = [ $deathe3, player_diee4 ] {}; +void() player_diee4 = [ $deathe4, player_diee5 ] {}; +void() player_diee5 = [ $deathe5, player_diee6 ] {}; +void() player_diee6 = [ $deathe6, player_diee7 ] {}; +void() player_diee7 = [ $deathe7, player_diee8 ] {}; +void() player_diee8 = [ $deathe8, player_diee9 ] {}; +void() player_diee9 = [ $deathe9, player_diee9 ] {PlayerDead();}; + +void() player_die_ax1 = [ $axdeth1, player_die_ax2 ] {}; +void() player_die_ax2 = [ $axdeth2, player_die_ax3 ] {}; +void() player_die_ax3 = [ $axdeth3, player_die_ax4 ] {}; +void() player_die_ax4 = [ $axdeth4, player_die_ax5 ] {}; +void() player_die_ax5 = [ $axdeth5, player_die_ax6 ] {}; +void() player_die_ax6 = [ $axdeth6, player_die_ax7 ] {}; +void() player_die_ax7 = [ $axdeth7, player_die_ax8 ] {}; +void() player_die_ax8 = [ $axdeth8, player_die_ax9 ] {}; +void() player_die_ax9 = [ $axdeth9, player_die_ax9 ] {PlayerDead();}; diff --git a/quakec/basemod/progs.src b/quakec/basemod/progs.src new file mode 100644 index 000000000..a89e2dc9d --- /dev/null +++ b/quakec/basemod/progs.src @@ -0,0 +1,21 @@ +./qwprogs.dat + +defs.qc +subs.qc +engine.qc +effects.qc +obituary.qc +combat.qc +items.qc +weapons.qc +world.qc +client.qc +spectate.qc +player.qc +doors.qc +buttons.qc +triggers.qc +plats.qc +misc.qc + +server.qc diff --git a/quakec/basemod/server.qc b/quakec/basemod/server.qc new file mode 100644 index 000000000..38df848a1 --- /dev/null +++ b/quakec/basemod/server.qc @@ -0,0 +1,99 @@ + +void() monster_ogre = {remove(self);}; +void() monster_demon1 = {remove(self);}; +void() monster_shambler = {remove(self);}; +void() monster_knight = {remove(self);}; +void() monster_army = {remove(self);}; +void() monster_wizard = {remove(self);}; +void() monster_dog = {remove(self);}; +void() monster_zombie = {remove(self);}; +void() monster_boss = {remove(self);}; +void() monster_tarbaby = {remove(self);}; +void() monster_hell_knight = {remove(self);}; +void() monster_fish = {remove(self);}; +void() monster_shalrath = {remove(self);}; +void() monster_enforcer = {remove(self);}; +void() monster_oldone = {remove(self);}; +void() event_lightning = {remove(self);}; + +/* +============================================================================== + +MOVETARGET CODE + +The angle of the movetarget effects standing and bowing direction, but has no effect on movement, which allways heads to the next target. + +targetname +must be present. The name of this movetarget. + +target +the next spot to move to. If not present, stop here for good. + +pausetime +The number of seconds to spend standing or bowing for path_stand or path_bow + +============================================================================== +*/ + +/* +============= +t_movetarget + +Something has bumped into a movetarget. If it is a monster +moving towards it, change the next destination and continue. +============== +*/ +void() t_movetarget = +{ +local entity temp; + + if (other.movetarget != self) + return; + + if (other.enemy) + return; // fighting, not following a path + + temp = self; + self = other; + other = temp; + + if (self.classname == "monster_ogre") + sound (self, CHAN_VOICE, "ogre/ogdrag.wav", 1, ATTN_IDLE);// play chainsaw drag sound + +//dprint ("t_movetarget\n"); + self.goalentity = self.movetarget = find (world, targetname, other.target); + self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin); + if (!self.movetarget) + { + self.pausetime = time + 999999; + self.th_stand (); + } +}; + + + +void() movetarget_f = +{ + if (!self.targetname) + objerror ("monster_movetarget: no targetname"); + + self.solid = SOLID_TRIGGER; + self.touch = t_movetarget; + setsize (self, '-8 -8 -8', '8 8 8'); + +}; + +/*QUAKED path_corner (0.5 0.3 0) (-8 -8 -8) (8 8 8) +Monsters will continue walking towards the next target corner. +*/ +void() path_corner = +{ + if (deathmatch) + remove(self); + else + movetarget_f (); +}; + + + +//============================================================================ diff --git a/quakec/basemod/spectate.qc b/quakec/basemod/spectate.qc new file mode 100644 index 000000000..e675c4409 --- /dev/null +++ b/quakec/basemod/spectate.qc @@ -0,0 +1,80 @@ +// Spectator functions +// Added Aug11'97 by Zoid +// +// These functions are called from the server if they exist. +// Note that Spectators only have one think since they movement code doesn't +// track them much. Impulse commands work as usual, but don't call +// the regular ImpulseCommand handler in weapons.qc since Spectators don't +// have any weapons and things can explode. +// +// --- Zoid. + +/* +=========== +SpectatorConnect + +called when a spectator connects to a server +============ +*/ +void() SpectatorConnect = +{ + bprint3 (PRINT_MEDIUM, "Spectator ", self.netname, " entered the game\n"); + + self.goalentity = world; // used for impulse 1 below +}; + +/* +=========== +SpectatorDisconnect + +called when a spectator disconnects from a server +============ +*/ +void() SpectatorDisconnect = +{ + bprint3 (PRINT_MEDIUM, "Spectator ", self.netname, " left the game\n"); +}; + +/* +================ +SpectatorImpulseCommand + +Called by SpectatorThink if the spectator entered an impulse +================ +*/ +void() SpectatorImpulseCommand = +{ + if (self.impulse == 1) { + // teleport the spectator to the next spawn point + // note that if the spectator is tracking, this doesn't do + // much + self.goalentity = find(self.goalentity, classname, "info_player_deathmatch"); + if (self.goalentity == world) + self.goalentity = find(self.goalentity, classname, "info_player_deathmatch"); + if (self.goalentity != world) { + setorigin(self, self.goalentity.origin); + self.angles = self.goalentity.angles; + self.fixangle = TRUE; // turn this way immediately + } + } + + self.impulse = 0; +}; + +/* +================ +SpectatorThink + +Called every frame after physics are run +================ +*/ +void() SpectatorThink = +{ + // self.origin, etc contains spectator position, so you could + // do some neat stuff here + + if (self.impulse) + SpectatorImpulseCommand(); +}; + + diff --git a/quakec/basemod/sprites.qc b/quakec/basemod/sprites.qc new file mode 100644 index 000000000..f1bb605f4 --- /dev/null +++ b/quakec/basemod/sprites.qc @@ -0,0 +1,26 @@ + +// these are the only sprites still in the game... + +$spritename s_explod +$type vp_parallel +$load /raid/quake/id1/gfx/sprites/explod03.lbm +$frame 24 24 56 56 +$frame 120 24 56 56 +$frame 216 24 56 56 +$frame 24 88 56 56 +$frame 120 88 56 56 +$frame 216 88 56 56 + + +$spritename s_bubble +$type vp_parallel +$load /raid/quake/id1/gfx/sprites/bubble.lbm +$frame 16 16 16 16 +$frame 40 16 16 16 + + +$spritename s_light +$type vp_parallel +$load /raid/quake/id1/gfx/sprites/light.lbm +$frame 104 32 32 32 + diff --git a/quakec/basemod/subs.qc b/quakec/basemod/subs.qc new file mode 100644 index 000000000..a9c165698 --- /dev/null +++ b/quakec/basemod/subs.qc @@ -0,0 +1,284 @@ + + +void() SUB_Null = {}; + +void() SUB_Remove = {remove(self);}; + + +/* +QuakeEd only writes a single float for angles (bad idea), so up and down are +just constant angles. +*/ +void() SetMovedir = +{ + if (self.angles == '0 -1 0') + self.movedir = '0 0 1'; + else if (self.angles == '0 -2 0') + self.movedir = '0 0 -1'; + else + { + makevectors (self.angles); + self.movedir = v_forward; + } + + self.angles = '0 0 0'; +}; + +/* +================ +InitTrigger +================ +*/ +void() InitTrigger = +{ +// trigger angles are used for one-way touches. An angle of 0 is assumed +// to mean no restrictions, so use a yaw of 360 instead. + if (self.angles != '0 0 0') + SetMovedir (); + self.solid = SOLID_TRIGGER; + setmodel (self, self.model); // set size and link into world + self.movetype = MOVETYPE_NONE; + self.modelindex = 0; + self.model = ""; +}; + +/* +============= +SUB_CalcMove + +calculate self.velocity and self.nextthink to reach dest from +self.origin traveling at speed +=============== +*/ +void(entity ent, vector tdest, float tspeed, void() func) SUB_CalcMoveEnt = +{ +local entity stemp; + stemp = self; + self = ent; + + SUB_CalcMove (tdest, tspeed, func); + self = stemp; +}; + +void(vector tdest, float tspeed, void() func) SUB_CalcMove = +{ +local vector vdestdelta; +local float len, traveltime; + + if (!tspeed) + objerror("No speed is defined!"); + + self.think1 = func; + self.finaldest = tdest; + self.think = SUB_CalcMoveDone; + + if (tdest == self.origin) + { + self.velocity = '0 0 0'; + self.nextthink = self.ltime + 0.1; + return; + } + +// set destdelta to the vector needed to move + vdestdelta = tdest - self.origin; + +// calculate length of vector + len = vlen (vdestdelta); + +// divide by speed to get time to reach dest + traveltime = len / tspeed; + + if (traveltime < 0.03) + traveltime = 0.03; + +// set nextthink to trigger a think when dest is reached + self.nextthink = self.ltime + traveltime; + +// scale the destdelta vector by the time spent traveling to get velocity + self.velocity = vdestdelta * (1/traveltime); // qcc won't take vec/float +}; + +/* +============ +After moving, set origin to exact final destination +============ +*/ +void() SUB_CalcMoveDone = +{ + setorigin(self, self.finaldest); + self.velocity = '0 0 0'; + self.nextthink = -1; + if (self.think1) + self.think1(); +}; + + +/* +============= +SUB_CalcAngleMove + +calculate self.avelocity and self.nextthink to reach destangle from +self.angles rotating + +The calling function should make sure self.think is valid +=============== +*/ +void(entity ent, vector destangle, float tspeed, void() func) SUB_CalcAngleMoveEnt = +{ +local entity stemp; + stemp = self; + self = ent; + SUB_CalcAngleMove (destangle, tspeed, func); + self = stemp; +}; + +void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove = +{ +local vector destdelta; +local float len, traveltime; + + if (!tspeed) + objerror("No speed is defined!"); + +// set destdelta to the vector needed to move + destdelta = destangle - self.angles; + +// calculate length of vector + len = vlen (destdelta); + +// divide by speed to get time to reach dest + traveltime = len / tspeed; + +// set nextthink to trigger a think when dest is reached + self.nextthink = self.ltime + traveltime; + +// scale the destdelta vector by the time spent traveling to get velocity + self.avelocity = destdelta * (1 / traveltime); + + self.think1 = func; + self.finalangle = destangle; + self.think = SUB_CalcAngleMoveDone; +}; + +/* +============ +After rotating, set angle to exact final angle +============ +*/ +void() SUB_CalcAngleMoveDone = +{ + self.angles = self.finalangle; + self.avelocity = '0 0 0'; + self.nextthink = -1; + if (self.think1) + self.think1(); +}; + + +//============================================================================= + +void() DelayThink = +{ + activator = self.enemy; + SUB_UseTargets (); + remove(self); +}; + +/* +============================== +SUB_UseTargets + +the global "activator" should be set to the entity that initiated the firing. + +If self.delay is set, a DelayedUse entity will be created that will actually +do the SUB_UseTargets after that many seconds have passed. + +Centerprints any self.message to the activator. + +Removes all entities with a targetname that match self.killtarget, +and removes them, so some events can remove other triggers. + +Search for (string)targetname in all entities that +match (string)self.target and call their .use function + +============================== +*/ +void() SUB_UseTargets = +{ + local entity t, stemp, otemp, act; + +// +// check for a delay +// + if (self.delay) + { + // create a temp object to fire at a later time + t = spawn(); + t.classname = "DelayedUse"; + t.nextthink = time + self.delay; + t.think = DelayThink; + t.enemy = activator; + t.message = self.message; + t.killtarget = self.killtarget; + t.target = self.target; + return; + } + + +// +// print the message +// + if (activator.classname == "player" && self.message != "") + { + centerprint (activator, self.message); + if (!self.noise) + sound (activator, CHAN_VOICE, "misc/talk.wav", 1, ATTN_NORM); + } + +// +// kill the killtagets +// + if (self.killtarget) + { + t = world; + do + { + t = find (t, targetname, self.killtarget); + if (!t) + return; + remove (t); + } while ( 1 ); + } + +// +// fire targets +// + if (self.target) + { + act = activator; + t = world; + do + { + t = find (t, targetname, self.target); + if (!t) + { + return; + } + stemp = self; + otemp = other; + self = t; + other = stemp; + if (self.use != SUB_Null) + { + if (self.use) + self.use (); + } + self = stemp; + other = otemp; + activator = act; + } while ( 1 ); + } + + +}; + diff --git a/quakec/basemod/triggers.qc b/quakec/basemod/triggers.qc new file mode 100644 index 000000000..6bdfac114 --- /dev/null +++ b/quakec/basemod/triggers.qc @@ -0,0 +1,631 @@ +void() trigger_reactivate = +{ + self.solid = SOLID_TRIGGER; +}; + +//============================================================================= + +float SPAWNFLAG_NOMESSAGE = 1; +float SPAWNFLAG_NOTOUCH = 1; + +// the wait time has passed, so set back up for another activation +void() multi_wait = +{ + if (self.max_health) + { + self.health = self.max_health; + self.takedamage = DAMAGE_YES; + self.solid = SOLID_BBOX; + } +}; + + +// the trigger was just touched/killed/used +// self.enemy should be set to the activator so it can be held through a delay +// so wait for the delay time before firing +void() multi_trigger = +{ + if (self.nextthink > time) + { + return; // allready been triggered + } + + if (self.classname == "trigger_secret") + { + if (self.enemy.classname != "player") + return; + found_secrets = found_secrets + 1; + WriteByte (MSG_ALL, SVC_FOUNDSECRET); + } + + if (self.noise) + sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM); + +// don't trigger again until reset + self.takedamage = DAMAGE_NO; + + activator = self.enemy; + + SUB_UseTargets(); + + if (self.wait > 0) + { + self.think = multi_wait; + self.nextthink = time + self.wait; + } + else + { // we can't just remove (self) here, because this is a touch function + // called wheil C code is looping through area links... + self.touch = SUB_Null; + self.nextthink = time + 0.1; + self.think = SUB_Remove; + } +}; + +void() multi_killed = +{ + self.enemy = damage_attacker; + multi_trigger(); +}; + +void() multi_use = +{ + self.enemy = activator; + multi_trigger(); +}; + +void() multi_touch = +{ + if (other.classname != "player") + return; + +// if the trigger has an angles field, check player's facing direction + if (self.movedir != '0 0 0') + { + makevectors (other.angles); + if (v_forward * self.movedir < 0) + return; // not facing the right way + } + + self.enemy = other; + multi_trigger (); +}; + +/*QUAKED trigger_multiple (.5 .5 .5) ? notouch +Variable sized repeatable trigger. Must be targeted at one or more entities. If "health" is set, the trigger must be killed to activate each time. +If "delay" is set, the trigger waits some time after activating before firing. +"wait" : Seconds between triggerings. (.2 default) +If notouch is set, the trigger is only fired by other entities, not by touching. +NOTOUCH has been obsoleted by trigger_relay! +sounds +1) secret +2) beep beep +3) large switch +4) +set "message" to text string +*/ +void() trigger_multiple = +{ + switch (self.sounds) + { + case 1: + precache_sound ("misc/secret.wav"); + self.noise = "misc/secret.wav"; + break; + case 2: + precache_sound ("misc/talk.wav"); + self.noise = "misc/talk.wav"; + break; + case 3: + precache_sound ("misc/trigger1.wav"); + self.noise = "misc/trigger1.wav"; + break; + } + + if (!self.wait) + self.wait = 0.2; + self.use = multi_use; + + InitTrigger (); + + if (self.health) + { + if (self.spawnflags & SPAWNFLAG_NOTOUCH) + objerror ("health and notouch don't make sense\n"); + self.max_health = self.health; + self.th_die = multi_killed; + self.takedamage = DAMAGE_YES; + self.solid = SOLID_BBOX; + setorigin (self, self.origin); // make sure it links into the world + } + else + { + if ( !(self.spawnflags & SPAWNFLAG_NOTOUCH) ) + { + self.touch = multi_touch; + } + } +}; + + +/*QUAKED trigger_once (.5 .5 .5) ? notouch +Variable sized trigger. Triggers once, then removes itself. You must set the key "target" to the name of another object in the level that has a matching +"targetname". If "health" is set, the trigger must be killed to activate. +If notouch is set, the trigger is only fired by other entities, not by touching. +if "killtarget" is set, any objects that have a matching "target" will be removed when the trigger is fired. +if "angle" is set, the trigger will only fire when someone is facing the direction of the angle. Use "360" for an angle of 0. +sounds +1) secret +2) beep beep +3) large switch +4) +set "message" to text string +*/ +void() trigger_once = +{ + self.wait = -1; + trigger_multiple(); +}; + +//============================================================================= + +/*QUAKED trigger_relay (.5 .5 .5) (-8 -8 -8) (8 8 8) +This fixed size trigger cannot be touched, it can only be fired by other events. It can contain killtargets, targets, delays, and messages. +*/ +void() trigger_relay = +{ + self.use = SUB_UseTargets; +}; + + +//============================================================================= + +/*QUAKED trigger_secret (.5 .5 .5) ? +secret counter trigger +sounds +1) secret +2) beep beep +3) +4) +set "message" to text string +*/ +void() trigger_secret = +{ + total_secrets = total_secrets + 1; + self.wait = -1; + if (!self.message) + self.message = "You found a secret area!"; + if (!self.sounds) + self.sounds = 1; + + if (self.sounds == 1) + { + precache_sound ("misc/secret.wav"); + self.noise = "misc/secret.wav"; + } + else if (self.sounds == 2) + { + precache_sound ("misc/talk.wav"); + self.noise = "misc/talk.wav"; + } + + trigger_multiple (); +}; + +//============================================================================= + + +void() counter_use = +{ + self.count = self.count - 1; + if (self.count < 0) + return; + + if (self.count != 0) + { + if (activator.classname == "player" + && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0) + { + if (self.count >= 4) + centerprint (activator, "There are more to go..."); + else if (self.count == 3) + centerprint (activator, "Only 3 more to go..."); + else if (self.count == 2) + centerprint (activator, "Only 2 more to go..."); + else + centerprint (activator, "Only 1 more to go..."); + } + return; + } + + if (activator.classname == "player" + && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0) + centerprint(activator, "Sequence completed!"); + self.enemy = activator; + multi_trigger (); +}; + +/*QUAKED trigger_counter (.5 .5 .5) ? nomessage +Acts as an intermediary for an action that takes multiple inputs. + +If nomessage is not set, t will print "1 more.. " etc when triggered and "sequence complete" when finished. + +After the counter has been triggered "count" times (default 2), it will fire all of it's targets and remove itself. +*/ +void() trigger_counter = +{ + self.wait = -1; + if (!self.count) + self.count = 2; + + self.use = counter_use; +}; + + +/* +============================================================================== + +TELEPORT TRIGGERS + +============================================================================== +*/ + +float PLAYER_ONLY = 1; +float SILENT = 2; + +void() play_teleport = +{ + local float v; + local string tmpstr; + + v = random(); + if (v < 0.2) + tmpstr = "misc/r_tele1.wav"; + else if (v < 0.4) + tmpstr = "misc/r_tele2.wav"; + else if (v < 0.6) + tmpstr = "misc/r_tele3.wav"; + else if (v < 0.8) + tmpstr = "misc/r_tele4.wav"; + else + tmpstr = "misc/r_tele5.wav"; + + sound (self, CHAN_VOICE, tmpstr, 1, ATTN_NORM); + remove (self); +}; + +void(vector org) spawn_tfog = +{ + local entity s; + s = spawn (); + s.origin = org; + s.nextthink = time + 0.2; + s.think = play_teleport; + + TE_teleport(org); +}; + + +void() tdeath_touch = +{ + if (other == self.owner) + return; + +// frag anyone who teleports in on top of an invincible player + if (other.classname == "player") + { + if (other.invincible_finished > time && + self.owner.invincible_finished > time) { + other.invincible_finished = 0; + self.owner.invincible_finished = 0; + T_Damage (other, self, self.owner, 50000, MOD_TELEFRAGDEFLECT); + T_Damage (self.owner, self, other, 50000, MOD_TELEFRAGDEFLECT); + return; + } + + if (other.invincible_finished > time) + { + T_Damage (self.owner, self, self.owner, 50000, MOD_TELEFRAGDEFLECT); + return; + } + + } + + if (other.health) + { + T_Damage (other, self, self.owner, 50000, MOD_TELEFRAG); + } +}; + + +void(vector org, entity death_owner) spawn_tdeath = +{ +local entity death; + + death = spawn(); + death.classname = "teledeath"; + death.movetype = MOVETYPE_NONE; + death.solid = SOLID_TRIGGER; + death.angles = '0 0 0'; + setsize (death, death_owner.mins - '1 1 1', death_owner.maxs + '1 1 1'); + setorigin (death, org); + death.touch = tdeath_touch; + death.nextthink = time + 0.2; + death.think = SUB_Remove; + death.owner = death_owner; + + force_retouch = 2; // make sure even still objects get hit +}; + +void() teleport_touch = +{ +local entity t; +local vector org; + + if (self.targetname) + { + if (self.nextthink < time) + { + return; // not fired yet + } + } + + if (self.spawnflags & PLAYER_ONLY) + { + if (other.classname != "player") + return; + } + +// only teleport living creatures + if (other.health <= 0 || other.solid != SOLID_SLIDEBOX) + return; + + SUB_UseTargets (); + +// put a tfog where the player was + spawn_tfog (other.origin); + + t = find (world, targetname, self.target); + if (!t) + objerror ("couldn't find target"); + +// spawn a tfog flash in front of the destination + makevectors (t.mangle); + org = t.origin + 32 * v_forward; + + spawn_tfog (org); + spawn_tdeath(t.origin, other); + +// move the player and lock him down for a little while + if (!other.health) + { + other.origin = t.origin; + other.velocity = (v_forward * other.velocity_x) + (v_forward * other.velocity_y); + return; + } + + setorigin (other, t.origin); + other.angles = t.mangle; + if (other.classname == "player") + { + other.fixangle = 1; // turn this way immediately + other.teleport_time = time + 0.7; + if (other.flags & FL_ONGROUND) + other.flags = other.flags - FL_ONGROUND; + other.velocity = v_forward * 300; + } + other.flags = other.flags - other.flags & FL_ONGROUND; +}; + +/*QUAKED info_teleport_destination (.5 .5 .5) (-8 -8 -8) (8 8 32) +This is the destination marker for a teleporter. It should have a "targetname" field with the same value as a teleporter's "target" field. +*/ +void() info_teleport_destination = +{ +// this does nothing, just serves as a target spot + self.mangle = self.angles; + self.angles = '0 0 0'; + self.model = ""; + self.origin = self.origin + '0 0 27'; + if (!self.targetname) + objerror ("no targetname"); +}; + +void() teleport_use = +{ + self.nextthink = time + 0.2; + force_retouch = 2; // make sure even still objects get hit + self.think = SUB_Null; +}; + +/*QUAKED trigger_teleport (.5 .5 .5) ? PLAYER_ONLY SILENT +Any object touching this will be transported to the corresponding info_teleport_destination entity. You must set the "target" field, and create an object with a "targetname" field that matches. + +If the trigger_teleport has a targetname, it will only teleport entities when it has been fired. +*/ +void() trigger_teleport = +{ + local vector o; + + InitTrigger (); + self.touch = teleport_touch; + // find the destination + if (!self.target) + objerror ("no target"); + self.use = teleport_use; + + if (!(self.spawnflags & SILENT)) + { + precache_sound ("ambience/hum1.wav"); + o = (self.mins + self.maxs)*0.5; + ambientsound (o, "ambience/hum1.wav",0.5 , ATTN_STATIC); + } +}; + +/* +============================================================================== + +trigger_setskill + +============================================================================== +*/ + +/*QUAKED trigger_setskill (.5 .5 .5) ? +sets skill level to the value of "message". +Only used on start map. +*/ +void() trigger_setskill = +{ + remove (self); +}; + + +/* +============================================================================== + +ONLY REGISTERED TRIGGERS + +============================================================================== +*/ + +void() trigger_onlyregistered_touch = +{ + if (other.classname != "player") + return; + if (self.attack_finished > time) + return; + + self.attack_finished = time + 2; + if (cvar("registered")) + { + self.message = ""; + SUB_UseTargets (); + remove (self); + } + else + { + if (self.message != "") + { + centerprint (other, self.message); + sound (other, CHAN_BODY, "misc/talk.wav", 1, ATTN_NORM); + } + } +}; + +/*QUAKED trigger_onlyregistered (.5 .5 .5) ? +Only fires if playing the registered version, otherwise prints the message +*/ +void() trigger_onlyregistered = +{ + precache_sound ("misc/talk.wav"); + InitTrigger (); + self.touch = trigger_onlyregistered_touch; +}; + +//============================================================================ + +void() hurt_on = +{ + self.solid = SOLID_TRIGGER; + self.nextthink = -1; +}; + +void() hurt_touch = +{ + if (other.takedamage) + { + self.solid = SOLID_NOT; + T_Damage (other, self, self, self.dmg, MOD_HURT); + self.think = hurt_on; + self.nextthink = time + 1; + } + + return; +}; + +/*QUAKED trigger_hurt (.5 .5 .5) ? +Any object touching this will be hurt +set dmg to damage amount +defalt dmg = 5 +*/ +void() trigger_hurt = +{ + InitTrigger (); + self.touch = hurt_touch; + if (!self.dmg) + self.dmg = 5; +}; + +//============================================================================ + +float PUSH_ONCE = 1; + +void() trigger_push_touch = +{ + if (other.classname == "grenade") + other.velocity = self.speed * self.movedir * 10; + else if (other.health > 0) + { + other.velocity = self.speed * self.movedir * 10; + if (other.classname == "player") + { + if (other.fly_sound < time) + { + other.fly_sound = time + 1.5; + sound (other, CHAN_AUTO, "ambience/windfly.wav", 1, ATTN_NORM); + } + } + } + if (self.spawnflags & PUSH_ONCE) + remove(self); +}; + + +/*QUAKED trigger_push (.5 .5 .5) ? PUSH_ONCE +Pushes the player +*/ +void() trigger_push = +{ + InitTrigger (); + precache_sound ("ambience/windfly.wav"); + self.touch = trigger_push_touch; + if (!self.speed) + self.speed = 1000; +}; + +//============================================================================ + +void() trigger_monsterjump_touch = +{ + if ( other.flags & (FL_MONSTER | FL_FLY | FL_SWIM) != FL_MONSTER ) + return; + +// set XY even if not on ground, so the jump will clear lips + other.velocity_x = self.movedir_x * self.speed; + other.velocity_y = self.movedir_y * self.speed; + + if ( !(other.flags & FL_ONGROUND) ) + return; + + other.flags = other.flags - FL_ONGROUND; + + other.velocity_z = self.height; +}; + +/*QUAKED trigger_monsterjump (.5 .5 .5) ? +Walking monsters that touch this will jump in the direction of the trigger's angle +"speed" default to 200, the speed thrown forward +"height" default to 200, the speed thrown upwards +*/ +void() trigger_monsterjump = +{ + if (!self.speed) + self.speed = 200; + if (!self.height) + self.height = 200; + if (self.angles == '0 0 0') + self.angles = '0 360 0'; + InitTrigger (); + self.touch = trigger_monsterjump_touch; +}; + diff --git a/quakec/basemod/weapons.qc b/quakec/basemod/weapons.qc new file mode 100644 index 000000000..e0d09999b --- /dev/null +++ b/quakec/basemod/weapons.qc @@ -0,0 +1,1394 @@ +/* +*/ +void (entity targ, entity inflictor, entity attacker, float damage, INTEGER mod) T_Damage; +void () player_run; +void(entity bomb, entity attacker, float rad, entity ignore, INTEGER mod) T_RadiusDamage; +void(vector org, float damage) SpawnBlood; +void() SuperDamageSound; + + +// called by worldspawn +void() W_Precache = +{ + precache_sound ("weapons/r_exp3.wav"); // new rocket explosion + precache_sound ("weapons/rocket1i.wav"); // spike gun + precache_sound ("weapons/sgun1.wav"); + precache_sound ("weapons/guncock.wav"); // player shotgun + precache_sound ("weapons/ric1.wav"); // ricochet (used in c code) + precache_sound ("weapons/ric2.wav"); // ricochet (used in c code) + precache_sound ("weapons/ric3.wav"); // ricochet (used in c code) + precache_sound ("weapons/spike2.wav"); // super spikes + precache_sound ("weapons/tink1.wav"); // spikes tink (used in c code) + precache_sound ("weapons/grenade.wav"); // grenade launcher + precache_sound ("weapons/bounce.wav"); // grenade bounce + precache_sound ("weapons/shotgn2.wav"); // super shotgun +}; + +float() crandom = +{ + return 2*(random() - 0.5); +}; + +/* +================ +W_FireAxe +================ +*/ +void() W_FireAxe = +{ + local vector source; + local vector org; + + makevectors (self.v_angle); + source = self.origin + '0 0 16'; + traceline (source, source + v_forward*64, FALSE, self); + if (trace_fraction == 1.0) + return; + + org = trace_endpos - v_forward*4; + + if (trace_ent.takedamage) + { + SpawnBlood (org, 20); + if (deathmatch > 3) + T_Damage (trace_ent, self, self, 75, MOD_AXE); + else + T_Damage (trace_ent, self, self, 20, MOD_AXE); + } + else + { // hit wall + sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM); + + TE_gunshot(org); + } +}; + + +//============================================================================ + + +vector() wall_velocity = +{ + local vector vel; + + vel = normalize (self.velocity); + vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5)); + vel = vel + 2*trace_plane_normal; + vel = vel * 200; + + return vel; +}; + + +/* +================ +SpawnMeatSpray +================ +*/ +void(vector org, vector vel) SpawnMeatSpray = +{ + local entity missile; + + missile = spawn (); + missile.owner = self; + missile.movetype = MOVETYPE_BOUNCE; + missile.solid = SOLID_NOT; + + makevectors (self.angles); + + missile.velocity = vel; + missile.velocity_z = missile.velocity_z + 250 + 50*random(); + + missile.avelocity = '3000 1000 2000'; + +// set missile duration + missile.nextthink = time + 1; + missile.think = SUB_Remove; + + setmodel (missile, "progs/zom_gib.mdl"); + setsize (missile, '0 0 0', '0 0 0'); + setorigin (missile, org); +}; + +/* +================ +spawn_touchblood +================ +*/ +void(float damage) spawn_touchblood = +{ + local vector vel; + + vel = wall_velocity () * 0.2; + SpawnBlood (self.origin + vel*0.01, damage); +}; + +/* +============================================================================== + +MULTI-DAMAGE + +Collects multiple small damages into a single damage + +============================================================================== +*/ + +entity multi_ent; +float multi_damage; +INTEGER multi_mod; + +vector blood_org; +float blood_count; + +vector puff_org; +float puff_count; + +void() ClearMultiDamage = +{ + multi_ent = world; + multi_damage = 0; + blood_count = 0; + puff_count = 0; + multi_mod = MOD_NONE; +}; + +void() ApplyMultiDamage = +{ + if (!multi_ent) + return; + T_Damage (multi_ent, self, self, multi_damage, multi_mod); +}; + +void(entity hit, float damage, INTEGER mod) AddMultiDamage = +{ + if (!hit) + return; + + if (hit != multi_ent || mod != multi_mod) + { + ApplyMultiDamage (); + multi_damage = damage; + multi_ent = hit; + } + else + multi_damage = multi_damage + damage; +}; + +void() Multi_Finish = +{ + if (puff_count) + TE_gunshot(puff_org); + + if (blood_count) + SpawnBlood(blood_org, blood_count); +}; + +/* +============================================================================== +BULLETS +============================================================================== +*/ + +/* +================ +TraceAttack +================ +*/ +void(float damage, vector dir, INTEGER mod) TraceAttack = +{ + local vector vel, org; + + vel = normalize(dir + v_up*crandom() + v_right*crandom()); + vel = vel + 2*trace_plane_normal; + vel = vel * 200; + + org = trace_endpos - dir*4; + + if (trace_ent.takedamage) + { + blood_count = blood_count + 1; + blood_org = org; + AddMultiDamage (trace_ent, damage, mod); + } + else + { + puff_count = puff_count + 1; + } +}; + +/* +================ +FireBullets + +Used by shotgun, super shotgun, and enemy soldier firing +Go to the trouble of combining multiple pellets into a single damage call. +================ +*/ +void(float shotcount, vector dir, vector spread, INTEGER mod) FireBullets = +{ + local vector direction; + local vector src; + + makevectors(self.v_angle); + + src = self.origin + v_forward*10; + src_z = self.absmin_z + self.size_z * 0.7; + + ClearMultiDamage (); + + traceline (src, src + dir*2048, FALSE, self); + puff_org = trace_endpos - dir*4; + + while (shotcount > 0) + { + direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up; + traceline (src, src + direction*2048, FALSE, self); + if (trace_fraction != 1.0) + TraceAttack (4, direction, mod); + + shotcount = shotcount - 1; + } + ApplyMultiDamage (); + Multi_Finish (); +}; + +/* +================ +W_FireShotgun +================ +*/ +void() W_FireShotgun = +{ + local vector dir; + + sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM); + + VK_smallkick(self); + + if (deathmatch != 4 ) + self.currentammo = self.ammo_shells = self.ammo_shells - 1; + + dir = aim (self, 100000); + FireBullets (6, dir, '0.04 0.04 0', MOD_SHOTGUN); +}; + + +/* +================ +W_FireSuperShotgun +================ +*/ +void() W_FireSuperShotgun = +{ + local vector dir; + + if (self.currentammo == 1) + { + W_FireShotgun (); + return; + } + + sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM); + + VK_bigkick(self); + + if (deathmatch != 4) + self.currentammo = self.ammo_shells = self.ammo_shells - 2; + dir = aim (self, 100000); + FireBullets (14, dir, '0.14 0.08 0', MOD_SUPERSHOTGUN); +}; + + +/* +============================================================================== + +ROCKETS + +============================================================================== +*/ + +void() T_MissileTouch = +{ + local float damg; + +// if (deathmatch == 4) +// { +// if ( ((other.weapon == 32) || (other.weapon == 16))) +// { +// if (random() < 0.1) +// { +// if (other != world) +// { +// // bprint (PRINT_HIGH, "Got here\n"); +// other.deathtype = "blaze"; +// T_Damage (other, self, self.owner, 1000 ); +// T_RadiusDamage (self, self.owner, 1000, other); +// } +// } +// } +// } + + if (other == self.owner) + return; // don't explode on owner + + if (self.voided) { + return; + } + self.voided = 1; + + if (pointcontents(self.origin) == CONTENT_SKY) + { + remove(self); + return; + } + + damg = 100 + random()*20; + + if (other.health) + T_Damage (other, self, self.owner, damg, MOD_ROCKET); + + // don't do radius damage to the other, because all the damage + // was done in the impact + + + T_RadiusDamage (self, self.owner, 120, other, MOD_ROCKETRADIUS); + +// sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM); + self.origin = self.origin - 8 * normalize(self.velocity); + + TE_explosion(self.origin); + remove(self); +}; + + + +/* +================ +W_FireRocket +================ +*/ +void() W_FireRocket = +{ + if (deathmatch != 4) + self.currentammo = self.ammo_rockets = self.ammo_rockets - 1; + + sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM); + + VK_smallkick(self); + + newmis = spawn (); + newmis.owner = self; + newmis.movetype = MOVETYPE_FLYMISSILE; + newmis.solid = SOLID_BBOX; + +// set newmis speed + + makevectors (self.v_angle); + newmis.velocity = aim(self, 1000); + newmis.velocity = newmis.velocity * 1000; + newmis.angles = vectoangles(newmis.velocity); + + newmis.touch = T_MissileTouch; + newmis.voided = 0; + +// set newmis duration + newmis.nextthink = time + 5; + newmis.think = SUB_Remove; + newmis.classname = "rocket"; + + setmodel (newmis, "progs/missile.mdl"); + setsize (newmis, '0 0 0', '0 0 0'); + setorigin (newmis, self.origin + v_forward*8 + '0 0 16'); +}; + +/* +=============================================================================== +LIGHTNING +=============================================================================== +*/ + +void(entity from, float damage) LightningHit = +{ + TE_lightningblood(trace_endpos); + + T_Damage (trace_ent, from, from, damage, MOD_SHAFT); +}; + +/* +================= +LightningDamage +================= +*/ +void(vector p1, vector p2, entity from, float damage) LightningDamage = +{ + local entity e1, e2; + local vector f; + + f = p2 - p1; + f = normalize(f); + f_x = 0 - f_y; + f_y = f_x; + f_z = 0; + f = f*16; + + e1 = e2 = world; + + traceline (p1, p2, FALSE, self); + + if (trace_ent.takedamage) + LightningHit (from, damage); + e1 = trace_ent; + + traceline (p1 + f, p2 + f, FALSE, self); + if (trace_ent != e1 && trace_ent.takedamage) + LightningHit (from, damage); + e2 = trace_ent; + + traceline (p1 - f, p2 - f, FALSE, self); + if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage) + LightningHit (from, damage); +}; + + +void() W_FireLightning = +{ + local vector org; + local float cells; + + if (self.ammo_cells < 1) + { + self.weapon = W_BestWeapon (); + W_SetCurrentAmmo (); + return; + } + +// explode if under water + if (self.waterlevel > 1) + { + if (deathmatch > 3) + { + if (random() <= 0.5) + { + T_Damage (self, self, self.owner, 4000, MOD_SELFWATER); + return; + } + } + + cells = self.ammo_cells; + self.ammo_cells = 0; + W_SetCurrentAmmo (); + if (self.watertype == CONTENT_SLIME) + T_RadiusDamage (self, self, 35*cells, world, MOD_SHAFTSLIME); + else if (self.watertype == CONTENT_LAVA) + T_RadiusDamage (self, self, 35*cells, world, MOD_SHAFTLAVA); + else + T_RadiusDamage (self, self, 35*cells, world, MOD_SHAFTWATER); + return; + } + + if (self.lsound_time < time) + { + sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM); + self.lsound_time = time + 0.6; + } + VK_smallkick(self); + + if (deathmatch != 4) + self.currentammo = self.ammo_cells = self.ammo_cells - 1; + + org = self.origin + '0 0 16'; + + traceline (org, org + v_forward*600, TRUE, self); + + TE_lightning2(self, org, trace_endpos); + + LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30); +}; + + +//============================================================================= + + +void() GrenadeExplode = +{ + if (self.voided) { + return; + } + self.voided = 1; + + T_RadiusDamage (self, self.owner, 120, world, MOD_GRENADE); + + TE_explosion(self.origin); + remove (self); +}; + +void() GrenadeTouch = +{ + if (other == self.owner) + return; // don't explode on owner + if (other.takedamage == DAMAGE_AIM) + { + GrenadeExplode(); + return; + } + sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound + if (self.velocity == '0 0 0') + self.avelocity = '0 0 0'; +}; + +/* +================ +W_FireGrenade +================ +*/ +void() W_FireGrenade = +{ + if (deathmatch != 4) + self.currentammo = self.ammo_rockets = self.ammo_rockets - 1; + + sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM); + + VK_smallkick(self); + + newmis = spawn (); + newmis.voided=0; + newmis.owner = self; + newmis.movetype = MOVETYPE_BOUNCE; + newmis.solid = SOLID_BBOX; + newmis.classname = "grenade"; + +// set newmis speed + + makevectors (self.v_angle); + + if (self.v_angle_x) + newmis.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10; + else + { + newmis.velocity = aim(self, 10000); + newmis.velocity = newmis.velocity * 600; + newmis.velocity_z = 200; + } + + newmis.avelocity = '300 300 300'; + + newmis.angles = vectoangles(newmis.velocity); + + newmis.touch = GrenadeTouch; + +// set newmis duration + if (deathmatch == 4) + { + newmis.nextthink = time + 2.5; + self.attack_finished = time + 1.1; + T_Damage (self, self, self.owner, 10, MOD_GRENADE); + } + else + newmis.nextthink = time + 2.5; + + newmis.think = GrenadeExplode; + + setmodel (newmis, "progs/grenade.mdl"); + setsize (newmis, '0 0 0', '0 0 0'); + setorigin (newmis, self.origin); +}; + + +//============================================================================= + +void() spike_touch; +void() superspike_touch; + + +/* +=============== +launch_spike + +Used for both the player and the ogre +=============== +*/ +void(vector org, vector dir) launch_spike = +{ + newmis = spawn (); + newmis.voided=0; + newmis.owner = self; + newmis.movetype = MOVETYPE_FLYMISSILE; + newmis.solid = SOLID_BBOX; + + newmis.angles = vectoangles(dir); + + newmis.touch = spike_touch; + newmis.classname = "spike"; + newmis.think = SUB_Remove; + newmis.nextthink = time + 6; + setmodel (newmis, "progs/spike.mdl"); + setsize (newmis, VEC_ORIGIN, VEC_ORIGIN); + setorigin (newmis, org); + + newmis.velocity = dir * 1000; +}; + +void() W_FireSuperSpikes = +{ + local vector dir; + + sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM); + if (deathmatch != 4) + self.currentammo = self.ammo_nails = self.ammo_nails - 2; + dir = aim (self, 1000); + launch_spike (self.origin + '0 0 16', dir); + newmis.touch = superspike_touch; + setmodel (newmis, "progs/s_spike.mdl"); + setsize (newmis, VEC_ORIGIN, VEC_ORIGIN); + VK_smallkick(self); +}; + +void(float ox) W_FireSpikes = +{ + local vector dir; + + makevectors (self.v_angle); + + if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN) + { + W_FireSuperSpikes (); + return; + } + + if (self.ammo_nails < 1) + { + self.weapon = W_BestWeapon (); + W_SetCurrentAmmo (); + return; + } + + sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM); + if (deathmatch != 4) + self.currentammo = self.ammo_nails = self.ammo_nails - 1; + dir = aim (self, 1000); + launch_spike (self.origin + '0 0 16' + v_right*ox, dir); + + VK_smallkick(self); +}; + +void() spike_touch = +{ + if (other == self.owner) + return; + + if (self.voided) { + return; + } + self.voided = 1; + + if (other.solid == SOLID_TRIGGER) + return; // trigger field, do nothing + + if (pointcontents(self.origin) == CONTENT_SKY) + { + remove(self); + return; + } + +// hit something that bleeds + if (other.takedamage) + { + spawn_touchblood (9); + T_Damage (other, self, self.owner, 9, MOD_SPIKE); + } + else + { + if (self.classname == "wizspike") + TE_wizspike(self.origin); + else if (self.classname == "knightspike") + TE_knightspike(self.origin); + else + TE_spike(self.origin); + } + + remove(self); + +}; + +void() superspike_touch = +{ + if (other == self.owner) + return; + + if (self.voided) { + return; + } + self.voided = 1; + + + if (other.solid == SOLID_TRIGGER) + return; // trigger field, do nothing + + if (pointcontents(self.origin) == CONTENT_SKY) + { + remove(self); + return; + } + +// hit something that bleeds + if (other.takedamage) + { + spawn_touchblood (18); + T_Damage (other, self, self.owner, 18, MOD_SUPERSPIKE); + } + else + { + TE_superspike(self.origin); + } + + remove(self); + +}; + + +/* +=============================================================================== + +PLAYER WEAPON USE + +=============================================================================== +*/ +// different from W_CheckNoAmmo due to SSG/SNG being able to fire 1 shot instead of 2... +float(float wep) W_HasAmmo = +{ + switch (wep) + { + case IT_SHOTGUN: + return self.ammo_shells >= 1; + case IT_SUPER_SHOTGUN: + return self.ammo_shells >= 2; + case IT_NAILGUN: + return self.ammo_nails >= 1; + case IT_SUPER_NAILGUN: + return self.ammo_nails >= 2; + case IT_GRENADE_LAUNCHER: + case IT_ROCKET_LAUNCHER: + return self.ammo_rockets >= 1; + case IT_LIGHTNING: + return self.ammo_cells >= 1; + } + + return TRUE; +}; + +void() W_SetCurrentAmmo = +{ + player_run (); // get out of any weapon firing states + + self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) ); + + switch (self.weapon) + { + case IT_AXE: + self.currentammo = 0; + self.weaponmodel = "progs/v_axe.mdl"; + self.weaponframe = 0; + break; + case IT_SHOTGUN: + self.currentammo = self.ammo_shells; + self.weaponmodel = "progs/v_shot.mdl"; + self.weaponframe = 0; + self.items = self.items | IT_SHELLS; + break; + case IT_SUPER_SHOTGUN: + self.currentammo = self.ammo_shells; + self.weaponmodel = "progs/v_shot2.mdl"; + self.weaponframe = 0; + self.items = self.items | IT_SHELLS; + break; + case IT_NAILGUN: + self.currentammo = self.ammo_nails; + self.weaponmodel = "progs/v_nail.mdl"; + self.weaponframe = 0; + self.items = self.items | IT_NAILS; + break; + case IT_SUPER_NAILGUN: + self.currentammo = self.ammo_nails; + self.weaponmodel = "progs/v_nail2.mdl"; + self.weaponframe = 0; + self.items = self.items | IT_NAILS; + break; + case IT_GRENADE_LAUNCHER: + self.currentammo = self.ammo_rockets; + self.weaponmodel = "progs/v_rock.mdl"; + self.weaponframe = 0; + self.items = self.items | IT_ROCKETS; + break; + case IT_ROCKET_LAUNCHER: + self.currentammo = self.ammo_rockets; + self.weaponmodel = "progs/v_rock2.mdl"; + self.weaponframe = 0; + self.items = self.items | IT_ROCKETS; + break; + case IT_LIGHTNING: + self.currentammo = self.ammo_cells; + self.weaponmodel = "progs/v_light.mdl"; + self.weaponframe = 0; + self.items = self.items | IT_CELLS; + break; + default: + self.currentammo = 0; + self.weaponmodel = ""; + self.weaponframe = 0; + } +}; + +float() W_BestWeapon = +{ + float fl; + + if (self.waterlevel <= 1) + fl = IT_LIGHTNING; + else + fl = IT_SUPER_NAILGUN; + + while (1) + { + if ( (self.items & fl) && W_HasAmmo(fl) ) + return fl; + + // best weapon order + switch (fl) + { + case IT_LIGHTNING: + fl = IT_SUPER_NAILGUN; + break; + case IT_SUPER_NAILGUN: + fl = IT_SUPER_SHOTGUN; + break; + case IT_SUPER_SHOTGUN: + fl = IT_NAILGUN; + break; + case IT_NAILGUN: + fl = IT_SHOTGUN; + break; + case IT_SHOTGUN: + default: + return IT_AXE; // so we don't get an infinite loop with certain engines + } + } +}; + +float() W_CheckNoAmmo = +{ + if (self.currentammo > 0) + return TRUE; + + if (self.weapon == IT_AXE) + return TRUE; + + self.weapon = W_BestWeapon (); + + W_SetCurrentAmmo (); + +// drop the weapon down + return FALSE; +}; + +/* +============ +W_Attack + +An attack impulse can be triggered now +============ +*/ +void() player_axe1; +void() player_axeb1; +void() player_axec1; +void() player_axed1; +void() player_shot1; +void() player_nail1; +void() player_nail2; +void() player_light1; +void() player_light2; +void() player_rocket1; +void() muzzleflash; + +void() W_Attack = +{ + float r; + + if (!W_CheckNoAmmo ()) + return; + + makevectors (self.v_angle); // calculate forward angle for velocity + self.show_hostile = time + 1; // wake monsters up + + if (self.weaponframe == 0) // start delay + self.delay = time + 0.1; + + // animations are dealt with here + switch (self.weapon) + { + case IT_AXE: + r = random(); + if (r < 0.25) + { + self.weaponframe = 1; + player_axe1 (); + } + else if (r < 0.5) + { + self.weaponframe = 5; + player_axeb1 (); + } + else if (r < 0.75) + { + self.weaponframe = 1; + player_axec1 (); + } + else + { + self.weaponframe = 5; + player_axed1 (); + } + break; + case IT_NAILGUN: + case IT_SUPER_NAILGUN: + muzzleflash(); + if (self.weaponframe == 0) + self.weaponframe = 1; + + if (self.weaponframe & 1) + player_nail1(); + else + player_nail2(); + break; + case IT_GRENADE_LAUNCHER: + case IT_ROCKET_LAUNCHER: + self.weaponframe = 1; + muzzleflash(); + player_rocket1(); + break; + case IT_LIGHTNING: + muzzleflash(); + if (self.weaponframe == 0) + { + sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM); + self.weaponframe = 1; + } + + if (self.weaponframe & 1) + player_light1(); + else + player_light2(); + break; + default: + muzzleflash(); + self.weaponframe = 1; + player_shot1(); + } + + SuperDamageSound(); + + // firing is done here (r is used for round time instead of a temp here) + switch (self.weapon) + { + case IT_AXE: + // frame handles most of this so skip most of it + sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM); + r = 0.5; + break; + case IT_SHOTGUN: + W_FireShotgun (); + r = 0.5; + break; + case IT_SUPER_SHOTGUN: + W_FireSuperShotgun (); + r = 0.7; + break; + case IT_NAILGUN: + if (self.weaponframe & 1) + W_FireSpikes(4); + else + W_FireSpikes(-4); + + r = 0.1; + break; + case IT_SUPER_NAILGUN: + W_FireSpikes(0); + r = 0.1; + break; + case IT_GRENADE_LAUNCHER: + W_FireGrenade(); + r = 0.6; + break; + case IT_ROCKET_LAUNCHER: + W_FireRocket(); + r = 0.8; + break; + case IT_LIGHTNING: + W_FireLightning(); + r = 0.1; + break; + } + + // advance attack time + if (self.attack_finished <= time) + self.attack_finished = self.attack_finished + r; +}; + +/* +============ +W_ChangeWeapon + +============ +*/ +void() W_ChangeWeapon = +{ + local float fl; + + switch (self.impulse) + { + case 1: + fl = IT_AXE; + break; + case 2: + fl = IT_SHOTGUN; + break; + case 3: + fl = IT_SUPER_SHOTGUN; + break; + case 4: + fl = IT_NAILGUN; + break; + case 5: + fl = IT_SUPER_NAILGUN; + break; + case 6: + fl = IT_GRENADE_LAUNCHER; + break; + case 7: + fl = IT_ROCKET_LAUNCHER; + break; + case 8: + fl = IT_LIGHTNING; + break; + } + + + if (!(self.items & fl)) + { // don't have the weapon or the ammo + sprint1 (self, PRINT_HIGH, "no weapon.\n"); + return; + } + + if (!W_HasAmmo(fl)) + { // don't have the ammo + sprint1 (self, PRINT_HIGH, "not enough ammo.\n"); + return; + } + +// +// set weapon, set ammo +// + self.weapon = fl; + W_SetCurrentAmmo (); +}; + +/* +============ +CheatCommand +============ +*/ +void() CheatCommand = +{ + if (deathmatch || coop) + return; + + self.ammo_rockets = 100; + self.ammo_nails = 200; + self.ammo_shells = 100; + self.ammo_cells = 100; + self.items |= IT_AXE | + IT_SHOTGUN | + IT_SUPER_SHOTGUN | + IT_NAILGUN | + IT_SUPER_NAILGUN | + IT_GRENADE_LAUNCHER | + IT_ROCKET_LAUNCHER | + IT_LIGHTNING | + IT_KEY1 | IT_KEY2; + + self.weapon = IT_ROCKET_LAUNCHER; + W_SetCurrentAmmo (); +}; + +/* +============ +CycleWeaponCommand + +Go to the next weapon with ammo +============ +*/ +void() CycleWeaponCommand = +{ + local float w; + w = self.weapon; + + while (1) + { + switch (w) + { + case IT_LIGHTNING: + w = IT_AXE; + break; + case IT_AXE: + w = IT_SHOTGUN; + break; + case IT_SHOTGUN: + w = IT_SUPER_SHOTGUN; + break; + case IT_SUPER_SHOTGUN: + w = IT_NAILGUN; + break; + case IT_NAILGUN: + w = IT_SUPER_NAILGUN; + break; + case IT_SUPER_NAILGUN: + w = IT_GRENADE_LAUNCHER; + break; + case IT_GRENADE_LAUNCHER: + w = IT_ROCKET_LAUNCHER; + break; + case IT_ROCKET_LAUNCHER: + w = IT_LIGHTNING; + break; + } + + if ( (self.items & w) && W_HasAmmo(w) ) + { + self.weapon = w; + W_SetCurrentAmmo (); + return; + } + } + +}; + + +/* +============ +CycleWeaponReverseCommand + +Go to the prev weapon with ammo +============ +*/ +void() CycleWeaponReverseCommand = +{ + local float w; + w = self.weapon; + + while (1) + { + switch (w) + { + case IT_LIGHTNING: + w = IT_ROCKET_LAUNCHER; + break; + case IT_ROCKET_LAUNCHER: + w = IT_GRENADE_LAUNCHER; + break; + case IT_GRENADE_LAUNCHER: + w = IT_SUPER_NAILGUN; + break; + case IT_SUPER_NAILGUN: + w = IT_NAILGUN; + break; + case IT_NAILGUN: + w = IT_SUPER_SHOTGUN; + break; + case IT_SUPER_SHOTGUN: + w = IT_SHOTGUN; + break; + case IT_SHOTGUN: + w = IT_AXE; + break; + case IT_AXE: + w = IT_LIGHTNING; + break; + } + + if ( (self.items & w) && W_HasAmmo(w) ) + { + self.weapon = w; + W_SetCurrentAmmo (); + return; + } + } + +}; + + +/* +============ +ServerflagsCommand + +Just for development +============ +*/ +void() ServerflagsCommand = +{ + if (deathmatch || coop) + return; + + serverflags = serverflags * 2 + 1; +}; + + +/* +============ +ImpulseCommands + +============ +*/ +void() ImpulseCommands = +{ + switch (self.impulse) { + case 1 .. 8: + W_ChangeWeapon (); + break; + case 9: + CheatCommand (); + break; + case 10: + CycleWeaponCommand (); + break; + case 11: + ServerflagsCommand (); + break; + case 12: + CycleWeaponReverseCommand (); + break; + } + + self.impulse = 0; +}; + +/* +============ +W_HandlePlayerFrame + +Handle player weapon model +============ +*/ +void() W_HandlePlayerFrame = +{ + if (!self.weaponframe) + return; + + if (self.weaponframe_time >= time) + return; + + switch (self.weapon) + { + case IT_AXE: + // axe frames can start at 1 or 5 + self.weaponframe_time = time + 0.1; + self.weaponframe = self.weaponframe + 1; + if (self.weaponframe == 5) + self.weaponframe = 0; + else if (self.weaponframe > 8) + self.weaponframe = 0; + + return; + case IT_NAILGUN: + case IT_SUPER_NAILGUN: + // cycle until fire button is released + if (self.button0) + { + self.weaponframe_time = time + 0.1; + self.weaponframe = self.weaponframe + 1; + if (self.weaponframe > 8) + self.weaponframe = 1; + } + else + self.weaponframe = 0; + + return; + case IT_LIGHTNING: + // cycle until fire button is released + if (self.button0) + { + self.weaponframe_time = time + 0.1; + self.weaponframe = self.weaponframe + 1; + if (self.weaponframe > 4) + self.weaponframe = 1; + } + else + self.weaponframe = 0; + return; + default: + self.weaponframe = self.weaponframe + 1; + self.weaponframe_time = time + 0.1; + if (self.weaponframe > 6) + self.weaponframe = 0; + } +}; + +/* +============ +W_WeaponFrame + +Called every frame so impulse events can be handled as well as possible +============ +*/ +void() W_WeaponFrame = +{ + local float scount; + + W_HandlePlayerFrame(); + + if (time < self.attack_finished) + return; + + if (self.impulse) + ImpulseCommands (); + +// check for attack + if (self.button0) + { + scount = 0; + // play catchup but don't allow more than 4 shots per frame + while (self.attack_finished <= time) + { + if (scount >= 4) + { + self.attack_finished = time; + break; + } + + W_Attack(); + scount++; + } + } + else + self.attack_finished = time; +}; + +/* +======== +SuperDamageSound + +Plays sound if needed +======== +*/ +void() SuperDamageSound = +{ + if (self.super_damage_finished > time) + { + if (self.super_sound < time) + { + self.super_sound = time + 1; + sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM); + } + } + return; +}; + + diff --git a/quakec/basemod/world.qc b/quakec/basemod/world.qc new file mode 100644 index 000000000..6b07fec60 --- /dev/null +++ b/quakec/basemod/world.qc @@ -0,0 +1,356 @@ + +void() main = +{ +// these are just commands the the prog compiler to copy these files + + precache_file ("progs.dat"); + precache_file ("gfx.wad"); + precache_file ("quake.rc"); + precache_file ("default.cfg"); + + precache_file ("end1.bin"); + precache_file2 ("end2.bin"); + + precache_file ("demo1.dem"); + precache_file ("demo2.dem"); + precache_file ("demo3.dem"); + +// +// these are all of the lumps from the cached.ls files +// + precache_file ("gfx/palette.lmp"); + precache_file ("gfx/colormap.lmp"); + + precache_file2 ("gfx/pop.lmp"); + + precache_file ("gfx/complete.lmp"); + precache_file ("gfx/inter.lmp"); + + precache_file ("gfx/ranking.lmp"); + precache_file ("gfx/vidmodes.lmp"); + precache_file ("gfx/finale.lmp"); + precache_file ("gfx/conback.lmp"); + precache_file ("gfx/qplaque.lmp"); + + precache_file ("gfx/menudot1.lmp"); + precache_file ("gfx/menudot2.lmp"); + precache_file ("gfx/menudot3.lmp"); + precache_file ("gfx/menudot4.lmp"); + precache_file ("gfx/menudot5.lmp"); + precache_file ("gfx/menudot6.lmp"); + + precache_file ("gfx/menuplyr.lmp"); + precache_file ("gfx/bigbox.lmp"); + precache_file ("gfx/dim_modm.lmp"); + precache_file ("gfx/dim_drct.lmp"); + precache_file ("gfx/dim_ipx.lmp"); + precache_file ("gfx/dim_tcp.lmp"); + precache_file ("gfx/dim_mult.lmp"); + precache_file ("gfx/mainmenu.lmp"); + + precache_file ("gfx/box_tl.lmp"); + precache_file ("gfx/box_tm.lmp"); + precache_file ("gfx/box_tr.lmp"); + + precache_file ("gfx/box_ml.lmp"); + precache_file ("gfx/box_mm.lmp"); + precache_file ("gfx/box_mm2.lmp"); + precache_file ("gfx/box_mr.lmp"); + + precache_file ("gfx/box_bl.lmp"); + precache_file ("gfx/box_bm.lmp"); + precache_file ("gfx/box_br.lmp"); + + precache_file ("gfx/sp_menu.lmp"); + precache_file ("gfx/ttl_sgl.lmp"); + precache_file ("gfx/ttl_main.lmp"); + precache_file ("gfx/ttl_cstm.lmp"); + + precache_file ("gfx/mp_menu.lmp"); + + precache_file ("gfx/netmen1.lmp"); + precache_file ("gfx/netmen2.lmp"); + precache_file ("gfx/netmen3.lmp"); + precache_file ("gfx/netmen4.lmp"); + precache_file ("gfx/netmen5.lmp"); + + precache_file ("gfx/sell.lmp"); + + precache_file ("gfx/help0.lmp"); + precache_file ("gfx/help1.lmp"); + precache_file ("gfx/help2.lmp"); + precache_file ("gfx/help3.lmp"); + precache_file ("gfx/help4.lmp"); + precache_file ("gfx/help5.lmp"); + + precache_file ("gfx/pause.lmp"); + precache_file ("gfx/loading.lmp"); + + precache_file ("gfx/p_option.lmp"); + precache_file ("gfx/p_load.lmp"); + precache_file ("gfx/p_save.lmp"); + precache_file ("gfx/p_multi.lmp"); + +// sounds loaded by C code + precache_sound ("misc/menu1.wav"); + precache_sound ("misc/menu2.wav"); + precache_sound ("misc/menu3.wav"); + + precache_sound ("ambience/water1.wav"); + precache_sound ("ambience/wind2.wav"); + +// shareware + precache_file ("maps/start.bsp"); + + precache_file ("maps/e1m1.bsp"); + precache_file ("maps/e1m2.bsp"); + precache_file ("maps/e1m3.bsp"); + precache_file ("maps/e1m4.bsp"); + precache_file ("maps/e1m5.bsp"); + precache_file ("maps/e1m6.bsp"); + precache_file ("maps/e1m7.bsp"); + precache_file ("maps/e1m8.bsp"); + +// registered + precache_file2 ("gfx/pop.lmp"); + + precache_file2 ("maps/e2m1.bsp"); + precache_file2 ("maps/e2m2.bsp"); + precache_file2 ("maps/e2m3.bsp"); + precache_file2 ("maps/e2m4.bsp"); + precache_file2 ("maps/e2m5.bsp"); + precache_file2 ("maps/e2m6.bsp"); + precache_file2 ("maps/e2m7.bsp"); + + precache_file2 ("maps/e3m1.bsp"); + precache_file2 ("maps/e3m2.bsp"); + precache_file2 ("maps/e3m3.bsp"); + precache_file2 ("maps/e3m4.bsp"); + precache_file2 ("maps/e3m5.bsp"); + precache_file2 ("maps/e3m6.bsp"); + precache_file2 ("maps/e3m7.bsp"); + + precache_file2 ("maps/e4m1.bsp"); + precache_file2 ("maps/e4m2.bsp"); + precache_file2 ("maps/e4m3.bsp"); + precache_file2 ("maps/e4m4.bsp"); + precache_file2 ("maps/e4m5.bsp"); + precache_file2 ("maps/e4m6.bsp"); + precache_file2 ("maps/e4m7.bsp"); + precache_file2 ("maps/e4m8.bsp"); + + precache_file2 ("maps/end.bsp"); + + precache_file2 ("maps/dm1.bsp"); + precache_file2 ("maps/dm2.bsp"); + precache_file2 ("maps/dm3.bsp"); + precache_file2 ("maps/dm4.bsp"); + precache_file2 ("maps/dm5.bsp"); + precache_file2 ("maps/dm6.bsp"); +}; + + +entity lastspawn; + +//======================= +/*QUAKED worldspawn (0 0 0) ? +Only used for the world entity. +Set message to the level name. +Set sounds to the cd track to play. + +World Types: +0: medieval +1: metal +2: base +*/ +//======================= +void() worldspawn = +{ + lastspawn = world; + + ENG_Check(); + +#ifndef NETQUAKE +// custom map attributes + if (self.model == "maps/e1m8.bsp") + cvar_set ("sv_gravity", "100"); + else + cvar_set ("sv_gravity", "800"); +#endif + +// the area based ambient sounds MUST be the first precache_sounds + +// player precaches + W_Precache (); // get weapon precaches + +// sounds used from C physics code + precache_sound ("demon/dland2.wav"); // landing thud + precache_sound ("misc/h2ohit1.wav"); // landing splash + +// setup precaches allways needed + precache_sound ("items/itembk2.wav"); // item respawn sound + precache_sound ("player/plyrjmp8.wav"); // player jump + precache_sound ("player/land.wav"); // player landing + precache_sound ("player/land2.wav"); // player hurt landing + precache_sound ("player/drown1.wav"); // drowning pain + precache_sound ("player/drown2.wav"); // drowning pain + precache_sound ("player/gasp1.wav"); // gasping for air + precache_sound ("player/gasp2.wav"); // taking breath + precache_sound ("player/h2odeath.wav"); // drowning death + + precache_sound ("misc/talk.wav"); // talk + precache_sound ("player/teledth1.wav"); // telefrag + precache_sound ("misc/r_tele1.wav"); // teleport sounds + precache_sound ("misc/r_tele2.wav"); + precache_sound ("misc/r_tele3.wav"); + precache_sound ("misc/r_tele4.wav"); + precache_sound ("misc/r_tele5.wav"); + precache_sound ("weapons/lock4.wav"); // ammo pick up + precache_sound ("weapons/pkup.wav"); // weapon up + precache_sound ("items/armor1.wav"); // armor up + precache_sound ("weapons/lhit.wav"); //lightning + precache_sound ("weapons/lstart.wav"); //lightning start + precache_sound ("items/damage3.wav"); + + precache_sound ("misc/power.wav"); //lightning for boss + +// player gib sounds + precache_sound ("player/gib.wav"); // player gib sound + precache_sound ("player/udeath.wav"); // player gib sound + precache_sound ("player/tornoff2.wav"); // gib sound + +// player pain sounds + + precache_sound ("player/pain1.wav"); + precache_sound ("player/pain2.wav"); + precache_sound ("player/pain3.wav"); + precache_sound ("player/pain4.wav"); + precache_sound ("player/pain5.wav"); + precache_sound ("player/pain6.wav"); + +// player death sounds + precache_sound ("player/death1.wav"); + precache_sound ("player/death2.wav"); + precache_sound ("player/death3.wav"); + precache_sound ("player/death4.wav"); + precache_sound ("player/death5.wav"); + + precache_sound ("boss1/sight1.wav"); + +// ax sounds + precache_sound ("weapons/ax1.wav"); // ax swoosh + precache_sound ("player/axhit1.wav"); // ax hit meat + precache_sound ("player/axhit2.wav"); // ax hit world + + precache_sound ("player/h2ojump.wav"); // player jumping into water + precache_sound ("player/slimbrn2.wav"); // player enter slime + precache_sound ("player/inh2o.wav"); // player enter water + precache_sound ("player/inlava.wav"); // player enter lava + precache_sound ("misc/outwater.wav"); // leaving water sound + + precache_sound ("player/lburn1.wav"); // lava burn + precache_sound ("player/lburn2.wav"); // lava burn + + precache_sound ("misc/water1.wav"); // swimming + precache_sound ("misc/water2.wav"); // swimming + +// Invulnerability sounds + precache_sound ("items/protect.wav"); + precache_sound ("items/protect2.wav"); + precache_sound ("items/protect3.wav"); + + + precache_model ("progs/player.mdl"); + precache_model ("progs/eyes.mdl"); + precache_model ("progs/h_player.mdl"); + precache_model ("progs/gib1.mdl"); + precache_model ("progs/gib2.mdl"); + precache_model ("progs/gib3.mdl"); + + precache_model ("progs/s_bubble.spr"); // drowning bubbles + precache_model ("progs/s_explod.spr"); // sprite explosion + + precache_model ("progs/v_axe.mdl"); + precache_model ("progs/v_shot.mdl"); + precache_model ("progs/v_nail.mdl"); + precache_model ("progs/v_rock.mdl"); + precache_model ("progs/v_shot2.mdl"); + precache_model ("progs/v_nail2.mdl"); + precache_model ("progs/v_rock2.mdl"); + + precache_model ("progs/bolt.mdl"); // for lightning gun + precache_model ("progs/bolt2.mdl"); // for lightning gun + precache_model ("progs/bolt3.mdl"); // for boss shock + precache_model ("progs/lavaball.mdl"); // for testing + + precache_model ("progs/missile.mdl"); + precache_model ("progs/grenade.mdl"); + precache_model ("progs/spike.mdl"); + precache_model ("progs/s_spike.mdl"); + + precache_model ("progs/backpack.mdl"); + + precache_model ("progs/zom_gib.mdl"); + + precache_model ("progs/v_light.mdl"); + + +// +// Setup light animation tables. 'a' is total darkness, 'z' is maxbright. +// + + // 0 normal + lightstyle(0, "m"); + + // 1 FLICKER (first variety) + lightstyle(1, "mmnmmommommnonmmonqnmmo"); + + // 2 SLOW STRONG PULSE + lightstyle(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"); + + // 3 CANDLE (first variety) + lightstyle(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg"); + + // 4 FAST STROBE + lightstyle(4, "mamamamamama"); + + // 5 GENTLE PULSE 1 + lightstyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj"); + + // 6 FLICKER (second variety) + lightstyle(6, "nmonqnmomnmomomno"); + + // 7 CANDLE (second variety) + lightstyle(7, "mmmaaaabcdefgmmmmaaaammmaamm"); + + // 8 CANDLE (third variety) + lightstyle(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"); + + // 9 SLOW STROBE (fourth variety) + lightstyle(9, "aaaaaaaazzzzzzzz"); + + // 10 FLUORESCENT FLICKER + lightstyle(10, "mmamammmmammamamaaamammma"); + + // 11 SLOW PULSE NOT FADE TO BLACK + lightstyle(11, "abcdefghijklmnopqrrqponmlkjihgfedcba"); + + // styles 32-62 are assigned by the light program for switchable lights + + // 63 testing + lightstyle(63, "a"); +}; + +void() StartFrame = +{ + timelimit = cvar("timelimit") * 60; + fraglimit = cvar("fraglimit"); +#ifdef NETQUAKE + deathmatch = cvar("deathmatch"); + coop = cvar("coop"); + teamplay = cvar("teamplay"); +#endif + skill = cvar("skill"); + + framecount = framecount + 1; +};