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

[Spell/Talkaction] Absorbing Shield

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,839
Solutions
18
Reaction score
618
Location
Poland
Hello.
I have request for godlike scripters.

I wanna make a spell or talkactions for vocations: 3,4 .

If player run spell (sayed spell words) then player active Absorbing Shield on him for 2 minutes.

Absorbing Shield (spell) attributes:
- Shield protects player from ALL hits done by player/monster (miss/puffs hits)
- If player/monster hit more than player have HP, they broke the absorb shield
- Player spends 10 mana points per seconds after 0 mana player lost the shield
- If player have Absorb shield ON, he have magic effect = 88 on him (all the time)
- Exhausted for this spell is 5 minutes.


Anyone can make it ?:thumbup:
 
Last edited:
Bump. Somebody ? Cykotitan ? JDB ? Anyone ;O
Where is me =/
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Shield" author="C" enabled="yes">	
	<config name="shield_setup">
		<![CDATA[
			storage = 23142
			vocations = {3,4}
			spentMana = 10
			time = 2 * 60 * 1000
			condition = createConditionObject(CONDITION_INFIGHT)
			setConditionParam(condition, CONDITION_PARAM_TICKS, time)
			
			function doFinish(cid)
				return isPlayer(cid) and stopEvent(event1) and doPlayerSetStorageValue(cid, storage, 0)
			end
			
			function doWaste(cid)
				if isPlayer(cid) then
					if getCreatureMana(cid) >= spentMana then 	
						doCreatureAddMana(cid, -spentMana) 
						doSendMagicEffect(getThingPos(cid), CONST_ME_LOSEENERGY)
						event1 = addEvent(doWaste, 1000, cid)
					else
						stopEvent(event2)
						doPlayerSetStorageValue(cid, storage, 0)
						doPlayerSendCancel(cid, 'Your shield has worn out.')
					end
				end	
			end
		]]>
	</config>
		   
	<event type="login" name="shield2" event="script">
		<![CDATA[
			domodlib('shield_setup')
			function onLogin(cid)
				registerCreatureEvent(cid, "shield3")
				doPlayerSetStorageValue(cid, storage, 0)
				return true
			end
		]]>	
	</event>
		
	<event type="statschange" name="shield3" event="script">
		<![CDATA[
			domodlib('shield_setup')
			function onStatsChange(cid, attacker, type, combat, value)
				if isInArray(vocations, getPlayerVocation(cid)) and combat ~= COMBAT_HEALING and isCreature(attacker) and getPlayerStorageValue(cid, storage) > 0 then
					if math.abs(value) > getCreatureHealth(cid) then
						stopEvent(event1)
						stopEvent(event2)
						doSendAnimatedText(getThingPos(cid), TEXTCOLOR_DARKORANGE, 'BREAK')
						doPlayerSendCancel(cid, 'Your shield was broken!')
						doPlayerSetStorageValue(cid, storage, 0)
						return true
					else
						return false
					end
				end
				return true
			end
		]]>
	</event>
			 
	<instant name="Absorb Shield" words="utamo gran" lvl="40" mana="100" soul="5" exhaustion="30000" event="script">
		<text>
			<![CDATA[
				domodlib('shield_setup')
				function onCastSpell(cid, var)
					if getPlayerStorageValue(cid, storage) > 0 then
						doPlayerSendCancel(cid,'Your shield is still active.')
						return false
					end
		   
					doAddCondition(cid, condition)
					doPlayerSetStorageValue(cid, storage, 1)
					event1 = addEvent(doWaste, 1000, cid)
					event2 = addEvent(doFinish, time, cid)
					doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
					doPlayerSendCancel(cid,'You have just enabled shield for 2 minutes.')
					return true
				end
			]]>
		</text>
		<vocation id="3;4"/>
	</instant>
</mod>
dunno why "If player/monster hit more than player have HP, they broke the absorb shield" part is not working =/
 
this is part that should work but doesn't =/
Code:
if math.abs(value) > getCreatureHealth(cid) then
    stopEvent(event1)
    stopEvent(event2)
    doSendAnimatedText(getThingPos(cid), TEXTCOLOR_DARKORANGE, 'BREAK')
    doPlayerSendCancel(cid, 'Your shield was broken!')
    doPlayerSetStorageValue(cid, storage, 0)
    return true
 
Maybe

if math.abs(value) >= getCreatureHealth(cid) then
stopEvent(event1)
stopEvent(event2)
doSendAnimatedText(getThingPos(cid), TEXTCOLOR_DARKORANGE, 'BREAK')
doPlayerSendCancel(cid, 'Your shield was broken!')
doPlayerSetStorageValue(cid, storage, 0)
return true
 
Here is a little fix , this should work to break shield , and send you the amount you absorbed to check if really shield break if hitpoint is more than player health
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Shield" author="C" enabled="yes">	
	<config name="shield_setup">
		<![CDATA[
			storage = 212123
			vocations = {2,3,4}
			spentMana = 1
			time = 10 -- in minutes
			condition = createConditionObject(CONDITION_INFIGHT)
			setConditionParam(condition, CONDITION_PARAM_TICKS, time*60*1000)
 
			function doFinish(cid)
				if isPlayer(cid) and getPlayerStorageValue(cid,storage) > 0 then
					return doPlayerSetStorageValue(cid, storage, 0)
				end
			end
 
			function doWaste(cid)
				if isPlayer(cid) then
					if getPlayerStorageValue(cid,storage) > 0 then
						if getCreatureMana(cid) >= spentMana then 	
							doCreatureAddMana(cid, -spentMana) 
							doSendMagicEffect(getThingPos(cid), CONST_ME_LOSEENERGY)
							addEvent(doWaste, 1000, cid)
						else
							doPlayerSetStorageValue(cid, storage, 0)
							doPlayerSendCancel(cid, 'Your shield has worn out.')
						end
					end	
				end
			end
		]]>
	</config>
 
	<event type="login" name="shield2" event="script">
		<![CDATA[
			domodlib('shield_setup')
			function onLogin(cid)
				registerCreatureEvent(cid, "shield3")
				doPlayerSetStorageValue(cid, storage, 0)
				return true
			end
		]]>	
	</event>
 
	<event type="statschange" name="shield3" event="script">
		<![CDATA[
			domodlib('shield_setup')
			function onStatsChange(cid, attacker, type, combat, value)
				if isPlayer(cid) and getPlayerStorageValue(cid, storage) > 0 then
					if isInArray(vocations, getPlayerVocation(cid)) and combat ~= COMBAT_HEALING and isCreature(attacker) then 
						if value >= getCreatureHealth(cid) then
							doSendAnimatedText(getThingPos(cid), TEXTCOLOR_DARKORANGE, 'BREAK')
							doPlayerSendTextMessage(cid,27,"Your shield was broken.")
							setPlayerStorageValue(cid, storage, 0)
							return true
						else
							doPlayerSendTextMessage(cid,27, "Shield : absorbed "..value.." hit points.")
							return false
						end
					end
				end
				return true
			end
		]]>
	</event>
 
	<instant name="Absorb Shield" words="utamo gran" lvl="5" mana="0" soul="0" exhaustion="30000" event="script">
		<text>
			<![CDATA[
				domodlib('shield_setup')
				function onCastSpell(cid, var)
					if getPlayerStorageValue(cid, storage) > 0 then
						doPlayerSendCancel(cid,'Your shield is still active.')
						return false
					end
 
					doAddCondition(cid, condition)
					doPlayerSetStorageValue(cid, storage, 1)
					addEvent(doWaste, 1000, cid)
					addEvent(doFinish, time*60*1000, cid)
					doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
					doPlayerSendCancel(cid,'You have just enabled shield for "..time.." minutes.')
					return true
				end
			]]>
		</text>
		<vocation id="2;3;4"/>
	</instant>
</mod>
 
Well I would help you, but my server doesnt even set storage values lol xD

You should change this part with return false at the end otherwise the player will die (I understood that the hit should be blocked to and then shield breaks)
Lua:
if value >= getCreatureHealth(cid) then
	doSendAnimatedText(getThingPos(cid), TEXTCOLOR_DARKORANGE, 'BREAK')
	doPlayerSendTextMessage(cid,27,"Your shield was broken.")
	setPlayerStorageValue(cid, storage, 0)
	return false
 
Thanks you all :).
But :
You must spread some Reputation around (...)

angry-guy.jpg
 
Back
Top