Hey Tk102, Darth333, or any other scripting guru!
Here's what I need help on.
I'm trying to figure out a script that allows me to spawn a creature into combat through the activation of a grenade last untill all enemies are dead then destroy itself.
Now I know how to spawn a creature and I figure the creature would spawn at the location the grenade lands and not next to myself but I could be wrong. I haven't tried testing this yet as I want to wait to find out what command in a script I would use to create a delay untill combat ends.
I also know I will be using the destroy object function at the end of combat. I'm also pretty sure all I have to do for the creature is have it set as an allie when it spawns so that it will attack hostile opponent but I could be wrong on this.
I didn't think this belonged in the talk fight talk thread but if a moderator feels that it does feel free to move this question there.
Correct me if I'm wrong Darth333, but grenades do not fire scripts...
Never mind... I'll correct myself...(they do the k_sup_grenade script)..
Originally posted by tk102
Correct me if I'm wrong Darth333, but grenades do not fire scripts...
uh?
the action of the grenade exploding is a script firing in the game. It effects objects in an area by using script commands that say do x damage to y objects in z radius, right?
All I intend to do is replace the meat of a grenade script with spawn meaney creature to kill enemies, combat over meaney creature go bye bye.:D
***Note too self give scripting urus chance to self edit***:cool:
Sorry darkkender, I misposted. :)
Anyway --
Location: as per k_sup_grenade.nss, you can spawn the creature at the location of the thrown grenade using the GetSpellTargetLocation function.
Destroy At Combat's End: There's probably another way to do it, but I would specify a user-defined script for the .utc that does a GetIsInCombat(GetFirstPC()) function to determine if you're still fighting. If not, do the DestroyObject function on the .utc.
I'll add more details...
In the .utc's OnSpawn field, set it to point to a script that looks like this:
Now change the ScriptSpawn field to point to a new script file that contains the following:
#include "k_inc_generic"
void main()
{
//This will make our user-defined event fire
GN_SetSpawnInCondition(
SW_FLAG_EVENT_ON_COMBAT_ROUND_END);
GN_SetDayNightPresence(
AMBIENT_PRESENCE_ALWAYS_PRESENT);
GN_SetListeningPatterns();
GN_WalkWayPoints();
}
In the .utc's OnUserDefined field, point it to a script that contains:
void main()
{
if (!GetIsInCombat(GetFirstPC()) {
DestroyObject(OBJECT_SELF);
}
I think that should do it.
Okay I'm a little confused on the getspelltargetlocation implementation. on the getfirstpc I assume that is the user definition your refering to that would look like this
getfirstpc = "n_rancor"; or the line that is very similiar to this. correct?
Regarding the GetSpellTargetLocation:
Okay let me back up. Your grenade's .uti file will be just like another grenade's .uti except its Property Subtype will point a new row in the spells.2da file.
Now in that new row of spells.2da, you'll change the impactscript field to a new script name, say, dk_grenade or something.
The dk_grenade.nss will look like this:
#include "k_inc_debug"
#include "k_inc_force"
void main()
{
//whatever visual effect you like
ApplyEffectAtLocation(DURATION_TYPE_INSTANT,
EffectVisualEffect(1044),
GetSpellTargetLocation());
//create creature
CreateObject(OBJECT_TYPE_CREATURE, "my_utc_filename", GetSpellTargetLocation());
}See what I mean?
Thanks Tk I'll go try this. I have to say I just noticed your sig link and read a good chunk.(starting to think I'm a we bit quick on the reply button.)
No problem. I like the idea of a 'canned creature' for use in battle. Hope it works!
^^^^
Just to jump in here, like TK102 said I also like the Minion-Grenade idea darkkender! :)
I hope it works, that would be really cool! :D
Creature-In-A-Can© ;)
Just please for the love of anything good & decent, don't make it a Pokйmon. I'll have to hunt you down and do 'mean' things to you....
shock1 :lightning
"I choose you...Pikachu!"
[pc] oh yeah..."I choose you...Rancor!"
** Rancor eats Pikachu **
For fine tuning, you may need to use the DelayCommand function on the CreateObject function. This will help synchronize the visual effect with the appearane of the creature. Likewise, you could do the same with the DestroyObject functon if you use a visual effect there.
****hmmm somebody posted a tip on fine tuning before I posted my problems****
You know what's sad chainz is I relized after I came up with the idea it may end up similiar to that especially if I can't get the bugs out of the scripts i might have to have the creature destroyed from a dialogue.
but at any rate her is what I have so far TK;
The grenade itself works with the following script however it has a delay from when it explodes and the creature appears. Now this is a minor quirk I can live with if I have to.
#include "k_inc_debug"
#include "k_inc_force"
void main()
{
ApplyEffectAtLocation(DURATION_TYPE_INSTANT,
EffectVisualEffect(1044),
GetSpellTargetLocation());
CreateObject(OBJECT_TYPE_CREATURE, "dk_terantanak", GetSpellTargetLocation());
//!GetIsInCombat(GetFirstPC());
//DestroyObject(GetObjectByTag("dk_terantanak"));
}
the following are the spawn in and user define scripts. I'm not sure which one is not functioning correctly but the creature does not get destroyed at combat end.
spawn in
#include "k_inc_generic"
#include "k_inc_debug"
void main()
{
GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_COMBAT_ROUND_END); GN_SetDayNightPresence(AMBIENT_PRESENCE_ALWAYS_PRESENT);
GN_SetListeningPatterns();
GN_WalkWayPoints();
}
user define
#include "k_inc_generic"
#include "k_inc_debug"
#include "k_inc_utility"
void main()
{
int nUser = GetUserDefinedEventNumber();
if(nUser == 1001) //HEARTBEAT
{
}
else if(nUser == 1002) // PERCEIVE
{
}
else if(nUser == 1003) // END OF COMBAT
{
DestroyObject(GetObjectByTag("DK_TERANTANAK"));
}
else if(nUser == 1004) // ON DIALOGUE
{
}
else if(nUser == 1005) // ATTACKED
{
}
this is shortened down from it's actual user def I just took out the excess def fluff for posting.
Now I tried to make use of the following code and kept getting syntax errors or if I corrected the errors it still had different comiple errors.
void main()
{
if (!GetIsInCombat(GetFirstPC()) {
DestroyObject(OBJECT_SELF);
}
I also could not figure out where i needed to actually in sert this other script command
GetIsInCombat(GetFirstPC())
If you can help me get these figured out we might be able to avoid the go pikachu I choose you running gags.:D
On the other hand I was seriously thinking of having a force lightning using tach being one of the summoned critters.:lightning :D
Ok. Let's try using the heartbeat event instead then...
Try this for your Spawn script:
#include "k_inc_generic"
#include "k_inc_debug"
void main()
{
GN_SetSpawnInCondition(
SW_FLAG_EVENT_ON_HEARTBEAT);
GN_SetDayNightPresence(
AMBIENT_PRESENCE_ALWAYS_PRESENT);
GN_SetListeningPatterns();
GN_WalkWayPoints();
}
and this for your UserDefined script
void main()
{
int nUser = GetUserDefinedEventNumber();
if(nUser == 1001) { //HEARTBEAT
if (GetIsInCombat(GetFirstPC()) == FALSE) {
DestroyObject(OBJECT_SELF);
}
}
}
As for the 'fine tuning' of the explosion try this script modification:
#include "k_inc_debug"
#include "k_inc_force"
void main()
{
CreateObject(OBJECT_TYPE_CREATURE, "dk_terantanak", GetSpellTargetLocation());
DelayCommand(0.4, //you may have to tweak this number
ApplyEffectAtLocation(
DURATION_TYPE_INSTANT,
EffectVisualEffect(1044),
GetSpellTargetLocation()
)
);
}
I have another suggestion to destroy the creature, although not necessarily when combat ends: you could add a line to the spawn script that uses the DelayCommand function and automatically destroys the creature after a certain time. It could make those grenades more balanced too (a fight can be pretty long on the Starforge)
DelayCommand(25.0, DestroyObject(GetObjectByTag("dk_terantanak")));
I agree that's a pretty easy solution. Then if the fight is over sooner, you can talk to the creature. :p
Anyway you should be able to use the OBJECT_SELF shortcut instead of the GetObjectByTag function... it's faster, shorter, and more generic.
And my personal taste would be to add some visual effects like fire when it's time for the creature to disappear. (see the 'Carth magic trick' in this (
http://www.lucasforums.com/showthread.php?s=&threadid=139381) thread).
Originally posted by tk102
And my personal taste would be to add some visual effects like fire when it's time for the creature to disappear. (see the 'Carth magic trick' in this (
http://www.lucasforums.com/showthread.php?s=&threadid=139381) thread).
There is also a "cloud type effect" I like to combine with the fire effect. It is what I used in my Tach morphing mod:
EffectVisualEffect(1046) // sort of white cloud effect
EffectVisualEffect(1010) // I don't remember what is this one
EffectVisualEffect(1039) // fire
And this one is useful:
EffectVisualEffect(8000) //invisible
in conjuction with the puff of smoke. But I suppose it's up to Darkkender what he wants to do even though this is a fun tangent to go off on. :)
Originally posted by tk102
I agree that's a pretty easy solution. Then if the fight is over sooner, you can talk to the creature. :p
Anyway you should be able to use the OBJECT_SELF shortcut instead of the GetObjectByTag function... it's faster, shorter, and more generic.
And my personal taste would be to add some visual effects like fire when it's time for the creature to disappear. (see the 'Carth magic trick' in this (
http://www.lucasforums.com/showthread.php?s=&threadid=139381) thread).
I'll give those a try TK, I originally had the object_self command in the scripts however it removed my character from the party and not the monster. So I went back to the getobjectbytag method since I knew that would work and figured I would Tach around with things and eventually figure out how to finesse the code.
I originally had the object_self command in the scripts however it removed my character from the party :o
Ha ha. It depends on who is the caller of the script. For the heartbeat script, the caller is the .utc, (obviously). :)