ID:162429
 
Alright, this question may be a bit of a doosy.

I want to create a spell for my game that allows the player to summon a monster, only have 1 monster summoned at a time, follow the caster, and attack anything the caster attacks or anyone that attacks the caster (unless of course the caster hits himself from being too close to a blast radius from another spell.)

And of course, the summon will also attack anything which attacks the summon itself...unless it is the caster who called him.

I know this is alot to ask, but I have finally gotten through most of my code and I am ready to start work on AIs and figure this would be a great starting point. Any tips and advice are very welcome.
All of these can be made with variables. An "owner" variable can tell the monster what to follow, what not to attack, etc. And the owner can have a variable with how many monsters they own.
In response to Kaiochao2536
I guess I should start at the top:

How do I spawn a monster?

spawn() just causes a command to be processed so not to interfere with a proc.

New seems like it would be the trick, but I am not sure how to use it to create a monster.
In response to Zuglilth
monster = new /mob/monster/blob()
In response to Garthor
Something like this?

        Summon_Fire_Elemental
verb
cast()
locate(usr.x,usr.y+1,usr.z) = new /mob/summon/Elemental/FireElemental()
In response to Zuglilth
No, something like:

Garthor wrote:
monster = new /mob/monster/blob()
In response to Garthor
That returns a bad variable at compile time. [spellsystem.dm:601:error:monster:undefined var]

I take it I first need to set a variable somewhere in this spell that defines monster? If so, am I just defining the path to the monster I want to summon?
In response to Zuglilth
Presumably you'd define mob/var/mob/monster (or mob/player/var...), so that you always are able to find the monster you've summoned.

Note that this would cause the monster to be saved along with the player. If you don't want that, change it to mob/var/tmp/mob/monster. If you do want it saved, though, remember to change the Read() proc for summoned monsters so that they're properly placed on the map when the owner logs back on (and to remove the monster after a player logs out, either way).
In response to Garthor
        Summon_Fire_Elemental
verb
cast()
var/tmp/mob/summon/Elemental/FireElemental/S = new(locate(usr.x,usr.y+1,usr.z))
view()<<"[usr] summons a [S]!"


This should work then?
In response to Zuglilth
No, you're not creating it anymore.
In response to DisturbedSixx
Well, it works... unless I am completely missing something. The way Garthor told me to do it (while I appricate his help) didn't make much sense to me...but then again I am very new.

If I defined the variable already as the monster I want to summon why type out the entire path again? Even when I did, and had the variable defined it wouldn't spawn a monster.
In response to Zuglilth
It works. don't worry, Good how you figured out to pass the locate() as an argument for the new()

Remember that variable you made is saved as tmp. and won't save when written to a savefile.