Jump to content

Home

k1 scripting advice


Dark_lord_Cheez

Recommended Posts

okay, so I started up again trying to get my Opperation Kill Bastila to work, and I've finally learned from my mistakes and have decided to post my script on here so someone can actually tell me if it'll work or not without me posting it up and finding out the hard way. :smash:

 

Well, here's my script, it's based off of the "k_bandattack" script.

 

 

#include "k_inc_debug"

#include "k_inc_generic"

 

void main()

{

object oThug1 = GetObjectByTag("SithGuard", 0);

object oThug2 = GetObjectByTag("SithPatrol023", 1);

object oThug3 = GetObjectByTag("SithPatrol022", 0);

object oThug4 = GetObjectByTag("tat_bandon_thug2", 0);

 

while(GetIsObjectValid(oThug1) ||

GetIsObjectValid(oThug2) ||

GetIsObjectValid(oThug3) ||

GetIsObjectValid(oThug4))

{

if(GetIsObjectValid(oThug1))

{

Db_PostString("Jedi 1 Is Angry", 5, 10, 3.0);

ChangeToStandardFaction(oThug1, STANDARD_FACTION_HOSTILE_1);

DelayCommand(0.5, AssignCommand(oThug1, ClearAllActions()));

DelayCommand(0.5, AssignCommand(oThug1, GN_DetermineCombatRound()));

}

if(GetIsObjectValid(oThug2))

{

Db_PostString("Jedi 1 Is Angry", 5, 12, 3.0);

ChangeToStandardFaction(oThug2, STANDARD_FACTION_HOSTILE_1);

DelayCommand(0.5, AssignCommand(oThug2, ClearAllActions()));

DelayCommand(0.5, AssignCommand(oThug2, GN_DetermineCombatRound()));

}

if(GetIsObjectValid(oThug3))

{

Db_PostString("Jedi 1 Is Angry", 5, 12, 3.0);

ChangeToStandardFaction(oThug3, STANDARD_FACTION_HOSTILE_1);

DelayCommand(0.5, AssignCommand(oThug3, ClearAllActions()));

DelayCommand(0.5, AssignCommand(oThug3, GN_DetermineCombatRound()));

}

if(GetIsObjectValid(oThug4))

{

Db_PostString("Jedi 1 Is Angry", 5, 12, 3.0);

ChangeToStandardFaction(oThug4, STANDARD_FACTION_HOSTILE_1);

DelayCommand(0.5, AssignCommand(oThug4, ClearAllActions()));

DelayCommand(0.5, AssignCommand(oThug4, GN_DetermineCombatRound()));

}

}

ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_HOSTILE_1);

DelayCommand(0.5, ClearAllActions());

DelayCommand(0.5, GN_DetermineCombatRound());

}

 

 

 

I plan on firing this in a conversation with someone in the taris upper city, and using it to turn that character, as well as everyone with the tags "SithGuard", "SithPatrol022", and "SithPatrol023" hostile.

Link to comment
Share on other sites

okay, so I started up again trying to get my Opperation Kill Bastila to work, and I've finally learned from my mistakes and have decided to post my script on here so someone can actually tell me if it'll work or not without me posting it up and finding out the hard way. :smash:

 

Well, here's my script, it's based off of the "k_bandattack" script.

 

(SNIP!)

 

I plan on firing this in a conversation with someone in the taris upper city, and using it to turn that character, as well as everyone with the tags "SithGuard", "SithPatrol022", and "SithPatrol023" hostile.

 

From a quick glance, the most obvious mistake I can spot is the while-loop. Unless I misunderstand what you do it would be an infinite loop which would continually change the faction, clear actions and issue attack actions every few microseconds to the specified NPCs until the game engine kills the script due to execution time overflow.

 

If you remove the loop I think it should work. You could also outsource the repeated task of making them hostile to a separate function to optimize it a little. Like this:

 

#include "k_inc_generic"

void Enemy(object oEnemy=OBJECT_SELF) {
   if (GetIsObjectValid(oEnemy)) {
       ChangeToStandardFaction(oEnemy, STANDARD_FACTION_HOSTILE_1);
       DelayCommand(0.5, AssignCommand(oEnemy, ClearAllActions()));
       DelayCommand(0.5, AssignCommand(oEnemy, GN_DetermineCombatRound()));
   }
}

void main() {
   Enemy(GetObjectByTag("SithGuard"));
   Enemy(GetObjectByTag("SithPatrol023"));
   Enemy(GetObjectByTag("SithPatrol022"));
   Enemy(GetObjectByTag("tat_bandon_thug2"));
   Enemy();
}

 

That is assuming that all the NPCs with those tags exist in the same area/module. If they are in another area the script can't find them. It also assumes that the Tag of the NPCs are correct. Make sure you have specified the Tag and not the Resref of the NPCs.

Link to comment
Share on other sites

thank you stoffe :) I'm glad I didn't go and upload it again like I did with previous versions :p I'd have to edit it again if I did :smash:

 

 

I'll make the changes right away, and then (once I get to my computer that actually plays the game) I'll playtest it and (hopefullY) finally be able to release it :D (provided everything else in the mod works well)

 

 

Once again stoffe, thanks :thmbup1: you are awesome :D

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...