Creating a custom augment NPC

kennxonline
Posts: 56
Joined: Sun Mar 23, 2014 2:58 pm

Re: Creating a custom augment NPC

Post by kennxonline » Fri Jan 29, 2016 2:01 pm

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?

User avatar
whasf
Site Admin
Posts: 1312
Joined: Thu Jul 19, 2012 9:11 pm

Re: Creating a custom augment NPC

Post by whasf » Fri Jan 29, 2016 4:02 pm

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.
-- Whasf

kennxonline
Posts: 56
Joined: Sun Mar 23, 2014 2:58 pm

Re: Creating a custom augment NPC

Post by kennxonline » Fri Jan 29, 2016 6:17 pm

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.

Avatarati
Posts: 53
Joined: Mon Jun 30, 2014 2:51 pm

Re: Creating a custom augment NPC

Post by Avatarati » Mon Feb 15, 2016 8:05 pm

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.

User avatar
TeoTwawki
Developer
Posts: 527
Joined: Mon Jul 15, 2013 9:50 pm

Re: Creating a custom augment NPC

Post by TeoTwawki » Sat Feb 20, 2016 4:39 pm

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.
Hi, I run The Demiurge server.


Image
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
PLS USE [ code ] CODE TAGS [ /code ] WHEN POSTING CODE
DO NOT PRIVATE MESSAGE ME ABOUT BUGS

Avatarati
Posts: 53
Joined: Mon Jun 30, 2014 2:51 pm

Re: Creating a custom augment NPC

Post by Avatarati » Sun Feb 21, 2016 1:26 am

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.

User avatar
TeoTwawki
Developer
Posts: 527
Joined: Mon Jul 15, 2013 9:50 pm

Re: Creating a custom augment NPC

Post by TeoTwawki » Sun Feb 21, 2016 4:58 pm

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
Hi, I run The Demiurge server.


Image
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
PLS USE [ code ] CODE TAGS [ /code ] WHEN POSTING CODE
DO NOT PRIVATE MESSAGE ME ABOUT BUGS

lion85xx
Posts: 17
Joined: Sun Jul 30, 2017 11:03 am

Re: Creating a custom augment NPC

Post by lion85xx » Sat Aug 19, 2017 5:14 am

i have follow all the instruction but my npc don't work plz help

tindin
Posts: 1
Joined: Thu Apr 19, 2018 11:38 pm

Re: Creating a custom augment NPC

Post by tindin » Thu Apr 19, 2018 11:39 pm

any tips on how to get this to work

User avatar
Aale
Posts: 22
Joined: Thu Aug 07, 2014 1:08 pm

Re: Creating a custom augment NPC

Post by Aale » Wed Jun 27, 2018 9:20 pm

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.

Post Reply