• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 0.3.4pl2 Movements

Rooteh

New Member
Joined
Jul 24, 2008
Messages
95
Reaction score
0
Addmana.lua
Code:
function onEquip(cid, item, slot)
	if item.actionid == 2222 then
		setCreatureMaxMana(cid, getCreatureMaxMana(cid)+100)
	end
	return true
end

removemana.lua
Code:
function onDeEquip(cid, item, slot)
	if item.actionid == 2222 then
			setCreatureMaxMana(cid, getCreatureMaxMana(cid)-100)
	end
	return true
end

movements.xml
Code:
	<movevent type="Equip" itemid="2465" slot="armor" event="script" value="addmana.lua"/>
	<movevent type="DeEquip" itemid="2465" slot="armor" event="script" value="removemana.lua"/>

Does anyone know why this doesn't work? It adds mana, but when you take off the armor it doesn't remove the mana.

Or.. Could you just explain to me how you use a script for an item on equip / deequip?
 
Addmana.lua
Code:
function onEquip(cid, item, slot)
	if item.actionid == 2222 then
		setCreatureMaxMana(cid, getCreatureMaxMana(cid)+100)
	end
	return true
end

removemana.lua
Code:
function onDeEquip(cid, item, slot)
	if item.actionid == 2222 then
			setCreatureMaxMana(cid, getCreatureMaxMana(cid)-100)
	end
	return true
end

movements.xml
Code:
	<movevent type="Equip" itemid="2465" slot="armor" event="script" value="addmana.lua"/>
	<movevent type="DeEquip" itemid="2465" slot="armor" event="script" value="removemana.lua"/>

Does anyone know why this doesn't work? It adds mana, but when you take off the armor it doesn't remove the mana.

Or.. Could you just explain to me how you use a script for an item on equip / deequip?


Uhm, quick explanation.

You have this:
Code:
	<movevent type="Equip" itemid="2465" slot="armor" event="script" [COLOR="Red"]value="addmana.lua"/[/COLOR]>
	<movevent type="DeEquip" itemid="2465" slot="armor" event="script" [COLOR="Red"]value="removemana.lua"[/COLOR]/>

What you want is:
Code:
	<movevent type="Equip" itemid="2465" slot="armor" event="script" [COLOR="Red"]value="mana.lua"/[/COLOR]>
	<movevent type="DeEquip" itemid="2465" slot="armor" event="script" [COLOR="Red"]value="mana.lua"[/COLOR]/>

They both need to read from the same script. So change your script to mana.lua then
Add:
Lua:
local mana = 100 --Amount you want added
function onEquip(cid, item, slot)
	if item.actionid == 2222 then
		setCreatureMaxMana(cid, (getCreatureMaxMana(cid)+mana))
	return true
        end
end

function onDeEquip(cid, item, slot)
	if item.actionid == 2222 then
			setCreatureMaxMana(cid, (getCreatureMaxMana(cid)-mana))
	return true
        end
end

If you want to make the script available for more armor, just do this:

Lua:
function onEquip(cid, item, slot)
	local mana = (item.actionid - 1000)
	if item.actionid == 1100 then
		setCreatureMaxMana(cid, (getCreatureMaxMana(cid)+mana))
        return true	
        end
end

function onDeEquip(cid, item, slot)
local mana = (item.actionid - 1000)
	if item.actionid == 1100 then
			setCreatureMaxMana(cid, (getCreatureMaxMana(cid)-mana))
        return true	
        end
end

That way whatever you have as the item.action id, it will take away 1000, then add that to their mana.
 
Last edited:
@edit
Omg, Dilio was faster :D

But if it won't work, try:
Code:
function onDeEquip(cid, item, slot)
	local maxMana = getCreatureMaxMana(cid)
	if(item.actionid == 2222) then
		setCreatureMaxMana(cid, maxMana - 100)
		doPlayerAddMana(cid, -100)
	end
	return TRUE
end
I think that when it sets max mana it does not remove mana, so player (for example). has 1100/1000 mana :f.
 
Dilio joined June 2008,
No rep bars, good scripter...

Where'd you go?
where'd you come from? :cool:
 
For some reason, while putting on the armor it adds 200 mana instead of 100.

Then, when I take off the armor it does not remove the 100 mana.



That is why I split the scripts.

Code:
  local mana = 100 --Amount you want added
function onEquip(cid, item, slot)
        if item.actionid == 2222 then
                setCreatureMaxMana(cid, (getCreatureMaxMana(cid)+mana))
        end
        return true
end

function onDeEquip(cid, item, slot)
        if item.actionid == 2222 then
                        setCreatureMaxMana(cid, (getCreatureMaxMana(cid)-mana))
						doPlayerAddMana(cid, -mana)
        end
        return true
end

Code:
		<movevent type="Equip" itemid="2465" slot="armor" event="script" value="mana.lua"/>
	<movevent type="DeEquip" itemid="2465" slot="armor" event="script" value="mana.lua"/>

Just to clarify.. When I start the test I have 345 max mana. I put the armor on and have 345 current mana and 545 max mana.

I take the armor off, and now I have 245 current mana and 545 max mana.
 
For some reason, while putting on the armor it adds 200 mana instead of 100.

Then, when I take off the armor it does not remove the 100 mana.



That is why I split the scripts.

Code:
  local mana = 100 --Amount you want added
function onEquip(cid, item, slot)
        if item.actionid == 2222 then
                setCreatureMaxMana(cid, (getCreatureMaxMana(cid)+mana))
        end
        return true
end

function onDeEquip(cid, item, slot)
        if item.actionid == 2222 then
                        setCreatureMaxMana(cid, (getCreatureMaxMana(cid)-mana))
						doPlayerAddMana(cid, -mana)
        end
        return true
end

Code:
		<movevent type="Equip" itemid="2465" slot="armor" event="script" value="mana.lua"/>
	<movevent type="DeEquip" itemid="2465" slot="armor" event="script" value="mana.lua"/>

Just to clarify.. When I start the test I have 345 max mana. I put the armor on and have 345 current mana and 545 max mana.

I take the armor off, and now I have 245 current mana and 545 max mana.

Fixed the script in my first post, it should work now. :)
 
Easy... go to your items.xml... find your item, add this:
PHP:
<attribute key="maxmanapercent" value="105"/>
Now go to your movements.xml and add this:
PHP:
	<movevent type="Equip" itemid="ID" slot="armor" event="function" value="onEquipItem"/>
	<movevent type="DeEquip" itemid="ID" slot="armor" event="function" value="onDeEquipItem"/>

It will add 5% more of HP.
 
Code:
  local mana = 100 --Amount you want added
function onEquip(cid, item, slot)
        if item.actionid == 2222 then
                setCreatureMaxMana(cid, (getCreatureMaxMana(cid)+mana))
        return true
        end
end

function onDeEquip(cid, item, slot)
        if item.actionid == 2222 then
                        setCreatureMaxMana(cid, (getCreatureMaxMana(cid)-mana))
        return true
        end
end

Code:
<movevent type="Equip" itemid="2465" slot="armor" event="script" value="mana.lua"/>
	<movevent type="DeEquip" itemid="2465" slot="armor" event="script" value="mana.lua"/>

Before I start the test, I have 445 max mana and 445 current mana. I put the armor on and have 645 max mana and 445 current mana.

I take the armor off and have 545 max mana and 445 current mana. Any ideas?

@the post above.. It isn't that easy. I am just using add mana as an example. I just can't get the script to work for obvious reasons and have larger plans, such as requiring a player to wear a whole set to receive a benefit (Extra mana, hp, skills) etc.
 
Code:
function onEquip(cid, item, slot)
local maxMana = getCreatureMaxMana(cid)
    if(item.itemid == 2465) then
        setCreatureMaxMana(cid, maxMana+100)
        doPlayerAddMana(cid, 100)
    end
    return TRUE
end

function onDeEquip(cid, item, slot)
local maxMana = getCreatureMaxMana(cid)
    if(item.itemid == 2465) then
        setCreatureMaxMana(cid, maxMana-100)
        doPlayerAddMana(cid, -100)
    end
    return TRUE
end

I had to add a + to line 4

[08/07/2009 19:55:39] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/mana.lua)
[08/07/2009 19:55:39] data/movements/scripts/mana.lua:4: ')' expected near '100'

BanditOT - Latest News if you want to log on and test it.
 
Last edited:
Wait, are you sure it didn't work?
I will keep editing the above post.

Edited again -- Try it now.
 
Last edited:
Easy... go to your items.xml... find your item, add this:
PHP:
<attribute key="maxmanapercent" value="105"/>
Now go to your movements.xml and add this:
PHP:
	<movevent type="Equip" itemid="ID" slot="armor" event="function" value="onEquipItem"/>
	<movevent type="DeEquip" itemid="ID" slot="armor" event="function" value="onDeEquipItem"/>

It will add 5% more of HP.

Keep thinking that it is the better xD
 
[08/07/2009 19:58:42] Lua Script Error: [MoveEvents Interface]
[08/07/2009 19:58:42] data/movements/scripts/mana.lua:eek:nEquip

[08/07/2009 19:58:42] luaSetCreatureMaxMana(). Creature not found


I guess I could always just do something like this.. but this is bugging the hell out of me lol.

Code:
function onEquip(cid, item, slot)
local maxMana = getCreatureMaxMana(cid)
    if(item.itemid == 2465) then
        setCreatureMaxMana(cid, maxMana+50)
        doPlayerAddMana(cid, 50)
    end
    return TRUE
end

function onDeEquip(cid, item, slot)
local maxMana = getCreatureMaxMana(cid)
    if(item.itemid == 2465) then
        setCreatureMaxMana(cid, maxMana-100)
        doPlayerAddMana(cid, -100)
    end
    return TRUE
end
 
Last edited:
Edit 3

Same thing. At start mana is 445 and max is 445. Put it on mana is 445 max is 645. Take it off mana is 445 max is 545.

Edit 4
Dont worry about it man. I can just do addmana/2 for the equip and addmana for the deequip. I didn't think of that before. But if you happen to find another solution, I would be happy if you pm'd me.
 
Last edited:
[08/07/2009 20:05:29] Lua Script Error: [MoveEvents Interface]
[08/07/2009 20:05:29] data/movements/scripts/mana.lua:eek:nEquip

[08/07/2009 20:05:29] luaSetCreatureMaxMana(). Creature not found


Can no longer put the armor on. "You can not dress this object there"

Editing the post above.
Watch for changes.
 
Back
Top