lfnetwork.com mark read register faq members calendar

Thread: A fight between PC and Party member
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 12-01-2005, 05:36 PM   #1
Pavlos
Scruffy Englishman
 
Pavlos's Avatar
 
Join Date: Sep 2005
Location: The real world/ivory towers
Posts: 1,974
Current Game: Viking Warrior Poets
A fight between PC and Party member

Code:
void main()
{
  object oPC= GetFirstPC();
  object oNPC= GetObjectByTag("kreia");
  object oWeap= CreateItemOnObject("kre_light",oNPC);
  AssignCommand (oNPC, ActionEquipItem(oWeap, INVENTORY_SLOT_RIGHTWEAPON));
  SetMinOneHP(oPC, 1);
  SetMinOneHP(oNPC, 1);
  ChangeToStandardFaction(oNPC, STANDARD_FACTION_PREY);
  ChangeToStandardFaction(oPC, STANDARD_FACTION_PREDATOR);
}
That much I can do on my own. However I am at a loss as to where to go next. What I wish to do is to start a fight between Kreia and the PC. I can equip kreia with a lightsaber and then set the PC hostile and her hostile but in such a way that everyone else should be neutral to them. However how do I make it so that when Kreia is down to 0VP the fight ends and it goes on to a new dialogue with her. I know how to resume a dialogue via a script it is just the bit inbetween. Also would I do the same thing as anyone suggests for the PC reaching 0VP only alter it slightly. I'd imagine it would involve local booleans and all that but I just can't fathom it! But I'm pleased with my progress anyway *Smiles to self while everyone s******s*
Pavlos is offline   you may: quote & reply,
Old 12-01-2005, 05:49 PM   #2
Achilles
Dapper Chimp
 
Achilles's Avatar
 
Join Date: May 2004
Posts: 8,204
Helpful! Veteran Modder Forum Veteran 
Well, I know absolutely nothing about scripting, but I do have a couple of questions/suggestions that may or may not be helpful:

1) Have you looked at the Secret Tomb fight to see how the devs did it? Is there source code referenced there that might be helpful?

2) Would it be possible to use existing "cheater" scripts (ala the giveitem script) to run this via a dialog without having to build your own code?
Achilles is offline   you may: quote & reply,
Old 12-01-2005, 06:05 PM   #3
Pavlos
Scruffy Englishman
 
Pavlos's Avatar
 
Join Date: Sep 2005
Location: The real world/ivory towers
Posts: 1,974
Current Game: Viking Warrior Poets
I intended to look at the Handmaiden fights but DeNCS doesn't seem to be able to handle it. What do you mean in number two? I'm sorry I don't quite understand it.

Edit: Oh I see what you mean! Erm well I tried a_atkonend but all my party came in and attacked Kreia, lol. So I decided to make an all inclusive one. What my problem is that I cannot get the fight to stop! They just carry on fighting, I set them to invinisible to avoid Kreia being killed so I need to know how to start up 1 dialogue option when Kreia reaches 0VP and the other when the PC reaches 0VP. As I say I'd imagine it would have something to do with Local Booleans being set but how do I get it to recognise that the PC or Kreia is on 0VP? Would this have something to do with the heartbeat script? I don't want to change anymore than is necessary.

Last edited by Pavlos; 12-02-2005 at 04:04 AM.
Pavlos is offline   you may: quote & reply,
Old 12-02-2005, 06:18 AM   #4
stoffe
Network Caretaker
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,833
Helpful! 10 year veteran! Notable contributor 
Quote:
Originally Posted by Pavlos
SetMinOneHP(oPC, 1);
SetMinOneHP(oNPC, 1);
ChangeToStandardFaction(oNPC, STANDARD_FACTION_PREY);
ChangeToStandardFaction(oPC, STANDARD_FACTION_PREDATOR);
You can't change the faction of the player character (or any members of the active party). They are automatically set to a special "Party" faction when they are added to the active party that there is no scripting constant defined for.

If Kreia isn't in the active party, just set her to STANDARD_FACTION_HOSTILE1 instead and she'll attack the player (remove her from the active party first if she is in it). Set any nearby creatures you don't want to interfere to STANDARD_FACTION_NEUTRAL, or disable their AI. You can turn off their AI by setting Local Boolean 87 to TRUE on them.


Quote:
Originally Posted by Pavlos
how do I make it so that when Kreia is down to 0VP the fight ends and it goes on to a new dialogue with her.
Since SetMinOneHP(), which you used above, prevents the creature from dropping below 1 VP, it wouldn't be meaningful to check if they are down to 0 VP since they never will be. Also, 0 VP = Death, so you could just as well use GetIsDead() instead then.

Nitpicking aside, the easiest way is probably to alter the custom OnDamaged event script of Kreia so that it checks her current VP whenever she is hit during the fight (set a Global to indicate that the fight is on). When her current VP is down to 1, call ClearAllActions(), CancelCombat() and set Kreia's faction back to STANDARD_FACTION_FRIENDLY1 (or add her to the active party again).

The easiest way would be to check the player's hitpoints in Kreia's OnDamage event script as well, and end the fight if the player is near death too. While it'll only make the player lose if they manage to hit Kreia, it saves you an extra script since you can't change which AI scripts the player character uses (and it's unnessesary to bog down the generic AI scripts with extra code of this specific nature).

You may need to kickstart the battle as well, since sometimes the combat AI doesn't trigger if a creature turns hostile right in front of their enemy. You can do this by calling...
Code:
ExecuteScript("k_ai_master", oNPC, 1003);

stoffe is offline   you may: quote & reply,
Old 12-02-2005, 08:44 AM   #5
Pavlos
Scruffy Englishman
 
Pavlos's Avatar
 
Join Date: Sep 2005
Location: The real world/ivory towers
Posts: 1,974
Current Game: Viking Warrior Poets
Thanks a lot I'll try that out. Just one little thing what is the function for checking a character's VP? Other than that I should be ok. Note: "Should."
Pavlos is offline   you may: quote & reply,
Old 12-02-2005, 04:12 PM   #6
Pavlos
Scruffy Englishman
 
Pavlos's Avatar
 
Join Date: Sep 2005
Location: The real world/ivory towers
Posts: 1,974
Current Game: Viking Warrior Poets
Code:
int StartingConditional()
{
  
    object oNPC= GetObjectByTag("kreia");    
    int nCurHP= GetCurrentHitPoints(oNPC);
    
    if ((nCurHP < 10))
                      {
                          ClearAllEffects();
                          ClearAllActions();
                          CancelCombat(oNPC);
                          ChangeToStandardFaction(oNPC, STANDARD_FACTION_FRIENDLY_1);
                          ActionDoCommand(ActionStartConversation(oNPC));
                       }
     

}
Would something like that work? I don't know what to put for an else I take it I need one. Is there a resume combat function? Any help would be appreciated.
Pavlos is offline   you may: quote & reply,
Old 12-03-2005, 12:46 AM   #7
Aurelius
Banned
 
Aurelius's Avatar
 
Status: Banned
Join Date: Apr 2005
Location: Mordor
Posts: 63
does anyone know how to script a fight between...
NPC Party member and NPC non-party member ?


example:
Atton fights the Twin Suns in the game


how does one go about isolating the NPC party member so you can control them and picking a fight with a NPC non-party member via script?
(and wouldnt there need to be some kind of exit scipt by the NPC non-party members death... i mean i dont want to be stuck controlling the NPC party member as the PC indefinately)


sorry to leech off your thread Pavlos, but the question is in related and a great place to ask
Aurelius is offline   you may: quote & reply,
Old 12-03-2005, 08:03 AM   #8
stoffe
Network Caretaker
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,833
Helpful! 10 year veteran! Notable contributor 
Quote:
Originally Posted by Pavlos
(snip)
Would something like that work? I don't know what to put for an else I take it I need one. Is there a resume combat function? Any help would be appreciated.
If this is run as Kreia's OnDamaged event script (rather than as a dialog conditional script with seems to be the case, for some reason) you don't need to get object by tag, you can use OBJECT_SELF instead since she's the one running the script.

Further, ActionDoCommand(ActionStartConversation(oNPC)); is rather unnessesary to do. The ActionDoCommand() function adds a function call to the action queue of the object, but functions with named starting with Action... are already added to the action queue. Just...
Code:
ActionStartConversation(GetFirstPC());
... should work.


Since I don't know anything about the situation where this will be used it's hard to say if this does what you want, but I think a custom OnDamaged event script like the one below, assigned to Kreia, might work. You'll need to add a new global for this (i used ST_KREIA_FIGHT_ON in the example below) to globalcat.2da, and set this global to TRUE when the fight starts.

While that is the easy way, it might be better to alter the custom userdefined event script and catch the OnDamaged event there instead since you are modifying a standard game character. It's probably not a good idea to alter Kreia's template (both to avoid possible naming conflicts and to prevent you from having to start a new game for the change to take effect). Just make the below main() into a custom function instead (remember to remove the call to "k_ai_master if you do this). Then add it to k_oei_hench_inc.nss, call the new function from DoKreiaUserDef() under the OnDamaged (1006) case. You'll probably need to enable the custom OnDamaged event in the DoKreiaSpawnIn() too, by adding GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DAMAGED); somewhere near the top of that function.

Code:
#include "k_inc_switch"

void StopFighting(object oCreature=OBJECT_SELF) {
    AssignCommand(oCreature, ClearAllEffects());
    AssignCommand(oCreature, ClearAllActions());
    CancelCombat(oCreature);
    DelayCommand(0.4, SetMinOneHP(oCreature, FALSE));
}

void main() {
    if (GetGlobalBoolean("ST_KREIA_FIGHT_ON") && (GetCurrentHitPoints() < 10)) {
        SetGlobalBoolean("ST_KREIA_FIGHT_ON", FALSE);
        
        object oPC = GetFirstPC();
        SurrenderToEnemies();
        StopFighting();
        StopFighting(oPC);
        ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_FRIENDLY_1);
        
        NoClicksFor(0.5);
        DelayCommand(0.5, ActionStartConversation(oPC));
    }
    else {
        ExecuteScript("k_ai_master", OBJECT_SELF, KOTOR_HENCH_EVENT_ON_DAMAGE);
    }
}

stoffe is offline   you may: quote & reply,
Old 12-03-2005, 12:57 PM   #9
Pavlos
Scruffy Englishman
 
Pavlos's Avatar
 
Join Date: Sep 2005
Location: The real world/ivory towers
Posts: 1,974
Current Game: Viking Warrior Poets
I hate to sound terribly ignorant now but how would I add it to k_oei_hench_inc.nss as a custom function? Do I just put my script inside that one and compile? Also, though you know far better than me (For obvious reasons) surely your
Code:
 GetGlobalBoolean("ST_KREIA_FIGHT_ON")
wouldn't work as it is not check whether or not it is active. Should it be:
Code:
 (GetGlobalBoolean("ST_KREIA_FIGHT_ON") == TRUE
?
I'm not going to use your script but hopefully build my own, I hate stealing other people's work. I just want to know whether that correction is, uh, correct and also how I go about adding the custom function. I'm really new to this whole concept. Thanks for all your help.
Pavlos is offline   you may: quote & reply,
Old 12-03-2005, 04:30 PM   #10
stoffe
Network Caretaker
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,833
Helpful! 10 year veteran! Notable contributor 
Quote:
Originally Posted by Pavlos
I hate to sound terribly ignorant now but how would I add it to k_oei_hench_inc.nss as a custom function? Do I just put my script inside that one and compile?
Near the top of k_oei_hench_inc.nss, just after the function prototypes, add these two functions:
Code:
// ST: NEW FUNCTION! Add after the function prototypes near the top of k_oei_hench_inc.nss
void StopFighting(object oCreature=OBJECT_SELF) {
    AssignCommand(oCreature, ClearAllEffects());
    AssignCommand(oCreature, ClearAllActions());
    CancelCombat(oCreature);
    DelayCommand(0.4, SetMinOneHP(oCreature, FALSE));
}

// ST: NEW FUNCTION! Add after the function prototypes near the top of k_oei_hench_inc.nss
void SurrenderOnLostDuel() {
    if (GetGlobalBoolean("ST_KREIA_FIGHT_ON") && (GetCurrentHitPoints() < 10)) {
        SetGlobalBoolean("ST_KREIA_FIGHT_ON", FALSE);
        
        object oPC = GetFirstPC();
        SurrenderToEnemies();
        StopFighting();
        StopFighting(oPC);
        ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_FRIENDLY_1);
        
        NoClicksFor(0.5);
        DelayCommand(0.5, ActionStartConversation(oPC));
    }
}
Then go down and find the implementation of the function DoKreiaSpawnIn() and make the following changes to it:
Code:
// ST: THIS FUNCTION ALREADY EXISTS! Added line at the top...
void DoKreiaSpawnIn(object oPartyMember, string sModuleName) {
    // ST: Added this line to handle duel!
    GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DAMAGED);

    int In003EBO = (sModuleName == "003EBO");
    int In711KOR = (sModuleName == "711KOR");

    if (In003EBO && (GetGlobalBoolean("003_cutscene_mode") == FALSE)) {
        AssignCommand(oPartyMember, GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DIALOGUE_END));
        AssignCommand(oPartyMember, ActionPlayAnimation(ANIMATION_LOOPING_MEDITATE, 1.0, -1.0));
    }
    else if (In711KOR) {
        GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DAMAGED);
        SetMinOneHP(oPartyMember,TRUE);
    }
}
Then find the implementation of the function DoKreiaUserDef() and make these changes to it:
Code:
// ST: THIS FUNCTION ALREADY EXISTS! Added call to custom function at ONDAMAGED event.
void DoKreiaUserDef(object oPartyMember,int pUserEvent, string sModuleName) {
    int In003EBO = (sModuleName == "003EBO");
    int In711KOR = (sModuleName == "711KOR");

    if (In711KOR) {
        Do711UserDef(oPartyMember, pUserEvent);
        return;
    }
    
    if (In003EBO && (GetGlobalBoolean("003_cutscene_mode") == FALSE)) {
        switch(pUserEvent) {
            case 1001://HEARTBEAT
            case 1002://PERCEIVE
            case 1003://END OF COMBAT
            case 1004://ON DIALOGUE
            case 1005://ATTACKED
            case 1006://DAMAGED
                // ST: Added call to custom function here...
                SurrenderOnLostDuel();
                break;
            case 1007://DEATH
            case 1008://DISTURBED
            case 1009://BLOCKED
            case 1010://SPELL CAST AT
                break;
            case 1011: //DIALOGUE END
                AssignCommand(oPartyMember, ActionPlayAnimation(ANIMATION_LOOPING_MEDITATE, 1.0, -1.0));
                break;
            case 1100://HOSTILE RETREAT
                AssignCommand(oPartyMember, UT_ReturnToBase());
                break;
        }
    }
}
Now, since the k_oei_hench_inc.nss file is an include file and not a stand-alone script you'll need to recompile the two scripts that use it that are relevant for this task. Save your modified k_oei_hench_inc.nss in the same folder as nwnnsscomp.exe and then recompile the scripts k_oei_spawn.nss and k_oei_userdef.nss. Put the resulting NCS files in override.

Quote:
Originally Posted by Pavlos
Also, though you know far better than me (For obvious reasons) surely your
Code:
 GetGlobalBoolean("ST_KREIA_FIGHT_ON")
wouldn't work as it is not check whether or not it is active. Should it be:
Code:
 (GetGlobalBoolean("ST_KREIA_FIGHT_ON") == TRUE
?
GetGlobalBoolean already returns a valid boolean value used as a parameter in the if-statement, it's unnessesary to do a check that produces the same result in this case. If the boolean is FALSE, GetGlobalBoolean() will return FALSE already, just like (GetGlobalBoolean() == FALSE) would.

And, in the cases of LocalBooleans it's dangerous to check directly if the value equals TRUE, since that function seems to either return FALSE or !FALSE (not FALSE). I.e. TRUE in NWScript is a constant with the value 1 and FALSE is a constant with value 0, but that function for some reason often return either 0 (FALSE) or a much larger value (which evaulates to a true boolean value, but not the NWScript TRUE constant). Any number other than 0 evaluates to a logical true value in nwscript, while a value only equals TRUE (as in the constant) if it's 1 and nothing else.

For example:
Code:
int nTest = 12;

if (nTest) {
    // This is run, since the test is true..
}

if (nTest == TRUE) {
    // This is not run, since 12 (bTest) does not equal 1 (TRUE)
}


Last edited by stoffe -mkb-; 12-04-2005 at 06:47 AM.
stoffe is offline   you may: quote & reply,
Old 12-04-2005, 02:50 AM   #11
Pavlos
Scruffy Englishman
 
Pavlos's Avatar
 
Join Date: Sep 2005
Location: The real world/ivory towers
Posts: 1,974
Current Game: Viking Warrior Poets
Wow thanks for your help but still it wont work. I have the following script for activation in my dialogue:
Code:
void main()
{
  object oNPC= GetObjectByTag("kreia");
  object oWeap= CreateItemOnObject("kre_light",oNPC);
  AssignCommand (oNPC, ActionEquipItem(oWeap, INVENTORY_SLOT_RIGHTWEAPON));
  ChangeToStandardFaction(oNPC, STANDARD_FACTION_HOSTILE_1);
  SetGlobalBoolean("ST_KREIA_FIGHT_ON", TRUE);
}
Then I made the changes that you suggested and Kreia wont stop fighting! I have to kill her! GAH! It is probably something really obvious that I have gotten wrong but I can't think what.
Pavlos is offline   you may: quote & reply,
Old 12-04-2005, 10:00 AM   #12
Pavlos
Scruffy Englishman
 
Pavlos's Avatar
 
Join Date: Sep 2005
Location: The real world/ivory towers
Posts: 1,974
Current Game: Viking Warrior Poets
Oh stupid me! I need to re-enter the module as the script for all the characters has changed. It works now. Do you mind if I use your changes? Thanks for all your help! Do you know how I would get it to result differently for a PC getting down to a certain level of health? Thanks once more!

Last edited by Pavlos; 12-04-2005 at 11:30 AM.
Pavlos is offline   you may: quote & reply,
Old 06-25-2009, 10:35 AM   #13
gsusfrk
Rookie
 
gsusfrk's Avatar
 
Join Date: Jun 2009
Location: Waiting to stage an ambush
Posts: 40
Current Game: COD:WAW and KOTOR II
Another way to get two creatures to fight and for everyone else to leave them alone is to set them as Predator and Prey. This makes them hostile to each other but neutral to everyone else. Check the last post in this thread to help you out.


gsusfrk is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > Knights of the Old Republic > Editing / Modding > Holowan Laboratories > A fight between PC and Party member

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:27 AM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.