Jump to content

Photo

Newbie questions - npcs faction join trouble, portal transitions


  • Please log in to reply
4 replies to this topic

#1
minigo

minigo

    Journeyman

  • Members
  • Pip
  • 23 posts

Hi, I've just started fooling around with the toolset for a few weeks using mostly prefabs to make my own little module.


I am having some problems with the toolset trying to make it do things I want it to do. I have a hard time grasping the scripting aspect of the toolset so I'm using scripts I've seen others use in different modules and scripts that have been explained in various toolset guides. I would be really grateful if someone could help me! Here are my problems:


1. I have created a conversation with a bad boss and his minions. I have set their faction to Commoner so that they don't attack the PC at the start. At the end of the conversation the boss flees and then I want the minions to attack the PC. I have tried using both ga_attack and ga_faction_join to get the minions to go from Commoner to Hostile. The problem is only one of them attacks the PC. That has probably got something to do with that they all have the same tag. I'm using the Death Knight creature blueprint and placed several of them in the area and changed everyone of them to Commoner. I guess I am probably going about this the wrong way...but how do I get ALL of them to attack me at the end of the conversation? I guess I could make everyone of them have different tags but there must be an easier sollution. I've tried to study other modules to figure out how they do it without success.


2. I made a portal in one area and I would want it to be sort of clickable by the PC to get the PC to transfer to another area. At the moment I'm using the NewAreaTransition trigger but that creates the "globe" graphics on the ground and I don't really want that. I tried using the Generic Trigger but I couldn't get that to work. Is there a way to do this?


Thank you all for your time! I hope someone has an answer.



#2
rjshae

rjshae

    Enthusiast

  • Members
  • PipPip
  • 224 posts

1.Yes, one way would be to give them all unique tags and fire the attack script for each one. Another is you could create a custom faction, assign the minions to it, then make the faction hostile to the player at the end of the conversation. Or you could write your own ga_mob_scene script and cycle through the creatures making each one hostile.

 

2. You could make the portal clickable, have it launch a conversation on use, and trigger the jump as an action in the conversation branch. Or you could use a generic trigger area to run a script that performs the party jump. The problem then is the player may be surprised by the unexpected jump.



#3
minigo

minigo

    Journeyman

  • Members
  • Pip
  • 23 posts

Thank you so much for the reply!

1. I managed to solve the first issue with the help of Aqvilinus on neverwintervault.org

He was kind to write a script for me that looked like this:

#include "ginc_group"

void CreateEnemyGroup()
{
    ResetGroup("group_badguys");
    object oPC = GetFactionLeader(GetFirstPC());
    int i = 1;
    object oBadGuy = GetNearestObjectByTag("tag_badguy", oPC, i);
    while(GetIsObjectValid(oBadGuy))
    {
        if(!GetIsDead(oBadGuy))
        {
            GroupAddMember("group_badguys", oBadGuy, TRUE);
        }
        i++;
        oBadGuy = GetNearestObjectByTag("tag_badguy", oPC, i);
    }
}

void main(int nAction)
{
    object oPC = GetPCSpeaker();
    switch ( nAction )
    {
        //Various conversation options
        case 100:
        break;

        case 200: //Enemy attack PC
            CreateEnemyGroup();
            object oCaptain = GetObjectByTag("tag_badguy_captain");
            object oWP =  GetObjectByTag("wp_captain_flees");
            AssignCutsceneActionToObject(oCaptain, ActionMoveToObject(oWP, TRUE));
            DelayCommand(0.0f, GroupGoHostile("group_badguys"));
            break;
    }
}

That managed to solve the issue with the minions not attack the PC. I wish I understood scripting better but I don't know if I have the patience to really learn how it works. When you say "make your own ga_mob_scene script" is that a script that is currently available in the toolset, and that one can modify it, or do you have to write it from scratch? I feel like, if there is a similar situation later in my mod when I want enemys to attack the PC after a conversation (without the part of the boss fleeing) that would be handy.

 

2. To launch a conversation was actually a pretty good idea. That would be quite easy actually. Even I could manage that. Still, it would be cool if the PC could walk to the portal, and when being close enough be transported to another area. I tried that before though by painting a New Generic (GenericTrigger) on the ground really close to the portal, and making a waypoint somewhere else, and then pointing the GenricTrigger to that. But that didn't work weirdly enough. When I do that with the New Area Transition there's never a problem. Any idea why that may be?


Edited by minigo, 04 August 2017 - 10:19 PM.


#4
Tchos

Tchos

    Cacoethes scribendi

  • Premium Member
  • 2,385 posts

Here's a script from Mysteries of Westgate that will cause any NPC with a specified tag to attack the PC Speaker in a conversation.  So if you have multiple death knights with their default tag, and you specify that tag in the conversation, they will all attack.  Keep in mind that this affects all death knights, or any creature that has the same tag as the death knights in the entire module, even if they're in different areas, up to the number that you set for "n".

// hf_a_group_npc_attack_by_tag
/*
	Description: Set a number of same tagged npc to hostile and then attack speaker
*/

#include "nw_i0_generic"

void main(string sTag, int n)
{
	object oNPC = GetObjectByTag(sTag);
	object oPC = GetPCSpeaker();
	
	int i;
	for (i = 0; i < n; i++)
	{
		ChangeToStandardFaction(oNPC, STANDARD_FACTION_HOSTILE);
		AssignCommand(oNPC, ActionAttack(oPC));
		oNPC = GetObjectByTag(sTag, i + 1);
	}
}

To use it, create a new script with any name you want, but I suggest putting "ga_" at the beginning of the name so it will show up when you add a conversation script.  The name doesn't really matter, but it automatically filters to show only scripts with "ga_" in the name, even though you can remove that filter.  Then compile the script, and it'll be ready to use.

 

The reason the normal attack script only affected one is that when you get an object by tag, it returns only the first object it finds matching that tag.  This script includes a loop that cycles through all objects it can find with that tag.

 

Generic triggers are extremely flexible and can be used for a very wide range of things, which is why they're not set up for transport specifically.  If you want to use a generic trigger to transport a player somewhere, you need to add a script to the trigger's On Enter script slot in its properties (the script will fire when any creature enters the trigger).  I believe the script would have to be custom, because as far as I know there's no built-in script for transporting the player's party just upon entering it, but if that's what you want, it can be done.  You can't read the Linked To field by script, though, so you'd have to use a local string containing the destination waypoint's tag and have the script read the local string on the trigger and jump to that tag. 

 

But I think that may be a little too advanced for you to be doing at this time.  It could be made a little simpler by naming the actual tag in the script itself and then you wouldn't have to use a local string, but then you'd need a new script for each area that you want to use this for.


Edited by Tchos, 05 August 2017 - 03:42 AM.


#5
minigo

minigo

    Journeyman

  • Members
  • Pip
  • 23 posts

Thank you for your insight Tchos!

 

That was really interesting to read. I think I'll stick to the New Area Transition for now since, as you say, the other way is too advanced for me at the moment.

 

That script was really interesting. I may have use of that further down the line in my module. It would be quite easy to make a uniqe blueprint with a uniqe tag that you only use once. That way you can use it in just that moment when you need for the baddies to attack the PC.

For this particular fight I think I'll stick with the one I got from Aqvilinus at the moment though, as that was proved to work.






IPB skins by Skinbox
Page loaded in: 0.896 seconds