Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2100
- %{
- #include "StdH.h"
- #include "EntitiesMP/CustomDebris.h"
- void CCustomEnemy_OnInitClass(void)
- {
- // init particle effects
- InitParticles();
- }
- %}
- uses "EntitiesMP/EnemyBase";
- enum AttackType {
- 0 AT_SINGLEFIRE "Single Fire",
- 1 AT_MULTIFIRE "Dual Fire",
- 2 AT_NONE "NONE",
- };
- enum CloseType {
- 0 CT_SINGLEHIT "Hit",
- 1 CT_KAMIKADZE "Kamikadze",
- 2 CT_NONE "NONE",
- 3 CT_DOUBLEHIT "Double hit",
- 4 CT_JUMP "Jump on enemy"
- };
- %{
- // info structure
- static EntityInfo eiCustMon = {
- EIBT_BONES, 250.0f,
- 0.0f, 1.9f, 0.0f, // source (eyes)
- 0.0f, 1.9f, 0.0f, // target (body)
- };
- #define BONES_HIT 2.8f
- #define FIRE_RIGHT_HAND FLOAT3D( 0.25f, 1.5f, 0.0f)
- #define FIRE_LEFT_HAND FLOAT3D(-0.25f, 1.5f, 0.0f)
- %}
- class CCustomEnemy : CEnemyBase {
- name "CustomEnemy";
- thumbnail "Thumbnails\\Boneman.tbn";
- features "ImplementsOnInitClass";
- properties:
- 1 CTFileName m_fnModel "&G Model" 'M' =CTFILENAME("Models\\Editor\\Axis.mdl"),
- 2 CTFileName m_fnTexture "&G Texture" 'T' =CTFILENAME("Models\\Editor\\Vector.tex"),
- 3 CTFileName m_fnReflection "&G Reflection" =CTString(""),
- 4 CTFileName m_fnSpecular "&G Specular" =CTString(""),
- 5 CTFileName m_fnBump "&G Bump" =CTString(""),
- 6 BOOL m_bFistHit = FALSE,
- 7 BOOL m_bRunSoundPlaying "Play runnning sound" = TRUE,
- 8 CSoundObject m_soFeet,
- 10 ANIMATION m_iStandAnim "&A Standing animation" = 0,
- 11 ANIMATION m_iRotateAnim "&A Rotating animation" = 0,
- 12 ANIMATION m_iWalkAnim "&A Walking animation" = 0,
- 13 ANIMATION m_iRunAnim "&A Running animation" = 0,
- 14 ANIMATION m_iFireAnim "&A Fireing animation" = 0,
- 15 ANIMATION m_iDieAnim "&A Dieing animation" = 0,
- 16 ANIMATION m_iDamAnim "&A Damaging animation" = 0,
- 17 ANIMATION m_iCloseAnim "&A CloseFireing animation" = 0,
- 18 ANIMATION m_iCloseDoubleAnim "&A CloseDoublehit animation" = 0,
- 188 ANIMATION m_iJumpAnim "&A Jumping animation" = 0,
- 20 enum SprayParticlesType m_sptPartType "&G Particle Type" = SPT_NONE,
- 21 FLOAT m_fHealth "&G Health" = 125.0f,
- 22 FLOAT m_fWlkSp "&S Walk Speed" = 2.5f,
- 23 FLOAT m_fWlkRotSp "&S Walk Rot. Speed" = 45.0f,
- 24 FLOAT m_fAttSp "&S Attack Speed" = 10.0f,
- 25 FLOAT m_fAttRotSp "&S Attack Rot. Speed" = 600.0f,
- 26 FLOAT m_fClsSp "&S Close Speed" = 13.0f,
- 27 FLOAT m_fClsRtSp "&S Close Rot. Speed" = 1000.0f,
- 228 FLOAT m_fJumpHeight "&S Jump height" = 10.0f,
- 28 FLOAT m_fAttDist "&D Attack Distance" = 100.0f,
- 29 FLOAT m_fClsDist "&D Close Distance" = 30.0f,
- 30 FLOAT m_fStpDist "&D Stop Distance" = 2.0f,
- 31 FLOAT m_fIgnRng "&D Ignore Range" = 200.0f,
- 32 FLOAT m_fAttFireTime "&F Attack Fire Time" = 3.0f,
- 33 FLOAT m_fClsFireTime "&F Close Fire Time" = 2.0f,
- 234 BOOL m_bJumpAnytime "&F Jump anytime" = FALSE,
- 34 FLOAT m_fScr "&M Score" = 1000.0f,
- 35 FLOAT m_fBlwUp "&M Blow Up Ammount" = 70.0f,
- 36 FLOAT m_fDensity "&M Density" = 2000.0f,
- 77 FLOAT m_fHitTime "&F Wait after hit" = 3.0f,
- 147 FLOAT m_fFirAngl "&F Fire angle" = 100.0f,
- 167 BOOL m_bAlwaysVisible "Always visible" = FALSE,
- 178 FLOAT m_fBeforeHitTime "&F Wait before hit" = 3.0f,
- 125 FLOAT m_fBetweenHitTime "&F Wait between hits" = 1.0f,
- 71 FLOAT m_fHitStrenght "&F Hit strenght" = 10.0f,
- 37 CTFileName m_fnMess "&M Message" = CTString(""), // message
- 38 CTString m_str "&M Kill Message" = CTString("%s was killed by a Custom Monster"),
- 40 enum ProjectileType m_ptType "&F Proj Type" 'T' = PRT_LAVA_COMET,
- 41 FLOAT m_FireOX "&FO Fire Offset X" 'X' = 0.25f,
- 42 FLOAT m_FireOY "&FO Fire Offset Y" 'Y' = 1.5f,
- 43 FLOAT m_FireOZ "&FO Fire Offset Z" 'Z' = 0.0f,
- 44 enum AttackType m_atType "&F Attack Type" = AT_SINGLEFIRE,
- 45 INDEX m_iPrCount "&F Proj. Count" 'P' = 1,
- 46 FLOAT m_fPrTime "&F Pr. Count Time" = 0.1f,
- 47 enum CloseType m_ctType "&F Close Attack Type" = CT_SINGLEHIT,
- 48 FLOAT m_fKamDist "&FK Kamikazi Dist." = 2.0f,
- 49 FLOAT m_fKamDam "&FK Kamikazi Damage" = 30.0f,
- 50 CTFileName m_fnSIdle "&S Sound Idle" = CTFILENAME("Sounds\\Default.wav"), // sound
- 51 CTFileName m_fnSWound "&S Sound Wound" = CTFILENAME("Sounds\\Default.wav"), // sound
- 52 CTFileName m_fnSAttack "&S Sound Attack" = CTFILENAME("Sounds\\Default.wav"), // sound
- 53 CTFileName m_fnSRun "&S Sound Run" = CTFILENAME("Sounds\\Default.wav"), // sound
- 54 CTFileName m_fnSSight "&S Sound Sight" = CTFILENAME("Sounds\\Default.wav"), // sound
- 55 CTFileName m_fnSDeath "&S Sound Death" = CTFILENAME("Sounds\\Default.wav"), // sound
- 56 FLOAT m_fDamageWoundedCustom "&F Damage for wound" = 80.0f,
- 60 BOOL m_bLS "&P Leave Stain" = TRUE,
- 61 CEntityPointer m_penCustomDestruction "&P Custom Debris" COLOR(C_GREEN|0xFF), // targeted when destroyed
- 62 BOOL m_bAD "&P Always Debris" = FALSE,
- 100 INDEX m_iLoopCounter = 0,
- 88 BOOL m_bJumpAllowed "&F Allow jumping" = FALSE,
- components:
- 0 class CLASS_BASE "Classes\\EnemyBase.ecl",
- 1 class CLASS_PROJECTILE "Classes\\Projectile.ecl",
- 2 class CLASS_BASIC_EFFECT "Classes\\BasicEffect.ecl",
- functions:
- void Precache(void) {
- CEnemyBase::Precache();
- //PrecacheModel(m_fnModel);
- PrecacheClass(CLASS_PROJECTILE,m_ptType);
- };
- void AdjustMipFactor(FLOAT &fMipFactor)
- {
- if(m_bAlwaysVisible==TRUE)
- {
- fMipFactor=0;
- }
- };
- // describe how this enemy killed player
- virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath)
- {
- CTString str;
- str.PrintF(TranslateConst(m_str), strPlayerName);
- return str;
- }
- SLONG GetUsedMemory(void)
- {
- // initial
- SLONG slUsedMemory = sizeof(CCustomEnemy) - sizeof(CEnemyBase) + CEnemyBase::GetUsedMemory();
- // add some more
- slUsedMemory += m_strName.Length();
- slUsedMemory += m_fnModel.Length();
- slUsedMemory += m_fnMess.Length();
- slUsedMemory += m_fnSIdle.Length();
- slUsedMemory += m_fnSWound.Length();
- slUsedMemory += m_fnSAttack.Length();
- slUsedMemory += m_fnSRun.Length();
- slUsedMemory += m_fnSSight.Length();
- slUsedMemory += m_fnSDeath.Length();
- slUsedMemory += m_str.Length();
- slUsedMemory += m_fnSpecular.Length();
- slUsedMemory += m_fnTexture.Length();
- slUsedMemory += m_fnReflection.Length();
- slUsedMemory += m_fnBump.Length();
- return slUsedMemory;
- }
- virtual const CTFileName &GetComputerMessageName(void) const {
- return m_fnMess;
- };
- void RenderParticles(void)
- {
- return;
- }
- /* Entity info */
- void *GetEntityInfo(void) {
- return &eiCustMon;
- };
- CAnimData *GetAnimData(SLONG slPropertyOffset)
- {
- if (slPropertyOffset==offsetof(CCustomEnemy, m_iStandAnim)) {
- return GetModelObject()->GetData();
- } else if (slPropertyOffset==offsetof(CCustomEnemy, m_iRotateAnim)) {
- return GetModelObject()->GetData();
- } else if (slPropertyOffset==offsetof(CCustomEnemy,m_iWalkAnim)) {
- return GetModelObject()->GetData();
- } else if (slPropertyOffset==offsetof(CCustomEnemy,m_iRunAnim)) {
- return GetModelObject()->GetData();
- } else if (slPropertyOffset==offsetof(CCustomEnemy,m_iFireAnim)) {
- return GetModelObject()->GetData();
- } else if (slPropertyOffset==offsetof(CCustomEnemy,m_iCloseDoubleAnim)) {
- return GetModelObject()->GetData();
- } else if (slPropertyOffset==offsetof(CCustomEnemy,m_iDieAnim)) {
- return GetModelObject()->GetData();
- } else if (slPropertyOffset==offsetof(CCustomEnemy,m_iDamAnim)) {
- return GetModelObject()->GetData();
- } else if (slPropertyOffset==offsetof(CCustomEnemy,m_iCloseAnim)) {
- return GetModelObject()->GetData();
- } else if (slPropertyOffset==offsetof(CCustomEnemy,m_iJumpAnim)) {
- return GetModelObject()->GetData();
- } else {
- return CEntity::GetAnimData(slPropertyOffset);
- }
- };
- /* Receive damage */
- void ReceiveDamage(CEntity *penInflictor, enum DamageType dmtType,
- FLOAT fDamageAmmount, const FLOAT3D &vHitPoint, const FLOAT3D &vDirection)
- {
- //if (!IsOfClass(penInflictor, "CustomEnemy") && m_iGroup!=((CEnemyBase *)penInflictor)->m_iGroup) {
- CEnemyBase::ReceiveDamage(penInflictor, dmtType, fDamageAmmount, vHitPoint, vDirection);
- //};
- };
- void LeaveStain(BOOL bGrow)
- {
- if(m_bLS){
- ESpawnEffect ese;
- FLOAT3D vPoint;
- FLOATplane3D vPlaneNormal;
- FLOAT fDistanceToEdge;
- // get your size
- FLOATaabbox3D box;
- GetBoundingBox(box);
- // on plane
- if( GetNearestPolygon(vPoint, vPlaneNormal, fDistanceToEdge)) {
- // if near to polygon and away from last stain point
- if( (vPoint-GetPlacement().pl_PositionVector).Length()<0.5f
- && (m_vLastStain-vPoint).Length()>1.0f ) {
- m_vLastStain = vPoint;
- FLOAT fStretch = box.Size().Length();
- ese.colMuliplier = C_WHITE|CT_OPAQUE;
- // stain
- if (bGrow) {
- ese.betType = BET_BLOODSTAINGROW;
- ese.vStretch = FLOAT3D( fStretch*1.5f, fStretch*1.5f, 1.0f);
- } else {
- ese.betType = BET_BLOODSTAIN;
- ese.vStretch = FLOAT3D( fStretch*0.75f, fStretch*0.75f, 1.0f);
- }
- ese.vNormal = FLOAT3D( vPlaneNormal);
- ese.vDirection = FLOAT3D( 0, 0, 0);
- FLOAT3D vPos = vPoint+ese.vNormal/50.0f*(FRnd()+0.5f);
- CEntityPointer penEffect = CreateEntity( CPlacement3D(vPos, ANGLE3D(0,0,0)), CLASS_BASIC_EFFECT);
- penEffect->Initialize(ese);
- }
- }
- }
- }
- // damage anim
- INDEX AnimForDamage(FLOAT fDamage) {
- StartModelAnim(m_iDamAnim, 0);
- //DeactivateRunningSound();
- return m_iDamAnim;
- };
- // death
- INDEX AnimForDeath(void) {
- if (m_ctType==CT_KAMIKADZE && CalcDist(m_penEnemy) < m_fKamDist) {
- // explode
- SetHealth(-10000.0f);
- m_vDamage = FLOAT3D(0,10000,0);
- Explode();
- SendEvent(EDeath());
- }
- if(m_bAD){
- SetHealth(-10000.0f);
- m_vDamage = FLOAT3D(0,10000,0);
- Explode();
- SendEvent(EDeath());
- }
- StartModelAnim(m_iDieAnim, 0);
- //DeactivateRunningSound();
- return m_iDieAnim;
- };
- FLOAT WaitForDust(FLOAT3D &vStretch) {
- vStretch=FLOAT3D(1,1,2)*0.75f;
- return 0.48f;
- };
- void DeathNotify(void) {
- };
- // virtual anim functions
- void StandingAnim(void) {
- StartModelAnim(m_iStandAnim, AOF_LOOPING|AOF_NORESTART);
- DeactivateRunningSound();
- };
- void WalkingAnim(void) {
- StartModelAnim(m_iWalkAnim, AOF_LOOPING|AOF_NORESTART);
- DeactivateRunningSound();
- };
- void RunningAnim(void) {
- StartModelAnim(m_iRunAnim, AOF_LOOPING|AOF_NORESTART);
- ActivateRunningSound();
- };
- void RotatingAnim(void) {
- StartModelAnim(m_iRotateAnim, AOF_LOOPING|AOF_NORESTART);
- DeactivateRunningSound();
- };
- void MortalJumpAnim(void) {
- StartModelAnim(m_iJumpAnim, AOF_LOOPING|AOF_NORESTART);
- DeactivateRunningSound();
- };
- // virtual sound functions
- void IdleSound(void) {
- PlaySound(m_soSound, m_fnSIdle, SOF_3D);
- };
- void SightSound(void) {
- PlaySound(m_soSound, m_fnSSight, SOF_3D);
- };
- void WoundSound(void) {
- PlaySound(m_soSound, m_fnSWound, SOF_3D);
- };
- void DeathSound(void) {
- PlaySound(m_soSound, m_fnSDeath, SOF_3D);
- /*m_soSound.Stop();
- m_soFeet.Stop();*/
- };
- void ActivateRunningSound(void)
- {
- if (!m_bRunSoundPlaying) {
- PlaySound(m_soFeet, m_fnSRun, SOF_3D|SOF_LOOP);
- m_bRunSoundPlaying = TRUE;
- }
- }
- void DeactivateRunningSound(void)
- {
- m_soFeet.Stop();
- m_bRunSoundPlaying = FALSE;
- }
- /************************************************************
- * BLOW UP FUNCTIONS *
- ************************************************************/
- // spawn body parts
- void BlowUp(void) {
- SwitchToEditorModel();
- SetPhysicsFlags(EPF_MODEL_IMMATERIAL);
- SetCollisionFlags(ECF_IMMATERIAL);
- if(m_ctType==CT_KAMIKADZE){
- Explode();
- }
- if(!(m_penCustomDestruction==NULL)){
- CCustomDebris *pmd;
- pmd=(CCustomDebris*)&*m_penCustomDestruction;
- pmd->SpawnDebris(this);
- }
- };
- BOOL ShouldBlowUp(void)
- {
- if ((m_ctType==CT_KAMIKADZE && GetHealth()<=0) || m_bAD) {
- return TRUE;
- } else {
- return CEnemyBase::ShouldBlowUp();
- }
- }
- void Explode(void) {
- if(m_bAD && !(m_ctType==CT_KAMIKADZE)){
- FLOAT3D vSource;
- GetEntityInfoPosition(this, eiCustMon.vTargetCenter, vSource);
- InflictDirectDamage(this, this, DMT_CLOSERANGE, 100.0f, vSource,
- -en_vGravityDir);
- }
- if(m_ctType==CT_KAMIKADZE){
- // inflict damage
- FLOAT3D vSource;
- GetEntityInfoPosition(this, eiCustMon.vTargetCenter, vSource);
- InflictDirectDamage(this, this, DMT_CLOSERANGE, 100.0f, vSource,
- -en_vGravityDir);
- InflictRangeDamage(this, DMT_EXPLOSION, m_fKamDam, vSource, 2.75f, 8.0f);
- // spawn explosion
- CPlacement3D plExplosion = GetPlacement();
- CEntityPointer penExplosion = CreateEntity(plExplosion, CLASS_BASIC_EFFECT);
- ESpawnEffect eSpawnEffect;
- eSpawnEffect.colMuliplier = C_WHITE|CT_OPAQUE;
- eSpawnEffect.betType = BET_BOMB;
- eSpawnEffect.vStretch = FLOAT3D(1.0f,1.0f,1.0f);
- penExplosion->Initialize(eSpawnEffect);
- // explosion debris
- eSpawnEffect.betType = BET_EXPLOSION_DEBRIS;
- CEntityPointer penExplosionDebris = CreateEntity(plExplosion, CLASS_BASIC_EFFECT);
- penExplosionDebris->Initialize(eSpawnEffect);
- // explosion smoke
- eSpawnEffect.betType = BET_EXPLOSION_SMOKE;
- CEntityPointer penExplosionSmoke = CreateEntity(plExplosion, CLASS_BASIC_EFFECT);
- penExplosionSmoke->Initialize(eSpawnEffect);
- }
- };
- void SetSpeedsToDesiredPosition(const FLOAT3D &vPosDelta, FLOAT fPosDistance, BOOL bGoingToPlayer)
- {
- // if very close to player
- if (m_ctType==CT_KAMIKADZE && CalcDist(m_penEnemy) < m_fKamDist) {
- // explode
- SetHealth(-10000.0f);
- m_vDamage = FLOAT3D(0,10000,0);
- Explode();
- SendEvent(EDeath());
- // if not close
- } else {
- // behave as usual
- CEnemyBase::SetSpeedsToDesiredPosition(vPosDelta, fPosDistance, bGoingToPlayer);
- }
- }
- procedures:
- /************************************************************
- * A T T A C K E N E M Y *
- ************************************************************/
- Fire(EVoid) : CEnemyBase::Fire {
- if(m_atType==AT_SINGLEFIRE || m_atType==AT_MULTIFIRE){
- StartModelAnim(m_iFireAnim, AOF_LOOPING);
- m_iLoopCounter = m_iPrCount;
- while(m_iLoopCounter>0) {
- if (m_iLoopCounter%2 && m_atType==AT_MULTIFIRE) {
- ShootProjectile(m_ptType, FLOAT3D(-m_FireOX,m_FireOY,m_FireOZ), ANGLE3D(0, 0, 0));
- } else {
- ShootProjectile(m_ptType, FLOAT3D(m_FireOX,m_FireOY,m_FireOZ), ANGLE3D(0, 0, 0));
- }
- PlaySound(m_soSound, m_fnSAttack, SOF_3D);
- if (m_iLoopCounter>1) {
- m_fLockOnEnemyTime = m_fPrTime;
- autocall CEnemyBase::LockOnEnemy() EReturn;
- }
- m_iLoopCounter--;
- }
- autowait(GetModelObject()->GetAnimLength(m_iFireAnim));
- }
- if(m_atType==AT_NONE){
- }
- //m_ptType*/
- return EReturn();
- };
- Hit(EVoid) : CEnemyBase::Hit {
- if(m_ctType==CT_SINGLEHIT){
- StartModelAnim(m_iCloseAnim, AOF_LOOPING);
- autowait(m_fBeforeHitTime);
- FLOAT3D vDirection = m_penEnemy->GetPlacement().pl_PositionVector-GetPlacement().pl_PositionVector;
- vDirection.Normalize();
- FLOAT3D vSpeed;
- GetHeadingDirection(AngleDeg(0.0f), vSpeed);
- vSpeed = vSpeed * 5.0f;
- if (CalcDist(m_penEnemy)<m_fClsDist) {
- InflictDirectDamage(m_penEnemy, this, DMT_CLOSERANGE, m_fHitStrenght, FLOAT3D(0, 0, 0), vDirection);
- KickEntity(m_penEnemy, vSpeed);
- autowait(m_fHitTime);
- };
- };
- if(m_ctType==CT_DOUBLEHIT){
- StartModelAnim(m_iCloseDoubleAnim, AOF_LOOPING);
- autowait(m_fBeforeHitTime);
- FLOAT3D vDirection = m_penEnemy->GetPlacement().pl_PositionVector-GetPlacement().pl_PositionVector;
- vDirection.Normalize();
- FLOAT3D vSpeed;
- GetHeadingDirection(AngleDeg(0.0f), vSpeed);
- vSpeed = vSpeed * 5.0f;
- if (CalcDist(m_penEnemy)<m_fClsDist) {
- InflictDirectDamage(m_penEnemy, this, DMT_CLOSERANGE, m_fHitStrenght, FLOAT3D(0, 0, 0), vDirection);
- KickEntity(m_penEnemy, vSpeed);
- };
- autowait(m_fBetweenHitTime);
- FLOAT3D vDirection = m_penEnemy->GetPlacement().pl_PositionVector-GetPlacement().pl_PositionVector;
- vDirection.Normalize();
- FLOAT3D vSpeed;
- GetHeadingDirection(AngleDeg(0.0f), vSpeed);
- if (CalcDist(m_penEnemy)<m_fClsDist) {
- InflictDirectDamage(m_penEnemy, this, DMT_CLOSERANGE, m_fHitStrenght, FLOAT3D(0, 0, 0), vDirection);
- KickEntity(m_penEnemy, vSpeed);
- };
- autowait(m_fHitTime);
- };
- if(m_ctType==CT_KAMIKADZE){
- };
- if(m_ctType==CT_JUMP){
- StartModelAnim(m_iCloseAnim, AOF_LOOPING);
- autowait(m_fBeforeHitTime);
- FLOAT3D vDirection = m_penEnemy->GetPlacement().pl_PositionVector-GetPlacement().pl_PositionVector;
- vDirection.Normalize();
- FLOAT3D vSpeed;
- GetHeadingDirection(AngleDeg(0.0f), vSpeed);
- vSpeed = vSpeed * 5.0f;
- if (CalcDist(m_penEnemy)<m_fClsDist) {
- KickEntity(m_penEnemy, vSpeed);
- autocall JumpOnce() EReturn;
- autowait(m_fHitTime);
- };
- };
- return EReturn();
- };
- JumpOnce(EVoid)
- {
- // ------------ Jump either in slightly randomized direction or mortal, streight and fast toward enemy
- // we are always going for enemy
- m_vDesiredPosition = m_penEnemy->GetPlacement().pl_PositionVector;
- m_fMoveFrequency = 0.1f;
- // if we are close enough for mortal jump
- if( CalcPlaneDist(m_penEnemy) < 10.0f)
- {
- // set mortal jump parameters (no random)
- m_fMoveSpeed = m_fCloseRunSpeed*1.5f;
- m_aRotateSpeed = m_aCloseRotateSpeed*0.5f;
- FLOAT fSpeedX = 0.0f;
- FLOAT fSpeedY = m_fJumpHeight;
- FLOAT fSpeedZ = -m_fMoveSpeed;
- // if can't see enemy
- if( !IsInFrustum(m_penEnemy, CosFast(30.0f)))
- {
- // rotate a lot
- m_aRotateSpeed = m_aCloseRotateSpeed*1.5f;
- // but don't jump too much
- fSpeedY /= 2.0f;
- fSpeedZ /= 4.0f;
- PlaySound(m_soSound, m_fnSAttack, SOF_3D);
- }
- else
- {
- PlaySound(m_soSound, m_fnSAttack, SOF_3D);
- }
- FLOAT3D vTranslation(fSpeedX, fSpeedY, fSpeedZ);
- SetDesiredTranslation(vTranslation);
- MortalJumpAnim();
- }
- // start slightly randomized jump
- else
- {
- if(m_bJumpAnytime==TRUE) {
- m_fMoveSpeed = m_fCloseRunSpeed;
- m_aRotateSpeed = m_aCloseRotateSpeed;
- // set random jump parameters
- FLOAT fSpeedX = (FRnd()-0.5f)*10.0f;
- FLOAT fSpeedY = FRnd()*5.0f+5.0f;
- FLOAT fSpeedZ = -m_fMoveSpeed-FRnd()*2.5f;
- FLOAT3D vTranslation(fSpeedX, fSpeedY, fSpeedZ);
- SetDesiredTranslation(vTranslation);
- RunningAnim();
- PlaySound(m_soSound, m_fnSAttack, SOF_3D);
- };
- }
- // ------------ While in air, adjust directions, on touch start new jump or explode
- while (TRUE)
- {
- // adjust direction and speed
- m_fMoveSpeed = 0.0f;
- m_aRotateSpeed = m_aCloseRotateSpeed;
- FLOAT3D vTranslation = GetDesiredTranslation();
- SetDesiredMovement();
- SetDesiredTranslation(vTranslation);
- wait(m_fBeforeHitTime)
- {
- on (EBegin) : { resume; };
- on (ESound) : { resume; } // ignore all sounds
- on (EWatch) : { resume; } // ignore watch
- on (ETimer) : { stop; } // timer tick expire
- on (ETouch etouch) :
- {
- // if we touched ground
- if( etouch.penOther->GetRenderType() & RT_BRUSH)
- {
- return EReturn();
- }
- // we touched player, explode
- else if ( IsDerivedFromClass( etouch.penOther, "Player"))
- {
- FLOAT3D vDirection = m_penEnemy->GetPlacement().pl_PositionVector-GetPlacement().pl_PositionVector;
- vDirection.Normalize();
- InflictDirectDamage(m_penEnemy, this, DMT_CLOSERANGE, m_fHitStrenght, FLOAT3D(0, 0, 0), vDirection);
- }
- // we didn't touch ground nor player, ignore
- resume;
- }
- }
- }
- };
- /************************************************************
- * M A I N *
- ************************************************************/
- Main(EVoid) {
- // declare yourself as a model
- InitAsModel();
- SetPhysicsFlags(EPF_MODEL_WALKING);
- SetCollisionFlags(ECF_MODEL);
- SetFlags(GetFlags()|ENF_ALIVE);
- SetHealth(m_fHealth);
- m_fMaxHealth = m_fHealth;
- en_fDensity = m_fDensity;
- // set your appearance
- SetModel(m_fnModel);
- GetModelObject()->AutoSetTextures();
- GetModelObject()->AutoSetAttachments();
- try
- {
- GetModelObject()->mo_toTexture.SetData_t(m_fnTexture);
- GetModelObject()->mo_toReflection.SetData_t(m_fnReflection);
- GetModelObject()->mo_toSpecular.SetData_t(m_fnSpecular);
- GetModelObject()->mo_toBump.SetData_t(m_fnBump);
- } catch (char *strError) {
- WarningMessage(strError);
- }
- m_fnTexture = GetModelObject()->mo_toTexture.GetName();
- m_fnReflection = GetModelObject()->mo_toReflection.GetName();
- m_fnSpecular = GetModelObject()->mo_toSpecular.GetName();
- m_fnBump = GetModelObject()->mo_toBump.GetName();
- StandingAnim();
- m_sptType = m_sptPartType;
- // setup moving speed
- m_fWalkSpeed = FRnd() + m_fWlkSp;
- m_aWalkRotateSpeed = FRnd()*m_fWlkRotSp/3 + m_fWlkRotSp;
- m_fAttackRunSpeed = FRnd() + m_fAttSp;
- m_aAttackRotateSpeed = FRnd()*m_fAttRotSp/3 + m_fAttRotSp;
- m_fCloseRunSpeed = FRnd() + m_fClsSp;
- m_aCloseRotateSpeed = FRnd()*m_fClsRtSp/3 + m_fClsRtSp;
- // setup attack distances
- m_fAttackDistance = m_fAttDist;
- m_fCloseDistance = m_fClsDist;
- m_fStopDistance = m_fStpDist;
- m_fAttackFireTime = m_fAttFireTime;
- m_fCloseFireTime = m_fClsFireTime;
- m_fIgnoreRange = m_fIgnRng;
- // damage/explode properties
- // m_fFireAngle = m_fFirAngl;
- m_fBlowUpAmount = m_fBlwUp;
- m_fBodyParts = 4;
- m_fDamageWounded = m_fDamageWoundedCustom;
- m_iScore = m_fScr;
- if (m_fStepHeight==-1) {
- m_fStepHeight = 4.0f;
- }
- GetModelObject()->AutoSetAttachments();
- // set stretch factors for height and width
- CEnemyBase::SizeModel();
- m_soFeet.Set3DParameters(80.0f, 5.0f, 1.0f, 1.0f);
- m_bRunSoundPlaying = FALSE;
- // continue behavior in base class
- jump CEnemyBase::MainLoop();
- };
- };
- //need some code for attachments && other fire types
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement