• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Summon system

Syryniss

Member
Joined
Feb 13, 2014
Messages
206
Reaction score
20
Hi. I got three questions/requests about summon system.

1. I want to master could not kill his summons - he shouldn't be able to deal damage to them.
2. I want to summons could not damage their master with area spells, because now that's how it works.
3. And last, not that important as two above, but I wanted to master recive full exp from killing monsters when using summons - even when he deal no damage to them.

Thanks for any help and sorry for my bad english, especially this post looks bad even to me.

down
Oops, I forgot, TFS 0.3.6pl1
 
Last edited:
A tip is to also determine what version you are using.

Kind Regards,
Eldin.


Ps: Text me if anyone got any kind of Pet System for TFS 1.0
 
How did you solved 3? I want to know.

1 and 2, creaturescripts:

Code:
function onStatsChange(cid, attacker, type, combat, value)
    if (isCreature(cid) == true and isCreature(attacker) == true) and (type == 1 or type == 3) then
        if getCreatureMaster(cid) == attacker or getCreatureMaster(attacker) == cid then
            doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
            return false
        end
    end
    return true
end
 
Thanks for reply. I made script summons.lua, added line in creaturescripts.xml and registred it in login.lua. Summons deals no damage to me, which is good, but if they fire area spell, im still reciving yellow skull which is annoying. And the 1. part isn't working at all, I can still kill my creatures.

For 3. I edited creature.cpp like this:
Code:
void Creature::onGainExperience(double& gainExp, bool fromMonster, bool multiplied)
{
    if(gainExp <= 0)
        return;

    if(master)
    {
        gainExp = gainExp;
        master->onGainExperience(gainExp, fromMonster, multiplied);
    }
    else if(!multiplied)
        gainExp *= g_config.getDouble(ConfigManager::RATE_EXPERIENCE);

    int16_t color = g_config.getNumber(ConfigManager::EXPERIENCE_COLOR);
    if(color < 0)
        color = random_range(0, 255);

    std::stringstream ss;
    ss << (uint64_t)gainExp;
    g_game.addAnimatedText(getPosition(), (uint8_t)color, ss.str());
}

Previously it was
Code:
gainExp = gainExp / 2;
and it seems to work for me.
 
You need to add the creaturescript both to the summons, and the player.

You registered your onStatsChange for the player in login.lua, but you need to register it for the monster too.

There are 2 ways to do this.
Either - Add the script event to each monster that you can summon on your server.
Or - make a spawn.lua creaturescript (which is basically a login for monsters) and register the onStatsChange there.
 
Thanks and where should I put event.lua because console says
Code:
unknown event name
It's located in creaturescripts/scripts now...
 
creaturescripts/creaturescripts.xml:
Code:
<event type="statschange" name="EVENT_NAME" event="script" value="event.lua"/>

creaturescripts/scripts/login.lua:
Code:
registerCreatureEvent(cid, "EVENT_NAME")

creaturescripts/scripts/event.lua:
http://otland.net/threads/summon-system.209896/#post-2012201

Add to every monster:
Inside the monster xml file:
Code:
<script>
        <event name="EVENT_NAME"/>
</script>
Or if you wont adding this to all mobs use this source code:
http://otland.net/threads/creaturee...ster-and-players-in-creatureevent-xml.134003/
 
Back
Top