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

Action [7.x][8.x] One more simple annihilator quest with useful options

Gandh1

Member
Joined
Jan 15, 2008
Messages
16
Reaction score
8
Hello. I have fresh annihilator quest, with some useful options like:
• you can set how many players are required to start quest
• players haven't to come with whole team, even one player can do quest
• players have to kill all monsters before exit room
• you can set whether monsters are spawned by script when players are joining the room, they number and name
• players can do quest many times, but prize can take only once
• prizes, switch, door in one script

First go to data/actions/scripts, create file annihilator.lua and paste there it:
Lua:
--[[
	Author: Gandhi [PL]
	Date: 24.03.2012 ~10.20-11.15
	Contanct: GG - 38138073 (I can do some not easy scripts for cash (Self-promotion, hah) )
	About:
		Simple script for annihilator quest. You can set:
			- more or less than 4 players (numbers of tables with position in config.positions.before_teleport and config.positions.after_teleport (this number must be equal in these two tables) )
			- player can do quest without all teammates
			- player can do quest only at once
			- players must kill all monsters to get prize
			- placing of monsters
			- prizes 
		
		Greetings for people of Go(o)d Will! 
]]

local config = {
	positions = { -- positions
		before_teleport = { -- positions where are players before teleport to quest
			{x=1221, y=969, z=11, stackpos=253},
			{x=1222, y=969, z=11, stackpos=253},
			{x=1223, y=969, z=11, stackpos=253},
			{x=1224, y=969, z=11, stackpos=253}
		},
		after_teleport = { -- positions of players after teleport
			{x=1221, y=969, z=12, stackpos=253},
			{x=1222, y=969, z=12, stackpos=253},
			{x=1223, y=969, z=12, stackpos=253},
			{x=1224, y=969, z=12, stackpos=253}
		},
		place_monsters = { -- positions to place monsters
			placeMonstersAfterTeleport = true, -- use placing monsters on quest by script?
			{name = 'Demon', position = {x=1222, y=967, z=12, stackpos=253}},
			{name = 'Demon', position = {x=1224, y=967, z=12, stackpos=253}},
			{name = 'Demon', position = {x=1221, y=971, z=12, stackpos=253}},
			{name = 'Demon', position = {x=1223, y=971, z=12, stackpos=253}}
		}
	},
	requiredLevel = 100, -- required level to join annihilator quest
	checkForPlayers = false, -- if false, you can do quest when you don't have whole team
	killAllMonstersToExitRoom = true, -- if true, you have to kill all monsters before exit the room
	requiredStorage = {
		storage = 8600, -- storage where are saving info that player has do this quest (has take a price)
		valueDone = 1, -- value after do quest
		checkStorage = false -- check storage before join (if true, players can do quest only once)
	},
	messagesType = 20, -- type of messages sent to players
	items = {
		itemActionIdType = 'uid', -- chest with price from annihilator quest have set its id in actionid ('aid') or uniqueid ('uid')?
		[2650] = {count = 1, itemid = 2494, name = 'demon armor'},
		[2651] = {count = 1, itemid = 2400, name = 'magic sword'},
		[2652] = {count = 1, itemid = 2431, name = 'stonecutter axe'},
		[2653] = {count = 1, itemid = 2421, name = 'thunder hammer'},
		[9000] = {switch = true}, -- is item with this id a switch to teleport?
		[9001] = {doors = true} -- is item with this id a doors to exit room?
	}
}

function onUse(cid, item, frompos, item2, topos)
	local prize = (config.items.itemActionIdType == 'uid' and config.items[item.uid] or config.items[item.actionid])
	if(prize == nil) then
		return 0
	end
	if(prize.itemid ~= nil) then
		if(getPlayerStorageValue(cid, config.requiredStorage.storage) == config.requiredStorage.valueDone) then
			doPlayerSendTextMessage(cid, config.messagesType, 'You already take your price from this quest.')
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
			return 1
		end
		doPlayerAddItem(cid, prize.itemid, prize.count)
		doPlayerSendTextMessage(cid, config.messagesType, 'You have found ' .. (prize.count == 1 and 'a' or prize.count) .. ' ' .. prize.name .. '.')
		setPlayerStorageValue(cid, config.requiredStorage.storage, config.requiredStorage.valueDone)
	elseif(prize.doors) then
		if(config.killAllMonstersToExitRoom) then
			local monsters, monster = {}, 0
			for k, v in pairs(config.positions.place_monsters) do
				if(type(v) == 'table') then
					monster = getThingfromPos(v.position)
					if(monster.uid > 0) then
						table.insert(monsters, monster.uid)
					end
				end
			end
			if(table.getn(monsters) > 0) then
				for _, v in pairs(monsters) do
					doSendMagicEffect(getCreaturePosition(v), CONST_ME_MAGIC_RED)
				end
				doPlayerSendTextMessage(cid, config.messagesType, 'You have to kill ' .. table.getn(monsters) .. ' monsters.')
				return 1
			end
		end
		doTransformItem(item.uid, item.itemid + 1)
		doTeleportThing(cid, getThingPos(item.uid))
		if(config.killAllMonstersToExitRoom) then
			doPlayerSendTextMessage(cid, config.messagesType, 'Your team killed all monsters. You can pass doors.')
		end
		return 1
	elseif(not prize.switch) then
		return 0
	end
	if(table.getn(config.positions.before_teleport) ~= table.getn(config.positions.after_teleport)) then
		error('Numbers of positions before teleport and after teleport doesn\'t match.')
		return 0
	end
	local players, player = {}, 0
	for k, v in pairs(config.positions.after_teleport) do
		player = getThingfromPos(v)
		if(isPlayer(player.uid)) then
			doPlayerSendCancel(cid, 'Another team is doing annihilator quest now. Wait a moment.')
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
			return 1
		end
	end
	local sendMessageNotEnoughPlayers = false
	for k, v in pairs(config.positions.before_teleport) do
		player = getThingfromPos(v)
		if(not isPlayer(player.uid)) then
			if(config.checkForPlayers) then
				if(not sendMessageNotEnoughPlayers) then
					doPlayerSendTextMessage(cid, config.messagesType, 'You need ' .. table.getn(config.positions.before_teleport) .. ' players to do annihilator quest.')
					doSendMagicEffect(getCreaturePosition(player.uid), CONST_ME_POFF)
					sendMessageNotEnoughPlayers = true
				end
			else
				table.insert(players, -1)
			end
		elseif(getPlayerLevel(player.uid) < config.requiredLevel) then
			doPlayerSendTextMessage(cid, config.messagesType, 'Player ' .. getCreatureName(player.uid) .. ' from your team don\'t have required level (' .. config.requiredLevel .. ')')
			doPlayerSendCancel(player.uid, 'You don\'t have enough level to do annihilator quest. Come back if you reach ' .. config.requiredLevel .. ' level.')
			doSendMagicEffect(getCreaturePosition(player.uid), CONST_ME_POFF)
		elseif(config.requiredStorage.checkStorage and getPlayerStorageValue(player.uid, config.requiredStorage.storage) == config.requiredStorage.valueDone) then
			doPlayerSendTextMessage(cid, config.messagesType, 'Player ' .. getCreatureName(player.uid) .. ' from your team has done this quest.')
			doPlayerSendCancel(cid, 'You have done this quest.')
			doSendMagicEffect(getCreaturePosition(player.uid), CONST_ME_POFF)
		else
			table.insert(players, player.uid)
		end
	end
	if(table.getn(players) ~= table.getn(config.positions.before_teleport)) then
		return 1
	end
	local teleportPosition = 0
	for i, v in ipairs(players) do
		if(v ~= -1) then
			teleportPosition = config.positions.after_teleport[i]
			doTeleportThing(v, teleportPosition)
			doSendMagicEffect(teleportPosition, CONST_ME_MAGIC_BLUE)
			doPlayerSendTextMessage(v, config.messagesType, 'Now you are teleported to annihilator room. Good luck.')
		end
	end
	if(config.positions.place_monsters.placeMonstersAfterTeleport) then
		local monster = 0
		for k, v in pairs(config.positions.place_monsters) do
			if(type(v) == 'table') then
				monster = getThingfromPos(v.position)
				if(monster.uid == 0) then
					doSummonCreature(v.name, v.position)
					doSendMagicEffect(v.position, CONST_ME_MAGIC_RED)
				end
			end
		end
	end
	return 1
end

Second, paste it on actions.xml:
Version for newerTFS's
HTML:
	<action uniqueid="9000;9001;2650;2651;2652;2653" event="script" value="annihilator.lua"/>

Version for older engine's
HTML:
	<action uniqueid="9000" event="script" value="annihilator.lua"/>
	<action uniqueid="9001" event="script" value="annihilator.lua"/>
	<action uniqueid="2650" event="script" value="annihilator.lua"/>
	<action uniqueid="2651" event="script" value="annihilator.lua"/>
	<action uniqueid="2652" event="script" value="annihilator.lua"/>
	<action uniqueid="2653" event="script" value="annihilator.lua"/>

Enjoy.
 
If this script is not work in some version, say in this thread.

Can you comment this script? All constructive comments are welcome.
Sorry for bad grammar if somethere i wrote wrong. : D
 
[15/04/2012 22:27:16] [Error - Action Interface]
[15/04/2012 22:27:16] data/actions/scripts/quests/anihi.lua:eek:nUse
[15/04/2012 22:27:16] Description:
[15/04/2012 22:27:16] (luaGetThingPosition) Thing not found

when dont have four players
 
Code:
	checkForPlayers = false, -- if false, you can do quest when you don't have whole team
change it to true ;)
 
Back
Top