Guest User

Untitled

a guest
May 9th, 2016
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.65 KB | None | 0 0
  1.  
  2. func int Get_HeroSheath(var int ptr)
  3. {
  4. if(ptr==0){printdebug("HETGEROSHEATS-ERROR!");};
  5.  
  6. var string objname;
  7.  
  8. var int label; var int val; var int first_ptr; var int previous;
  9. first_ptr = ptr;
  10. val = MEM_ReadInt(ptr+16);//data zCVobVFX?
  11. if(val)
  12. {
  13. if(MEM_ReadInt(val)==8200452)
  14. {
  15. objname = MEM_ReadString(val+16);
  16. if(Hlp_StrCmp(STR_Prefix(objname,6),"V_ITMW"))
  17. {
  18. return val;
  19. };
  20. };
  21. };
  22.  
  23. MEM_InitLabels();
  24. label = MEM_StackPos.position;
  25. if(previous)
  26. {
  27. ptr = MEM_ReadInt(ptr+12);//next
  28. }
  29. else
  30. {
  31. ptr = MEM_ReadInt(ptr+8);//next
  32. };
  33. if(ptr==0)
  34. {
  35. previous=true;
  36. ptr=first_ptr;
  37. MEM_StackPos.position = label;
  38. };
  39. val = MEM_ReadInt(ptr+16);//data zCVobVFX?
  40. if(val)
  41. {
  42. if(MEM_ReadInt(val)==8200452)
  43. {
  44. objname = MEM_ReadString(val+16);
  45. if(Hlp_StrCmp(STR_Prefix(objname,6),"V_ITMW"))
  46. {
  47. return val;
  48. };
  49. }
  50. else if (first_ptr!=ptr)
  51. {
  52. MEM_StackPos.position = label;
  53. };
  54. }
  55. else { return 0;};
  56.  
  57.  
  58. };
  59.  
  60. func void Create_Sheath(var c_npc slf,var int itm_ptr)
  61. {
  62. if(!itm_ptr)
  63. { return;};
  64. if(MEM_ReadInt(itm_ptr+312)&ITEM_AXE)||(MEM_ReadInt(itm_ptr+312)&ITEM_2HD_AXE)//item.flags
  65. {return;};//no sheats 4 axes/maces
  66. if(MEM_ReadInt(itm_ptr+320)==8650)
  67. {printdebug("skip"); return;};
  68. var string sheath; var int itm_id_lenght;
  69. //Anti Crash
  70. itm_id_lenght = MEM_ReadInt(itm_ptr+504);
  71. if(itm_id_lenght>13)
  72. {
  73. if(Hlp_StrCmp(MEM_ReadString(itm_ptr+492),"ItMw_2H_Sword_Old_01.3DS"))
  74. ||(Hlp_StrCmp(MEM_ReadString(itm_ptr+492),"ItMw_1H_Sword_Old_01.3DS"))
  75. ||(!Hlp_StrCmp(Str_Prefix(MEM_ReadString(itm_ptr+492),13),"ItMw_1H_Sword"))
  76. ||(!Hlp_StrCmp(Str_Prefix(MEM_ReadString(itm_ptr+492),13),"ItMw_2H_Sword"))
  77. {
  78. return;
  79. };
  80. } else { return;};
  81.  
  82.  
  83. sheath = STR_Prefix(MEM_ReadString(itm_ptr+492),itm_id_lenght-6);//without: 0X.3ds
  84. sheath = concatstrings("V_",sheath);
  85. sheath = concatstrings(sheath,"SHEATH_0");
  86. sheath = concatstrings(sheath,inttostring(MEM_ReadInt(itm_ptr+744)%2+1));//instance%2
  87.  
  88. //bugfix npc's need another mesh ;/
  89. if(!Npc_IsPlayer(slf))
  90. {
  91. sheath = concatstrings(sheath,"_NPC");
  92.  
  93. };
  94. Wld_PlayEffect(sheath, slf, slf, 0, 0, DAM_INVALID, FALSE);
  95.  
  96. if(Npc_IsPlayer(slf))
  97. {
  98. var ocnpc hiro;
  99. hiro = hlp_getnpc(hero);
  100. itm_id_lenght = MEM_InstGetOffset(hiro);
  101. itm_id_lenght = MEM_ReadInt(itm_id_lenght+36);//hero zCTree
  102. itm_id_lenght = MEM_ReadInt(itm_id_lenght);//parent zCTree
  103. itm_id_lenght = MEM_ReadInt(itm_id_lenght+4);//child zCTree
  104. V_HeroSheath_Pointer = Get_HeroSheath(itm_id_lenght);
  105. };
  106.  
  107. };
  108.  
  109. func void Create_SheathItemID(var c_npc slf,var int itmID)
  110. {
  111. Npc_GetInvItem(slf,itmId);//item->itmid
  112. printdebug(concatstrings("SheatItem: ",item.visual));
  113. if(!itmID)
  114. { return;};
  115. if(item.flags&ITEM_AXE)||(item.flags&ITEM_2HD_AXE)//item.flags
  116. {return;};//no sheats 4 axes/maces
  117. if(item.value==8650)
  118. {printdebug("skip"); return;};
  119. var string sheath; var int itm_id_lenght;
  120. //Anti Crash
  121. itm_id_lenght = STR_Len(item.visual);
  122. if(itm_id_lenght>13)
  123. {
  124. if(Hlp_StrCmp(item.visual,"ItMw_2H_Sword_Old_01.3DS"))
  125. ||(Hlp_StrCmp(item.visual,"ItMw_1H_Sword_Old_01.3DS"))
  126. ||((!Hlp_StrCmp(Str_Prefix(item.visual,13),"ITMW_1H_SWORD"))&&(!Hlp_StrCmp(Str_Prefix(item.visual,13),"ITMW_2H_SWORD")))
  127. {
  128. printdebug(concatstrings(Str_Prefix(item.visual,13),concatstrings(" don't match: ","ITMW_nH_SWORD")));
  129. return;
  130. };
  131. } else { return;};
  132.  
  133.  
  134. sheath = STR_Prefix(item.visual,itm_id_lenght-6);//without: 0X.3ds
  135. sheath = concatstrings("V_",sheath);
  136. sheath = concatstrings(sheath,"SHEATH_0");
  137. sheath = concatstrings(sheath,inttostring(item.id%2+1));//instance%2
  138.  
  139. //bugfix npc's need another mesh ;/
  140. if(!Npc_IsPlayer(slf))
  141. {
  142. sheath = concatstrings(sheath,"_NPC");
  143.  
  144. };
  145. Wld_PlayEffect(sheath, slf, slf, 0, 0, DAM_INVALID, FALSE);
  146.  
  147. if(Npc_IsPlayer(slf))
  148. {
  149. var ocnpc hiro;
  150. hiro = hlp_getnpc(hero);
  151. itm_id_lenght = MEM_InstGetOffset(hiro);
  152. itm_id_lenght = MEM_ReadInt(itm_id_lenght+36);//hero zCTree
  153. itm_id_lenght = MEM_ReadInt(itm_id_lenght);//parent zCTree
  154. itm_id_lenght = MEM_ReadInt(itm_id_lenght+4);//child zCTree
  155. V_HeroSheath_Pointer = Get_HeroSheath(itm_id_lenght);
  156. };
  157.  
  158. };
  159.  
  160.  
  161. //TODO:
  162. //Fix bug, when hero haven't any sheat because he fe. euqiped pickaxe, at equiping another weapon game crash
  163. //(sure because of destroying uncreated vfx of sheat)
  164. func void Destroy_Sheath(var int hero,var int ptr)
  165. {
  166. if(ptr==0){return;};
  167. if(MEM_ReadInt(ptr)!=zCVisualFX_vtbl)
  168. {return;};//It'z a trap!
  169. var int val; var int p;
  170. p = MEM_ReadInt(ptr+184);//ZCviusal of VFX
  171. val = MEM_ReadInt(p+4);
  172. MEM_WriteInt(p+4,val-1);//zCVisual refctr-1
  173. MEM_WriteInt(ptr+184,0);//remove ptr to visual
  174. if(hero)
  175. {
  176. V_HeroSheath_Pointer=0;
  177. };
  178.  
  179. };
  180. func void Hero_SheathUpadteLightning()
  181. {
  182. if(!V_HeroSheath_Pointer)
  183. { return; };
  184. var ocnpc hiro;
  185. hiro = hlp_getnpc(hero);
  186. MEM_WriteInt(V_HeroSheath_Pointer+196,hiro._zCVob_lightColorStat);
  187. MEM_WriteInt(V_HeroSheath_Pointer+200,hiro._zCVob_lightColorDyn);
  188.  
  189. MEM_WriteInt(V_HeroSheath_Pointer+204,hiro._zCVob_lightDirectionStat[0]);
  190. MEM_WriteInt(V_HeroSheath_Pointer+208,hiro._zCVob_lightDirectionStat[1]);
  191. MEM_WriteInt(V_HeroSheath_Pointer+212,hiro._zCVob_lightDirectionStat[2]);
  192.  
  193. var int hlp;
  194. hlp = MEM_ReadInt(V_HeroSheath_Pointer+228);
  195. hlp = hlp | zCVob_bitfield0_lightColorStatDirty;
  196. hlp = hlp | zCVob_bitfield0_lightColorDynDirty;
  197. MEM_WriteInt(V_HeroSheath_Pointer+228,hlp);
  198.  
  199.  
  200. };
  201.  
  202.  
  203. FUNC VOID B_CheckSheath()
  204. {
  205. // TURN IT ON when check of npc strenght/needed weapon strength need to be checked
  206. // If(Npc_GetInvItembyslot(self,1,0)> 0)//has melee weapon?
  207. // {
  208. // print_s_i_s_i(self.name, self.attribute[ATR_STRENGTH],"/",item.cond_value[2]);
  209. // if(item.cond_value[2]>self.attribute[ATR_STRENGTH])
  210. // {
  211. // printdebug_s_i_s_i(concatstrings("TODO: correct - ",self.name), self.attribute[ATR_STRENGTH],"/",item.cond_value[2]);
  212. // self.attribute[ATR_STRENGTH] = item.cond_value[2];
  213. // };
  214. // };
  215. MEM_SetShowDebug(1);
  216. sheath_cycles+=1;
  217. if(sheath_cycles>11)
  218. { return;};
  219.  
  220. If(Npc_GetAivar(self,AIV_SHEATH)<Worlds_Inits)
  221. {
  222. Npc_SetAivar(Self,AIV_SHEATH,Worlds_Inits);
  223. var c_item itm; var int id; var int ptr;
  224. itm = Npc_GetEquippedMeleeWeapon(self);
  225. if(Hlp_IsValidItem(itm))
  226. {
  227. if((itm.flags & ITEM_SWD)==ITEM_SWD)||((itm.flags & ITEM_2HD_SWD)==ITEM_2HD_SWD)
  228. {
  229. id = Hlp_GetInstanceID(itm);
  230. ptr = MEM_InstGetOffset(id);
  231. Create_Sheath(Self,ptr);
  232. };
  233. };
  234. };
  235. //Npc_Percdisable(self,Perc_Npccommand);
  236.  
  237. //CheckDamage (it need to be here)
  238.  
  239. if ( Npc_IsPlayer( other ) )
  240. {
  241. add_CollPool(self);
  242. };
  243.  
  244. };
Advertisement
Add Comment
Please, Sign In to add comment