• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

addCreatureMaxHealth function

zerghel

Tsuni
Joined
Jul 1, 2008
Messages
299
Reaction score
9
As title says i need addCreatureMaxHealth 'cause setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+1000) is not working properly when a player is wearing a +%hp item. =/
Code:
function onUse(cid, item, frompos, item2, topos)
    if (getPlayerStorageValue(cid, STORAGE) < 1) then
    setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+1000)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your Health Is Now: " .. getCreatureMaxHealth(cid) .. ".")  
    doRemoveItem(item.uid, 1)
    else
      doPlayerSendTextMessage(cid, 22, "can not use it!")
  end
end

the script adds 1000 max hp each use
but adds more than 1000 hp when player is wearing such items on set
example:

armor +23% hp
helmet +23% hp
when using the script adds like 4k hp not 1k as the script says

i dunno how to solve this one but creating this function maybe!
but i'm not a scripter myself =/
 
Last edited:
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getCreatureStorage(cid, STORAGE) < 1) then
		setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + 1000)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your Health Is Now: " .. getCreatureMaxHealth(cid) .. ".")
		doRemoveItem(item.uid, 1)
	else
		doPlayerSendTextMessage(cid, 22, "can not use it!")
	end

	return true
end

I think I know what's happening with it adding "4k" HP: If the formula with those equipped items is "playerHP + 23% of playerHP", then with this script the formula would be "playerHP + 1000 + 23% of playerHP + 1000". Not "playerHP + 1000 + 23% of playerHP".
You could create a script for those items and make it check for an storage, then tweak the formula based on it.
 
Last edited:
may i say again that im not a scripter myself (?)
i use only logic when editing scripts

=(
may i say that i'm using mock's slot system o.o
i can see this in the creaturescript
Code:
--- HP
	conditionHP[i] = createConditionObject(CONDITION_ATTRIBUTES)
	setConditionParam(conditionHP[i], CONDITION_PARAM_TICKS, -1)
	setConditionParam(conditionHP[i], CONDITION_PARAM_STAT_MAXHEALTHPERCENT, 100+i)
	setConditionParam(conditionHP[i], CONDITION_PARAM_BUFF, true)
	setConditionParam(conditionHP[i], CONDITION_PARAM_SUBID, 50)
 
Last edited:
This is logic too :p
In simple words...
Player:
->Has equipped any of those HP adding items: "player HP" + 30% of the "player's HP"
->->Example:
->->->Player current HP is 3000: he equipped the items: HP is now: 3000 + 30% of 3000
->Has equipped any of those HP adding items PLUS triggered this script by using an item, lever or dunno what: ("player HP" + 1000 + 30% of the "player's NEW HP")
->->Example:
->->->Player current HP is 3000: he equipped the items plus activated this script: HP is now: 3000 + 1000 + 30% of 4000

Look carefully at the second case and the example, it's adding more HP since you added more with another method. I did the math, now it's your turn to "solve it". I say "solve it" because IMO it's working like it should (at least that's what I think it's happening by very quick looking at your and Mock's script). But if you really wanna change it it shouldn't be so hard, it's basically adding storages in both scripts (this and Mock's slot system) and a check in Mock's script.
How to verify if it's working as it should: make a player trigger the script and check if it just adds 1000 HP.
 
Last edited:
Back
Top