• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent Interactive training monk

Sportacus

Intermediate OT User
Joined
Aug 3, 2008
Messages
718
Reaction score
100
This script will make your training monk a little bit more interactive. It will tell you your average dps.

add this to creaturescripts.xml

XML:
	<event type="statschange" name="DPScounter" event="script" value="dpscounter.lua"/>


Add this file to your creaturescripts folder...

Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 82936)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 10000)

function getDamageDone(cid, targetpos)
	targetpos.x = targetpos.x - 1
	if(isPlayer(cid)) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Average DPS: ".. getPlayerStorageValue(cid, 82936) / 10 .."")
		doCreatureSay(cid, "You are currently dealing an average of ".. getPlayerStorageValue(cid, 82936) / 10 .." damage per second.", TALKTYPE_ORANGE_1, false, 0, targetpos)
		return setPlayerStorageValue(cid, 82936, 0)
	end
	return true
end

function onStatsChange(cid, attacker, type, combat, value)
	if(type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) then
		if(not isPlayer(attacker)) then
			return true
		end
		
		setPlayerStorageValue(attacker, 82936, getPlayerStorageValue(attacker, 82936) + value)
		
		if(getCreatureCondition(attacker, CONDITION_EXHAUST, 82936) == false) then
			setPlayerStorageValue(attacker, 82936, 0)
			addEvent(getDamageDone, 9900, attacker, getCreaturePosition(cid))
			doAddCondition(attacker, exhaust)
		end
	end
    return true
end



and lastly change your training monk script to this

XML:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Training Monk" nameDescription="a training monk" race="blood" experience="0" speed="210" manacost="0">
	<health now="99000" max="99000"/>
	<look type="57" corpse="3128"/>
	<targetchange interval="60000" chance="0"/>
	<strategy attack="100" defense="0"/>
	<flags>
		<flag summonable="0"/>
		<flag attackable="1"/>
		<flag hostile="1"/>
		<flag illusionable="0"/>
		<flag convinceable="0"/>
		<flag pushable="0"/>
		<flag canpushitems="1"/>
		<flag staticattack="50"/>
		<flag lightlevel="0"/>
		<flag lightcolor="0"/>
		<flag targetdistance="1"/>
		<flag runonhealth="0"/>
	</flags>
	<script>
		<event name="DPScounter"/>
	</script>
	<attacks>
		<attack name="melee" interval="5000" min="0" max="-1"/>
	</attacks>
	<defenses armor="0" defense="0">
		<defense name="healing" interval="10000" chance="100" min="24000" max="24000"/>
	</defenses>
</monster>



If anyone has a way to improve it, or a suggestion for what more a training monk can do, just post your feed back.

I personally don't even use training monks on my server outside of testing things but I find it a useful feature.
 
Looks interesting, I was actually thinking about trying to implement something similar to this (elfbot's healing % overlay) earlier today.

Just a piece of advice though, you should probably localize your internal functions :)
 
Back
Top