• 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!

Lua health based attack [Request]

ares413

New Member
Joined
Apr 1, 2010
Messages
130
Reaction score
3
I've been trying to make a spell or weapon that continues to increase in damage AFTER you rebirth

The only way's ive seen it done are by creating a function through source for rebirth.

is there a way to take a percentage of playermaxhp and make it the damage value?



is this possible?

someone please help, ill rep you ++
 
okay well here's the NPC's lua code who sets your storage and gives you rebirth:

LUA:
		if(getPlayerLevel(cid) >= level) then
			if(doPlayerRemoveMoney(cid, cost) == TRUE) then
				if(isInArray({9, 10, 11, 12, 22}, vocation)) then
					doCreatureSetStorage(cid, 85987, storage == -1 and 1 or storage + 1)
					doRemoveCreature(cid)
					db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `promotion` = 0 WHERE `id` ='"..id.."';")
					db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';")
				else
 
SWORD EXAMPLE :

Add this line to your datapack/weapons/weapons.xml (datapack being your server's directory)
LUA:
	<melee id="xxxx" event="script" value="rebirthweapon.lua">
NOTE: CHANGE XXXX to your weapons id!

Create a .lua file and put it in datapack/weapons/scripts/
Name it rebirthweapon.lua

Then add this text into that file :
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)

-- this function is used to determine the damage done on a hit
function onGetFormulaValues(cid, level, skill, attack, element, factor)
    local rebs = getPlayerStorageValue(cid, 85987)
	if rebs < 1 then 
	    rebs = 1
	end -- this if condition must be used , because if it isn't the weapon damage will be 0 on 0 rebirth players
    local formula = ((rebs*xx)*-1) -- change xx to be how much damage you want per rebirth
	return formula/2, formula*1.5
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
-- function ends here

function onUseWeapon(cid, var)
	return doCombat(cid, combat, var)
end
 
SWORD EXAMPLE :

Add this line to your datapack/weapons/weapons.xml (datapack being your server's directory)
LUA:
	<melee id="xxxx" event="script" value="rebirthweapon.lua">
NOTE: CHANGE XXXX to your weapons id!

Create a .lua file and put it in datapack/weapons/scripts/
Name it rebirthweapon.lua

Then add this text into that file :
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)

-- this function is used to determine the damage done on a hit
function onGetFormulaValues(cid, level, skill, attack, element, factor)
    local rebs = getPlayerStorageValue(cid, 85987)
	if rebs < 1 then 
	    rebs = 1
	end -- this if condition must be used , because if it isn't the weapon damage will be 0 on 0 rebirth players
    local formula = ((rebs*xx)*-1) -- change xx to be how much damage you want per rebirth
	return formula/2, formula*1.5
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
-- function ends here

function onUseWeapon(cid, var)
	return doCombat(cid, combat, var)
end

BUMP. Did you test that?? Also, move this thread to requests.
 
Yes, i did test it, it works perfectly, but a few more examples would be so great,

how would i use the same storage to make a command where you can check how many rebirths you have?

also how would i make spells that you can only use at a certain rebirth, that also, the damage goes up with rebirth

i gave you rep, please help me out
 
A- Command to tell you how many rebirths you have. If you type it like this '!rebirths', the script will tell you your own rebirths, if you type it like this '!rebirths Gandalf', the script will tell you how many rebirths has 'Gandalf' done.

1:
Go to datapack/talkactions/talkactions.xml, and add this:
XML:
	<talkaction words="!rebirths" script="rebirthscheck.lua"/>

2:
Go to datapack/talkactions/scripts/, create a new file here and name it 'rebirthscheck.lua', then add to it:
LUA:
function onSay(cid, words, param, channel)
    local tid = 0
    if param == '' then
        tid = cid
    else
        tid = getPlayerByNameWildcard(param)
	if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " not found.")
		return true
	end
    end
    if tid ~= cid then
        doPlayerPopupFYI(cid, "".. param .." has ".. rebirths .." rebirths.")
    else
        doPlayerPopupFYI(cid, "You currently have ".. rebirths .." rebirths.")
    end
    return TRUE
end

As for your second request, I'll do it a little later today. I'm tired now and I have to go to sleep. Good luck and wait for my return.
Zum~
 
Hi Zuma Master, I want to know how exactly your script affect the damage.
If i understood changing xx to 1 add 1 Atk to weapon damage formale and 100 add 100 Atk ?
It's very interesting to add direct damage based on a storage value : )
 

Similar threads

Back
Top