Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include "zzzInfomation.h"
- #include "ZzzOpenglUtil.h"
- #include "zzzBmd.h"
- #include "CustomPet.h"
- #include "zzzCharacter.h"
- #include "ZzzLodTerrain.h"
- #include "ZzzTexture.h"
- #include "ZzzAI.h"
- #include "ZzzEffect.h"
- #include "zzzOpenData.h"
- #include "ZzzObject.h"
- #include "CSChaosCastle.h"
- #include "GMHellas.h"
- #include "GMAida.h"
- #include "CDirection.h"
- #include "DSPlaySound.h"
- #include "CameraMove.h"
- #ifdef NEM_ADD_CUSTOM_PETS
- CCustomPet g_CustomPet;
- // -> Constructor
- CCustomPet::CCustomPet()
- {
- this->FlyRange=0.0f;
- }
- // -> Destructor
- CCustomPet::~CCustomPet()
- {
- }
- void CCustomPet::LoadItemModel()
- {
- for(int i=200;i<512;i++)
- {
- sprintf(this->CustomPetName,"CustomPet%d",i+1);
- AccessModel(MODEL_HELPER+i,"Data\\Custom\\Item\\",this->CustomPetName);
- }
- }
- void CCustomPet::LoadItemTexture()
- {
- for(int i=200;i<512;i++)
- {
- OpenTexture(MODEL_HELPER+i,"Custom\\Item\\");
- }
- }
- bool CCustomPet::IsCustomPet(ITEM* pITEM)
- {
- if(pITEM->Type>=ITEM_HELPER+200
- &&pITEM->Type<=ITEM_HELPER+511)
- {
- return true;
- }
- return false;
- }
- bool CCustomPet::CreateCustomPet(int Type,vec3_t Position,OBJECT *Owner,OBJECT *o,int SubType,int LinkBone)
- {
- if ( InChaosCastle()==true ) return false;
- if ( !o->Live )
- {
- o->Type = Type;
- o->Live = true;
- o->Visible = false;
- o->LightEnable = true;
- o->ContrastEnable = false;
- o->AlphaEnable = false;
- o->EnableBoneMatrix = false;
- o->Owner = Owner;
- o->SubType = SubType;
- o->HiddenMesh = -1;
- o->BlendMesh = -1;
- o->BlendMeshLight = 1.f;
- o->Scale = 0.7f;
- o->LifeTime = 30;
- o->Alpha = 0.f;
- o->AlphaTarget = 1.f;
- // ----
- VectorCopy(Position,o->Position);
- VectorCopy(Owner->Angle,o->Angle);
- // ----
- Vector(3.f,3.f,3.f,o->Light);
- // ----
- o->PriorAnimationFrame = 0.f;
- o->AnimationFrame = 0.f;
- o->Velocity = 0.5f;
- // ----
- ITEM *pItem;
- // ----
- if(this->IsCustomPet((ITEM*)&pItem->Type))
- {
- o->Scale = 0.5f;
- o->BlendMesh = 1;
- o->Position[2] = RequestTerrainHeight ( o->Position[0], o->Position[1] ) + (float)(rand()%100);
- }
- return FALSE;
- }
- return TRUE;
- }
- void CCustomPet::CreateCustomPetCount(int Type,vec3_t Position,OBJECT *Owner,int SubType,int LinkBone)
- {
- if ( InChaosCastle()==true ) return;
- if ( Owner->Type!=MODEL_PLAYER && Type!=MODEL_HELPER )
- return;
- for ( int i=0; i<200; i++ )
- {
- OBJECT* o = &CustomPets[i];
- if(this->CreateCustomPet(Type,Position,Owner,o,SubType,LinkBone)==FALSE) return;
- }
- }
- bool CCustomPet::MovementCustomPet(OBJECT *o,bool bForceRender)
- {
- if(o->Live)
- {
- if(SceneFlag==MAIN_SCENE)
- {
- if ( !o->Owner->Live || o->Owner->Kind!=KIND_PLAYER )
- {
- o->Live = false;
- return TRUE;
- }
- }
- // ----
- Alpha(o);
- // ----
- BMD* b = &Models[o->Type];
- VectorCopy(o->Owner->Position,this->TargetPosition);
- // ----
- ITEM *pItem;
- // ----
- if(this->IsCustomPet((ITEM*)&pItem->Type)==true)
- {
- if ( o->Owner->Teleport==TELEPORT_BEGIN || o->Owner->Teleport==TELEPORT )
- {
- o->Alpha -= 0.1f;
- if ( o->Alpha<0 ) o->Alpha = 0.f;
- }
- else
- {
- o->Alpha = 1.f;
- }
- // ----
- if( o->Owner && !g_isCharacterBuff(o->Owner, eBuff_Cloaking) )
- {
- this->FlyRange = 150.f;
- Vector(0.4f,0.4f,0.4f,this->Light);
- // ----
- for(int j=0;j<4;j++)
- {
- Vector ( (float)(rand()%16-8), (float)(rand()%16-8), (float)(rand()%16-8), this->Position );
- VectorAdd ( Position, o->Position, this->Position );
- CreateParticle ( BITMAP_SPARK, this->Position, o->Angle, this->Light, 1 );
- }
- }
- }
- // ----
- b->CurrentAction = o->CurrentAction;
- b->PlayAnimation(&o->AnimationFrame,&o->PriorAnimationFrame,&o->PriorAction,o->Velocity,o->Position,o->Angle);
- // ----
- //if(o->Type == this->IsCustomPet((ITEM*)&pItem->Type))
- if(o->Type >= MODEL_HELPER+200 && o->Type <= MODEL_HELPER+511)
- {
- vec3_t Range;
- VectorSubtract(TargetPosition,o->Position,Range);
- float Distance = Range[0]*Range[0]+Range[1]*Range[1];
- // ----
- if(Distance >= this->FlyRange*this->FlyRange)
- {
- float Angle = CreateAngle(o->Position[0],o->Position[1],TargetPosition[0],TargetPosition[1]);
- o->Angle[2] = TurnAngle2(o->Angle[2],Angle,20.f);
- }
- AngleMatrix(o->Angle,o->Matrix);
- vec3_t Direction;
- VectorRotate(o->Direction,o->Matrix,Direction);
- VectorAdd(o->Position,Direction,o->Position);
- o->Position[2] += (float)(rand()%16-8);
- if(rand()%32==0)
- {
- float Speed = 0;
- if(Distance >= this->FlyRange*this->FlyRange)
- Speed = -(float)(rand()%64+128)*0.1f;
- else
- {
- Speed = -(float)(rand()%64+16)*0.1f;
- o->Angle[2] = (float)(rand()%360);
- }
- o->Direction[0] = 0.f;
- o->Direction[1] = Speed;
- o->Direction[2] = (float)(rand()%64-32)*0.1f;
- }
- if(o->Position[2] < o->Owner->Position[2]+100.f) o->Direction[2] += 1.5f;
- if(o->Position[2] > o->Owner->Position[2]+200.f) o->Direction[2] -= 1.5f;
- }
- }
- return TRUE;
- }
- void CCustomPet::MovementCustomPetCount()
- {
- for(int i=0;i<200;i++)
- {
- OBJECT *o = &CustomPets[i];
- if (this->MovementCustomPet(o) == FALSE) return;
- }
- }
- bool CCustomPet::RenderCustomPet(OBJECT *o,bool bForceRender)
- {
- if(o->Live)
- {
- o->Visible = (bForceRender == FALSE ? TestFrustrum2D(o->Position[0]*0.01f,o->Position[1]*0.01f,-20.f) : true);
- // ----
- if(o->Visible)
- {
- if ( o->Owner->Type!=MODEL_PLAYER && o->Type!=MODEL_HELPER )
- return TRUE;
- // ----
- if(bForceRender)
- o->Scale = o->Scale;
- // ----
- else if(SceneFlag == CHARACTER_SCENE)
- o->Scale = 1.0f;
- // ----
- int State=0;
- // ----
- if( g_isCharacterBuff(o->Owner, eBuff_Cloaking) ) { State=200; }
- // ----
- RenderObject(o,false,0,State);
- // ----
- // -> ACA FUNCION PARA RENDERIZAR EFECTOS
- // ----
- }
- }
- return TRUE;
- }
- void CCustomPet::RenderCustomPetCount()
- {
- for(int i=0;i<200;i++)
- {
- OBJECT *o = &CustomPets[i];
- if(this->RenderCustomPet(o)==FALSE){return;}
- }
- }
- void CCustomPet::DeleteCustomPet(OBJECT *Owner)
- {
- for(int i=0;i<200;i++)
- {
- OBJECT *o = &CustomPets[i];
- if(o->Live)
- {
- if(o->Owner == Owner)
- o->Live = false;
- }
- }
- }
- #endif // NEM_ADD_CUSTOM_PETS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement