Advertisement
Kiosani

CustomPet.cpp (Maldita copia de GOBoid.cpp) hecha clase aparte :D

Aug 7th, 2021
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.36 KB | None | 0 0
  1. #include "stdafx.h"
  2.  
  3. #include "zzzInfomation.h"
  4. #include "ZzzOpenglUtil.h"
  5. #include "zzzBmd.h"
  6.  
  7. #include "CustomPet.h"
  8.  
  9. #include "zzzCharacter.h"
  10. #include "ZzzLodTerrain.h"
  11. #include "ZzzTexture.h"
  12. #include "ZzzAI.h"
  13. #include "ZzzEffect.h"
  14. #include "zzzOpenData.h"
  15. #include "ZzzObject.h"
  16. #include "CSChaosCastle.h"
  17. #include "GMHellas.h"
  18. #include "GMAida.h"
  19. #include "CDirection.h"
  20. #include "DSPlaySound.h"
  21.  
  22. #include "CameraMove.h"
  23.  
  24. #ifdef NEM_ADD_CUSTOM_PETS
  25.  
  26. CCustomPet g_CustomPet;
  27.  
  28. // -> Constructor
  29. CCustomPet::CCustomPet()
  30. {
  31. this->FlyRange=0.0f;
  32. }
  33.  
  34. // -> Destructor
  35. CCustomPet::~CCustomPet()
  36. {
  37.  
  38. }
  39.  
  40. void CCustomPet::LoadItemModel()
  41. {
  42. for(int i=200;i<512;i++)
  43. {
  44. sprintf(this->CustomPetName,"CustomPet%d",i+1);
  45. AccessModel(MODEL_HELPER+i,"Data\\Custom\\Item\\",this->CustomPetName);
  46. }
  47. }
  48.  
  49. void CCustomPet::LoadItemTexture()
  50. {
  51. for(int i=200;i<512;i++)
  52. {
  53. OpenTexture(MODEL_HELPER+i,"Custom\\Item\\");
  54. }
  55. }
  56.  
  57. bool CCustomPet::IsCustomPet(ITEM* pITEM)
  58. {
  59. if(pITEM->Type>=ITEM_HELPER+200
  60. &&pITEM->Type<=ITEM_HELPER+511)
  61. {
  62. return true;
  63. }
  64. return false;
  65. }
  66.  
  67. bool CCustomPet::CreateCustomPet(int Type,vec3_t Position,OBJECT *Owner,OBJECT *o,int SubType,int LinkBone)
  68. {
  69. if ( InChaosCastle()==true ) return false;
  70.  
  71. if ( !o->Live )
  72. {
  73. o->Type = Type;
  74. o->Live = true;
  75. o->Visible = false;
  76. o->LightEnable = true;
  77. o->ContrastEnable = false;
  78. o->AlphaEnable = false;
  79. o->EnableBoneMatrix = false;
  80. o->Owner = Owner;
  81. o->SubType = SubType;
  82. o->HiddenMesh = -1;
  83. o->BlendMesh = -1;
  84. o->BlendMeshLight = 1.f;
  85. o->Scale = 0.7f;
  86. o->LifeTime = 30;
  87. o->Alpha = 0.f;
  88. o->AlphaTarget = 1.f;
  89. // ----
  90. VectorCopy(Position,o->Position);
  91. VectorCopy(Owner->Angle,o->Angle);
  92. // ----
  93. Vector(3.f,3.f,3.f,o->Light);
  94. // ----
  95. o->PriorAnimationFrame = 0.f;
  96. o->AnimationFrame = 0.f;
  97. o->Velocity = 0.5f;
  98. // ----
  99. ITEM *pItem;
  100. // ----
  101. if(this->IsCustomPet((ITEM*)&pItem->Type))
  102. {
  103. o->Scale = 0.5f;
  104. o->BlendMesh = 1;
  105. o->Position[2] = RequestTerrainHeight ( o->Position[0], o->Position[1] ) + (float)(rand()%100);
  106. }
  107. return FALSE;
  108. }
  109. return TRUE;
  110. }
  111.  
  112. void CCustomPet::CreateCustomPetCount(int Type,vec3_t Position,OBJECT *Owner,int SubType,int LinkBone)
  113. {
  114. if ( InChaosCastle()==true ) return;
  115.  
  116. if ( Owner->Type!=MODEL_PLAYER && Type!=MODEL_HELPER )
  117. return;
  118.  
  119. for ( int i=0; i<200; i++ )
  120. {
  121. OBJECT* o = &CustomPets[i];
  122.  
  123. if(this->CreateCustomPet(Type,Position,Owner,o,SubType,LinkBone)==FALSE) return;
  124. }
  125. }
  126.  
  127. bool CCustomPet::MovementCustomPet(OBJECT *o,bool bForceRender)
  128. {
  129. if(o->Live)
  130. {
  131. if(SceneFlag==MAIN_SCENE)
  132. {
  133. if ( !o->Owner->Live || o->Owner->Kind!=KIND_PLAYER )
  134. {
  135. o->Live = false;
  136. return TRUE;
  137. }
  138. }
  139. // ----
  140. Alpha(o);
  141. // ----
  142. BMD* b = &Models[o->Type];
  143. VectorCopy(o->Owner->Position,this->TargetPosition);
  144. // ----
  145. ITEM *pItem;
  146. // ----
  147. if(this->IsCustomPet((ITEM*)&pItem->Type)==true)
  148. {
  149. if ( o->Owner->Teleport==TELEPORT_BEGIN || o->Owner->Teleport==TELEPORT )
  150. {
  151. o->Alpha -= 0.1f;
  152. if ( o->Alpha<0 ) o->Alpha = 0.f;
  153. }
  154. else
  155. {
  156. o->Alpha = 1.f;
  157. }
  158. // ----
  159. if( o->Owner && !g_isCharacterBuff(o->Owner, eBuff_Cloaking) )
  160. {
  161. this->FlyRange = 150.f;
  162. Vector(0.4f,0.4f,0.4f,this->Light);
  163. // ----
  164. for(int j=0;j<4;j++)
  165. {
  166. Vector ( (float)(rand()%16-8), (float)(rand()%16-8), (float)(rand()%16-8), this->Position );
  167. VectorAdd ( Position, o->Position, this->Position );
  168. CreateParticle ( BITMAP_SPARK, this->Position, o->Angle, this->Light, 1 );
  169. }
  170. }
  171. }
  172. // ----
  173. b->CurrentAction = o->CurrentAction;
  174. b->PlayAnimation(&o->AnimationFrame,&o->PriorAnimationFrame,&o->PriorAction,o->Velocity,o->Position,o->Angle);
  175. // ----
  176. //if(o->Type == this->IsCustomPet((ITEM*)&pItem->Type))
  177. if(o->Type >= MODEL_HELPER+200 && o->Type <= MODEL_HELPER+511)
  178. {
  179. vec3_t Range;
  180. VectorSubtract(TargetPosition,o->Position,Range);
  181. float Distance = Range[0]*Range[0]+Range[1]*Range[1];
  182. // ----
  183. if(Distance >= this->FlyRange*this->FlyRange)
  184. {
  185. float Angle = CreateAngle(o->Position[0],o->Position[1],TargetPosition[0],TargetPosition[1]);
  186. o->Angle[2] = TurnAngle2(o->Angle[2],Angle,20.f);
  187. }
  188. AngleMatrix(o->Angle,o->Matrix);
  189. vec3_t Direction;
  190. VectorRotate(o->Direction,o->Matrix,Direction);
  191. VectorAdd(o->Position,Direction,o->Position);
  192. o->Position[2] += (float)(rand()%16-8);
  193. if(rand()%32==0)
  194. {
  195. float Speed = 0;
  196. if(Distance >= this->FlyRange*this->FlyRange)
  197. Speed = -(float)(rand()%64+128)*0.1f;
  198. else
  199. {
  200. Speed = -(float)(rand()%64+16)*0.1f;
  201. o->Angle[2] = (float)(rand()%360);
  202. }
  203. o->Direction[0] = 0.f;
  204. o->Direction[1] = Speed;
  205. o->Direction[2] = (float)(rand()%64-32)*0.1f;
  206. }
  207. if(o->Position[2] < o->Owner->Position[2]+100.f) o->Direction[2] += 1.5f;
  208. if(o->Position[2] > o->Owner->Position[2]+200.f) o->Direction[2] -= 1.5f;
  209. }
  210. }
  211. return TRUE;
  212. }
  213.  
  214. void CCustomPet::MovementCustomPetCount()
  215. {
  216. for(int i=0;i<200;i++)
  217. {
  218. OBJECT *o = &CustomPets[i];
  219. if (this->MovementCustomPet(o) == FALSE) return;
  220. }
  221. }
  222.  
  223. bool CCustomPet::RenderCustomPet(OBJECT *o,bool bForceRender)
  224. {
  225. if(o->Live)
  226. {
  227. o->Visible = (bForceRender == FALSE ? TestFrustrum2D(o->Position[0]*0.01f,o->Position[1]*0.01f,-20.f) : true);
  228. // ----
  229. if(o->Visible)
  230. {
  231. if ( o->Owner->Type!=MODEL_PLAYER && o->Type!=MODEL_HELPER )
  232. return TRUE;
  233. // ----
  234. if(bForceRender)
  235. o->Scale = o->Scale;
  236. // ----
  237. else if(SceneFlag == CHARACTER_SCENE)
  238. o->Scale = 1.0f;
  239. // ----
  240. int State=0;
  241. // ----
  242. if( g_isCharacterBuff(o->Owner, eBuff_Cloaking) ) { State=200; }
  243. // ----
  244. RenderObject(o,false,0,State);
  245. // ----
  246. // -> ACA FUNCION PARA RENDERIZAR EFECTOS
  247. // ----
  248. }
  249. }
  250. return TRUE;
  251. }
  252.  
  253. void CCustomPet::RenderCustomPetCount()
  254. {
  255. for(int i=0;i<200;i++)
  256. {
  257. OBJECT *o = &CustomPets[i];
  258. if(this->RenderCustomPet(o)==FALSE){return;}
  259. }
  260. }
  261.  
  262. void CCustomPet::DeleteCustomPet(OBJECT *Owner)
  263. {
  264. for(int i=0;i<200;i++)
  265. {
  266. OBJECT *o = &CustomPets[i];
  267. if(o->Live)
  268. {
  269. if(o->Owner == Owner)
  270. o->Live = false;
  271. }
  272. }
  273. }
  274.  
  275. #endif // NEM_ADD_CUSTOM_PETS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement