if(this.target2 && this.target2 != "" && this.goalentity.targetname != this.target2)
this.goalentity = find(NULL, targetname, this.target2);
- if(STAT(FROZEN, this) == 2)
+ if(STAT(FROZEN, this))
{
- this.revive_progress = bound(0, this.revive_progress + this.ticrate * this.revive_speed, 1);
- this.health = max(1, this.revive_progress * this.max_health);
- this.iceblock.alpha = bound(0.2, 1 - this.revive_progress, 1);
-
- if(!(this.spawnflags & MONSTERFLAG_INVINCIBLE) && this.sprite)
- WaypointSprite_UpdateHealth(this.sprite, this.health);
-
movelib_brake_simple(this, stpspeed);
setanim(this, this.anim_idle, true, false, false);
-
- this.enemy = NULL;
- this.nextthink = time + this.ticrate;
-
- if(this.revive_progress >= 1)
- Unfreeze(this);
-
- return;
- }
- else if(STAT(FROZEN, this) == 3)
- {
- this.revive_progress = bound(0, this.revive_progress - this.ticrate * this.revive_speed, 1);
- this.health = max(0, autocvar_g_nades_ice_health + (this.max_health-autocvar_g_nades_ice_health) * this.revive_progress );
-
- if(!(this.spawnflags & MONSTERFLAG_INVINCIBLE) && this.sprite)
- WaypointSprite_UpdateHealth(this.sprite, this.health);
-
- movelib_brake_simple(this, stpspeed);
- setanim(this, this.anim_idle, true, false, false);
-
- this.enemy = NULL;
- this.nextthink = time + this.ticrate;
-
- if(this.health < 1)
- {
- Unfreeze(this);
- this.health = 0;
- if(this.event_damage)
- this.event_damage(this, this, this.frozen_by, 1, DEATH_NADE_ICE_FREEZE.m_id, this.origin, '0 0 0');
- }
-
- else if ( this.revive_progress <= 0 )
- Unfreeze(this);
-
- return;
+ return; // no physics while frozen!
}
if(this.flags & FL_SWIM)
if(DIFF_TEAM(this.monster_follow, this))
this.monster_follow = NULL;
- if(time >= this.last_enemycheck)
- {
- if(!this.enemy)
- {
- this.enemy = Monster_FindTarget(this);
- if(this.enemy)
- {
- WarpZone_RefSys_Copy(this.enemy, this);
- WarpZone_RefSys_AddInverse(this.enemy, this); // wz1^-1 ... wzn^-1 receiver
- this.moveto = WarpZone_RefSys_TransformOrigin(this.enemy, this, (0.5 * (this.enemy.absmin + this.enemy.absmax)));
- this.monster_moveto = '0 0 0';
- this.monster_face = '0 0 0';
-
- //this.pass_distance = vlen((('1 0 0' * this.enemy.origin_x) + ('0 1 0' * this.enemy.origin_y)) - (('1 0 0' * this.origin_x) + ('0 1 0' * this.origin_y)));
- Monster_Sound(this, monstersound_sight, 0, false, CH_VOICE);
- }
- }
-
- this.last_enemycheck = time + 1; // check for enemies every second
- }
-
if(this.state == MONSTER_ATTACK_RANGED && IS_ONGROUND(this))
{
this.state = 0;
turny = bound(turny * -1, shortangle_f(real_angle.y, this.angles.y), turny);
this.angles_y += turny;
}
-
- .entity weaponentity = weaponentities[0]; // TODO?
- Monster_Attack_Check(this, this.enemy, weaponentity);
}
void Monster_Remove(entity this)
*/
}
+void Monster_Frozen_Think(entity this)
+{
+ if(STAT(FROZEN, this) == 2)
+ {
+ this.revive_progress = bound(0, this.revive_progress + this.ticrate * this.revive_speed, 1);
+ this.health = max(1, this.revive_progress * this.max_health);
+ this.iceblock.alpha = bound(0.2, 1 - this.revive_progress, 1);
+
+ if(!(this.spawnflags & MONSTERFLAG_INVINCIBLE) && this.sprite)
+ WaypointSprite_UpdateHealth(this.sprite, this.health);
+
+ if(this.revive_progress >= 1)
+ Unfreeze(this);
+ }
+ else if(STAT(FROZEN, this) == 3)
+ {
+ this.revive_progress = bound(0, this.revive_progress - this.ticrate * this.revive_speed, 1);
+ this.health = max(0, autocvar_g_nades_ice_health + (this.max_health-autocvar_g_nades_ice_health) * this.revive_progress );
+
+ if(!(this.spawnflags & MONSTERFLAG_INVINCIBLE) && this.sprite)
+ WaypointSprite_UpdateHealth(this.sprite, this.health);
+
+ if(this.health < 1)
+ {
+ Unfreeze(this);
+ this.health = 0;
+ if(this.event_damage)
+ this.event_damage(this, this, this.frozen_by, 1, DEATH_NADE_ICE_FREEZE.m_id, this.origin, '0 0 0');
+ }
+
+ else if ( this.revive_progress <= 0 )
+ Unfreeze(this);
+ }
+ // otherwise, no revival!
+
+ this.enemy = NULL; // TODO: save enemy, and attack when revived?
+}
+
+void Monster_Enemy_Check(entity this)
+{
+ if(!this.enemy)
+ {
+ this.enemy = Monster_FindTarget(this);
+ if(this.enemy)
+ {
+ WarpZone_RefSys_Copy(this.enemy, this);
+ WarpZone_RefSys_AddInverse(this.enemy, this); // wz1^-1 ... wzn^-1 receiver
+ // update move target immediately?
+ this.moveto = WarpZone_RefSys_TransformOrigin(this.enemy, this, (0.5 * (this.enemy.absmin + this.enemy.absmax)));
+ this.monster_moveto = '0 0 0';
+ this.monster_face = '0 0 0';
+
+ //this.pass_distance = vlen((('1 0 0' * this.enemy.origin_x) + ('0 1 0' * this.enemy.origin_y)) - (('1 0 0' * this.origin_x) + ('0 1 0' * this.origin_y)));
+ Monster_Sound(this, monstersound_sight, 0, false, CH_VOICE);
+ }
+ }
+}
+
void Monster_Think(entity this)
{
setthink(this, Monster_Think);
return;
}
+ if(STAT(FROZEN, this))
+ Monster_Frozen_Think(this);
+ else if(time >= this.last_enemycheck)
+ {
+ Monster_Enemy_Check(this);
+ this.last_enemycheck = time + 1; // check for enemies every second
+ }
+
Monster mon = Monsters_from(this.monsterid);
if(mon.mr_think(mon, this))
+ {
Monster_Move(this, this.speed2, this.speed, this.stopspeed);
+ .entity weaponentity = weaponentities[0]; // TODO?
+ Monster_Attack_Check(this, this.enemy, weaponentity);
+ }
+
Monster_Anim(this);
CSQCMODEL_AUTOUPDATE(this);