Raised This Month: $ Target: $400
 0% 

Entity always go underground[Added the source code]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
csoldjb
Member
Join Date: Dec 2010
Old 04-25-2013 , 01:08   Entity always go underground[Added the source code]
Reply With Quote #1

Here is the npc code . When playing some sequences,it always go underground.Before playing the sequences,it works perfect.
PHP Code:
LINK_ENTITY_TO_CLASS(mst_angraCMonsterAngra);


void CMonsterAngra::Spawn(void)
{
    
Precache();
    
pev->classname MAKE_STRING("monster_angra");
    
pev->movetype MOVETYPE_STEP;
    
pev->solid SOLID_SLIDEBOX;
    
pev->takedamage DAMAGE_YES;
    
pev->flags |= FL_MONSTER;
    
pev->deadflag DEAD_NO;
    
pev->max_health ANGRA_MONSTER_HEALTH_BASE;
    
pev->health pev->max_health;
    
pev->gravity 1;
    
pev->view_ofs VEC_MONSTER_VIEW;
    
pev->velocity Vector(000);

    if (
pev->spawnflags SF_MONSTER_HITMONSTERCLIP)
        
pev->flags |= FL_MONSTERCLIP;

    if (
pev->skin 0)
        
pev->skin 0;

    
SET_MODEL(ENT(pev), STRING(pev->model));
    
m_pTarget NULL;

    
UTIL_SetSize(pevVEC_MONSTER_HULL_MINVEC_MONSTER_HULL_MAX);
    
UTIL_MakeVectors(pev->v_angle);
    
SetBoneController(0UTIL_VecToYaw(gpGlobals->v_forward));

    
SetThink(&CMonsterAngra::IdleThink);
    
pev->nextthink gpGlobals->time RANDOM_FLOAT(0.10.2);
    
pev->modelindex m_iModelIndex;

    
DROP_TO_FLOOR(ENT(pev));

    
// Set Enemy
    
m_bAppeared false;
    
SetSequence(ANIM_APPEAR1);
    
    
m_fChangeTarget 0;
    
    
m_pTarget = (CBaseEntity *)GET_PRIVATE(INDEXENT(1)); 
This is the code about playing sequence
PHP Code:
void CMonsterAngra::SetSequence(MONSTER_SEQUENCE iSequence,bool forcePlay)
{
    if(
forcePlay || (pev->sequence != iSequence&& !forcePlay))
    {
        
pev->frame 0;
        
pev->sequence iSequence;
        
ResetSequenceInfo();
        
m_fAnimationTimer gpGlobals->time;
        
m_Activity Activity::ACT_SPECIAL_ATTACK2;
    }
}
void CMonsterAngra::SetActivity(Activity activity)
{
    if (
m_Activity != activity)
    {
        
int animDesired LookupActivity(activity);

        if (
animDesired != -1)
        {
            if (
pev->sequence != animDesired)
            {
                if ((
m_Activity != ACT_WALK || m_Activity != ACT_RUN) && (activity != ACT_WALK || activity != ACT_RUN))
                    
pev->frame 0;

                
pev->sequence animDesired;
            }

            
m_Activity activity;
            
ResetSequenceInfo();
            
m_fAnimationTimer gpGlobals->time;
        }
    }

Here is the CPP(Metamod plugin)
PHP Code:
#include <extdll.h>
#include <meta_api.h>
#include "cbase.h"
#include "monsters.h"
#include "monster_angra.h"
#include "Extra.h"
CBaseEntity *UTIL_FindEntityByClassname(CBaseEntity *pStartEntity, const char *szName);
CBaseEntity *UTIL_FindEntityInSphere(CBaseEntity *pStartEntity, const Vector &vecCenterfloat flRadius);
CBaseEntity *UTIL_PlayerByIndex(int playerIndex);

LINK_ENTITY_TO_CLASS(bte_mst_angraCMonsterAngra);

CMonsterAngra *g_pMonsterAngra;
void CMonsterAngra::Spawn(void)
{
    
Precache();
    
pev->classname MAKE_STRING("monster_angra");
    
pev->movetype MOVETYPE_FLY;
    
pev->solid SOLID_SLIDEBOX;
    
pev->takedamage DAMAGE_YES;
    
pev->flags |= FL_MONSTER;
    
pev->deadflag DEAD_NO;
    
pev->max_health ANGRA_MONSTER_HEALTH_BASE;
    
pev->health pev->max_health;
    
pev->gravity 1;
    
pev->view_ofs VEC_MONSTER_VIEW;
    
pev->velocity Vector(000);

    if (
pev->spawnflags SF_MONSTER_HITMONSTERCLIP)
        
pev->flags |= FL_MONSTERCLIP;

    if (
pev->skin 0)
        
pev->skin 0;

    
SET_MODEL(ENT(pev), STRING(pev->model));
    
m_pTarget NULL;

    
UTIL_SetSize(pevVEC_MONSTER_HULL_MINVEC_MONSTER_HULL_MAX);
    
UTIL_MakeVectors(pev->v_angle);
    
SetBoneController(0UTIL_VecToYaw(gpGlobals->v_forward));
    
DROP_TO_FLOOR(ENT(pev));

    
SetThink(&CMonsterAngra::IdleThink);
    
pev->nextthink gpGlobals->time RANDOM_FLOAT(0.10.2);
    
pev->modelindex m_iModelIndex;

    
DROP_TO_FLOOR(ENT(pev));

    
// Set Enemy
    
m_bAppeared false;
    
SetSequence(ANIM_APPEAR1);
    
    
m_fChangeTarget 0;
    
    
m_pTarget = (CBaseEntity *)GET_PRIVATE(INDEXENT(1));
    
AtOrigin(m_pTarget->pev->origin);
    
m_bDash m_bRadiusAttack m_bTentacle m_bPoison false;
    
m_bInSkill =false;
    
m_bDead =false;
    
m_fDashSkillTimer m_fRadiusAttackTimer m_fTentacleSkillTimer m_fPoisonSkillTimer 0;
    
g_pMonsterAngra this;

void CMonsterAngra::IdleThink(void)
{
    
pev->nextthink gpGlobals->time + (1.0 30);
    
DispatchAnimEvents(StudioFrameAdvance());
    
RunAI();
}
void CMonsterAngra::AtOrigin(Vector &origin)
{
    
pev->angles.0;
    
pev->angles.UTIL_VecToAngles(origin pev->origin).y;
    
pev->angles.0;
}
void CMonsterAngra::Touch(CBaseEntity *pOther)
{
    
pev->movetype MOVETYPE_STEP;
    if(
m_bDash && m_iDashStat == DASH// 冲刺过程中撞到东西
    
{
        if( (
m_vecLastTouchPos-pev->origin).Length2D() < 20.0)
        {
            
m_iDashStat DASH_END;
            
SetSequence(ANIM_ROOLING3);
            
m_fDashTimer gpGlobals->time 1.7;
        }
        
m_vecLastTouchPos pev->origin;
        
// 碰到玩家或世界停止
        
int iHitEntity ENTINDEX(pOther->edict());
        if( 
IsPlayer(pOther) )
        {
            
Vector vecDir =  (pOther->pev->origin pev->origin).Normalize() * 800.0;
            
pOther->pev->velocity vecDir;
            
pOther->pev->velocity.500.0;
            
MakeDamage(pOther,20.0);
            return;
        }
        
        
Vector vecDir =  (pOther->pev->origin pev->origin).Normalize() * 800.0;
        
pOther->pev->velocity vecDir;
        
pOther->pev->velocity.500.0;
    }
}
float CMonsterAngra::GetModifiedDamage(float flDamage)
{
    switch (
m_iLastHitGroup)
    {
        case 
HITGROUP_GENERICflDamage *= 1.75; break;
        case 
HITGROUP_HEADflDamage *= 2.5; break;
        case 
HITGROUP_CHESTflDamage *= 1.5; break;
        case 
HITGROUP_STOMACHflDamage *= 1.75; break;
        case 
HITGROUP_LEFTARM:
        case 
HITGROUP_RIGHTARMflDamage *= 0.75; break;
        case 
HITGROUP_LEFTLEG:
        case 
HITGROUP_RIGHTLEGflDamage *= 0.6; break;
    }
    
float iGot = (pev->max_health pev->health) / pev->max_health 1.0;
    
flDamage *= iGot;

    return 
flDamage;
}
void CMonsterAngra::SpawnBlood(Vector vecSpotint colorfloat flDamage)
{
    
int amount = (int)flDamage;

    if ( 
amount == )
        return;

    
amount *= 2;

    if ( 
amount 255 )
        
amount 255;

    
MESSAGE_BEGINMSG_PVSSVC_TEMPENTITYvecSpot );
    
WRITE_BYTETE_BLOODSPRITE );
    
WRITE_COORDvecSpot.x);                                // pos
    
WRITE_COORDvecSpot.y);
    
WRITE_COORDvecSpot.z);
    
WRITE_SHORTm_iModelIndexBloodSpray );                // initial sprite model
    
WRITE_SHORTm_iModelIndexBloodDrop);                // droplet sprite models
    
WRITE_BYTEcolor );                                // color index into host_basepal
    
WRITE_BYTEminmax3amount 10 ), 16 ) );        // size
    
MESSAGE_END();
}
void CMonsterAngra::Killed(entvars_t *pAttacker,int iGibs)
{
    
SetSequence(ANIM_EXIT2);
    
m_bDead true;
    
pev->movetype MOVETYPE_TOSS;
    
pev->solid SOLID_NOT;
    
pev->takedamage DAMAGE_NO;
    
pev->deadflag DEAD_DEAD;
    
SetActivity(ACT_DIE_HEADSHOT);
    
pev->nextthink gpGlobals->time 18.0;
    
SetThink(&CMonsterAngra::Remove);
    
CBaseMonster::Killed(pAttacker,GIB_NEVER); 
}
void CMonsterAngra::Remove(void)
{
    
pev->nextthink = -1;
    
REMOVE_ENTITY(ENT(pev));
}
int CMonsterAngra::TakeDamage(entvars_t *pevInflictorentvars_t *pevAttackerfloat flDamageint bitsDamageType)
{
    
pev->health -= flDamage;
    if(
pev->health  1)
    {
        
Killed(pevInflictor,0);
    }
    return 
0;
}
void CMonsterAngra::TraceAttack(entvars_t *pevAttackerfloat flDamageVector vecDirTraceResult *ptrint bitsDamageType)
{
    
m_iLastHitGroup ptr->iHitgroup;
    
flDamage GetModifiedDamage(flDamage) ;
    
SpawnBlood(ptr->vecEndPos,3,flDamage);
    
TakeDamage(pevAttacker,pevAttacker,flDamage,bitsDamageType);
}
float CMonsterAngra::GetTargetDistance(void)
{
    return (
m_pTarget->pev->origin pev->origin).Length2D();
}
CBaseEntity *CMonsterAngra::GetRandomTarget(void)
{
    
CBaseEntity *pArray[33];
    
int iCount 0;
    for(
int i=1;i<33;i++)
    {
        
CBaseEntity *pPlayer UTIL_PlayerByIndex(i);
        if(
pPlayer && pPlayer->pev->health 0)
        {
            
pArray[iCount++] = pPlayer;
        }
    }
    if(!
iCount) return NULL;
    return 
pArray[RANDOM_LONG(0,iCount-1)];
}
void CMonsterAngra::Attack(void)
{
    
m_bCreatedRangeAttack false;
    
//AtOrigin(m_pTarget->pev->origin); // 先瞄准一下目标
    
m_fRangeAttackAnimationTimer gpGlobals->time 3.5;
    
SetSequence(ANIM_ZBS_BITE,true);
}
void CMonsterAngra::Shake(CBaseEntity *pTarget)
{
    
MESSAGE_BEGINMSG_ONEiMsgID_ScreenShakeNULLpTarget->edict());
    
WRITE_SHORT((1<<12)*6);
    
WRITE_SHORT((1<<12)*3);
    
WRITE_SHORT((1<<12)*13); 
    
MESSAGE_END();
}
void CMonsterAngra::MakeDamage(CBaseEntity *pTarget,float fDamage)
{
    if(!
IsPlayer(pTarget)) return;
    
CBaseMonster *pVictim = (CBaseMonster *)pTarget;
    
pVictim->m_LastHitGroup HITGROUP_GENERIC;
    
pVictim->TakeDamage(pev,pev,fDamage,DMG_BLAST);
}

void CMonsterAngra::RadiusDamage2(Vector vecStart,float fDamage,float fRange)
{
    
CBaseEntity *pTarget NULL;
    while(( 
pTarget UTIL_FindEntityInSphere(pTargetvecStart,fRange)))
    {
        
MakeDamage(pTarget,fDamage);
        
//Shake(pTarget);
    
}
}
bool CMonsterAngra::IsPlayer(CBaseEntity *pPlayer)
{
    if(
pPlayer->pev->flags FL_CLIENT) return true;
    if(
pPlayer->pev->flags FL_FAKECLIENT) return true;
    return 
false;
}
bool CMonsterAngra::CheckTarget(void)
{
    if(
m_pTarget && m_pTarget->pev->health 1)
    {
        
m_pTarget NULL;
    }
    if(
m_fChangeTarget gpGlobals->time)
    {
        
m_fChangeTarget gpGlobals->time RANDOM_FLOAT(6.08.0);
        
m_pTarget GetRandomTarget();    
    }
    if(!
m_pTarget)
    {
        
m_pTarget GetRandomTarget();    
        if(!
m_pTarget) return false;
    }
    return 
true;
}

void AngraRemoveThink(edict_t *pEnt)
{
    if(!
g_pMonsterAngra)
    {
        
REMOVE_ENTITY(pEnt);
        return;
    }
    if(
pEnt->v.iuser1 == g_pMonsterAngra->iEntID_EF_TENTACLE || pEnt->v.iuser1 == g_pMonsterAngra->iEntID_EF_TENTACLE2)
    {
        if(
pEnt->v.iuser1 == g_pMonsterAngra->iEntID_EF_TENTACLE)
        {
            
pEnt->v.iuser1 g_pMonsterAngra->iEntID_EF_TENTACLE2;
            
pEnt->v.nextthink gpGlobals->time 2.0;
        }
        else 
        {
            
pEnt->v.iuser1 g_pMonsterAngra->iEntID_EF_TENTACLE_REMOVE;
            
pEnt->v.nextthink gpGlobals->time 3.0;
        }

        
edict_t *pEnt2 CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
        
pEnt2->v.model MAKE_STRING("models/tentacle.mdl");
        
pEnt2->v.movetype MOVETYPE_FLY;
        
pEnt2->v.solid SOLID_NOT;
        
pEnt2->v.origin pEnt->v.origin;
        
pEnt2->v.animtime gpGlobals->time;
        
pEnt2->v.framerate 1.0;
        
pEnt2->v.iuser1 g_pMonsterAngra->iEntID_TENTACLE;
        
SET_MODEL(pEnt2STRING(pEnt2->v.model));
        
pEnt2->v.nextthink gpGlobals->time 0.2;
        
SetThink2(pEnt2,&AngraRemoveThink);
    }
    else if(
pEnt->v.iuser1 == g_pMonsterAngra->iEntID_TENTACLE)
    {
        
pEnt->v.iuser1 g_pMonsterAngra->iEntID_TENTACLE2;
        for(
int i=1;i<33;i++)
        {
            
CBaseEntity *pPlayer UTIL_PlayerByIndex(i);
            if(
pPlayer && pPlayer->pev->health 1)
            {
                if( (
pPlayer->pev->origin -pEnt->v.origin).Length2D()< 50.0 )
                {
                    
pPlayer->pev->velocity.+= 600.0;
                }
            }
        }
        
pEnt->v.nextthink gpGlobals->time 0.8;
    }
    else 
REMOVE_ENTITY(pEnt);
}
void CMonsterAngra::Poison(void)
{
    
m_bPoison true;
    
m_bInSkill true;
    
m_iPoisonCount 0;
    
m_fPoisonLastLaunch 0;
    
m_fPoisonTimer gpGlobals->time 6.5;
    
SetSequence(ANIM_ZBS_POISON1);
    
m_bCreatedPoison false;
}
void AngraPoisonThink(edict_t *pEnt)
{
    if(!
g_pMonsterAngra)
    {
        
REMOVE_ENTITY(pEnt);
        return;
    }
    
pEnt->v.nextthink gpGlobals->time 0.1;
    
Vector vecAngle g_pMonsterAngra->GetVelocityAngle(pEnt->v.velocity);
    
pEnt->v.angles vecAngle;
}
void _fastcall AngraPoisonTouch(void *pEntData,int iFixCall,void *pEnt2Data// thiscall -> fastcall
{
    
edict_t *pEntToucher PrivateToEdict(pEntData);
    
edict_t *pEntTouched PrivateToEdict(pEnt2Data);
    if(
ENTINDEX(pEntTouched)!= 0) return;
    
edict_t *pEnt CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
    
pEnt->v.model MAKE_STRING("models/ef_poison02.mdl");
    
pEnt->v.movetype MOVETYPE_FLY;
    
pEnt->v.solid SOLID_NOT;
    
pEnt->v.gravity 1.0;
    
pEnt->v.scale 2.0;
    
pEnt->v.framerate 1.0;
    
pEnt->v.animtime gpGlobals->time;
    
pEnt->v.origin pEntToucher->v.origin;
    
pEnt->v.rendermode kRenderTransAdd;
    
pEnt->v.renderamt 255;
    
SET_MODEL(pEntSTRING(pEnt->v.model));
    
pEnt->v.nextthink gpGlobals->time 1.0;
    
SetThink2(pEnt,&AngraRemoveThink);
    
REMOVE_ENTITY(pEntToucher);
}
void CMonsterAngra::PoisonEffect(void)
{
    
m_bCreatedPoison true;
    
Vector vecAngle pev->angles;
    
Vector vecVelocity ;
    
//vecAngle[0] += -60.0;
    
vecAngle[1] -= 60.0;
    for(
int i=0;i<10;i++)
    {
        
edict_t *pEnt CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
        
pEnt->v.model MAKE_STRING("models/ef_poison01.mdl");
        
pEnt->v.movetype MOVETYPE_TOSS;
        
pEnt->v.solid SOLID_BBOX;
        
pEnt->v.gravity 1.0;
        
pEnt->v.scale 2.0;
        
pEnt->v.origin pev->origin;
        
pEnt->v.origin.+= 180.0;
        
pEnt->v.origin.z  += 10.0 i;
        
pEnt->v.angles pev->angles;
        
SET_MODEL(pEntSTRING(pEnt->v.model));
        
UTIL_SetSize(pevVector(-1,-1,-1), Vector(1,1,1));
        
vecAngle[1] += 10.0;
        
        
g_engfuncs.pfnAngleVectors(vecAngle,vecVelocity,NULL,NULL);
        
vecVelocity.*= 600.0;
        
vecVelocity.*= 600.0;
        
vecVelocity.*= 600.0;
        
pEnt->v.velocity vecVelocity;
        
pEnt->v.nextthink gpGlobals->time 0.1;
        
pEnt->v.fuser1 gpGlobals->time 1.0;
        
SetThink2(pEnt,&AngraPoisonThink);
        
SetTouch2(pEnt,&AngraPoisonTouch);
    }
}

void CMonsterAngra::RadiusAttackEffect(void)
{
    
m_bRadiusAttacked true;
    
edict_t *pEnt CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
    
pEnt->v.model MAKE_STRING("models/ef_swing.mdl");
    
pEnt->v.movetype MOVETYPE_FLY;
    
pEnt->v.solid SOLID_NOT;
    
pEnt->v.origin pev->origin;
    
pEnt->v.origin.-= 20.0;
    
pEnt->v.rendermode kRenderTransAdd;
    
pEnt->v.renderamt 255;
    
pEnt->v.scale 2.5;
    
pEnt->v.animtime gpGlobals->time;
    
pEnt->v.framerate 1.0;
    
SET_MODEL(pEntSTRING(pEnt->v.model));
    
pEnt->v.nextthink gpGlobals->time 0.6;
    
SetThink2(pEnt,&AngraRemoveThink);
}
void CMonsterAngra::RadiusAttack(void)
{
    
m_bInSkill true;
    
m_bRadiusAttack true;
    
m_fRadiusAttackTimer gpGlobals->time 2.0;
    
SetSequence(ANIM_ZBS_SWING);
    
m_bRadiusAttacked false;
}
void CMonsterAngra::TentacleEffect(void)
{
    if(
m_fTentacleLastLaunch gpGlobals->time && m_iTentacleCount <8)
    {
        
m_fTentacleLastLaunch gpGlobals->time 0.3;
        
Vector vecAngle pev->angles;
        
vecAngle.-= 90.0;
        
vecAngle[0] = 0;

        for(
int i=0;i<3;i++)
        {
            
edict_t *pEnt CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
            
pEnt->v.model MAKE_STRING("models/ef_tentacle.mdl");
            
pEnt->v.movetype MOVETYPE_FLY;
            
pEnt->v.solid SOLID_NOT;
            
vecAngle.+=45.0;
            
Vector vecVelocity ;
            
g_engfuncs.pfnAngleVectors(vecAngle,vecVelocity,NULL,NULL);

            
pEnt->v.origin pev->origin vecVelocity*200.0*m_iTentacleCount;
            
pEnt->v.origin.+= 10;
            
pEnt->v.angles pev->angles;
            
pEnt->v.iuser1 iEntID_EF_TENTACLE;
            
//pEnt->v.rendermode = kRenderTransAdd;
            //pEnt->v.renderamt = 255;
            
SET_MODEL(pEntSTRING(pEnt->v.model));
            
pEnt->v.nextthink gpGlobals->time 3.0;
            
SetThink2(pEnt,&AngraRemoveThink);
        }
        
m_iTentacleCount ++;
    }
}
void CMonsterAngra::Tentacle(void)
{
    
m_bInSkill true;
    
m_bTentacle true;
    
m_iTentacleCount 0;
    
m_fTentacleLastLaunch 0;
    
m_fTentacleTimer gpGlobals->time 7.5;
    
SetSequence(ANIM_ZBS_TENTACLE1);
}
void CMonsterAngra::RunAI(void)
{
    if(
m_bDead) return;
    if(!
m_bAppeared)
    {
        if(
pev->sequence == ANIM_APPEAR1 && gpGlobals->time m_fAnimationTimer 1.1)
        {
            
SetSequence(ANIM_APPEAR2);
        }
        else if(
pev->sequence == ANIM_APPEAR2 && gpGlobals->time m_fAnimationTimer 1.1)
        {
            
// GOGOGO
            
Vector vecAngle pev->angles;
            
vecAngle[0] = -60.0;
            
Vector vecVelocity ;
            
g_engfuncs.pfnAngleVectors(vecAngle,vecVelocity,NULL,NULL);
            
//vecVelocity.x *= 600.0;
            //vecVelocity.z *= 600.0;
            //vecVelocity.y *= 600.0;
            
pev->velocity vecVelocity;
            
SetSequence(ANIM_APPEAR3);
        }
        else if(
pev->sequence == ANIM_APPEAR3 && gpGlobals->time m_fAnimationTimer 6.4)
        {
            
m_bAppeared true;
        }
    }
    else
    {
        if(
m_fRangeAttackAnimationTimer && m_fRangeAttackAnimationTimer gpGlobals->time)
        {
            if(
m_fRangeAttackAnimationTimer gpGlobals->time <2.5 && !m_bCreatedRangeAttack)
            {
                
RadiusDamage2(pev->origin,10.0,200.0);
                
m_bCreatedRangeAttack true;
            }
            return;
        }
        if(
m_fDashSkillTimer gpGlobals->time && !m_bInSkill)
        {
            
Dash();
            
m_fDashSkillTimer gpGlobals->time RANDOM_FLOAT(10.0,30.0);
        }
        if(
m_fRadiusAttackSkillTimer gpGlobals->time && !m_bInSkill)
        {
            
RadiusAttack();
            
m_fRadiusAttackSkillTimer gpGlobals->time 5.0;
        }
        if(
m_fTentacleSkillTimer gpGlobals->time && !m_bInSkill)
        {
            
Tentacle();
            
m_fTentacleSkillTimer gpGlobals->time 10.0;
        }
        if(
m_fPoisonSkillTimer gpGlobals->time && !m_bInSkill)
        {
            
Poison();
            
m_fPoisonSkillTimer gpGlobals->time 7.0;
        }
        
        if(
m_bDash)
        {
            if(
m_iDashStat == DASH_START &&m_fDashTimer gpGlobals->time)
            {
                
m_iDashStat DASH;
            }
            if(
m_iDashStat == DASH)
            {
                
SetSequence(ANIM_ROOLING2);
                
pev->velocity m_vecDashVelocity;
            }
            if(
m_iDashStat == DASH_END)
            {
                if(
m_fDashTimer gpGlobals->time)
                {
                    
m_bDash false;
                    
m_bInSkill false;
                }
            }
            return;
        }
        if(
m_bRadiusAttack)
        {
            if(
m_fRadiusAttackTimer>gpGlobals->time && m_fRadiusAttackTimer<gpGlobals->time+6.2 )
            {
                
RadiusAttackEffect();
            }
            if(
m_fRadiusAttackTimer gpGlobals->time)
            {
                
m_bRadiusAttack false;
                
m_bInSkill false;
            }
            return;
        }
        if(
m_bTentacle)
        {
            if(
m_fTentacleTimer>gpGlobals->time)
            {
                
TentacleEffect();
            }
            if(
m_fTentacleTimer gpGlobals->time)
            {
                
m_bTentacle false;
                
m_bInSkill false;
            }
            return;
        }
        if(
m_bPoison)
        {
            if(
m_fPoisonTimer>gpGlobals->time&&m_fPoisonTimer<gpGlobals->time+3.0 && !m_bCreatedPoison)
            {
                
PoisonEffect();
            }
            if(
m_fPoisonTimer gpGlobals->time)
            {
                
m_bPoison false;
                
m_bInSkill false;
            }
            return;
        }
        
float fDistance GetTargetDistance();
        if(
fDistance 200.0Attack();
        else 
MoveTowardEnemy();
    }
    return;
}
void CMonsterAngra::Dash(void)
{
    
m_bInSkill true;
    
AtOrigin(m_pTarget->pev->origin);
    
m_vecDashVelocity =  (m_pTarget->pev->origin pev->origin).Normalize() * 1000.0;
    
m_vecDashVelocity.50.0;
    
m_bDash true;
    
m_iDashStat DASH_START;
    
m_fDashTimer gpGlobals->time 1.0;
    
SetSequence(ANIM_ROOLING1);
}
void CMonsterAngra::MoveTowardEnemy(void)
{
    
Vector vecForward;
    
Vector vecMove m_pTarget->pev->origin pev->origin;
    
Vector vecAngles UTIL_VecToAngles(vecMove);
    
Vector yAngles Vector(0vecAngles.y0);
    
UTIL_MakeVectorsPrivate(yAnglesvecForwardNULLNULL);

    
AtOrigin(m_pTarget->pev->origin);
    
m_fSpeed DEFAULT_ANGRA_MONSTER_SPEED;

    
pev->velocity.vecForward.m_fSpeed;
    
pev->velocity.vecForward.m_fSpeed;
    
pev->velocity.20;
    
SetSequence(ANIM_ZBS_WALK);
}
void CMonsterAngra::SetSequence(MONSTER_SEQUENCE iSequence,bool forcePlay)
{
    if(
forcePlay || (pev->sequence != iSequence&& !forcePlay))
    {
        
pev->frame 0;
        
pev->sequence iSequence;
        
ResetSequenceInfo();
        
m_fAnimationTimer gpGlobals->time;
        
m_Activity Activity::ACT_SPECIAL_ATTACK2;
    }
}
void CMonsterAngra::SetActivity(Activity activity)
{
    if (
m_Activity != activity)
    {
        
int animDesired LookupActivity(activity);

        if (
animDesired != -1)
        {
            if (
pev->sequence != animDesired)
            {
                if ((
m_Activity != ACT_WALK || m_Activity != ACT_RUN) && (activity != ACT_WALK || activity != ACT_RUN))
                    
pev->frame 0;

                
pev->sequence animDesired;
            }

            
m_Activity activity;
            
ResetSequenceInfo();
            
m_fAnimationTimer gpGlobals->time;
        }
    }
}
void CMonsterAngra::Precache(void)
{
    if (
FStringNull(pev->model))
        
pev->model MAKE_STRING("models/boss3.mdl");

    
m_iModelIndex PRECACHE_MODEL((char *)STRING(pev->model));
    
m_iModelIndexBloodSpray PRECACHE_MODEL ("sprites/bloodspray.spr"); // initial blood
    
m_iModelIndexBloodDrop PRECACHE_MODEL ("sprites/blood.spr"); // splattered blood 
}
Vector CMonsterAngra::GetVelocityAngle(Vector vecVelocity)
{
    
Vector vecReturn;
    
VEC_TO_ANGLES(vecVelocity,vecReturn);
    if( 
vecReturn[0] > 90.0 vecReturn[0] = -(360.0 vecReturn[0]);
    return 
vecReturn;


Last edited by csoldjb; 05-01-2013 at 09:08. Reason: Share the cpp
csoldjb is offline
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 04-25-2013 , 09:14   Re: Entity always go underground
Reply With Quote #2

Post the full code.
Podarok is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-25-2013 , 11:23   Re: Entity always go underground
Reply With Quote #3

Quote:
Originally Posted by Podarok View Post
Post the full code.
LOL, since when are you making modules ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 04-25-2013 , 11:57   Re: Entity always go underground
Reply With Quote #4

may be you need change VEC_MONSTER_HULL_MIN
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
csoldjb
Member
Join Date: Dec 2010
Old 04-25-2013 , 13:01   Re: Entity always go underground
Reply With Quote #5

I changed the hull,but the problem still happened

Last edited by csoldjb; 04-25-2013 at 14:30.
csoldjb is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 04-25-2013 , 15:45   Re: Entity always go underground
Reply With Quote #6

What about changing the move type to MOVETYPE_FLY and just leaving the world to drop it to floor?
After it touches world I think you can change the move type to the one you want. Cannot ensure whether Touch forward will be executed.
You can also try to set the solid state to SOLID_BBOX.
__________________

Last edited by claudiuhks; 04-25-2013 at 15:51.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 04-25-2013 , 19:30   Re: Entity always go underground
Reply With Quote #7

You have to call someting to link nodes like in Engfunc_SetSize

Try (it's from engine, check which pfn do the call)

PF_setorigin_I
PF_dropfloor_I
SetMinMaxSize

Of course this should be called after setting pev variables.
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 04-26-2013 , 03:32   Re: Entity always go underground
Reply With Quote #8

Quote:
Originally Posted by ConnorMcLeod View Post
LOL, since when are you making modules ?
Im starting to learn things and I hope soon I will be able to do something.
By the way, could you please give me any useful tutorial, if there is one on forum. I start learning from Joropito's ZP core module version.

Last edited by Podarok; 04-26-2013 at 03:33.
Podarok is offline
csoldjb
Member
Join Date: Dec 2010
Old 04-26-2013 , 08:48   Re: Entity always go underground
Reply With Quote #9

Quote:
Originally Posted by joropito View Post
You have to call someting to link nodes like in Engfunc_SetSize

Try (it's from engine, check which pfn do the call)

PF_setorigin_I
PF_dropfloor_I
SetMinMaxSize

Of course this should be called after setting pev variables.
I have tried the way you mentioned(pfnSetSize,pfnSetOrigin,pfnSetModel (the api engine provide)).It didn't work I noticed if the entity touched something,it will also cause the problem
csoldjb is offline
csoldjb
Member
Join Date: Dec 2010
Old 04-26-2013 , 08:52   Re: Entity always go underground
Reply With Quote #10

Quote:
Originally Posted by claudiuhks View Post
What about changing the move type to MOVETYPE_FLY and just leaving the world to drop it to floor?
After it touches world I think you can change the move type to the one you want. Cannot ensure whether Touch forward will be executed.
You can also try to set the solid state to SOLID_BBOX.
I have tried your way:

In Spawn Function
PHP Code:
pev->movetype MOVETYPE_FLY;
pev->solid SOLID_BBOX;
DROP_TO_FLOOR(ENT(pev)) 
and in Touch Function
PHP Code:
void CMonsterAngra::Touch(CBaseEntity *pOther)
{
    
pev->movetype MOVETYPE_STEP// Touched Sth.
    
if(m_bDash && m_iDashStat == DASH
    {
        if( (
m_vecLastTouchPos-pev->origin).Length2D() < 20.0)
        {
            
m_iDashStat DASH_END;
            
SetSequence(ANIM_ROOLING3);
            
m_fDashTimer gpGlobals->time 1.7;
        }
        
m_vecLastTouchPos pev->origin;
        
int iHitEntity ENTINDEX(pOther->edict());
        if( 
IsPlayer(pOther) )
        {
            
Vector vecDir =  (pOther->pev->origin pev->origin).Normalize() * 800.0;
            
pOther->pev->velocity vecDir;
            
pOther->pev->velocity.500.0;
            
MakeDamage(pOther,20.0);
            return;
        }
        
        
Vector vecDir =  (pOther->pev->origin pev->origin).Normalize() * 800.0;
        
pOther->pev->velocity vecDir;
        
pOther->pev->velocity.500.0;
    }

It didn't work either

Last edited by csoldjb; 04-26-2013 at 09:00.
csoldjb is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode