Page 1 of 1

Modified NPC Summon code

Posted: Mon Oct 04, 2010 2:17 pm
by paboperfecto
I made a quick change to /game/modules/tome/data/talents/misc/npcs.lua that you may or may not be interested in. In the Summon talent I changed (somewhere close to line 319, didn't save an original)

Code: Select all

local m = game.zone:makeEntity(game.level, "actor", filter, nil, true)
to this

Code: Select all

local m = nil
            if filter.name then 
                m = game.zone:makeEntityByName(game.level, "actor", filter.name)
            end            
            if not m then 
                m = game.zone:makeEntity(game.level, "actor", filter, nil, true) 
            end
This does a couple of things. When summon calls for an entity that is known by name it is a lot quicker, not having to use the brute force method of creating a huge list of possible creatures for the level and then searching it for one that matches the filter. I did this to see how hard it would be to add a different cold drake hatchling that could get summoned by cold drakes instead of the escorted kind (My poor summoner was running for the stairs and then got surround by the 12 hatchling mob that got summoned and cut of....not nice :)). I added the following to /game/modules/tome/data/general/nps/cold-drake.lua:

Code: Select all

newEntity{ base = "BASE_NPC_COLD_DRAKE",
    define_as = "cold drake hatchling",
    name = "cold drake hatchling", color=colors.WHITE, display="d",
    desc = [[A drake hatchling, summoned by its Mother.]],
    level_range = {8, nil}, exp_worth = 1,
    rank = 1, size_category = 2,
    max_life = resolvers.rngavg(40,60),
    combat_armor = 5, combat_def = 0,
    combat = { dam=resolvers.rngavg(25,40), atk=resolvers.rngavg(25,50), apr=25, dammod={str=1.1} },
    on_melee_hit = {[DamageType.COLD]=resolvers.mbonus(7, 2)},
    combat = { dam=resolvers.rngavg(10,15), atk=15, apr=5, dammod={str=0.6} }, 
}
Now when I go to Carn Dum I can run into hatchlings in their groups of 4 or a cold drake may summon three of them (notice there is no rarity field in the above hatchling definition, they will never appear on the level without getting summoned). I thought the different text for the two different groups was neat for thematic reasons in game. With the above code the define_as field in the newEntity must match the name field in the summon entry for the creature that will summon. The changes in the summon code work for all currently existing creature definitions as well since the makeEntityByName will fail without the define_as it will call makeEntity as before.

Now I admit this is a pretty trivial example, if you want less hatchlings summoned you can just reduce the number in the summon definition to 1 and you get 4 instead of 12 (as an aside this makes Carn Dum much more playable, the cold drakes are still hard but you have a few turns to deal with them before they overwhelm the level). If however you have a devious mind (like I do) you could maybe add something like the following to the npc file for tol falas:

Code: Select all

newEntity{ base = "BASE_NPC_VAMPIRE",
    define_as "bodyguard",
    name = "Master's Bodyguard", color=colors.SLATE,
    desc=[[It is a humanoid with an aura of power. You notice a sharp set of front teeth.  This one looks like it might have been trained by the Master himself.]],
    level_range = {25, nil}, exp_worth = 1,
    max_life = resolvers.rngavg(70,80),
    combat_armor = 9, combat_def = 6,

    resolvers.talents{ [Talents.T_STUN]=1, [Talents.T_BLUR_SIGHT]=1, [Talents.T_ROTTING_DISEASE]=1,[Talents.T_RUSH]=2, },
}
Then the Master instead of summoning weak regular vampires might summon these with the level range buffed up and having taught them to rush. The possibilities become endless...bosses can summon creatures with pinning shots, stunning moves or even just their own predefined text on mouse over.

Re: Modified NPC Summon code

Posted: Mon Oct 04, 2010 3:47 pm
by Feanor.81
Seems great! I think it's quite useful having the ability to define special npcs which can only be summoned and never generated by the RNG :)

Just a dumb note: your texts state that only female drakes exist... :P

Re: Modified NPC Summon code

Posted: Mon Oct 04, 2010 3:53 pm
by paboperfecto
Just a dumb note: your texts state that only female drakes exist...
Or that baby drakes only respond to their mother. :)

Yeah, I was more testing the code than the text....needed to make sure that they were summoning the right creature and that my unescorted hatchlings weren't appearing on the level.