PDA

View Full Version : Limiting Force Power range to one room and more


Miltiades
02-22-2007, 02:36 PM
-How can I limit the range of a Force Power. In the module I created, when using Force Wave or Force lightning (others are possible too) on an NPC, other NPC join the fight, even when in another room. How can I prevent this from happening?

-Something different: How can I make henchman spawn with together with the PC when entering a module?

stoffe
02-22-2007, 03:11 PM
-How can I limit the range of a Force Power. In the module I created, when using Force Wave or Force lightning (others are possible too) on an NPC, other NPC join the fight, even when in another room. How can I prevent this from happening?


You could try to turn on Line of Sight checking in the impact script for those powers by setting the the fourth parameter to GetFirstObjectInShape() and GetNextObjectInShape() to TRUE. That may help in many cases.

Be aware however that the line of sight checking in the Odyssey engine is terrible in some areas. On some occasions it will report someone as seen who's behind a closed door, while it won't spot someone standing right in front of you.

Miltiades
02-22-2007, 03:19 PM
Hmm, I don't really want to fiddle with the Force powers. Is there no way for an NPC to be held back from attacking before the PC enters a room (or opens a door)?

stoffe
02-22-2007, 04:33 PM
Hmm, I don't really want to fiddle with the Force powers. Is there no way for an NPC to be held back from attacking before the PC enters a room (or opens a door)?

Well, you could alter the AI scripts of the NPC to not do anything if the object that attacked or damaged them cannot be seen. Then they would just go about their business and not react while being killed so long as they can't see their attacker. :)

Only do this for custom AI scripts for NPCs in particular situations. If you add this to the standard AI there will be too many situations where the player can trick NPCs into not fighting back and kill them easily.

At the top of the OnDamaged event script, add:

if (!GetObjectSeen(GetLastDamager())) {
return;
}


At the top of the OnAttacked event script, add:

if (!GetObjectSeen(GetLastAttacker())) {
return;
}


At the top of the OnSpellCastAt event, add:

if (!GetObjectSeen(GetLastSpellCaster())) {
return;
}


At the top of the OnDialogue event, add:

if (GetIsInCombat(GetLastSpeaker())
&& GetIsFriend(GetLastSpeaker())
&& !GetObjectSeen(GetLastHostileActor(GetLastSpeaker( ))))
{
return;
}

Miltiades
02-22-2007, 05:50 PM
Hmm, apparently that doesn't work. I'm not sure if I added those lines correctly. I just placed them under the Executescript line, which is placed just under the void main.
But if it doesn't work, it won't trouble me, 'cause I'll leave the the room before the NPCs empty then. No big deal.

Anyway, do you know how I can spawn henchmen together with my PC in a module. I now know a bit about the scripts that make NPCs follow the PC. Where exactly do I put these scripts then?

spyblade
02-26-2007, 03:45 AM
I'm a beginner when it comes to scripting, (so I may be way off the mark, (please tell me if I am)) but would it be possible to write a spawn script that would fire after the deaths of the enemies in one room and spawn more enemies in the next room? It wouldn't be quite the same and sneaking passed enemies would kind of eliminate the next room's foes altogether.

Miltiades
02-26-2007, 12:24 PM
Hmm, great idea mattz, but for now, I'll just keep it this way and leave a room empty between two rooms filled with enemies. But I appreciate your help, thanks. I'll keep it in mind.

stoffe
02-26-2007, 05:56 PM
Hmm, apparently that doesn't work. I'm not sure if I added those lines correctly. I just placed them under the Executescript line, which is placed just under the void main.

You need to insert it at the top of the main() functions in those scripts, before the ExecuteScript() function calls. The point of those additions is to block the AI under certain circumstances, and it can't do that if it checks after the AI has already done its thing :)


Anyway, do you know how I can spawn henchmen together with my PC in a module.

Henchmen? What are those? NPCs that should assist the player?



[QUOTE=Miltiades]Hmm, great idea mattz, but for now, I'll just keep it this way and leave a room empty between two rooms filled with enemies.

If you want rooms populated with enemies that don't react to the player's presence until they enter that room you can use Encounters that spawn them into the room when the player approached the door. That way the NPCs won't be there to notice anything until moments before the player is about to meet them. Just place the encounter trigger area just outside the door(s) to the room, and put the encounter spawn location inside the room.

Miltiades
02-26-2007, 07:04 PM
You need to insert it at the top of the main() functions in those scripts, before the ExecuteScript() function calls. The point of those additions is to block the AI under certain circumstances, and it can't do that if it checks after the AI has already done its thing :)

Oh. Yeah, that's why that didn't work.



Henchmen? What are those? NPCs that should assist the player?

Yeah. Just NPC that follow the PC and fight with them, without being able to control them like partymembers. But that problem has already been fixed.


If you want rooms populated with enemies that don't react to the player's presence until they enter that room you can use Encounters that spawn them into the room when the player approached the door. That way the NPCs won't be there to notice anything until moments before the player is about to meet them. Just place the encounter trigger area just outside the door(s) to the room, and put the encounter spawn location inside the room.

That sounds very useful. Encounter work just like normal triggers, yes? So I just put a spawnscript in the OnEntered field? Oh yeah, does this also mean the NPCs that spawn with the encounter can't be placed in a module with the Module Editor?

Anyway, thanks again!

stoffe
02-26-2007, 07:51 PM
That sounds very useful. Encounter work just like normal triggers, yes? So I just put a spawnscript in the OnEntered field? Oh yeah, does this also mean the NPCs that spawn with the encounter can't be placed in a module with the Module Editor?


Encounters are a special type of trigger (they are under their own list field "EncounterList", in the GIT file). They maintain lists of NPCs to spawn whenever the player trips the trigger area of the encounter, and have a marker you can set where the encounter spawns should show up. They have some built-in features where you can determine how many (if any) times creatures are respawned if you trip the trigger area again, and it can maintain level-balanced lists. You don't need any scripts attached to an encounter for it to work.

I haven't used the KotorTool module editor so I don't know if it supports adding Encounters. If not, and you don't want to do it manually, you can use a normal trigger with a script that spawns creatures instead of an Encounter if you want to, to produce similar functionality.

Miltiades
02-26-2007, 08:03 PM
Okay, thanks.

deathdisco
02-27-2007, 12:54 AM
KT's module editor will add an encounter but not the "spawn points". You'll have to add them manually in the .git. Once they're in the .git, you can manipulate them with the module editor. The encounter(.ute) should also point to a .utc of the character(s) you are spawning. Check out the Harbinger module (151har). I've recreated the Sith Assasins attacks for a mod I'm doing.

FYI: don't try to load a module without spawn points added to an encounter, unless you want to bring your system to a crawl while the game decides where to spawn the NPC's.

It might be easier to do as Stoffe suggested and use a trigger to fire a script.

Miltiades
02-27-2007, 01:04 PM
Thanks for the clarification. I'll try the encounter first, should it not work, I'll use a normal trigger.