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

Scripter Zbizu / Free scripting service

Sopago

Member
Joined
Dec 15, 2020
Messages
32
Reaction score
11
GitHub
Sopago
Hi, thanks for this.

Version: TFS 1.3
Client: 10.98

Creating npc next to player
-To create npc you need item X and item Y (ids) together in your bp
-Npc can give X Money or Y Experience(can only choose one)
-After giving what you chose npc dissapears
-Only player who create npc can talk to him
-After you get reward the item dissapear from bp.
-Cant use item to create npc if he is already created by me, items become inactive during the time he is created.

Thanks in advance.
 

Nekiro

Legendary OT User
TFS Developer
Joined
Sep 7, 2015
Messages
2,496
Solutions
113
Reaction score
1,745
Nah, it's engine bug. Freshly generated variant just makes it ignore cast direction.

2 attempts were made:
Code:
    local p = creature:getPosition()
    combat2:execute(creature, {type = 2, pos = {x = p.x, y = p.y, z = p.z, stackpos = p.stackpos}})

and

Code:
    local p = creature:getPosition()
    combat2:execute(creature, Variant(creature, p))
Post automatically merged:

Ok. Now I see why the support for legacy combat functions wasn't dropped yet.

Here's an example of working spell(revscriptsys mod):

Code:
local area1 = {
    {0, 1, 0},
    {0, 1, 0},
    {0, 3, 0}
}

local area2 = {
    {1, 1, 1},
    {1, 1, 1},
    {1, 1, 1},
    {0, 0, 0},
    {0, 0, 0},
    {0, 2, 0}
}

local area2_full = createCombatArea(area2)

function onGetFormulaValues(player, level, ninjutsu)
    local min = (level / 5) + (ninjutsu * 1.6) + 9
    local max = (level / 5) + (ninjutsu * 3.2) + 19
    return -min, -max
end

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setArea(createCombatArea(area1))
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
  
local spell = Spell(SPELL_INSTANT)
spell:name("jutsu my ass")
spell:words("jutsu my ass")
spell:id(220)
spell:level(20)
spell:magicLevel(5)
spell:needDirection(true)
spell:isAggressive(true)
spell:vocation("sorcerer;true", "master sorcerer")

local function castSpell(creatureId)
    local player = Player(creatureId)
    if not player then
        return
    end
  
    local level = player:getLevel()
    local ninjutsu = player:getMagicLevel()
    local min = (level / 5) + (ninjutsu * 1.6) + 9
    local max = (level / 5) + (ninjutsu * 3.2) + 19
  

    local pos = player:getPosition()
    pos:getNextPosition(player:getDirection())

    doAreaCombatHealth(creatureId, COMBAT_FIREDAMAGE, pos, area2_full, min, max, CONST_ME_MORTAREA)
end

function spell.onCastSpell(creature, variant)
    combat:execute(creature, variant)
    addEvent(castSpell, 100, creature:getId())
    return true
end

spell:register()

@poe6man3

if anyone needs more examples of target/area combat with delays, see here (scroll to pastebin link):
Why are you passing creature to variant? Variant is either creature id, position, thing or string

 
OP
OP
zbizu

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,146
Solutions
20
Reaction score
2,299
Location
Poland
GitHub
Zbizu
I messed reverting the code after trying something else. Previously I tried Variant(pos), but I kept getting weird results.

The centerPos of combatArea is in front of the player btw so you also have to call getNextPosition when you want to make a new Variant object.
full code (finished):
Code:
local area1 = {
    {0, 1, 0},
    {0, 1, 0},
    {0, 3, 0}
}

local area2 = {
    {1, 1, 1},
    {1, 1, 1},
    {1, 1, 1},
    {0, 0, 0},
    {0, 0, 0},
    {0, 2, 0}
}

function onGetFormulaValues(player, level, ninjutsu)
    local min = (level / 5) + (ninjutsu * 1.6) + 9
    local max = (level / 5) + (ninjutsu * 3.2) + 19
    return -min, -max
end

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setArea(createCombatArea(area1))
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onGetFormulaValues(player, level, ninjutsu)
    local min = (level / 5) + (ninjutsu * 1.6) + 9
    local max = (level / 5) + (ninjutsu * 3.2) + 19
    return -min, -max
end

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat2:setArea(createCombatArea(area2))
combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local spell = Spell(SPELL_INSTANT)
spell:name("jutsu my ass")
spell:words("jutsu my ass")
spell:id(220)
spell:level(20)
spell:magicLevel(5)
spell:needDirection(true)
spell:isAggressive(true)
spell:vocation("sorcerer;true", "master sorcerer")

local function castSpell(creatureId)
	local player = Player(creatureId)
	if not player then
		return
	end
	
	local level = player:getLevel()
	local ninjutsu = player:getMagicLevel()
	local min = (level / 5) + (ninjutsu * 1.6) + 9
	local max = (level / 5) + (ninjutsu * 3.2) + 19
	

	local pos = player:getPosition()
	pos:getNextPosition(player:getDirection())

	combat2:execute(player, Variant(pos))
end

function spell.onCastSpell(creature, variant)
    combat:execute(creature, variant)
    addEvent(castSpell, 2000, creature:getId())
    return true
end

spell:register()
 

Evil Puncker

prolonged absenteeism
TFS Developer
Joined
May 30, 2009
Messages
7,957
Solutions
203
Reaction score
3,787

Landera

Veteran OT User
Joined
Nov 24, 2011
Messages
868
Solutions
1
Reaction score
283
Bringing back the oldskool guildmaster npc :)

For 1.3 tfs
 

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
897
Solutions
21
Reaction score
427
Location
Santiago - Chile
Hi @zbizu

I wonder if would be a good request a remake of this old system

There's a detail on the request, I would like that the carpet follows an specific route when the player is in traveling and being translated.
carpet.png

This feature would be in replacement of the talkaction commands. When the carpet ends the route, it stays and wait for a next onMoveIn event to occur. The next event should be the carpet "traveling back" following the same route. I attached the map with and without carpets. Anything else that is needed i'll do (setting up the coordinates too).

Regards and thanks!
 

Attachments

Top