Aller au contenu

Photo

Sarge's I need help thread


  • Veuillez vous connecter pour répondre
26 réponses à ce sujet

#1
Sgt KillEmAll

Sgt KillEmAll
  • Members
  • 11 messages
I loved playing AD&D back in the day, but it's a little low tech for my 10yo, he prefers video games to pencil and paper and rule books. So, I decided that I could still make this father/son thing work by creating a campaign world and adding modules to it as his character grows.
I have started my first (very basic) module and while I have made progress near completion, I am stuck on a few things that are keeping it from all coming together. I need help with some things that I'm sure are elementary to the more advanced scripters and I am seeking to learn from you.
I will start with the two things that has me stuck and then as each question gets answered, I'll ask a new one. Just to keep things organized.
 It all starts as most adventures do. The player has decided he is bored and takes off to seek fame and fortune. The first place (1st module) he comes to is a village in which the Mayor asks the player to find out why the towns miners have not returned from the mine.

1st problem- I noticed that when you make a new character, he doesn't have any weapons. How did you solve this without knowing what kind of character class a player would make?
2nd problem- I made 5 Companions that are standing by the mine but I only want the PC to be able to take 4 of them in. How do I do that? Right now he can take all 5. I may even add more to give more choices but I only want 4 in the party no matter what.
2a- Also, what if he changes his mind and comes out of the mine and wants the rogue to join so he can open doors? How do you script that? I don't have it where he can switch out companions (dont know how).

Anyway, that's it for this round of questions. Please keep in mind that I'm an uber n00b when it comes to scripting so the more detailed (step by step) your answers the better.

THANKS !!!
Sarge

#2
Morbane

Morbane
  • Members
  • 1 883 messages
1) Create a store - or - have a chest nearby with a variety of items to get started with and possibly sell for some spending money - you can set how much money any PC starts with by altering/creating a onEnter script to be placed in the module properties event list with some starting money if you choose the store option.



The chest option is used in the original campaign (OC)



Try getting that working and update us on your progress.

#3
Sgt KillEmAll

Sgt KillEmAll
  • Members
  • 11 messages
Thanks Morbane,
I like the idea of giving the PC some starter gold. I have a store with all of the basic items in the game and I could give him just enough to buy a basic weapon no matter what character class he picks to play.
This is where my lack of understanding scripting comes in.I know how to get to the Module Properties and see the onEnter area. I'm guessing you would use the ga_give_gold script that reads as follows:

// ga_give_gold
/*
This gives the player some gold
nGP = The amount of gold coins given to the PC
bAllPartyMembers = If set to 1 it gives gold to all the PCs in the party (MP only)
*/
// FAB 9/30
// MDiekmann 4/9/07 using GetFirst and NextFactionMember() instead of GetFirst and NextPC(), changed nAllPCs to bAllPartyMembers


void main(int nGP, int bAllPartyMembers)
{
object oPC = (GetPCSpeaker()==OBJECT_INVALID?OBJECT_SELF:GetPCSpeaker());
if ( bAllPartyMembers == 0 )
GiveGoldToCreature( oPC,nGP );
else
{
object oTarg = GetFirstFactionMember(oPC);
while(GetIsObjectValid(oTarg))
{
GiveGoldToCreature( oTarg,nGP );
oTarg = GetNextFactionMember(oPC);
}
}

}

Where in all that mess do I put in the amount of gold if I just wanted to give him 25 gold?

Modifié par Sgt KillEmAll, 29 janvier 2011 - 03:37 .


#4
Morbane

Morbane
  • Members
  • 1 883 messages
the ga_* scripts are generally for use in conversations - but - it can be modified to be used as a stand alone script...



void main()

{

object oPC = GetFirstPC();

GiveGoldToCreature(oPC, 500);

}



500 could be any hard coded number you might choose.



It really is pretty straight forward if you pick it all apart from the ga_** scripts.



Don't forget to compile the script and save your project before testing.

#5
Morbane

Morbane
  • Members
  • 1 883 messages
This tutorial might be of some use as well::

http://nwvault.ign.c...s.Detail&id=124



It was written by a bloke that is a strong scripter known as Knightmare - you will see him around these forums a lot.

#6
Mad.Hatter

Mad.Hatter
  • Members
  • 165 messages
I run a DM'd campaign with a group of close friends and family. Based on the tone of your post, I assume you're planning on DM'ing the campaign rather than being a second player. Forgive me if that was a poor assumption.



The beauty of a DM'd campaign is that not everything has to be (nor should be) scripted and very few conversations need to be written out. Want to give him starting gear when his character first appears in the game world? Great! Log in via the DM client, open the Creator, and give him the items or grant him gold through the normal context menus. If you aren't a solid scripter (which, once again I'll make an assumption--you probably aren't based on this question), you'll save yourself hours of pain AND ultimately be more adaptive and immersive.



If you want your campaign to progress at a relatively good pace (as in not spend 2-4 weeks between modules while you figure out how to script stuff) then script and write as little as possible. Dedicate most of your time to crafting an excellent plot, creating the necessary NPCs, monsters, and items, and creating or finding the necessary maps. Use prefabs as much as possible. Run your NPCs ab-lib with notes like you would in PnP.



Truthfully, the only things you should be scripting are things you can't accomplish with a few clicks of the DM client. For example, your core module events can't really be emulated (okay son, I'm now going to roll a real life die to see if you stabilize and recover from bleeding out--don't respawn yet!).



Now, if you're planning on being a player as well, that changes things completely.



I respect the world out of Morbane (his posts are always extremely helpful for a novice like myself), but for a DM'd campaign his recommendation is not the solution..

#7
Mad.Hatter

Mad.Hatter
  • Members
  • 165 messages
That last part came out way harsher than I intended. I apologize. What I meant to express is--"Why script things when you can use the DM tools to do it?"

#8
Morbane

Morbane
  • Members
  • 1 883 messages
Hmm, I think I will have to actually explore the DM Client! Sounds pretty cool - but there would need to be 2 PCs (or more) with internet access, yes?

#9
Sgt KillEmAll

Sgt KillEmAll
  • Members
  • 11 messages
Once again thank you Morbane, that script worked great. I'll start paying more attention to the other scripts besides the ga* ones. I just got in the habit of looking those over cause they're the only ones I've used so far.



@Mad.Hatter -- We may try the DM client later. Right now, I'm being a little selfish cause I'm kinda enjoying learning how to do this, and its fun creating a one player adventure that he can play at his convienance. Thanks for the advise, I had considered going that route and still may do it. After we get going I'll see if he has a couple of friends that may be interested, seems like it'd be more fun with 3 or 4 and a DM.



OK, that takes care of question #1, anybody got a cure for problem #2?



2nd problem- I made 5 Companions that are standing by the mine but I only want the PC to be able to take 4 of them in. How do I do that? Right now he can take all 5. I may even add more to give more choices but I only want 4 in the party no matter what.

2a- Also, what if he changes his mind and comes out of the mine and wants the rogue to join so he can open doors? How do you script that? I don't have it where he can switch out companions

(I dont know how).




#10
Shaughn78

Shaughn78
  • Members
  • 637 messages
You have 2 options for adding companions.



First is to use the ga_* add roster meber to party. This script will ignore the party limit set. to make it work you will need to add a conditional check to the conversation



PC: Join my party

NPC: Too many (gc_num_comps(>= limit) )

NPC: OK (ga_roster_party_add)



or you can call up the party roster. This will enforce the party limit and allow you to remove the extra player.

PC: Join my party - ga_roster_gui_screen



2a. The roster option will solve that. If you want to do it via conversation only (no roster gui) you will need to have a "leave the party" option in their dialog and have them despawn from the party and respawn at a waypoint outside the mine or where you want them to wait.



scripts you may need:

ga_roster_add_object -This will add the object to the roster

ga_roster_selectable -When set true this will allow you select companions in the party roster gui

ga_roster_party_add -Adds companion to party

ga_roster_gui_screen -Open roster gui from conversation

ga_roster_despawn -Remove companion from party and save them

ga_roster_spawn -Move or create companion at a givenwaypoint

gc_num_comps -Check the number of companion members

#11
Mad.Hatter

Mad.Hatter
  • Members
  • 165 messages
@Sgt

You know what they say about assumptions!



In addition to Shaughn's post, you might want to check this thread out:

http://social.biowar...-3181671-1.html



@Morbane: The DM Client is the best solution for multiplayer games. You can avoid spending tons of time scripting because on the fly you can do things like giving items, spawning encounters, talking through NPCs (including "conditional" nodes ;)), giving XP and so on. It does require a second connection because the DM is an actual player inside the game. If you ever want to mess around with it, I'll happily let you murder me in the OC or check out Carlo's "DM 101" mod on the Vault.

#12
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages
I'm going to suggest that you download a fairly simple campaign from the vault, play it, and then you can use the toolset to figure out how it does what you are trying to do. I'm going to suggest my own Kings Festival campaign because (1) it has solutions for both problems you mention, (2) it is a NWN2 remake of an original PnP campaign so it has that old D&D feel to it which you may enjoy, and (3) I wrote it so why not recommend it. I assume that you have MotB and SoZ as well as NWN2. They are required for King's Festival to work. If not then you should get them.



I have an older campaign on the vault called the Silverwand Sample Campaign which I designed specifically to help people like yourself who were just starting to create a campaign. It is short, easy to understand, and does many of the things I thought a typical basic campaign would require. However, it was written before MotB and SoZ were released and so it lacks some of the functionality that was provided with those expansions like player created party members.



Regards

#13
Sgt KillEmAll

Sgt KillEmAll
  • Members
  • 11 messages
@Shaughn78 - Thanks, I now have the limit on the party at 4+the PC and it works. I would like to be able to remove the party member via the roster gui, but, I would like for them to respawn in a spot incase I want to re-add them to the party later. I have Spawn points set up for each companion but I don't know how to get them to go there when I remove them from the roster (this is by using the roster gui, not, through conversation) right now they just dissapear when I remove them.

#14
Sgt KillEmAll

Sgt KillEmAll
  • Members
  • 11 messages
Alrighty, I now have everything working and the Module plays through quite well (thank you to all who replied, everyone contributed good ideas and I used most of them in some way or another), however, I have decided that it needs one good tweek and I'm not sure how to do it.

I have (as most modules do) a boss creature to fight at the end. The Heros walk into a room and there he is. They talk for a bit and then he attacks them (thank you Kaldor) I have now decided he needs a few bodyguards to fight along side him.

The boss goes hostile after the conversation from a conversation action but I'm having a little trouble figuring out how to link him and 4 minor minons so they don't attack until he does.

All help on this puzzle will be greatly appreciated.

#15
Dann-J

Dann-J
  • Members
  • 3 161 messages
The simplest way is to give all of the minions individual tags, set them to a non-hostile faction (defender, commoner, etc) and make each hostile in turn in the same conversation node as the boss.

If you want the minions to be a surprise, then make them hostile but script-hidden, place them in various shadowy corners, and un-hide them in the same conversation node that the boss turns hostile in.

I'm working on a module at the moment where many of the NPCs have a neutral faction, so you can attack them and make them hostile at any time. With a couple of local variables on each NPC, I've been able to define 'minion' and 'boss' tags so that when you attack or injure one, all of his friends turn hostile as well. Attacking a boss turns him and all of his minions hostile, while attacking a minion will turn all other generic minions with the same tag (and their boss, if they have a 'boss' variable set) hostile.

Once I get home I can look up the details of the script I'm using at the moment. The advantage of 'OnAttacked' or 'On Damaged' scripts is that no conversation is required.

Modifié par DannJ, 03 février 2011 - 04:11 .


#16
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages
For having a group turn hostile during a conversation I use the script below. To use it create a unique faction for the boss and his minions and make the faction neutral to your party so that he is willing to talk to you. On the conversation node in which they should all turn hostile use the below action script setting the CreatureTag parm to the boss's tag and the Target faction to HOSTILE.

// ga_bb_set_faction
// by Brendan Bellina
// Dec, 2007

// This script set all members of the specified creature's faction to a different standard
// faction. If being set to HOSTILE then they will attack the nearest PC.

#include "ginc_param_const"
#include "nw_i0_generic"
#include "ginc_actions"

void main(string sCreatureTag, string sTargetFaction)
{
// Get the PC Speaker - if used from command line, then use OBJECT_SELF
// In a conversation, OBJECT_SELF refers to the NPC.
// From the command line, OBJECT_SELF refers to the currently possessed character.
object oPC = (GetPCSpeaker()==OBJECT_INVALID?OBJECT_SELF:GetPCSpeaker());

// If debug text is on, this will let you know the script fired.
PrettyDebug("Script Fired on target: " + GetName(oPC) + "!");

int nFaction = GetStandardFaction(sTargetFaction);
object oCreature = GetObjectByTag(sCreatureTag);

if (nFaction != -1 && oCreature != OBJECT_INVALID)
{
int done = 0;
while (!done)
{
int count = 0;
object oFactionMember = GetFirstFactionMember(oCreature, FALSE);

while(GetIsObjectValid(oFactionMember) == TRUE)
{
if (oCreature != oFactionMember)
{
count++;
ChangeToStandardFaction(oFactionMember, nFaction);
if (nFaction == STANDARD_FACTION_HOSTILE)
StandardAttack(oFactionMember, GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC, oFactionMember));
else
AssignCommand(oFactionMember, DetermineCombatRound());
}
oFactionMember = GetNextFactionMember(oCreature, FALSE);
}

// Keep looping through until no faction member except the initial creature remain.
// Shouldn't really have to loop like this, but sometimes some creatures are missed.
done = (count == 0);
} // end while (!done)

ChangeToStandardFaction(oCreature, nFaction);
if (nFaction == STANDARD_FACTION_HOSTILE)
StandardAttack(oCreature, GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC, oCreature));
else
AssignCommand(oCreature, DetermineCombatRound());
}
}

Modifié par Kaldor Silverwand, 03 février 2011 - 05:22 .


#17
Dann-J

Dann-J
  • Members
  • 3 161 messages
Here's my version, that uses local variables to determine who is boss or minion to an individual creature. I use this as an 'OnDamaged' script for neutral-faction creatures. It should also work from a conversation node, turning the conversation owner and any of their same-tag allies, minions, or their boss hostile. It also un-hides any script-hidden creatures.

// OnDamaged script to make neutral
// creature and allies hostile
//
// variable Boss = tag of creature's boss
// variable Minions = tag of creature's minions
// no variables set makes all of same tag hostile

void MakeHostile(object oTarget)
{
SetPlotFlag(oTarget,0);
SetImmortal(oTarget,0);
SetScriptHidden(oTarget,0);
ChangeToStandardFaction(oTarget, STANDARD_FACTION_HOSTILE);
SetLocalInt(oTarget,"MadeHostile", 1);
}

void main()
{
string sMinion = GetLocalString(OBJECT_SELF,"Minions");
string sBoss = GetLocalString(OBJECT_SELF,"Boss");
int iOnce = GetLocalInt(OBJECT_SELF, "MadeHostile");

if (iOnce == 1)
{
ExecuteScript("nw_c2_default6", OBJECT_SELF);// run default OnDamaged script
return;
}

MakeHostile(OBJECT_SELF); // make caller hostile

if (sBoss != "")
{
object oBoss = GetObjectByTag(sBoss); // make their boss hostile
MakeHostile(oBoss);
}

if (sMinion == "")
sMinion = GetTag(OBJECT_SELF); // If has no minions (isn't a boss), make those with same tag hostile

object oTarg = GetObjectByTag(sMinion);

int i = 0;
while ( GetIsObjectValid(oTarg) )
{
i++;
iOnce = GetLocalInt(oTarg, "MadeHostile");
if (iOnce != 1)
{
MakeHostile(oTarg);
}
oTarg = GetObjectByTag(sMinion, i);
}

ExecuteScript("nw_c2_default6", OBJECT_SELF);// run default OnDamaged script
}

Modifié par DannJ, 03 février 2011 - 09:14 .


#18
Sgt KillEmAll

Sgt KillEmAll
  • Members
  • 11 messages
I tried both of the answers above and couldn't get them to work for me (I'm sure its me, not the scripts)



@Kaldor- I have a Boss named Nagash and I'm giving him 3 Goblin bodyguards so I created a new faction called nagashfac and they are set at 50 across the board. I then copied your script above and made a script called ga_fachostile. I added ga_fachostile to my nagash1 conversation and in the action script area I put Nagash's tag (nagash1) for the sCreature Tag (string) and I put HOSTILE for the sTargetFaction (string) and made sure to refresh and save. I then tested and after the conversation no one attacked. Any idea what I did wrong?



@DannJ- I made a script out of yours and put Nagash's tag in the line if (sBoss != "") so it ended up reading if (sBoss != "nagash1") and I put the tag of his minons in the line if (sMinion == "") so it read if (sMinion == "c_goblin_n") compiled and saved. I renamed it ga_bossminon_hostile and put it at the end of the conversation. I then tested. Nagash attacked but the 3 bodyguards did not. Any ideas on why?



Thanks for the help folks. I am learning a lot by being able to "reverse engineer" your scripts and seeing how it's done through examples. I really appreciate it.








#19
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Well if it works the same way for NWN1 couldn't you just do something really simple from the "ActionsTaken" conversation node like so:


#include "nw_i0_generic"
void main()
{
object oPC = GetPCSpeaker();
object oBodyGuard1 = GetNearestObjectByTag("BodyGuard1", oPC, 1);
object oBodyGuard2 = GetNearestObjectByTag("BodyGuard2", oPC, 1);
object oBodyGuard3 = GetNearestObjectByTag("BodyGuard3", oPC, 1);

DetermineCombatRound(oPC);
AssignCommand(oBodyGuard1, DetermineCombatRound(oPC));
AssignCommand(oBodyGuard2, DetermineCombatRound(oPC));
AssignCommand(oBodyGuard3, DetermineCombatRound(oPC));
}

Hope it helps. Good luck.

#20
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages

Sgt KillEmAll wrote...
@Kaldor- I have a Boss named Nagash and I'm giving him 3 Goblin bodyguards so I created a new faction called nagashfac and they are set at 50 across the board. I then copied your script above and made a script called ga_fachostile. I added ga_fachostile to my nagash1 conversation and in the action script area I put Nagash's tag (nagash1) for the sCreature Tag (string) and I put HOSTILE for the sTargetFaction (string) and made sure to refresh and save. I then tested and after the conversation no one attacked. Any idea what I did wrong?


Did you compile your ga_fachostile script?

The boss and minions must all be in the same faction.  Check this by clicking on each creature in the area (not the blueprints unless you are spawning them in via script) and looking at its properties.

Did you put the action on the correct conversation node? It needs to be on a node that is actually used.

Those are the ideas that come to mind.

#21
Sgt KillEmAll

Sgt KillEmAll
  • Members
  • 11 messages
Yes, I compiled and saved the script and it said it was ok. Nagash and all 3 guards are in the same faction, Nagashfac, and that faction is neutral (50). The Action is on the last node of the conversation where Nagash says "We're done talking, now you DIE!". At that point the conversation ends and they all just stand there looking at each other, still neutral I guess?

#22
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages
Here is a newer version of the script. It defaults to the conversation owner and the hostile faction, so you don't normally need to set the parameters at all. If you do, then set the faction to $HOSTILE.

// ga_bb_set_faction
// by Brendan Bellina
// Dec, 2007
// rev. June, 2008

// This script sets all members of the specified creature's faction to a different standard
// faction. If being set to $HOSTILE then they will attack the nearest PC.
// Defaults to conversation owner tag and $HOSTILE.

//  Parameters:
//  sCreatureTag - Tag of a creature who is in the faction to change, defaults to conversation owner
// 	sTargetFaction - One of the 4 standard factions $COMMONER, $DEFENDER, $HOSTILE, $MERCHANT.
//                   Defaults to $HOSTILE.

#include "ginc_param_const"
#include "nw_i0_generic"
#include "ginc_actions"

void main(string sCreatureTag, string sTargetFaction)
{
	// Get the PC Speaker - if used from command line, then use OBJECT_SELF
	// In a conversation, OBJECT_SELF refers to the NPC.
	// From the command line, OBJECT_SELF refers to the currently possessed character.
    object oPC = (GetPCSpeaker()==OBJECT_INVALID?OBJECT_SELF:GetPCSpeaker());

	// If debug text is on, this will let you know the script fired.
	PrettyDebug("Script Fired on target: " + GetName(oPC) + "!");

	if (sTargetFaction == "")
		sTargetFaction = "$HOSTILE"; // default to $HOSTILE
		
	int nFaction = GetStandardFaction(sTargetFaction);
	object oCreature;
	if (sCreatureTag == "")
		oCreature = GetTarget("", TARGET_OWNER);
	else
		oCreature = GetObjectByTag(sCreatureTag);
	
	if (nFaction != -1 && oCreature != OBJECT_INVALID)
	{
		int done = 0;
		while (!done)
		{
			int count = 0;
			object oFactionMember = GetFirstFactionMember(oCreature, FALSE);

			while(GetIsObjectValid(oFactionMember) == TRUE)
			{
				if (oCreature != oFactionMember)
				{
					count++;
					ChangeToStandardFaction(oFactionMember, nFaction);
					if (nFaction == STANDARD_FACTION_HOSTILE)
						StandardAttack(oFactionMember, GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC, oFactionMember));
					else
						AssignCommand(oFactionMember, DetermineCombatRound());
				}
				oFactionMember = GetNextFactionMember(oCreature, FALSE);
			}

			// Keep looping through until no faction member except the initial creature remain.
			// Shouldn't really have to loop like this, but sometimes some creatures are missed.
			done = (count == 0);
		} // end while (!done)
	
		ChangeToStandardFaction(oCreature, nFaction);
		if (nFaction == STANDARD_FACTION_HOSTILE)
			StandardAttack(oCreature, GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC, oCreature));
		else
			AssignCommand(oCreature, DetermineCombatRound());
	}
}

For a small number of creatures you can also use the standard script ga_faction_join, but you need to do it for each creature individually.

Regards

Modifié par Kaldor Silverwand, 04 février 2011 - 04:12 .


#23
Sgt KillEmAll

Sgt KillEmAll
  • Members
  • 11 messages
That second one worked GREAT Kaldor! I know have my final battle and the module is almost done at this point. All I have to do now is clean up a few areas with some environmental stuff just for atmosphere and add a few NPC villagers here and there and maybe tweek a few of the conversations so they're not so B movie sounding and I think it will be ready to play.

Thanks to everyone that helped and had patients with my questions (espescially you Kaldor)

#24
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages
Glad to help. Good luck with the father son bonding.



Regards

#25
Sgt KillEmAll

Sgt KillEmAll
  • Members
  • 11 messages
Is there a way to delay the automatic respawn feature? I would like for any "dead" companions to not auto respawn after being "killed" for a few minutes, the PC too. A kind of penalty for getting killed. Is there a way to do this?