Jump to content
Sign in to follow this  
FapFap

Rep by Mob

Recommended Posts

Can anyone tell me how to make Mobs give Reputation automatically to the character that kill the mobs ( but not 100%, and i want a specified mob not every mob )

Something like this code:

    local dead_id = GetChaID(dead)
    local mob = {}
    mob[103] = {ItemDrop = 5555, Quantity = 1, Quality = 4,  Rate = 0.3}    --30% drop
    if mob[dead_id] ~= nil then
        if Percentage_Random(mob[dead_id].Rate) == 1 then
            GiveItem ( atk, 0, mob[dead_id].ItemDrop, mob[dead_id].Quantity , mob[dead_id].Quality)
        end
    end    


But instead of item i want Reputation to be given to the player, anyone can show me an idea? thanks

Edited by FapFap

Share this post


Link to post
Share on other sites

Inside GetExp_PKM function (exp_and_level.lua) you could add somewhere:

	local atk_fame = GetChaAttr(atk, ATTR_FAME)
	local dead_id = GetChaID(dead)
	local rep_by_mob{}
	rep_by_mob[103]= 1000;
	if mob[dead_id] ~= nil then
		atk_fame = atk_fame + rep_by_mob[dead_id]
		SetCharaAttr(atk_fame, atk, ATTR_FAME) 
	end

in that example the mob id 103 will give the killer 1000 rep.

if you want to add more mobs with their specific ammount of reputation you can just add more

    rep_by_mob[103]= 1000;

where 103 is the character id and 1000 is the reputation.

 

I hope it's clear.

  • Like 3

Share this post


Link to post
Share on other sites

@iZae what if i want a random amount of 10-100 reps to be given from killing mob ( not 100%, not every mob gives rep )
edit: also your code not adding anything

Edited by FapFap

Share this post


Link to post
Share on other sites
3 hours ago, FapFap said:

@iZae what if i want a random amount of 10-100 reps to be given from killing mob ( not 100%, not every mob gives rep )
edit: also your code not adding anything

math.random(10,100)




---*Add Reputation*---

function AddReputationx(role,amount)
local playerReputation = GetChaAttr(role, ATTR_FAME)
playerReputation = playerReputation + amount
SetCharaAttr(playerReputation, role, ATTR_FAME)
SystemNotice(role,"You've recieved "..amount.." reputation! ["..playerReputation.."]")
end

---*exp and level Lua, add in GetExp_New*---
function GetExp_New(dead , atk  ) 

for RepMob = 1 , MonsterRepID_Max , 1 do
            if rolemod_atker == 1 and rolemod_defer == 0 and MonsterID == MonsterRepID[RepMob] then
                local RepBossID = GetChaID(dead)
                local GetKillerName = GetChaDefaultName(atk)
                      
                AddReputationx(GetKillerName, MonsterRep[RepBossID])
                  
                                  
            end
        end
 

--*Variable*--

MonsterRepID_Max = 6
    MonsterRepID = {}                 MonsterRep = {} 

reprand = math.random(10,100) 

reprandz = math.random(50,500)--few examples
    MonsterRepID[1 ]  = 1429        MonsterRep[1429] = reprand        --    Demonic Chest                              
    MonsterRepID[2 ]  = 1430        MonsterRep[1430] = reprand        --    Incubus Chest                              
    MonsterRepID[3 ]  = 1428        MonsterRep[1428] = reprand        --    Nightmare Chest                            
    MonsterRepID[4 ]  = 712         MonsterRep[712] = reprandz            --    Abandoned Chest 1                          
    MonsterRepID[5 ]  = 713         MonsterRep[713] = reprandz           --    Abandoned Chest 2                          
    MonsterRepID[6 ]  = 714         MonsterRep[714] = reprandz            --    Abandoned Chest 3                          
  

--not tested but used on my other stuff. 

Edited by Onioni

Download: Nightmare Demonic Helm

Dimension Pirates Online files: get now

New map Project: Flag PK

Black Skin 3.1.3 for pko 1: Get now

Share this post


Link to post
Share on other sites
3 hours ago, FapFap said:

@iZae what if i want a random amount of 10-100 reps to be given from killing mob ( not 100%, not every mob gives rep )
edit: also your code not adding anything

could you paste your whole script?

Share this post


Link to post
Share on other sites

@Stinger Hey, thanks alot, check out the code i posted on top, it works fine but if i add for ex: Tree or Iron Ore, even if i make the % 100% after cutting the tree i dont get the item directly on invertory

Share this post


Link to post
Share on other sites
1 hour ago, FapFap said:

@Stinger Hey, thanks alot, check out the code i posted on top, it works fine but if i add for ex: Tree or Iron Ore, even if i make the % 100% after cutting the tree i dont get the item directly on invertory

maybe you could check on how resources work, as trees / iron ore seems to drop items everytime its cut, not when it dies like monsters.

Share this post


Link to post
Share on other sites
On 8/25/2018 at 9:12 PM, Onioni said:

math.random(10,100)




---*Add Reputation*---

function AddReputationx(role,amount)
local playerReputation = GetChaAttr(role, ATTR_FAME)
playerReputation = playerReputation + amount
SetCharaAttr(playerReputation, role, ATTR_FAME)
SystemNotice(role,"You've recieved "..amount.." reputation! ["..playerReputation.."]")
end

---*exp and level Lua, add in GetExp_New*---
function GetExp_New(dead , atk  ) 

for RepMob = 1 , MonsterRepID_Max , 1 do
            if rolemod_atker == 1 and rolemod_defer == 0 and MonsterID == MonsterRepID[RepMob] then
                local RepBossID = GetChaID(dead)
                local GetKillerName = GetChaDefaultName(atk)
                      
                AddReputationx(GetKillerName, MonsterRep[RepBossID])
                  
                                  
            end
        end
 

--*Variable*--

MonsterRepID_Max = 6
    MonsterRepID = {}                 MonsterRep = {} 

reprand = math.random(10,100) 

reprandz = math.random(50,500)--few examples
    MonsterRepID[1 ]  = 1429        MonsterRep[1429] = reprand        --    Demonic Chest                              
    MonsterRepID[2 ]  = 1430        MonsterRep[1430] = reprand        --    Incubus Chest                              
    MonsterRepID[3 ]  = 1428        MonsterRep[1428] = reprand        --    Nightmare Chest                            
    MonsterRepID[4 ]  = 712         MonsterRep[712] = reprandz            --    Abandoned Chest 1                          
    MonsterRepID[5 ]  = 713         MonsterRep[713] = reprandz           --    Abandoned Chest 2                          
    MonsterRepID[6 ]  = 714         MonsterRep[714] = reprandz            --    Abandoned Chest 3                          
  

--not tested but used on my other stuff. 

This code is in functions.lua?

 

---*Add Reputation*---

function AddReputationx(role,amount)
local playerReputation = GetChaAttr(role, ATTR_FAME)
playerReputation = playerReputation + amount
SetCharaAttr(playerReputation, role, ATTR_FAME)
SystemNotice(role,"You've recieved "..amount.." reputation! ["..playerReputation.."]")
end

 

 

Share this post


Link to post
Share on other sites

Hello @V1k1NGO!
 

Yes, you can place this code to file functions.lua and it should work.


Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...