📄 gamefunc.java
字号:
} }; static EntDieAdapter button_killed = new EntDieAdapter() { public String getID() { return "button_killed";} public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { self.activator = attacker; self.health = self.max_health; self.takedamage = Defines.DAMAGE_NO; button_fire.think(self); } }; static EntThinkAdapter SP_func_button = new EntThinkAdapter() { public String getID() { return "sp_func_button";} public boolean think(edict_t ent) { float[] abs_movedir = { 0, 0, 0 }; float dist; GameBase.G_SetMovedir(ent.s.angles, ent.movedir); ent.movetype = Defines.MOVETYPE_STOP; ent.solid = Defines.SOLID_BSP; GameBase.gi.setmodel(ent, ent.model); if (ent.sounds != 1) ent.moveinfo.sound_start = GameBase.gi .soundindex("switches/butn2.wav"); if (0 == ent.speed) ent.speed = 40; if (0 == ent.accel) ent.accel = ent.speed; if (0 == ent.decel) ent.decel = ent.speed; if (0 == ent.wait) ent.wait = 3; if (0 == GameBase.st.lip) GameBase.st.lip = 4; Math3D.VectorCopy(ent.s.origin, ent.pos1); abs_movedir[0] = (float) Math.abs(ent.movedir[0]); abs_movedir[1] = (float) Math.abs(ent.movedir[1]); abs_movedir[2] = (float) Math.abs(ent.movedir[2]); dist = abs_movedir[0] * ent.size[0] + abs_movedir[1] * ent.size[1] + abs_movedir[2] * ent.size[2] - GameBase.st.lip; Math3D.VectorMA(ent.pos1, dist, ent.movedir, ent.pos2); ent.use = button_use; ent.s.effects |= Defines.EF_ANIM01; if (ent.health != 0) { ent.max_health = ent.health; ent.die = button_killed; ent.takedamage = Defines.DAMAGE_YES; } else if (null == ent.targetname) ent.touch = button_touch; ent.moveinfo.state = STATE_BOTTOM; ent.moveinfo.speed = ent.speed; ent.moveinfo.accel = ent.accel; ent.moveinfo.decel = ent.decel; ent.moveinfo.wait = ent.wait; Math3D.VectorCopy(ent.pos1, ent.moveinfo.start_origin); Math3D.VectorCopy(ent.s.angles, ent.moveinfo.start_angles); Math3D.VectorCopy(ent.pos2, ent.moveinfo.end_origin); Math3D.VectorCopy(ent.s.angles, ent.moveinfo.end_angles); GameBase.gi.linkentity(ent); return true; } }; static EntThinkAdapter door_hit_top = new EntThinkAdapter() { public String getID() { return "door_hit_top";} public boolean think(edict_t self) { if (0 == (self.flags & Defines.FL_TEAMSLAVE)) { if (self.moveinfo.sound_end != 0) GameBase.gi.sound(self, Defines.CHAN_NO_PHS_ADD + Defines.CHAN_VOICE, self.moveinfo.sound_end, 1, Defines.ATTN_STATIC, 0); self.s.sound = 0; } self.moveinfo.state = STATE_TOP; if ((self.spawnflags & DOOR_TOGGLE) != 0) return true; if (self.moveinfo.wait >= 0) { self.think = door_go_down; self.nextthink = GameBase.level.time + self.moveinfo.wait; } return true; } }; static EntThinkAdapter door_hit_bottom = new EntThinkAdapter() { public String getID() { return "door_hit_bottom";} public boolean think(edict_t self) { if (0 == (self.flags & Defines.FL_TEAMSLAVE)) { if (self.moveinfo.sound_end != 0) GameBase.gi.sound(self, Defines.CHAN_NO_PHS_ADD + Defines.CHAN_VOICE, self.moveinfo.sound_end, 1, Defines.ATTN_STATIC, 0); self.s.sound = 0; } self.moveinfo.state = STATE_BOTTOM; door_use_areaportals(self, false); return true; } }; static EntThinkAdapter door_go_down = new EntThinkAdapter() { public String getID() { return "door_go_down";} public boolean think(edict_t self) { if (0 == (self.flags & Defines.FL_TEAMSLAVE)) { if (self.moveinfo.sound_start != 0) GameBase.gi.sound(self, Defines.CHAN_NO_PHS_ADD + Defines.CHAN_VOICE, self.moveinfo.sound_start, 1, Defines.ATTN_STATIC, 0); self.s.sound = self.moveinfo.sound_middle; } if (self.max_health != 0) { self.takedamage = Defines.DAMAGE_YES; self.health = self.max_health; } self.moveinfo.state = STATE_DOWN; if (Lib.strcmp(self.classname, "func_door") == 0) Move_Calc(self, self.moveinfo.start_origin, door_hit_bottom); else if (Lib.strcmp(self.classname, "func_door_rotating") == 0) AngleMove_Calc(self, door_hit_bottom); return true; } }; static EntUseAdapter door_use = new EntUseAdapter() { public String getID() { return "door_use";} public void use(edict_t self, edict_t other, edict_t activator) { edict_t ent; if ((self.flags & Defines.FL_TEAMSLAVE) != 0) return; if ((self.spawnflags & DOOR_TOGGLE) != 0) { if (self.moveinfo.state == STATE_UP || self.moveinfo.state == STATE_TOP) { // trigger all paired doors for (ent = self; ent != null; ent = ent.teamchain) { ent.message = null; ent.touch = null; door_go_down.think(ent); } return; } } // trigger all paired doors for (ent = self; ent != null; ent = ent.teamchain) { ent.message = null; ent.touch = null; door_go_up(ent, activator); } } }; static EntTouchAdapter Touch_DoorTrigger = new EntTouchAdapter() { public String getID() { return "touch_door_trigger";} public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { if (other.health <= 0) return; if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) return; if (0 != (self.owner.spawnflags & DOOR_NOMONSTER) && 0 != (other.svflags & Defines.SVF_MONSTER)) return; if (GameBase.level.time < self.touch_debounce_time) return; self.touch_debounce_time = GameBase.level.time + 1.0f; door_use.use(self.owner, other, other); } }; static EntThinkAdapter Think_CalcMoveSpeed = new EntThinkAdapter() { public String getID() { return "think_calc_movespeed";} public boolean think(edict_t self) { edict_t ent; float min; float time; float newspeed; float ratio; float dist; if ((self.flags & Defines.FL_TEAMSLAVE) != 0) return true; // only the team master does this // find the smallest distance any member of the team will be moving min = Math.abs(self.moveinfo.distance); for (ent = self.teamchain; ent != null; ent = ent.teamchain) { dist = Math.abs(ent.moveinfo.distance); if (dist < min) min = dist; } time = min / self.moveinfo.speed; // adjust speeds so they will all complete at the same time for (ent = self; ent != null; ent = ent.teamchain) { newspeed = Math.abs(ent.moveinfo.distance) / time; ratio = newspeed / ent.moveinfo.speed; if (ent.moveinfo.accel == ent.moveinfo.speed) ent.moveinfo.accel = newspeed; else ent.moveinfo.accel *= ratio; if (ent.moveinfo.decel == ent.moveinfo.speed) ent.moveinfo.decel = newspeed; else ent.moveinfo.decel *= ratio; ent.moveinfo.speed = newspeed; } return true; } }; static EntThinkAdapter Think_SpawnDoorTrigger = new EntThinkAdapter() { public String getID() { return "think_spawn_door_trigger";} public boolean think(edict_t ent) { edict_t other; float[] mins = { 0, 0, 0 }, maxs = { 0, 0, 0 }; if ((ent.flags & Defines.FL_TEAMSLAVE) != 0) return true; // only the team leader spawns a trigger Math3D.VectorCopy(ent.absmin, mins); Math3D.VectorCopy(ent.absmax, maxs); for (other = ent.teamchain; other != null; other = other.teamchain) { GameBase.AddPointToBounds(other.absmin, mins, maxs); GameBase.AddPointToBounds(other.absmax, mins, maxs); } // expand mins[0] -= 60; mins[1] -= 60; maxs[0] += 60; maxs[1] += 60; other = GameUtil.G_Spawn(); Math3D.VectorCopy(mins, other.mins); Math3D.VectorCopy(maxs, other.maxs); other.owner = ent; other.solid = Defines.SOLID_TRIGGER; other.movetype = Defines.MOVETYPE_NONE; other.touch = Touch_DoorTrigger; GameBase.gi.linkentity(other); if ((ent.spawnflags & DOOR_START_OPEN) != 0) door_use_areaportals(ent, true); Think_CalcMoveSpeed.think(ent); return true; } }; static EntBlockedAdapter door_blocked = new EntBlockedAdapter() { public String getID() { return "door_blocked";} public void blocked(edict_t self, edict_t other) { edict_t ent; if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) { // give it a chance to go away on it's own terms (like gibs) GameCombat.T_Damage(other, self, self, Globals.vec3_origin, other.s.origin, Globals.vec3_origin, 100000, 1, 0, Defines.MOD_CRUSH); // if it's still there, nuke it if (other != null) GameMisc.BecomeExplosion1(other); return; } GameCombat.T_Damage(other, self, self, Globals.vec3_origin, other.s.origin, Globals.vec3_origin, self.dmg, 1, 0, Defines.MOD_CRUSH); if ((self.spawnflags & DOOR_CRUSHER) != 0) return; // 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.moveinfo.wait >= 0) { if (self.moveinfo.state == STATE_DOWN) { for (ent = self.teammaster; ent != null; ent = ent.teamchain) door_go_up(ent, ent.activator); } else { for (ent = self.teammaster; ent != null; ent = ent.teamchain) door_go_down.think(ent); } } } }; static EntDieAdapter door_killed = new EntDieAdapter() { public String getID() { return "door_killed";} public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { edict_t ent; for (ent = self.teammaster; ent != null; ent = ent.teamchain) { ent.health = ent.max_health; ent.takedamage = Defines.DAMAGE_NO; } door_use.use(self.teammaster, attacker, attacker); } }; static EntTouchAdapter door_touch = new EntTouchAdapter() { public String getID() { return "door_touch";} public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { if (null == other.client) return; if (GameBase.level.time < self.touch_debounce_time) return; self.touch_debounce_time = GameBase.level.time + 5.0f; GameBase.gi.centerprintf(other, self.message); GameBase.gi.sound(other, Defines.CHAN_AUTO, GameBase.gi .soundindex("misc/talk1.wav"), 1, Defines.ATTN_NORM, 0); } }; static EntThinkAdapter SP_func_door = new EntThinkAdapter() { public String getID() { return "sp_func_door";} public boolean think(edict_t ent) { float[] abs_movedir = { 0, 0, 0 }; if (ent.sounds != 1) { ent.moveinfo.sound_start = GameBase.gi .soundindex("doors/dr1_strt.wav"); ent.moveinfo.sound_middle = GameBase.gi .soundindex("doors/dr1_mid.wav");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -