Advertisement
EliteAnax17

Untitled

May 30th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 b, u8 c)
  2. {
  3. struct MapObject2 *mapObj; //TODO: resolve the mapobj_unk_19b weirdness
  4. u8 var;
  5. u16 r3;
  6. u16 r2;
  7.  
  8. //asm("nop"::"r"(b));
  9. if (GetAvailableFieldObjectSlot(template->localId, b, c, &var) != 0)
  10. return 16;
  11. //_0805ACCE
  12. mapObj = (struct MapObject2 *)&gMapObjects[var];
  13. npc_clear_ids_and_state((struct MapObject *)mapObj);
  14. r3 = template->x + 7;
  15. r2 = template->y + 7;
  16. mapObj->active = TRUE;
  17. mapObj->mapobj_bit_2 = TRUE;
  18. mapObj->graphicsId = template->graphicsId;
  19. if(CheckSpeedchoiceOption(SPINNERS, HELL) == TRUE && gPlayerAvatar.mapObjectId != var && (template->unkC == 1 || template->unkC == 3))
  20. mapObj->animPattern = 1;
  21. else
  22. mapObj->animPattern = template->movementType;
  23. mapObj->localId = template->localId;
  24. mapObj->mapNum = b;
  25. mapObj->mapGroup = c;
  26. mapObj->coords1.x = r3;
  27. mapObj->coords1.y = r2;
  28. mapObj->coords2.x = r3;
  29. mapObj->coords2.y = r2;
  30. mapObj->coords3.x = r3;
  31. mapObj->coords3.y = r2;
  32. mapObj->mapobj_unk_0B_0 = template->elevation;
  33. mapObj->elevation = template->elevation;
  34. mapObj->mapobj_unk_19 = template->unkA_0;
  35. mapObj->mapobj_unk_19b = template->unkA_4;
  36. if(CheckSpeedchoiceOption(SPINNERS, HELL) == TRUE && gPlayerAvatar.mapObjectId != var && (template->unkC == 1 || template->unkC == 3))
  37. mapObj->trainerType = 1;
  38. else
  39. mapObj->trainerType = template->unkC;
  40. if(CheckSpeedchoiceOption(MAXVISION, OFF_2) == FALSE && gPlayerAvatar.mapObjectId != var && (template->unkC == 1 || template->unkC == 3))
  41. mapObj->trainerRange_berryTreeId = MAX_VISION_RANGE;
  42. else
  43. mapObj->trainerRange_berryTreeId = template->unkE;
  44. mapObj->mapobj_unk_20 = gUnknown_0836DC09[mapObj->animPattern];
  45. FieldObjectSetDirection((struct MapObject *)mapObj, mapObj->mapobj_unk_20);
  46. FieldObjectHandleDynamicGraphicsId(mapObj);
  47. //asm("":::"r5","r6");
  48. if (gUnknown_0836DBBC[mapObj->animPattern] != 0)
  49. {
  50. if (mapObj->mapobj_unk_19 == 0)
  51. mapObj->mapobj_unk_19++;
  52. if (mapObj->mapobj_unk_19b == 0)
  53. mapObj->mapobj_unk_19b++;
  54. }
  55. return var;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement