Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Spawning creature help Kotor II

Page: 1 of 1
 Lit Ridl
06-01-2006, 12:35 PM
#1
I want to make spawning computer for Kotor II. Can somebody give me the code for basic spawning creature script? I need script that can be attached to dialog and when I click on some reply and terminate from computer I will see behind me hostile creature (for example Dark Jedi).
 Darth333
06-01-2006, 1:41 PM
#2
Spawning containers, other palceables and creatures: it's all the same :) Check this tutorial: http://www.lucasforums.com/showthread.php?t=143536). You'll find various script samples to do that.

Basically, all you need to spawn a creature is this:

void main()
{
//this line checks is the creature already exists to avoid duplicate objects.
//If your dialogue only runs once, you don't need this line. You can also use a local variable to do this.
if (!GetIsObjectValid(GetObjectByTag("creature_tag")))
//this line spawns the creature
CreateObject(OBJECT_TYPE_CREATURE, "creature_templateresref", Location(Vector(0.00,0.00,0.00), 0.0));
}


Replace the "creature tag" and "creature_templateresref by those corresponding to your placeable. Note that the template resref must not exceed 16 chars (contrary to the above example).

Finally replace the 0.00 by the x,y,z and orientation coordinates you want. If you don't want to bother with specific coordinates, you can also simply spawn the creature near your PC by replacing the last line of the script by this one:

CreateObject( OBJECT_TYPE_CREATURE, "creature_template", GetLocation(GetFirstPC()) );


Edit: I first posted a script to spawn a container instead of a creature as I misread your initial post. To spawn a container, the only thing you need to change is the OBJECT_TYPE_CREATURE ->it has to be OBJECT_TYPE_PLACEABLE.
 Lit Ridl
06-02-2006, 2:07 AM
#3
Thank you Darth333!!! It was really useful!
 Lit Ridl
06-02-2006, 4:25 AM
#4
What do you think about my script for healer? Healer must heal all current party members. Is it Ok? If not write script that I will need. And is their function to replenish force points?
CODE:
void main() {
object oNPC = GetPartyMemberByIndex(0);
object object3 = GetPartyMemberByIndex(1);
object object5 = GetPartyMemberByIndex(2);
int int1 = (GetMaxHitPoints(oNPC) - GetCurrentHitPoints(oNPC));
if ((int1 > 0)) {
if (GetIsObjectValid(oNPC)) {
ApplyEffectToObject(0, EffectHeal(int1), oNPC, 0.0);
}
}
int1 = (GetMaxHitPoints(object3) - GetCurrentHitPoints(object3));
if ((int1 > 0)) {
if (GetIsObjectValid(object3)) {
ApplyEffectToObject(0, EffectHeal(int1), object3, 0.0);
}
}
int1 = (GetMaxHitPoints(object5) - GetCurrentHitPoints(object5));
if ((int1 > 0)) {
if (GetIsObjectValid(object5)) {
ApplyEffectToObject(0, EffectHeal(int1), object5, 0.0);
}
}
}
 stoffe
06-02-2006, 7:00 AM
#5
There is a corresponding EffectHealForcePoints effect that works pretty much like the Healing effect does, as seen below. You can also make your script a bit shorter by using a loop to get the active party members, like:


void main() {
int iSlot;
for (iSlot = 0; iSlot < GetPartyMemberCount(); iSlot++) {
object oNPC = GetPartyMemberByIndex(iSlot);
int iHealth = GetMaxHitPoints(oNPC) - GetCurrentHitPoints(oNPC);
int iForce = GetMaxForcePoints(oNPC) - GetCurrentForcePoints(oNPC);
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(iHealth), oNPC);
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHealForcePoints(iForce), oNPC);
}
}
 Lit Ridl
06-02-2006, 1:36 PM
#6
Looks perfect. Thanks Stoffe -mkb-. I've tested it it is working!
Edit: My friend made those script, is it right (He is hungarian don't worry about letters) say me if not correct it.
Code:
void main()
{
//CreateItemOnObject("a_heavy_07",GetFirstPC(), 10, 0);
//CreateItemOnObject("a_heavy_08",GetFirstPC(), 10, 0);
//CreateItemOnObject("a_heavy_10",GetFirstPC(), 10, 0);
CreateItemOnObject("a_light_09",GetFirstPC(), 10, 0);
CreateItemOnObject("d3_location",GetFirstPC(), 1, 0);
CreateItemOnObject("g_w_lghtsbr05",GetFirstPC(), 1, 0);
//AddJournalWorldEntry(1,"A zaszloaljad most erkezett meg Kemplex kilencrrol. Ulic es Exar Kun parancsara A Rettenthetetlen Mandalore Onderon fovarosanak Iziznek tamadasara indult.", "Kemplex Kilenc");
//AddJournalWorldEntry(2,"Mandalore Dxunra vitte seregeit, kipihenni a Kemplex kilenc csat?t,?s er?t gy?jteni, mert ?tban Onderon fel? probl?m?k akadtak...", "Dxun inv?zi?");
//AddJournalWorldEntry(3,"Keresd meg a Rettenthetetlen Mandaloret, ?s csatlakozz seregeiddel","Csatlakoz?s");
AddJournalQuestEntry("Kemplex Kilenc", 10, FALSE);
SwitchPlayerCharacter(-1);
string dxun = "1401DX";
StartNewModule(dxun);
}
 stoffe
06-03-2006, 6:26 AM
#7
My friend made this script, is it right, say me if not correct it.
Code:
(snip)


That depends on what you want the script to do. :)

As it currently reads it will add 10 Mandalorian Heavy Suits, one WhereAmI armband and one purple lightsaber to the party inventory, Add a custom entry to the journal (provided it has been added to global.jrl), make the Exile into the main character and start a custom module with the name "1401DX" (in the file 1401DX.mod usually).

If this is what you want then it should be correct. :)
 Lit Ridl
06-04-2006, 2:11 PM
#8
Yeah, thank STOFFE. Happy birthday to you again!
 Lit Ridl
06-05-2006, 12:36 PM
#9
Sorry for my noob... But I am only 12 year old pupil and of course have problems with scripting. I am making new area for KI. It is based on Taris Undercity. I have to turn all rakghouls to zombies from KII. Problem: I need two scripts - the first is to make zombies respawnable for unlimited times (make them endless). The second problem - is too make script that will teleport me on Ebon Hawk when I will have only 1 hp. Help is needed.
 Darth333
06-05-2006, 10:54 PM
#10
the first is to make zombies respawnable for unlimited times (make them endless). Just attach a script that will spawn another zombie to their Ondeath event. When a xombie dies, another spawns.


The second problem - is too make script that will teleport me on Ebon Hawk when I will have only 1 hp. Help is needed.1 hp is risky I believe that if an ennemy deals too much damage, you'll just die. Better keep it at < something like 20 or 10 hp.

It is similar to the talk-fight-talk sequence explained by tk102 here: http://www.lucasforums.com/showthread.php?t=126615)

Attach a script like this one as the On Spawn event of your npc (sets the On damaged flag) :


#include "k_inc_generic"
void main()
{
//This will make our user-defined event fire
GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DAMAGED);

GN_SetDayNightPresence( AMBIENT_PRESENCE_ALWAYS_PRESENT);
GN_SetListeningPatterns();
GN_WalkWayPoints();
}



Then as the User Deifned event, use a script to teleport you to the new module:

#include "k_inc_generic"
#include "k_inc_utility"
void main()
{
int nCurrentHP;
int nUser = GetUserDefinedEventNumber();
if(nUser == 1006) // DAMAGED
{
nCurrentHP=GetCurrentHitPoints();
if (nCurrentHP<20) {
CancelCombat (OBJECT_SELF);
ClearAllActions();
StartNewModule("my_module","my_waypoint");
}
}
}
 Lit Ridl
06-06-2006, 3:44 AM
#11
Thanks Darth333 and Stoffe! There are a lot of easy ways in KII to boost your attributes like here:

void main() {
AdjustCreatureAttributes(object GetPCSpeaker(), int ABILITY_SOMETHING, int 5);
}

But it seems to have no script atribute booster for KI? Is it true? Only one way I have found in KI is creating hide like HK has. Is their other ways? Like in KII?
How to grant feats and spells to your character in KI? I mean like with GrantFeat and GrantFeat functions in KII?
Another thing: I have adjusted spawn zombie script to it's death but when I kill zombie they are no other zombies? Teleport script looks to be working.:greedo:
 stoffe
06-06-2006, 6:35 AM
#12
1 hp is risky I believe that if an ennemy deals too much damage, you'll just die. Better keep it at < something like 20 or 10 hp.


You could use the SetMinOneHP() function on the player when entering the zombie infested area, and unset it when you leave. That way the player could only be taken down to 1 VP, never below it.

You just have to make sure you really unset it, or they'll be unkillable for the rest of the game. :)
 Darth333
06-06-2006, 10:26 AM
#13
You could use the SetMinOneHP() function on the player when entering the zombie infested area, and unset it when you leave. That way the player could only be taken down to 1 VP, never below it.
You're totally right. The worse is that I used that several times in the past. That's what happen when I post while I should be sleeping :p
 Lit Ridl
06-06-2006, 10:49 AM
#14
Thanks Darth333 and Stoffe! There are a lot of easy ways in KII to boost your attributes like here:

void main() {
AdjustCreatureAttributes(object GetPCSpeaker(), int ABILITY_SOMETHING, int 5);
}

But it seems to have no script atribute booster for KI? Is it true? Only one way I have found in KI is creating hide like HK has. Is their other ways? Like in KII?
How to grant feats and spells to your character in KI? I mean like with GrantFeat and GrantFeat functions in KII?
Another thing: I have adjusted spawn zombie script to it's death but when I kill zombie they are no other zombies? Teleport script looks to be working.:greedo:
 stoffe
06-06-2006, 12:06 PM
#15
But it seems to have no script atribute booster for KI? Is it true? Only one way I have found in KI is creating hide like HK has. Is their other ways? Like in KII?
How to grant feats and spells to your character in KI? I mean like with GrantFeat and GrantFeat functions in KII?


There is no corresponding way of doing it in KotOR1. You can grant ability bonuses temporarily by adding effects to a creature, but they'll only stay until effects are cleared, which many cutscenes tend to do. You can add a hide to the Hide creature slot which has bonus properties, but that will only work if the hide slot isn't already used by something else, and you'd need to create many hide templates if you wish the magnitude of the bonuses to be scalable.

Hides are probably the only way you could grant bonus feats as well in KotOR, but be warned that some feats will not work properly when added on an item instead of learned by the character directly.
 Lit Ridl
06-07-2006, 1:10 AM
#16
You mean to grant feat I should use hide too? If yes, when I became jedi in KI I equip some hide that grants me "Force Sensitive"???
 RedHawke
06-07-2006, 4:59 AM
#17
You mean to grant feat I should use hide too? If yes, when I became jedi in KI I equip some hide that grants me "Force Sensitive"???
Actually this is granted when you get your multi-class Jedi class, it isn't scripted, if I remember correctly. ;)
Page: 1 of 1