Advertisement
Guest User

Traget

a guest
Apr 23rd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. int target_pos(lua_State* L)
  2. {
  3. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  4. int iQuestIndex = CQuestManager::instance().GetCurrentPC()->GetCurrentQuestIndex();
  5.  
  6. if (!lua_isstring(L, 1) || !lua_isnumber(L, 2) || !lua_isnumber(L, 3))
  7. {
  8. sys_err("invalid argument, name: %s, quest_index %d", ch->GetName(), iQuestIndex);
  9.  return 0;
  10. }
  11.  
  12. PIXEL_POSITION pos;
  13.  
  14. if (!SECTREE_MANAGER::instance().GetMapBasePositionByMapIndex(ch->GetMapIndex(), pos))
  15. {
  16. sys_err("cannot find base position in this map %d", ch->GetMapIndex());
  17. return 0;
  18. }
  19.  
  20. int x = pos.x + (int) lua_tonumber(L, 2) * 100;
  21. int y = pos.y + (int) lua_tonumber(L, 3) * 100;
  22.  
  23. CTargetManager::instance().CreateTarget(ch->GetPlayerID(),
  24. iQuestIndex,
  25.  lua_tostring(L, 1),
  26. TARGET_TYPE_POS,
  27. x,
  28. y,
  29. (int) lua_tonumber(L, 4),
  30. lua_isstring(L, 5) ? lua_tostring(L, 5) : NULL,
  31.  lua_isnumber(L, 6) ? (int)lua_tonumber(L, 6): 1);
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement