Never mind, I was able to do it using a change of player experience after killing monster. I do not believe that I came to this. xDJ. M. Sower wrote:Apart from that I was trying to write a script that changes reputation after killing the monster of the chosen group. Unfortunately, I was able to only partially achieved. This script works well , but also works when a monster is killed by another monster, and I want it to work only when a player kills him. GrayFace, can you help?
Below is a complete script for those who are interested.
Code: Select all
local function getexp()
RemoveTimer(getexp)
vars.ParExp = 0 -- Does the team has gained experience; 0 - no, 1 - yes
if Party.Count == 1 then
if Party[0].Experience > vars.ParExp0 then
vars.ParExp = 1
end
vars.ParExp0 = Party[0].Experience
end
if Party.Count == 2 then
if (Party[0].Experience > vars.ParExp0 or Party[1].Experience > vars.ParExp1) then
vars.ParExp = 1
end
vars.ParExp0 = Party[0].Experience
vars.ParExp1 = Party[1].Experience
end
if Party.Count == 3 then
if (Party[0].Experience > vars.ParExp0 or Party[1].Experience > vars.ParExp1 or Party[2].Experience > vars.ParExp2) then
vars.ParExp = 1
end
vars.ParExp0 = Party[0].Experience
vars.ParExp1 = Party[1].Experience
vars.ParExp2 = Party[2].Experience
end
if Party.Count == 4 then
if (Party[0].Experience > vars.ParExp0 or Party[1].Experience > vars.ParExp1 or Party[2].Experience > vars.ParExp2 or Party[3].Experience > vars.ParExp3) then
vars.ParExp = 1
end
vars.ParExp0 = Party[0].Experience
vars.ParExp1 = Party[1].Experience
vars.ParExp2 = Party[2].Experience
vars.ParExp3 = Party[3].Experience
end
if Party.Count == 5 then
if (Party[0].Experience > vars.ParExp0 or Party[1].Experience > vars.ParExp1 or Party[2].Experience > vars.ParExp2 or Party[3].Experience > vars.ParExp3 or Party[4].Experience > vars.ParExp4) then
vars.ParExp = 1
end
vars.ParExp0 = Party[0].Experience
vars.ParExp1 = Party[1].Experience
vars.ParExp2 = Party[2].Experience
vars.ParExp3 = Party[3].Experience
vars.ParExp4 = Party[4].Experience
end
if vars.ParExp == 1 then
if vars.gr == 38 then -- if killed monster was in 38 group
-- change of reputations:
vars.repa = vars.repa - 1 -- Sun
vars.repb = vars.repb + 2 -- Moon
vars.repc = vars.repc - 1 -- Karigor
vars.repd = vars.repd - 0.2 -- Dwarfs
vars.repe = vars.repe + 2 -- Necro
vars.repg = vars.repg + 1 -- Pirates
vars.reph = vars.reph - 0.2 -- Vori
end
vars.ParExp = 0
end
end
function events.MonsterKilled(index, callDef)
if Party.Count == 1 then
vars.ParExp0 = Party[0].Experience
end
if Party.Count == 2 then
vars.ParExp0 = Party[0].Experience
vars.ParExp1 = Party[1].Experience
end
if Party.Count == 3 then
vars.ParExp0 = Party[0].Experience
vars.ParExp1 = Party[1].Experience
vars.ParExp2 = Party[2].Experience
end
if Party.Count == 4 then
vars.ParExp0 = Party[0].Experience
vars.ParExp1 = Party[1].Experience
vars.ParExp2 = Party[2].Experience
vars.ParExp3 = Party[3].Experience
end
if Party.Count == 5 then
vars.ParExp0 = Party[0].Experience
vars.ParExp1 = Party[1].Experience
vars.ParExp2 = Party[2].Experience
vars.ParExp3 = Party[3].Experience
vars.ParExp4 = Party[4].Experience
end
if index.Group == 0 then -- if killed monster was in 0 group
vars.gr = 0
--SimpleMessage("" .. index.Group .. "") -- shows the group number
end
if index.Group == 38 then -- if killed monster was in 38 group
vars.gr = 38
Timer(getexp, 1, true)
end
end
function events.ExitNPC(i) -- When you done talking with NPC in House - this is because quests also add experience
if Party.Count == 1 then
vars.ParExp0 = Party[0].Experience
end
if Party.Count == 2 then
vars.ParExp0 = Party[0].Experience
vars.ParExp1 = Party[1].Experience
end
if Party.Count == 3 then
vars.ParExp0 = Party[0].Experience
vars.ParExp1 = Party[1].Experience
vars.ParExp2 = Party[2].Experience
end
if Party.Count == 4 then
vars.ParExp0 = Party[0].Experience
vars.ParExp1 = Party[1].Experience
vars.ParExp2 = Party[2].Experience
vars.ParExp3 = Party[3].Experience
end
if Party.Count == 5 then
vars.ParExp0 = Party[0].Experience
vars.ParExp1 = Party[1].Experience
vars.ParExp2 = Party[2].Experience
vars.ParExp3 = Party[3].Experience
vars.ParExp4 = Party[4].Experience
end
end