Thread: Sven Co-op Zombie Scenario [Problem Custom NPCS]

Results 1 to 2 of 2
  1. #1
    Registered User yemez123's Avatar
    Join Date
    May 2017
    Posts
    10

    Sven Co-op Zombie Scenario [Problem Custom NPCS]

    Yo, I doing make new mode a from CSO, that's a zombie scenario. I maked someone new custom npc but script don't showing what's the problem..
    how I can found it and how can I debug plugins?.

    Script:

    Code:
    #include "monster_zhost"
    
    void MapInit()
    {
    	RegisterHZombie();
    }
    Map log.

    Code:
    Angelscript log openedServer started logging Angelscript on map 'sczs_cutyland' at: 2018-03-03 17:41:05
    WARNING: Attempted to execute non-existent function "void PluginInit()"!
    ERROR: Plugins must implement a PluginInit function!
    1 Plugin(s) failed compilation
    ERROR:  (0, 0) : Warnings are treated as errors by the application
    ERROR: Map script compilation failed
    Server stopped logging Angelscript at: 2018-03-03 17:41:40
    NPC Register class

    Code:
    RegisterHZombie()
    NPC Script(Zombie Host) = got from example

    Code:
    //=========================================================// Monster's Anim Events Go Here
    //=========================================================
    const int HZOMBIE_AE_ATTACK = 0x01;
    
    
    const int HZOMBIE_FLINCH_DELAY = 0.1;		// at most one flinch every n secs
    const int HZOMBIE_HEALTH = 50;
    const int HZOMBIE_DMG_SLASH = 15;
    
    
    const array<string> pAttackHitSounds = 
    {
    	"sczs/monster/zombi_attack_1.wav",
    	"sczs/monster/zombi_attack_2.wav",
    	"sczs/monster/zombi_attack_3.wav"
    };
    
    
    const array<string> pAttackMissSounds = 
    {
    	"sczs/monster/zombi_swing_1.wav",
    	"sczs/monster/zombi_swing_2.wav",
    	"sczs/monster/zombi_swing_3.wav"
    };
    
    
    const array<string> pDeathSounds = 
    {
    	"sczs/monster/zbs_death_1.wav"
    };
    
    
    class monster_zhost : ScriptBaseMonsterEntity
    {
    	float m_flNextFlinch;
    	
    	void Spawn()
    	{
    		Precache();
    
    
    		g_EntityFuncs.SetModel( self, "models/sczs/npc/zombi_host.mdl" );
    
    
    		g_EntityFuncs.SetSize( self.pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX );
    
    
    		self.pev.solid			= SOLID_SLIDEBOX;
    		self.pev.movetype		= MOVETYPE_STEP;
    		self.m_bloodColor		= BLOOD_COLOR_RED;
    		self.pev.health			= HZOMBIE_HEALTH;
    		self.pev.view_ofs		= VEC_VIEW;// position of the eyes relative to monster's origin.
    		self.m_flFieldOfView	= 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result )
    		self.m_MonsterState		= MONSTERSTATE_NONE;
    		self.m_afCapability		= bits_CAP_DOORS_GROUP;
    		g_EntityFuncs.DispatchKeyValue( self.edict(), "displayname", "Zombie Host" );
    
    
    		self.MonsterInit();
    	}
    
    
    	void Precache()
    	{
    		uint i;
    
    
    		g_Game.PrecacheModel( "models/sczs/npc/zombi_host.mdl" );
    
    
    		for( i = 0; i < pAttackHitSounds.length(); i++ )
    			g_SoundSystem.PrecacheSound( pAttackHitSounds[i] );
    
    
    		for( i = 0; i < pAttackMissSounds.length(); i++ )
    			g_SoundSystem.PrecacheSound( pAttackMissSounds[i] );
    			
    		for( i = 0; i < pDeathSounds.length(); i++ )
    			g_SoundSystem.PrecacheSound( pDeathSounds[i] );
    	}
    
    
    	//=========================================================
    	// SetYawSpeed - allows each sequence to have a different
    	// turn rate associated with it.
    	//=========================================================
    	void SetYawSpeed()
    	{
    		int ys = 70;
    		self.pev.yaw_speed = ys;
    	}
    
    
    	int	Classify()
    	{
    		return	CLASS_ALIEN_MONSTER;
    	}
    
    
    	//=========================================================
    	// HandleAnimEvent - catches the monster-specific messages
    	// that occur when tagged animation frames are played.
    	//=========================================================
    	void HandleAnimEvent( MonsterEvent@ pEvent )
    	{
    		switch( pEvent.event )
    		{
    			case HZOMBIE_AE_ATTACK:
    			{
    				// do stuff for this event.
    				CBaseEntity@ pHurt = CheckTraceHullAttack( self, 70, HZOMBIE_DMG_SLASH, DMG_NEVERGIB );
    				if( pHurt !is null )
    				{
    					// Play a random attack hit sound
    					g_SoundSystem.EmitSoundDyn( self.edict(), CHAN_WEAPON, pAttackHitSounds[Math.RandomLong(0,(pAttackHitSounds.length - 1))], 1.0, ATTN_NORM, 0, 100 + Math.RandomLong(-5,5) );
    				}
    				else // Play a random attack miss sound
    					g_SoundSystem.EmitSoundDyn( self.edict(), CHAN_WEAPON, pAttackMissSounds[Math.RandomLong(0,(pAttackMissSounds.length - 1))], 1.0, ATTN_NORM, 0, 100 + Math.RandomLong(-5,5) );
    			}
    			break;
    
    
    			default:
    				BaseClass.HandleAnimEvent( pEvent );
    				break;
    		}
    	}
    
    
    	int TakeDamage( entvars_t@ pevInflictor, entvars_t@ pevAttacker, float flDamage, int bitsDamageType )
    	{
    		// Take 30% damage from bullets
    		if( bitsDamageType == DMG_BULLET )
    		{
    			Vector vecDir = self.pev.origin - (pevInflictor.absmin + pevInflictor.absmax) * 0.5;
    			vecDir = vecDir.Normalize();
    			float flForce = self.DamageForce( flDamage );
    			self.pev.velocity = self.pev.velocity + vecDir * flForce;
    			flDamage *= 0.3;
    		}
    		
    		//Can't get this to work :[
    		//if( ( pevAttacker.flags & (FL_CLIENT)) == 1 )
    		if( pevAttacker.ClassNameIs("player") )
    		{
    			CBasePlayer@ pPlayer = g_PlayerFuncs.FindPlayerByName( pevAttacker.netname, true );
    			pPlayer.GetPointsForDamage( flDamage );
    		}
    
    
    		return BaseClass.TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
    	}
    
    
    	void DeathSound()
    	{
    		if( Math.RandomLong(0,5) < 2 )
    			g_SoundSystem.EmitSoundDyn( self.edict(), CHAN_VOICE, pDeathSounds[Math.RandomLong(0,(pDeathSounds.length - 1))], 1.0, ATTN_NORM, 0, 1 );
    	}
    
    
    	//=========================================================
    	// AI Schedules Specific to this monster
    	//=========================================================
    	int IgnoreConditions()
    	{
    		int iIgnore = BaseIgnoreConditions();
    
    
    		if( (self.m_Activity == ACT_MELEE_ATTACK1) || (self.m_Activity == ACT_MELEE_ATTACK1) )
    		{
    			if( m_flNextFlinch >= g_Engine.time )
    				iIgnore |= (bits_COND_LIGHT_DAMAGE|bits_COND_HEAVY_DAMAGE);
    		}
    
    
    		return iIgnore;
    	}
    	
    	int BaseIgnoreConditions()
    	{
    		int iIgnoreConditions = 0;
    
    
    		return iIgnoreConditions;
    	}
    
    
    	CBaseEntity@ CheckTraceHullAttack( CBaseMonster@ pThis, float flDist, int iDamage, int iDmgType )
    	{
    		TraceResult tr;
    
    
    		if( pThis.IsPlayer() )
    			Math.MakeVectors( pThis.pev.angles );
    		else
    			Math.MakeAimVectors( pThis.pev.angles );
    
    
    		Vector vecStart = self.pev.origin;
    		vecStart.z += self.pev.size.z * 0.5;
    		Vector vecEnd = vecStart + (g_Engine.v_forward * flDist );
    
    
    		g_Utility.TraceHull( vecStart, vecEnd, dont_ignore_monsters, head_hull, pThis.edict(), tr );
    		
    		if( tr.pHit !is null )
    		{
    			CBaseEntity@ pEntity = g_EntityFuncs.Instance( tr.pHit );
    
    
    			if( iDamage > 0 )
    			{
    				pEntity.TakeDamage( pThis.pev, pThis.pev, iDamage, iDmgType );
    			}
    
    
    			return pEntity;
    		}
    
    
    		return null;
    	}
    }
    
    
    string GetHZombieName()
    {
    	return "monster_zhost";
    }
    
    
    void RegisterHZombie()
    {
    	g_CustomEntityFuncs.RegisterCustomEntity( "monster_zhost", GetHZombieName() );
    }
    Last edited by yemez123; 03-03-2018 at 10:06 AM.

  2. #2
    Registered User yemez123's Avatar
    Join Date
    May 2017
    Posts
    10

    Re: Sven Co-op Zombie Scenario [Problem Custom NPCS]

    Solved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •