Dynamic NPC Script attachment ?
by Areal Person · in Torque Game Engine · 01/03/2009 (6:48 pm) · 4 replies
Is it possiable to attach a script to an NPC BOT (Kork etc.)
at runtime ?
Lets say I spawn 2 or 3 NPC's at startup at specific spawn points.
Is it possiable to then pull down the console and attach or run
a script that has been designed specificly for the NPC that I choose ?
And what about a generalized script attachment that would have common features
that would be approprate for any of the NPC's ? How would I attach that kind of script ?
What are some thoughts on how I might do this ?
I'm trying to get a better handle on dynamically controlling NPC's
Thanks,
at runtime ?
Lets say I spawn 2 or 3 NPC's at startup at specific spawn points.
Is it possiable to then pull down the console and attach or run
a script that has been designed specificly for the NPC that I choose ?
And what about a generalized script attachment that would have common features
that would be approprate for any of the NPC's ? How would I attach that kind of script ?
What are some thoughts on how I might do this ?
I'm trying to get a better handle on dynamically controlling NPC's
Thanks,
#2
That will really help with what I'm trying to do !
Any other suggestions anyone ?
Thanks much,
01/03/2009 (7:48 pm)
Thats kool !That will really help with what I'm trying to do !
Any other suggestions anyone ?
Thanks much,
#3
01/03/2009 (7:54 pm)
As a matter of fact, I do have a suggestion: Get friendly with eval() and constructing commands in script like you would any other text statement. You'll find a lot of flexibility in being able to cobble together dynamic functions, objects, GUI's, etc and using eval(%yourthinggoeshere) to execute it on the fly...
#4
It will really help me ! I've had trouble getting a handle on
these type issues.
Thanks !
01/03/2009 (8:11 pm)
Yep, thats real gold nugget stuff !It will really help me ! I've had trouble getting a handle on
these type issues.
Thanks !
Torque 3D Owner Ted Southard
And then in the datablock assigned to the NPC, there would be a field like "MOBType" or something that would say:
And in the generic AIPlayer scripts, I had a common AI framework that called functions similar to:
That's not everything, but if you think about it, you can have the AIPlayer namespace be just a wrapper for calling specific functions in script. You can put that functionality in AIPlayer::attack() and have that do the query for what attack function to call. This way, the script functions you want to use get attached at spawntime, or whenever you set that MOBType-like variable.