SphereCommunity
magery and npc - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: magery and npc (/Thread-magery-and-npc)



magery and npc - admin phoenix - 07-19-2012 05:24 AM

I know if a npc has enough magery he will cast hardcoded spells.
but how do I know which spells the npc will be cast?
is there a chance to define it?
I know there was an option doing it via spellbook?
but long time ago...
I saw that when I give my dragon 100.0 magery he cast spells after spells Smile
what I want to say him, which spellshe should speak....

gr

phoenix


RE: magery and npc - Khaos - 07-19-2012 06:29 AM

Its conditional. They start with offensive spells. Unless they are hurt. Then they will heal/cure. I also remember some conditions set for them to use debuffs/buffs (Curse/Bless, etc).

You could just recode your spell system. Anarch Cassius could give you some pointers. His is completely custom.


RE: magery and npc - Anarch Cassius - 07-19-2012 12:42 PM

http://forum.spherecommunity.net/sshare.php?srt=0&cat=5

You can find it in my AI pack.

Just add the magery (and/or Necro and Chivalry events) and skip the rest of the system. You can copy and/or edit the events to create unique casting patterns.

I do intend to add a system to check the spellbook but that would be using my custom crazy spellbook system.


RE: magery and npc - Q23A - 07-19-2012 09:43 PM

I have something like this:

[ITEMDEF i_monster_cast]
NAME=Monster cast
ID=i_memory
TYPE=t_eq_script

ON=@CREATE
ATTR=attr_decay|attr_invis

ON=@EQUIP
IF (<MORE2>==101)
TIMERD=34
ELIF (<MORE2>==102)
TIMERD=20
ENDIF

ON=@UNEQUIP

IF (<TAG0.FIZZLE>==1)
RETURN 0
ENDIF

// -===================== if player can see - fizzle ==
IF !(<LINK>==04ffffffff)
IF (!<LINK.CANSEELOS>)
EFFECT 3,14133,5,30,1
RETURN 1
ENDIF
ENDIF


// -========================== Teleport to player ==
IF (<MORE2>==99)
IF (!<LINK.CANSEELOS>)
CONT.P=<LINK.P>
CONT.UPDATE
RETURN 0
ENDIF
ENDIF

// -============================= Attack spells ===
IF (<MORE2>==101)
LINK.SPELLEFFECT s_flamestrike,2000
ELIF (<MORE2>==102)
LINK.SPELLEFFECT s_lightning,2000
ENDIF

ON=@TIMER
REMOVE
RETURN 1


RE: magery and npc - admin phoenix - 07-19-2012 11:37 PM

@Anarch Cassius
I think I opend it yesterday and I remember that this script is based on timer?
Q23A script is based on timer for example and this is not what I want.
If you put the magery skill to the npc he will cast every x sec/min. Don´t know from what this this is depented or which trigger is triggered Smile
What about the special action trigger. Can we control the spells with this one?
Maybe it will be nice, if we have a tag.override.spell
there you can put your spell like
tag.override.spell=s_bless|s_fireball
and give the npc the magery skill Smile

Very nice and I like my idea Wink


RE: magery and npc - darksun84 - 07-20-2012 12:54 AM

I just enabled NPC_AI_EXTRA, with the trigger @NPCAction you can set and know the spell you want!
Actarg1 holds the spell.

ON=@NpcAction
if <action> == skill_magery // 25 is magery
say I am Casting <serv.spell.<actarg1>.name> !
return 0
endif


Still, @NpcAction it's called everytime a npc do something, so it can be very laggy or no?

I am super dumb, instead of using @NpcAction you can control spell npc cast with trigger @Spellcast (it does the same thing)

ON=@Spellcast
argn1 = 30
say Casting <serv.spell.<argn1>.name> //always cast lighting

For field spells, you have to set act = 0 otherwise the npc will always fizzle.


RE: magery and npc - admin phoenix - 07-20-2012 05:44 AM

@darksun84
yes, that´s a very good solution with spellcast

thanks!


RE: magery and npc - Anarch Cassius - 07-20-2012 07:15 AM

@admin phoenix. Yes and no. The timers are only for squads, to coordinate healing and group attacks. The casting events in their basic forms use @NPCActFight and other triggers.

@darksun. I don't use @Spellcast because that means letting the default AI decide when its a good time to cast. That's a fine approach but I wanted more control of the behavior of different NPCs.

See the NPCCast function at the bottom of the attack events file in my script. Also look at the functions for various types of spellcasting. That's really the simplest core without any of my AI.


RE: magery and npc - darksun84 - 07-20-2012 06:07 PM

Your system looks impressive !

Do you have any performance issues with it ?


RE: magery and npc - Anarch Cassius - 07-21-2012 07:16 AM

No but I haven't done serious stress testing. It involves a lot of checks but most of them are pretty streamlined.

This is one reason so many events like potion use and casting are separated, I wanted them addable to NPCs who didn't need the full bulk of the faction AI. The Swarm event in the NPC abilties is meant for factionless animals that fight in groups. It calls all nearby NPCs with the user's type in their desires who aren't already in combat. Attack one animal and the whole herd moves in.