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

[Creaturescript] Invincible monster (endless HP loop / stays at 1HP)

Ratser

Retired // Making time for yoloswagmod
Joined
Feb 11, 2009
Messages
482
Reaction score
36
Two requests:
  1. A script that cures completely the HP of a monster if it goes to 0.
  2. A script that makes a monster's HP stay in 1. It can be cured and you can continue to attack it but its HP may never fall to 0.
 
Last edited:
smells like pets

1st
Lua:
local monsters = {'troll','sheep','bat'}

function onStatsChange(cid, attacker, type, combat, value)
    if isMonster(cid) and isCreature(attacker) and isInArray(monsters, getCreatureName(cid):lower()) and combat ~= COMBAT_HEALING or type == STATSCHANGE_HEALTHLOSS then
        if value >= getCreatureHealth(cid) then
            doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
            doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
            return false
        end
    end
    return true
end

2nd
Lua:
local monsters = {'troll','sheep','bat'}

function onStatsChange(cid, attacker, type, combat, value)
    if isMonster(cid) and isCreature(attacker) and isInArray(monsters, getCreatureName(cid):lower()) and combat ~= COMBAT_HEALING or type == STATSCHANGE_HEALTHLOSS then
        if value >= getCreatureHealth(cid) then
            doCreatureAddHealth(cid, -getCreatureMaxHealth(cid)+1)
            return false
        end
    end
    return true
end

Lua:
<event type="statschange" name="first" event="script" value="first.lua"/>
<event type="statschange" name="second" event="script" value="second.lua"/>

inside monster's xml file
Lua:
	<script>
		<event name="first"/> 
	</script>

Lua:
	<script>
		<event name="second"/> 
	</script>
 
The first script worked well. The second script half worked...the monster's HP stays in 1 but there's an error in console:
Code:
06/08/2010 13:58:27] [Error - CreatureEvent::executeStatsChange] Call stack overflow.

P.D. A simple question: How does the Target Dummies HP work?
 
Last edited:
Last edited:
Try
Code:
local monsters = {'troll','sheep','bat'}

function onStatsChange(cid, attacker, type, combat, value)
    if isMonster(cid) and isCreature(attacker) and isInArray(monsters, getCreatureName(cid):lower()) and combat ~= COMBAT_HEALING or type == STATSCHANGE_HEALTHLOSS then
        if value > getCreatureHealth(cid) then
            doCreatureAddHealth(cid, -getCreatureHealth(cid)+1)
            return false
        end
    end
    return true
end
 
Didn't work...now the monster died.

EDIT: I think I fixed it:
Code:
local monsters = {'target dummy'}

function onStatsChange(cid, attacker, type, combat, value)
	if isMonster(cid) and isCreature(attacker) and isInArray(monsters, getCreatureName(cid):lower()) and combat ~= COMBAT_HEALING or type == STATSCHANGE_HEALTHLOSS then
		if value >= getCreatureHealth(cid) then
			doCreatureAddHealth(cid, -getCreatureHealth(cid)+1)
		return false
		end
	end
	return true
end

EDIT2: Yeah it's fixed. Kthx everyone.
 
Last edited:
Back
Top