X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmonsters%2Fsv_monsters.qc;h=c1414bfd48ed95d9973780a08b383254eac07107;hp=f03a51368628b06b9d41d7dbf5002934ad6decaf;hb=f4c77946d2b388b2ef4fae1057d1a636d9850923;hpb=b7d363a108963ca13647ee25b58c5a531366cf49 diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index f03a51368..c1414bfd4 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) { @@ -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))) @@ -413,16 +412,18 @@ bool Monster_Attack_Leap(entity this, vector anm, void(entity this, entity touch return true; } -void Monster_Attack_Check(entity this, entity targ) +void Monster_Attack_Check(entity this, entity targ, .entity weaponentity) { + int slot = weaponslot(weaponentity); + if((this == NULL || targ == NULL) || (!this.monster_attackfunc) - || (time < this.attack_finished_single[0]) + || (time < this.attack_finished_single[slot]) ) { return; } if(vdist(targ.origin - this.origin, <=, this.attack_range)) { - bool attack_success = this.monster_attackfunc(MONSTER_ATTACK_MELEE, this, targ); + bool attack_success = this.monster_attackfunc(MONSTER_ATTACK_MELEE, this, targ, weaponentity); if(attack_success == 1) Monster_Sound(this, monstersound_melee, 0, false, CH_VOICE); else if(attack_success > 0) @@ -431,7 +432,7 @@ void Monster_Attack_Check(entity this, entity targ) if(vdist(targ.origin - this.origin, >, this.attack_range)) { - float attack_success = this.monster_attackfunc(MONSTER_ATTACK_RANGED, this, targ); + float attack_success = this.monster_attackfunc(MONSTER_ATTACK_RANGED, this, targ, weaponentity); if(attack_success == 1) Monster_Sound(this, monstersound_melee, 0, false, CH_VOICE); else if(attack_success > 0) @@ -508,6 +509,8 @@ bool Monster_Respawn_Check(entity this) void Monster_Respawn(entity this) { Monster_Spawn(this, this.monsterid); } +.vector pos1, pos2; + void Monster_Dead_Fade(entity this) { if(Monster_Respawn_Check(this)) @@ -543,6 +546,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 @@ -686,12 +690,14 @@ void Monster_CalculateVelocity(entity this, vector to, vector from, float turnra } .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; + entity targ = this.goalentity; if(STAT(FROZEN, this) == 2) { @@ -777,8 +783,6 @@ void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed) } } - targ = this.goalentity; - if (MUTATOR_CALLHOOK(MonsterMove, this, runspeed, walkspeed, targ) || gameover || this.draggedby != NULL @@ -865,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); @@ -891,7 +895,8 @@ void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed) this.angles_y += turny; } - Monster_Attack_Check(this, this.enemy); + .entity weaponentity = weaponentities[0]; // TODO? + Monster_Attack_Check(this, this.enemy, weaponentity); } void Monster_Remove(entity this) @@ -899,13 +904,17 @@ 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)) { delete(this.(weaponentity)); } + 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); delete(this); @@ -1029,7 +1038,10 @@ void Monster_Dead(entity this, entity attacker, float gibbed) mon.mr_death(mon, this); if(this.candrop && this.weapon) - W_ThrowNewWeapon(this, this.weapon, 0, this.origin, randomvec() * 150 + '0 0 325'); + { + .entity weaponentity = weaponentities[0]; // TODO: unhardcode + W_ThrowNewWeapon(this, this.weapon, 0, this.origin, randomvec() * 150 + '0 0 325', weaponentity); + } } void Monster_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) @@ -1317,6 +1329,7 @@ bool Monster_Spawn(entity this, int mon_id) this.classname = "monster"; this.takedamage = DAMAGE_AIM; this.bot_attack = true; + IL_PUSH(g_bot_targets, this); this.iscreature = true; this.teleportable = true; this.damagedbycontents = true;