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

[MONSTER] Monster drop (math.random 5-15) gold per hit like in Diablo.

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,839
Solutions
18
Reaction score
618
Location
Poland
Hello.
I want request someone to make an monster and creaturescript.

Idea: Treasure Goblin - Diablo Wiki

Info:
Monster drop random from 5 to 15 gold coins per hit. If player hit monster he drop random from 5-15 gold coins on floor.
 
Hmm it seems like a nice idea - i guess this would involve a creaturescript/global event?? Since the attack action/hit would drop money on the floor. So the monster would basically be a "trigger" i'll have a go and see what i can do xd pretty much a noob in the scripting world, but i know what functions do etc, just learning where to place them.

I'll attempt this.
 
Here is sprite:
scaled.php


Free to use.
I hope you, Ghostx will help me ;)
 
tbh i wouldn't need the sprite, since i would just make it walk around (run from player) possibly and drop gold under its feet when attacked.

btw just for some info, do you want it to be killable? and any reward inside?
 
i want it to be killable but i got script from Cykotitan for loot like in Diablo (when monster dead, items are dropping around the corpses on random squares)
 
This should work:

Code:
local targetList = {'monster name'}
function onStatsChange(cid, attacker, type, combat, value)
    if(isMonster(cid) and isPlayer(attacker)) then
        if(isInArray({STATSCHANGE_HEALTHLOSS, STATSCHANGE_MANALOSS}, type)) then
            if(isInArray(targetList, getCreatureName(string.lower(getCreatureName(cid)))) then
                doCreateItem(2148, math.random(5, 15), getCreaturePosition(cid))
            end
        end
    end

    return true
end
 
Last edited:
Where I have to put in this code?

at actions?

Data/Creaturescripts/Creaturescripts.xml
Add This line below:
Code:
<event type="statschange" name="GainCoins" event="script" value="Coins.lua"/>

Data/Creaturescripts/Scripts
Make new lua named: Coins and paste the code by J. Dre!

Code:
local targetList = {'monster name'}
function onStatsChange(cid, attacker, type, combat, value)
	if( isMonster(cid) and isPlayer(attacker) ) then
		if( isInArray({STATSCHANGE_HEALTHLOSS, STATSCHANGE_MANALOSS}, type) ) then
			if( isInArray(targetList, getCreatureName(string.lower(getCreatureName(cid))) ) then
				doCreateItem(2148, math.random(5, 15), getCreaturePosition(cid))
			end
		end
	end
 
	return true
end

Then at:
Data/Creaturescripts/Scripts/Login.lua

Add this line:
Code:
registerCreatureEvent(cid, "GainCoins")

Hope i helped :)
 
Lua:
local targetList = {'monster name'}
function onStatsChange(cid, attacker, type, combat, value)
	if (isMonster(cid) and isPlayer(attacker)) then
		if (isInArray({STATSCHANGE_HEALTHLOSS, STATSCHANGE_MANALOSS}, type)) then
			if isInArray(targetList, getCreatureName(string.lower(getCreatureName(cid)))) then
				doCreateItem(2148, math.random(5, 15), getCreaturePosition(cid))
			end
		end
	end
	return true
	end
 
MODS:

Lua:
<?xml version="1.0" encoding="UTF-8"?>  
<mod name="Test" version="1.0" author="none" contact="none.com" enabled="yes">  
<config name="GoldM_func"><![CDATA[
config = {
targetList = {'Demon','Hydra'},
item = 2148,
r = math.random(5, 15)
}
]]></config>
<event type="login" name="GoldMRegister" event="script"><![CDATA[
	function onLogin(cid)
		registerCreatureEvent(cid, "GoldStats")
		registerCreatureEvent(cid, "GoldAttack")
    return true
    end]]></event>       
	<event type="combat" name="GoldAttack" event="script"><![CDATA[
		domodlib('GoldM_func')
                registerCreatureEvent(target, "GoldStats")
		return true
	]]></event>
<event type="statschange" name="GoldStats" event="script"><![CDATA[
domodlib('GoldM_func')
	if (isMonster(cid) and isPlayer(attacker)) then
		if (isInArray({STATSCHANGE_HEALTHLOSS, STATSCHANGE_MANALOSS}, type)) then
			if isInArray(config.targetList, string.lower(getCreatureName(cid))) then
				doCreateItem(config.item, config.r, getCreaturePosition(cid))
			end
		end
	end
return true
]]></event>
</mod>
 
I know...this is my login.lua:


PHP:
local config = {
	loginMessage = getConfigValue('loginMessage'),
	useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

registerCreatureEvent(cid, "VipCheck")

function onLogin(cid)
	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
	end
	

	local accountManager = getPlayerAccountManager(cid)
	if(accountManager == MANAGER_NONE) then
		local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
		if(lastLogin > 0) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
			str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
		else
			str = str .. " Please choose your outfit."
			doPlayerSendOutfitWindow(cid)
		end

		doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
	elseif(accountManager == MANAGER_NAMELOCK) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
	elseif(accountManager == MANAGER_ACCOUNT) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
	end

	if(not isPlayerGhost(cid)) then
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
	end

	registerCreatureEvent(cid, "Mail")
	registerCreatureEvent(cid, "GuildMotd")

	registerCreatureEvent(cid, "Idle")
	if(config.useFragHandler) then
		registerCreatureEvent(cid, "SkullCheck")
	end

	registerCreatureEvent(cid, "ReportBug")
	registerCreatureEvent(cid, "AdvanceSave")
	return true
	
end

registerCreatureEvent(cid, "coins")
 
Back
Top