Page 2 of 3

Re: Creating a custom augment NPC

Posted: Fri Jan 29, 2016 2:01 pm
by kennxonline
How would one use this code to make it only accept a armor piece that I choose?

Artfact head only augments with code.

Code: Select all

-----------------------------------
-- Area: Upper Jeuno
-- NPC: Theraisie
-- AF NPC NPC
-----------------------------------

-----------------------------------
-- onTrade Action
-----------------------------------

function onTrade(player,npc,trade)
    
    local count = trade:getItemCount();
    local prize = trade:getItem(0);
    local a1 = 0;
    local a2 = 0;
    local a3 = 0;
    local a4 = 0;
    local v1 = 0;
    local v2 = 0;
    local v3 = 0;
    local v4 = 0;
	
      if trade:getItem(0) == 12516 then 	
      elseif trade:getItem(1) == 1126 then 
         a1 = 512,30
         v1 = 4
      elseif trade:getItem(2) == 1535 then 
          a2 = 512
          v2 = 4
      elseif trade:getItem(3) == 1535 then 
         a3 = 512
         v3 = 4
      elseif trade:getItem(4) == 1535 then 
          a4 = 512
         v4 = 4
       end	
	         
   if(player:getFreeSlotsCount() >= 1) then
      player:tradeComplete();
      player:addItem(prize,1,a1,v1,a2,v2,a3,v3,a4,v4);
      player:messageSpecial(ITEM_OBTAINED,prize);
   else
      player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,prize);
   end
 
end;
am I at least close?

Re: Creating a custom augment NPC

Posted: Fri Jan 29, 2016 4:02 pm
by whasf
You mean accept any piece that the player chooses? You'd have to account for each possible piece and handle each one. Might want to set up an array list (look how crafting does it).

It'll be tedious for you to code, that's for sure.

Re: Creating a custom augment NPC

Posted: Fri Jan 29, 2016 6:17 pm
by kennxonline
No, instead of it accepting any weapon or armor piece for augments.[currently how it works] Make it only accept a 1 gear piece. So the players cant get say Attack bonus on a level 1 item they have to trade what gear the NPC is augmenting.

Re: Creating a custom augment NPC

Posted: Mon Feb 15, 2016 8:05 pm
by Avatarati
Just wanted to throw out a quick update on this in case people can't get this to work.

Because luabaseentity.cpp is now looking for an 11th integer (for trials):

Code: Select all

    if (!lua_isnil(L, 11) && lua_isnumber(L, 11))
        trialNumber = (uint16)lua_tointeger(L, 11);
This will not work because it only contains 10 values:

Code: Select all

player:addItem(prize,1,a1,v1,a2,v2,a3,v3,a4,v4);
Insert a '0' at the end of the line, like this:

Code: Select all

player:addItem(prize,1,a1,v1,a2,v2,a3,v3,a4,v4,0);
And it should augment items.

Of course you can customize your script to retrieve the trial number and insert it if you'd like to retain Magian Trial assignments. The script line above is assuming you're not using trials.

Re: Creating a custom augment NPC

Posted: Sat Feb 20, 2016 4:39 pm
by TeoTwawki
Avatarati wrote:Just wanted to throw out a quick update on this in case people can't get this to work.

Because luabaseentity.cpp is now looking for an 11th integer (for trials):

Code: Select all

    if (!lua_isnil(L, 11) && lua_isnumber(L, 11))
        trialNumber = (uint16)lua_tointeger(L, 11);
This will not work because it only contains 10 values:

Code: Select all

player:addItem(prize,1,a1,v1,a2,v2,a3,v3,a4,v4);
Insert a '0' at the end of the line, like this:

Code: Select all

player:addItem(prize,1,a1,v1,a2,v2,a3,v3,a4,v4,0);
And it should augment items.

Of course you can customize your script to retrieve the trial number and insert it if you'd like to retain Magian Trial assignments. The script line above is assuming you're not using trials.
The trial value is not required for augments, only for trials. When its left out it is automatically zero.

Re: Creating a custom augment NPC

Posted: Sun Feb 21, 2016 1:26 am
by Avatarati
I would figure so too since it would assume a nil value, but after many attempts the only way I could get it to work was by manually adding in the 0 to account for every argument to be passed. If it works for most people great, but I was just throwing it out there for anyone that ran into probs like I did.

Re: Creating a custom augment NPC

Posted: Sun Feb 21, 2016 4:58 pm
by TeoTwawki

Code: Select all

addItem(itemID,Quantity,augment,value,augment,value,augment,value,augment,value,trial);
If I missed/skipped a field and try to continue, it throw the whole thing off. But if I just stop:

Code: Select all

addItem(itemID,Quantity,augment,value);
it will work, and just not fill in anything for the other fields (database table defaults will fill them with zeros). Its just how its been coded since forever. No other outcome is possible without someone changing the binding in luabaseentity.cpp

Re: Creating a custom augment NPC

Posted: Sat Aug 19, 2017 5:14 am
by lion85xx
i have follow all the instruction but my npc don't work plz help

Re: Creating a custom augment NPC

Posted: Thu Apr 19, 2018 11:39 pm
by tindin
any tips on how to get this to work

Re: Creating a custom augment NPC

Posted: Wed Jun 27, 2018 9:20 pm
by Aale
Updated version of what I did with this here:

viewtopic.php?f=19&t=21905

I used the Port Jeuno treasure box to closely mimic synergy augments. You can add to or modify my code to suit your server’s needs.