Apoccalypse
New Member
- Joined
- Apr 15, 2017
- Messages
- 114
- Solutions
- 2
- Reaction score
- 4
Hello community,
I am trying to create an item which gives higher exp rate and gives some protection , but only from monsters (this is why I can not use this " <attribute key="absorbPercentAll" value="5" />" to get some damage reduction.
I have two scripts.
It is working one for the rising an expirience.
To get some reduction I found at this forum this script.
Now I have to combine them but I have no idea how to achive this.
I know that I totally do not need a function OnEquiped from the first script. I was thinking about putting an experience part from the first script to the second one,but I can not manage it.
Anyone could help?
So from the beggining:
I want to achive three effects for the one item contained in the script.
1.Changing its apperance when equiped and un-equiped.
2.Boost of experience for the owner of the item.
3.Reduction of the damage only from monsters.
I 've made something like this:
So to the first script I added a part "registerCreatureEvent(cid,"Reduction").
Then I registered event in creaturescript.
And added a script:
I don't get any errors but unfortunately the event "Reduction" isn't working.
So presently I achieved for the item effects 1 and 2.
I suppose that a mistake can be somewhere in the Reduction.lua or the event is not trigerred, because when I equip the item I only get message (Your experience is now....) from the first script but I do not get any message from the event script ("MonsterName" dealt ....)
I totally do not understand what it is exactly in Reduction.lua script :
-----> Local storage= 815870 (what is this number?)
-----> if isCreature(attacker) and isPlayer(target) and (type == 1 or type == 3) then (What are these "type==1 and type==3" ?)
-----> if getPlayerStorageValue(target,storage) ~= 1 then
return false (Why is here "return false" ?)
If anyone could help to solve this problem that would be great
Bump
Up
I am trying to create an item which gives higher exp rate and gives some protection , but only from monsters (this is why I can not use this " <attribute key="absorbPercentAll" value="5" />" to get some damage reduction.
I have two scripts.
It is working one for the rising an expirience.
local config = {
rate = 1.25, -- 25% faster than normal.
un_equip = 10310, -- Item ID of the UN-Equipped ring.
equip = 10309, -- Item ID of the Equipped ring.
}
function onDeEquip(cid, item, slot)
doPlayerSetExperienceRate(cid, 1.0)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has ended.")
doTransformItem(item.uid, config.un_equip)
return true
end
function onEquip(cid, item, slot)
if getConfigValue("experienceStages") == "yes" then
doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid))*1.25)
else
doPlayerSetExperienceRate(cid, getConfigValue("rateExperience")*1.25)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate is now " .. config.rate .. "x doubled your former experience rate.")
doTransformItem(item.uid, config.equip)
doDecayItem(item.uid)
return true
end
rate = 1.25, -- 25% faster than normal.
un_equip = 10310, -- Item ID of the UN-Equipped ring.
equip = 10309, -- Item ID of the Equipped ring.
}
function onDeEquip(cid, item, slot)
doPlayerSetExperienceRate(cid, 1.0)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has ended.")
doTransformItem(item.uid, config.un_equip)
return true
end
function onEquip(cid, item, slot)
if getConfigValue("experienceStages") == "yes" then
doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid))*1.25)
else
doPlayerSetExperienceRate(cid, getConfigValue("rateExperience")*1.25)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate is now " .. config.rate .. "x doubled your former experience rate.")
doTransformItem(item.uid, config.equip)
doDecayItem(item.uid)
return true
end
To get some reduction I found at this forum this script.
local reduction = 70 --this means that the damage is reduced by 70%
local storage = 815870 --the storage value used
function onStatsChange(target, attacker, type, combat, value)
if isCreature(attacker) and isPlayer(target) and (type == 1 or type == 3) then
if getPlayerStorageValue(target,storage) ~= 1 then
return false,doCreatureAddHealth(target,-value*(1-(reduction/100))), doPlayerSendTextMessage(target,MESSAGE_EVENT_DEFAULT, getCreatureName(attacker).. " dealt " ..value*(1-(reduction/100)).. " damage to you!"),setPlayerStorageValue(target,storage,1)
else
setPlayerStorageValue(target,storage,0)
end
end
return true
end
local storage = 815870 --the storage value used
function onStatsChange(target, attacker, type, combat, value)
if isCreature(attacker) and isPlayer(target) and (type == 1 or type == 3) then
if getPlayerStorageValue(target,storage) ~= 1 then
return false,doCreatureAddHealth(target,-value*(1-(reduction/100))), doPlayerSendTextMessage(target,MESSAGE_EVENT_DEFAULT, getCreatureName(attacker).. " dealt " ..value*(1-(reduction/100)).. " damage to you!"),setPlayerStorageValue(target,storage,1)
else
setPlayerStorageValue(target,storage,0)
end
end
return true
end
Now I have to combine them but I have no idea how to achive this.
I know that I totally do not need a function OnEquiped from the first script. I was thinking about putting an experience part from the first script to the second one,but I can not manage it.
Anyone could help?
So from the beggining:
I want to achive three effects for the one item contained in the script.
1.Changing its apperance when equiped and un-equiped.
2.Boost of experience for the owner of the item.
3.Reduction of the damage only from monsters.
I 've made something like this:
<movevent type="Equip" itemid="10309" slot="ammo" event="function" value="onEquipItem"/>
<movevent type="Equip" itemid="10310" slot="ammo" event="script" value="FireHand.lua"/>
<movevent type="DeEquip" itemid="10309" slot="ammo" event="script" value="FireHand.lua"/>
<movevent type="Equip" itemid="10310" slot="ammo" event="script" value="FireHand.lua"/>
<movevent type="DeEquip" itemid="10309" slot="ammo" event="script" value="FireHand.lua"/>
local config = {
rate = 2.0, -- 2.0 = 2x faster than normal.
un_equip = 10310, -- Item ID of the UN-Equipped ring.
equip = 10309, -- Item ID of the Equipped ring.
}
function onDeEquip(cid, item, slot)
doPlayerSetExperienceRate(cid, 1.0)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has ended.")
doTransformItem(item.uid, config.un_equip)
return true
end
function onEquip(cid, item, slot)
if getConfigValue("experienceStages") == "yes" then
doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid))*2)
registerCreatureEvent(cid,"Reduction")
else
doPlayerSetExperienceRate(cid, getConfigValue("rateExperience")*2)
registerCreatureEvent(cid,"Reduction")
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate is now " .. config.rate .. "x doubled your former experience rate.")
doTransformItem(item.uid, config.equip)
doDecayItem(item.uid)
return true
end
rate = 2.0, -- 2.0 = 2x faster than normal.
un_equip = 10310, -- Item ID of the UN-Equipped ring.
equip = 10309, -- Item ID of the Equipped ring.
}
function onDeEquip(cid, item, slot)
doPlayerSetExperienceRate(cid, 1.0)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has ended.")
doTransformItem(item.uid, config.un_equip)
return true
end
function onEquip(cid, item, slot)
if getConfigValue("experienceStages") == "yes" then
doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid))*2)
registerCreatureEvent(cid,"Reduction")
else
doPlayerSetExperienceRate(cid, getConfigValue("rateExperience")*2)
registerCreatureEvent(cid,"Reduction")
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate is now " .. config.rate .. "x doubled your former experience rate.")
doTransformItem(item.uid, config.equip)
doDecayItem(item.uid)
return true
end
So to the first script I added a part "registerCreatureEvent(cid,"Reduction").
Then I registered event in creaturescript.
<event type="statschange" name="Reduction" event="script" value="Reduction.lua"/>
And added a script:
local reduction = 90 --this means that the damage is reduced by 90%
local storage = 815870 --the storage value used
function onStatsChange(target, attacker, type, combat, value)
if isCreature(attacker) and isPlayer(target) and (type == 1 or type == 3) then
if getPlayerStorageValue(target,storage) ~= 1 then
return false,doCreatureAddHealth(target,-value*(1-(reduction/100))), doPlayerSendTextMessage(target,MESSAGE_EVENT_DEFAULT, getCreatureName(attacker).. " dealt " ..value*(1-(reduction/100)).. " damage to you!"),setPlayerStorageValue(target,storage,1)
else
setPlayerStorageValue(target,storage,0)
end
end
return true
end
local storage = 815870 --the storage value used
function onStatsChange(target, attacker, type, combat, value)
if isCreature(attacker) and isPlayer(target) and (type == 1 or type == 3) then
if getPlayerStorageValue(target,storage) ~= 1 then
return false,doCreatureAddHealth(target,-value*(1-(reduction/100))), doPlayerSendTextMessage(target,MESSAGE_EVENT_DEFAULT, getCreatureName(attacker).. " dealt " ..value*(1-(reduction/100)).. " damage to you!"),setPlayerStorageValue(target,storage,1)
else
setPlayerStorageValue(target,storage,0)
end
end
return true
end
I don't get any errors but unfortunately the event "Reduction" isn't working.
So presently I achieved for the item effects 1 and 2.
I suppose that a mistake can be somewhere in the Reduction.lua or the event is not trigerred, because when I equip the item I only get message (Your experience is now....) from the first script but I do not get any message from the event script ("MonsterName" dealt ....)
I totally do not understand what it is exactly in Reduction.lua script :
-----> Local storage= 815870 (what is this number?)
-----> if isCreature(attacker) and isPlayer(target) and (type == 1 or type == 3) then (What are these "type==1 and type==3" ?)
-----> if getPlayerStorageValue(target,storage) ~= 1 then
return false (Why is here "return false" ?)
If anyone could help to solve this problem that would be great
Bump
Up
Last edited by a moderator: