• 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 Party Dueling (Summons)

J.Dre

Unity Games
Joined
May 18, 2011
Messages
2,647
Solutions
3
Reaction score
648
Location
United States
Party Dueling
For quests, tasks, or whatever.

Information
This script was made for and tested on TFS 0.3.7, it will not work for TFS 0.2 in its current form. I made this script for someone who requested it for "Pokemon" stuff, if I remember correctly. I thought since the thread was closed and renamed, no one would ever find it via searching, or it would be more difficult than it already is. Therefor, I decided to make a thread to share this with others who may be interested in such a script for whatever purpose. Anyway, I'm sure it will be of use to someone. Even if there's only one person I helped by posting this, I'm still happy to have done so - enjoy!

Note: The current form of this script is very simple and basic. I did not add many additional features because I want people to learn how to do so themselves. You can incorporate tasks, missions, or even check areas of the map where this script can be enabled. If you need help, please post here or send me a private message - I'll do my best to assist you, or refer you to someone who can.

What does this script do?
It restricts dueling to those in the same party, specifically with summons.

Need further support?
Please do not be afraid to post here if you need assistance. I may not respond immediately, but I will respond.

Feedback is appreciated! ;)


creaturescripts.xml
XML:
<event type="target" name="Duel" event="script" value="duel.lua" />

login.lua
Lua:
registerCreatureEvent(cid, "Duel")

duel.lua
Lua:
local storage = 12345 -- the storage of a quest or assignment (task)
function onTarget(cid, target)
	if(isSummon(target)) then
 
		local master = getCreatureMaster(target)
		if(master and master == target) then return true end
 
		if(master and master ~= target) then
			if(not isInParty(cid) and not isInParty(master)) then
				if(getCreatureStorage(cid, storage) > 0) then
					return true
				else
					doPlayerSendCancel(cid, "You must be in a party to duel.")
					return false
				end
			elseif(getPlayerParty(cid) ~= getPlayerParty(master)) then
				if(getCreatureStorage(cid, storage) > 0) then
					return true
				else
					doPlayerSendCancel(cid, "You must be in the same party to duel.")
					return false
				end
			end
		end
	end
	return true
end
 
Hello :D It works very nice! Thank you.

I only have a little problem. Even though player's pokemon can attack each other while in party, they don't inflict any damage :( so they can be fighting forever without a winner hehe. Do you have any idea of how can I fix this?

Thank you :)
 
When I tested this myself it worked just fine. Check the monster files and make sure their attacks are properly set. Monsters not hurting each other can be several things...
 
Thanks for answering!

Hello

Thank you for answering :) I've already checked the monsters .xml files but I'm not an expert in monster properties so I couldn't identify any abnormality in them. Maybe I'm missing something.

I made the following experiment.

1.- I took two players to a pvp-zone
2.- The world was set to pvp mode
3.- The players started a party in order to allow them to attack each other

Results
1.- The players can attack each other as expected
2.- Pokemon can attack other pokemon but no damage is inflicted among them
3.- Pokemon can attack humans and damage them normally

I attach the .xml files of the monsters I've used in the experiment, maybe they need an aditional property

Totodile.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Totodile" nameDescription="a Totodile" race="undead" experience="200" speed="220" manacost="600">
  <health now="1400" max="1400"/>
  <look type="623" head="20" body="30" legs="40" feet="50" corpse="11481"/>
	<targetchange interval="5" chance="1000"/>
  <strategy attack="100" defense="0"/>

  <flags>
    <flag summonable="1"/>
    <flag attackable="1"/>
    <flag hostile="1"/>
    <flag illusionable="1"/>
    <flag convinceable="0"/>
    <flag pushable="0"/>
    <flag canpushitems="1"/>
    <flag canpushcreatures="1"/>
    <flag targetdistance="1"/>
    <flag staticattack="90"/>
    <flag runonhealth="0"/>
  </flags>


  <attacks>
    <attack name="melee" interval="2000" min="-40" max="-140"/>
    <attack name="auravoador" interval="2000" chance="12" min="-800" max="-1200"> </attack>
  </attacks>


  <defenses armor="20" defense="22">
    <defense name="healing" interval="1000" chance="17" min="30" max="50">
      <attribute key="areaEffect" value="blueshimmer"/>    </defense>
  </defenses>


  <elements>
  <element deathPercent="50"/>
  </elements>
  <immunities>
    <immunity physical="0"/>
    <immunity energy="0"/>
    <immunity fire="0"/>
    <immunity poison="0"/>
    <immunity lifedrain="0"/>
    <immunity paralyze="0"/>
    <immunity outfit="1"/>
    <immunity drunk="1"/>
    <immunity invisible="1"/>
  </immunities>
  <voices interval="5000" chance="10">
    <voice sentence="ToooToo DILE"/>
  </voices>
</monster>

Bayleef.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Bayleef" nameDescription="a Bayleef" race="undead" experience="200" speed="220" manacost="600">
  <health now="6000" max="6000"/>
  <look type="536" head="20" body="30" legs="40" feet="50" corpse="11396"/>
	<targetchange interval="5" chance="1000"/>
  <strategy attack="200" defense="0"/>

  <flags>
    <flag summonable="1"/>
    <flag attackable="1"/>
    <flag hostile="1"/>
    <flag illusionable="1"/>
    <flag convinceable="0"/>
    <flag pushable="0"/>
    <flag canpushitems="1"/>
    <flag canpushcreatures="1"/>
    <flag targetdistance="1"/>
    <flag staticattack="90"/>
    <flag runonhealth="0"/>
  </flags>


  <attacks>
    <attack name="melee" interval="2000" min="-40" max="-140"/>
  </attacks>


  <defenses armor="20" defense="22">
    <defense name="healing" interval="1000" chance="17" min="30" max="50">
      <attribute key="areaEffect" value="blueshimmer"/>    </defense>
  </defenses>


  <elements>
  <element deathPercent="50"/>
  </elements>
  <immunities>
    <immunity physical="0"/>
    <immunity energy="0"/>
    <immunity fire="0"/>
    <immunity poison="0"/>
    <immunity lifedrain="0"/>
    <immunity paralyze="0"/>
    <immunity outfit="1"/>
    <immunity drunk="1"/>
    <immunity invisible="1"/>
  </immunities>
  <voices interval="5000" chance="10">
    <voice sentence="BAAY BAAY"/>
  </voices>
</monster>

Once again, thanks for helping, I appreciate it a lot.
 
Edit: Never mind. I'm not sure why it isn't working. Which TFS are you using?
 
Last edited:
Try checking the functions list in the server "docs" folder. Compare/contrast them from the script and replace them to match your server. I'm certain this script worked for me, but I was using TFS 0.3.7 - a much later version of TFS than what you're using. Perhaps "onTarget" does not exist in 0.3.6. You may have to try "onAttack" or something else.
 
Back
Top