X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmonsters%2Fsv_monsters.qc;h=72e79d58ac60e563be638bc961dca1b0e76e7376;hb=8c965aa90470cfa8cbfaff88db71b6b5899a90ce;hp=795e0310a263f35fd922478f1e9a1ad1125ad47d;hpb=2300937585fd409c578a516ed5e051ba389646d4;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 795e0310a..72e79d58a 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -1,29 +1,27 @@ -#if defined(CSQC) -#elif defined(MENUQC) -#elif defined(SVQC) - #include - #include "../constants.qh" - #include "../teams.qh" - #include "../util.qh" - #include "all.qh" - #include "sv_monsters.qh" - #include "../physics/movelib.qh" - #include "../weapons/all.qh" - #include - #include - #include "../deathtypes/all.qh" - #include - #include - #include "../turrets/sv_turrets.qh" - #include "../turrets/util.qh" - #include "../vehicles/all.qh" - #include - #include - #include - #include "../triggers/triggers.qh" - #include - #include -#endif +#include "sv_monsters.qh" + +#include +#include +#include "../constants.qh" +#include "../teams.qh" +#include "../util.qh" +#include "all.qh" +#include "../physics/movelib.qh" +#include "../weapons/_mod.qh" +#include +#include +#include "../deathtypes/all.qh" +#include +#include +#include "../turrets/sv_turrets.qh" +#include "../turrets/util.qh" +#include "../vehicles/all.qh" +#include +#include +#include "../triggers/triggers.qh" +#include +#include +#include void monsters_setstatus(entity this) { @@ -50,7 +48,7 @@ void monster_dropitem(entity this, entity attacker) e.noalign = true; e.monster_loot(e); e.gravity = 1; - e.movetype = MOVETYPE_TOSS; + set_movetype(e, MOVETYPE_TOSS); e.reset = SUB_Remove; setorigin(e, org); e.velocity = randomvec() * 175 + '0 0 325'; @@ -94,16 +92,17 @@ bool Monster_ValidTarget(entity this, entity targ) || (SAME_TEAM(targ, this)) || (STAT(FROZEN, targ)) || (targ.alpha != 0 && targ.alpha < 0.5) + || (MUTATOR_CALLHOOK(MonsterValidTarget, this, targ)) ) { // if any of the above checks fail, target is not valid return false; } - traceline(this.origin + this.view_ofs, targ.origin, 0, this); + traceline(this.origin + this.view_ofs, targ.origin, MOVE_NOMONSTERS, this); - if((trace_fraction < 1) && (trace_ent != targ)) - return false; + if(trace_fraction < 1) + return false; // solid if(autocvar_g_monsters_target_infront || (this.spawnflags & MONSTERFLAG_INFRONT)) if(this.enemy != targ) @@ -247,7 +246,7 @@ void Monster_Sound_Precache(string f) { if(tokenize_console(s) != 3) { - LOG_TRACE("Invalid sound info line: ", s, "\n"); + LOG_TRACE("Invalid sound info line: ", s); continue; } PrecacheGlobalSound(strcat(argv(1), " ", argv(2))); @@ -302,7 +301,7 @@ bool Monster_Sounds_Load(entity this, string f, int first) fh = fopen(f, FILE_READ); if(fh < 0) { - LOG_TRACE("Monster sound file not found: ", f, "\n"); + LOG_TRACE("Monster sound file not found: ", f); return false; } while((s = fgets(fh))) @@ -338,7 +337,7 @@ void Monster_Sound(entity this, .string samplefield, float sound_delay, float de if(delaytoo) if(time < this.msound_delay) return; // too early - GlobalSound_string(this, this.(samplefield), chan, VOICETYPE_PLAYERSOUND); + GlobalSound_string(this, this.(samplefield), chan, VOL_BASE, VOICETYPE_PLAYERSOUND); this.msound_delay = time + sound_delay; } @@ -506,7 +505,9 @@ bool Monster_Respawn_Check(entity this) return true; } -void Monster_Respawn(entity this) { Monster_Spawn(this, this.monsterid); } +void Monster_Respawn(entity this) { Monster_Spawn(this, true, this.monsterid); } + +.vector pos1, pos2; void Monster_Dead_Fade(entity this) { @@ -543,6 +544,7 @@ void Monster_Use(entity this, entity actor, entity trigger) if(Monster_ValidTarget(this, actor)) { this.enemy = actor; } } +.float pass_distance; vector Monster_Move_Target(entity this, entity targ) { // enemy is always preferred target @@ -685,9 +687,13 @@ void Monster_CalculateVelocity(entity this, vector to, vector from, float turnra //this.angles = vectoangles(this.velocity); } +.entity draggedby; +.entity target2; + void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed) { - if(this.target2) { this.goalentity = find(NULL, targetname, this.target2); } + // update goal entity if lost + if(this.target2 && this.goalentity.targetname != this.target2) { this.goalentity = find(NULL, targetname, this.target2); } entity targ; @@ -763,15 +769,15 @@ void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed) } - this.movetype = MOVETYPE_BOUNCE; + set_movetype(this, MOVETYPE_BOUNCE); //this.velocity_z = -200; return; } - else if(this.movetype == MOVETYPE_BOUNCE) + else if(this.move_movetype == MOVETYPE_BOUNCE) { this.angles_x = 0; - this.movetype = MOVETYPE_WALK; + set_movetype(this, MOVETYPE_WALK); } } @@ -863,10 +869,10 @@ void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed) } else { - entity e = find(NULL, targetname, this.target2); + entity e = this.goalentity; //find(NULL, targetname, this.target2); if(e.target2) this.target2 = e.target2; - else if(e.target) + else if(e.target) // compatibility this.target2 = e.target; movelib_brake_simple(this, stpspeed); @@ -897,16 +903,20 @@ void Monster_Remove(entity this) if(IS_CLIENT(this)) return; // don't remove it? - .entity weaponentity = weaponentities[0]; if(!this) { return; } if(!MUTATOR_CALLHOOK(MonsterRemove, this)) Send_Effect(EFFECT_ITEM_PICKUP, this.origin, '0 0 0', 1); - if(this.(weaponentity)) { remove(this.(weaponentity)); } - if(this.iceblock) { remove(this.iceblock); } + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(this.(weaponentity)) + delete(this.(weaponentity)); + } + if(this.iceblock) { delete(this.iceblock); } WaypointSprite_Kill(this.sprite); - remove(this); + delete(this); } void Monster_Dead_Think(entity this) @@ -924,8 +934,7 @@ void Monster_Dead_Think(entity this) void Monster_Appear(entity this, entity actor, entity trigger) { this.enemy = actor; - this.spawnflags &= ~MONSTERFLAG_APPEAR; // otherwise, we get an endless loop - Monster_Spawn(this, this.monsterid); + Monster_Spawn(this, false, this.monsterid); } bool Monster_Appear_Check(entity this, int monster_id) @@ -1010,7 +1019,7 @@ void Monster_Dead(entity this, entity attacker, float gibbed) this.takedamage = DAMAGE_AIM; this.deadflag = DEAD_DEAD; this.enemy = NULL; - this.movetype = MOVETYPE_TOSS; + set_movetype(this, MOVETYPE_TOSS); this.moveto = this.origin; settouch(this, Monster_Touch); // reset incase monster was pouncing this.reset = func_null; @@ -1119,23 +1128,19 @@ void Monster_Move_2D(entity this, float mspeed, bool allow_jumpoff) return; } - float reverse = false; - vector a, b; - makevectors(this.angles); - a = this.origin + '0 0 16'; - b = this.origin + '0 0 16' + v_forward * 32; + vector a = CENTER_OR_VIEWOFS(this); + vector b = CENTER_OR_VIEWOFS(this) + v_forward * 32; traceline(a, b, MOVE_NORMAL, this); + bool reverse = false; if(trace_fraction != 1.0) - { reverse = true; - - if(trace_ent) - if(IS_PLAYER(trace_ent) && !(trace_ent.items & IT_STRENGTH)) - reverse = false; - } + if(trace_ent && IS_PLAYER(trace_ent) && !(trace_ent.items & ITEM_Strength.m_itemid)) + reverse = false; + if(trace_ent && IS_MONSTER(trace_ent)) + reverse = true; // TODO: fix this... tracing is broken if the floor is thin /* @@ -1203,7 +1208,7 @@ void Monster_Anim(entity this) void Monster_Think(entity this) { setthink(this, Monster_Think); - this.nextthink = this.ticrate; + this.nextthink = time + this.ticrate; if(this.monster_lifetime) if(time >= this.monster_lifetime) @@ -1282,7 +1287,7 @@ bool Monster_Spawn_Setup(entity this) return true; } -bool Monster_Spawn(entity this, int mon_id) +bool Monster_Spawn(entity this, bool check_appear, int mon_id) { // setup the basic required properties for a monster entity mon = Monsters_from(mon_id); @@ -1290,7 +1295,13 @@ bool Monster_Spawn(entity this, int mon_id) if(!autocvar_g_monsters) { Monster_Remove(this); return false; } - if(Monster_Appear_Check(this, mon_id)) { return true; } // return true so the monster isn't removed + if(!(this.spawnflags & MONSTERFLAG_RESPAWNED)) + { + IL_PUSH(g_monsters, this); + IL_PUSH(g_damagedbycontents, this); + } + + if(check_appear && Monster_Appear_Check(this, mon_id)) { return true; } // return true so the monster isn't removed if(!this.monster_skill) this.monster_skill = cvar("g_monsters_skill"); @@ -1311,6 +1322,8 @@ bool Monster_Spawn(entity this, int mon_id) this.flags = FL_MONSTER; this.classname = "monster"; this.takedamage = DAMAGE_AIM; + if(!this.bot_attack) + IL_PUSH(g_bot_targets, this); this.bot_attack = true; this.iscreature = true; this.teleportable = true; @@ -1320,7 +1333,7 @@ bool Monster_Spawn(entity this, int mon_id) settouch(this, Monster_Touch); this.use = Monster_Use; this.solid = SOLID_BBOX; - this.movetype = MOVETYPE_WALK; + set_movetype(this, MOVETYPE_WALK); this.spawnshieldtime = time + autocvar_g_monsters_spawnshieldtime; this.enemy = NULL; this.velocity = '0 0 0'; @@ -1336,13 +1349,13 @@ bool Monster_Spawn(entity this, int mon_id) this.oldtarget2 = this.target2; this.pass_distance = 0; this.deadflag = DEAD_NO; - this.noalign = ((mon.spawnflags & MONSTER_TYPE_FLY) || (mon.spawnflags & MONSTER_TYPE_SWIM)); this.spawn_time = time; this.gravity = 1; this.monster_moveto = '0 0 0'; this.monster_face = '0 0 0'; this.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_BOTCLIP | DPCONTENTS_MONSTERCLIP; + if(!this.noalign) { this.noalign = ((mon.spawnflags & MONSTER_TYPE_FLY) || (mon.spawnflags & MONSTER_TYPE_SWIM)); } if(!this.scale) { this.scale = 1; } if(autocvar_g_monsters_edit) { this.grab = 1; } if(autocvar_g_fullbrightplayers) { this.effects |= EF_FULLBRIGHT; } @@ -1355,7 +1368,7 @@ bool Monster_Spawn(entity this, int mon_id) if(mon.spawnflags & MONSTER_TYPE_FLY) { this.flags |= FL_FLY; - this.movetype = MOVETYPE_FLY; + set_movetype(this, MOVETYPE_FLY); } if(!(this.spawnflags & MONSTERFLAG_RESPAWNED))