Aller au contenu

Photo

local integers


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

#26
Shallina

Shallina
  • Members
  • 1 011 messages
GetFirstPC(TRUE) to get the created character or main char of a party.

GetFirstPC(FALSE) to get the controled character wich can be an henchman.

Those are just exmple where you need those function if you don't want to do a loop each time, wich isn't good if it run in a heartbat.

MP scripting is fine and all, but if you are doing a party with henchmen, it doesn't always work for everything.

After hearbat to much used and so on, that's an other story.

Don't put in the same bag an implementation wich isn't working as it should with the use of function instead of an other.

Doing a loop each time instead of using GetFirstPC just to don't use getFirstPC in a hearbat for exemple isn't really good.

It's all depend of the target of your module. single player isn't scripted the same a multiplayer.

Different constraints means different way to do it. NWN2 scripting is powerfull enought for it.

Modifié par Shallina, 26 octobre 2011 - 10:28 .


#27
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
Your example is out of context, where are you using GetFirstPC() exactly, then let us get the nuts and bolts of if that is the correct function.

I rely on the following functions to get those:

object GetOwnedCharacter( object oControlled );
object GetControlledCharacter( object oCreature );
object GetFactionLeader(object oMemberOfFaction);

There is no simple answer as to how to get the object those are called on, as you HAVE to know the event you are dealing with, and in some cases GetFirstPC() is a good option. The issue is this function should be your last resort, and your first step should be comparing the function you wish to write to similar functions written by the developers of the game.

If your goal is to have a simple answer which always works, well you already have your answer. However if a scripter comes here, asking how to do a script for a particular event, and i suggest using a function that works, and it turns into a SP vs MP debate. SP and MP have far more in common than they have different, and we are too small of a community to turn every discussion into a us versus them type of thing, especially when there are official examples by the game developers showing the correct usage of functions in the events for the SP game which you can refer to.

#28
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
I'm not taking sides in the debate here, just wanted to say that I have written hundreds of scripts for a SP module, fired from all sorts of events, and have never ever had GetFirstPC() let me down. However, pain has a good point, you have to know what you are trying to refer to. In my case, since it is SP, I save variables on the PC. Since I always want to save it to, and retrieve it from, the same specific PC (the one the player created at game start) I use GetFirstPC() which of course has GetFirstPC(TRUE) as the default unless you put the FALSE in there. When I do things where I want it to affect the currently controlled PC (in a multi-character [not multi-player] module) I use GetFirstPC(FALSE). For other things, like wanting to do something to the last character that attacked or whatever, I will use a different function entirely to get the PC.

As far as SP scripting goes, the following are interchangeable when referencing the PC:
GetFactionLeader() = GetFirstPC(TRUE) - both return the originally created PC
GetControlledCharacter() = GetFirstPC(FALSE) - both return the currently controlled character

Modifié par _Knightmare_, 27 octobre 2011 - 12:12 .


#29
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
When I stopped using GetFirstPC() for my scripts, and forced myself to familiarize myself with the various object identifiers, I developed a fuller and more functional understanding of how my scripts were working. This helped me improve my understanding of the logic and write scripts with fewer bugs and greater utility from the outset.

I think that is is beneficial for a beginning scripter (like me) to force him/herself to take a stricter approach to object identification. In the long run I believe it has saved me time. The few extra minutes it may take you to track down the right identifier is offset by the greater understanding of scripting that you gain. You eventually learn to do more things better, plus your mod is now much more compatible for MP, which is a selling er.... downloading point.....

#30
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
For this situation, the event only matters in terms of advancing the plot. It doesn't matter who or what is the actual cause of death, only that the NPC has been killed and that affects the (first) PC's plot status. So the OP really didn't want the last killer, but the chief protagonist, the PC.

Saying "never use GetFirstPC(), except in a loop with GetNextPC()" is like those annoying English teachers that say "never use the passive voice". Sure, it gets some people to write better, but sometimes it's just the right tool for the job.

BTW, is the object returned by GetFirstPC() always the player's original created character, or does it fluctuate between different party members? In a MP game, is it always the player that logged in first?

#31
kevL

kevL
  • Members
  • 4 052 messages
void main()
{
  object oPC = GetFirstPC();
  object oPC_false = GetFirstPC(FALSE);

  string sPC = GetName(oPC);
  string sPC_false = GetName(oPC_false);

  SendMessageToPC(oPC_false, "___oOo___");
  SendMessageToPC(oPC_false, "object oPC : " + sPC);
  SendMessageToPC(oPC_false, ". . Is PC : "
      + IntToString(GetIsPC(oPC)));
  SendMessageToPC(oPC_false, ". . Is Owned By Player : "
      + IntToString(GetIsOwnedByPlayer(oPC)));
  SendMessageToPC(oPC_false, ". . Is Player Created : "
      + IntToString(GetIsPlayerCreated(oPC)));
  SendMessageToPC(oPC_false, ". . Is Roster Member : "
      + IntToString(GetIsRosterMember(oPC)));

  SendMessageToPC(oPC_false, "\\nobject oPC_false : " + sPC_false);
  SendMessageToPC(oPC_false, ". . Is PC : "
      + IntToString(GetIsPC(oPC_false)));
  SendMessageToPC(oPC_false, ". . Is Owned By Player : "
      + IntToString(GetIsOwnedByPlayer(oPC_false)));
  SendMessageToPC(oPC_false, ". . Is Player Created : "
      + IntToString(GetIsPlayerCreated(oPC_false)));
  SendMessageToPC(oPC_false, ". . Is Roster Member : "
      + IntToString(GetIsRosterMember(oPC_false)));


  object oFL = GetFactionLeader(oPC);
  string sFL = GetName(oFL);
  SendMessageToPC(oPC_false, "\\n. Faction Leader ( oPC ) : " + sFL);

  object oOC = GetOwnedCharacter(oPC);
  string sOC = GetName(oOC);
  SendMessageToPC(oPC_false, ". Owned Character ( oPC ) : " + sOC);

  object oCC = GetControlledCharacter(oPC);
  string sCC = GetName(oCC);
  SendMessageToPC(oPC_false, ". Controlled Character ( oPC ) : " + sCC);

  oFL = GetFactionLeader(oPC_false);
  sFL = GetName(oFL);
  SendMessageToPC(oPC_false, "\\n. Faction Leader ( oPC_false ) : " + sFL);

  oOC = GetOwnedCharacter(oPC_false);
  sOC = GetName(oOC);
  SendMessageToPC(oPC_false, ". Owned Character ( oPC_false ) : " + sOC);

  oCC = GetControlledCharacter(oPC_false);
  sCC = GetName(oCC);
  SendMessageToPC(oPC_false, ". Controlled Character ( oPC_false ) : " + sCC);
}


Image IPB

Modifié par kevL, 27 octobre 2011 - 07:17 .


#32
Shallina

Shallina
  • Members
  • 1 011 messages
GetControlledCharacter() : You are in a MP setting with a party wich has 4 players and 2 henchmen.


Wich one will you get ? Exactly the same problem as GetFirstPC(FALSE), it can gives you 4 different object. Having it working flawlessly in a MP setting require more than just using GetFactionLeader() or GetControlledCharacter()

You have to check all the time for event, and when you can't check for event, you need to loop amongs  player and create your own event to catch the good one.

If your goal is a SP module and you need to do something like this in a heartbat, it won't be good, you'll "charge" your heartbat to much. And it's also an heavy number of hours for scripting that is not really necessary for a SP module.

Modifié par Shallina, 27 octobre 2011 - 06:48 .


#33
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

Lugaid of the Red Stripes wrote...

BTW, is the object returned by GetFirstPC() always the player's original created character, or does it fluctuate between different party members? In a MP game, is it always the player that logged in first?


It is the same in single-player, it gets the PC who logged in first. But, in SP, that is always the original character. Thus it is always the main PC. GetFirtPC(FALSE) gets the character the player is currently controlling, which could be the original character if the player is controlling them at the specific time.

#34
PJ156

PJ156
  • Members
  • 2 980 messages
I'm learning a lot here folks, some of it I even understand.

In the end I dropped the on damage script as advised and went with GetLastKiller.

void main()
{
object oPC = GetLastKiller();
int nInt;
nInt = GetLocalInt(oPC, "0001_killed");
nInt += 1;
SetLocalInt(oPC, "0001_killed", nInt);


I keep the integer on the PC as this is firmly SP and at this satge there are no others to confuse things.

Anyways, it works. The integer lets me work out how many were killed of the three but also where they were standing.

Heh the irony is I now have eight pc nodes ranging from I killed the one on the back porch to I snuck past them all but the player is only going to see one of those (the one that is true) and I'm going to get comments about not having enough convo choice.

Ah well is a good job this pays so well ...

PJ

#35
Shallina

Shallina
  • Members
  • 1 011 messages
GetLastKiller give the killer object, not the player.

If it's a party with henchmen, it will be stored on the henchman which does the kill.

So if you have several henchmen the count will be spread amonst all those which perform a kill. And you won't be able to count th enumber of mob killed propely.

if one of the "helpers " die you'll nevers got your count if the number of creature to count is "exact" and that they are not respawned.

If you have NPC helping the player that aren't in the party, you'll nevers get the count unless your circle all the creature.

So this works great in aMP setting where player have no henchmen and when you want to count what each player did.

But in a SP module with henchmen, it will be more complex, you ll need to circle all the party member and make an addition of each party member count. And of course if the party member can change during the count you are screwed.


In a SP module and if the event s a one shot event I would store the information in the area or the module, not in the player.

Modifié par Shallina, 27 octobre 2011 - 09:11 .


#36
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
I would suggest that to do what you want, it's a bit complicated, and what you want is not to set something on the PC, but something on the quest itself. In other words you can aim your variables at either the character or the door, the door is much more likely to be entirely under your control, while who kills who, or even if the PC object is talking to the final conversation owner is an open question - rail roading the player though can ensure this is a non issue of course.

This eliminates the entire issue of the PC and what they are doing, and allows for the player to use companions, remove some of those companions and swap them out, and even do some wonky save game editing and this all should work.

void main()
{
object oQuestGuy = GetObjectByTag( "QuestGuysTag" );
int nInt;
nInt = GetLocalInt(oQuestGuy, "0001_killed");
nInt += 1;
SetLocalInt(oQuestGuy, "0001_killed", nInt);
} 

Now the object which has the tag "QuestGuysTag" can be a waypoint, ipoint placeable, or it can be the actual object you are going to be talking to later ( which you would have as a object with the convo parameters already ).

If you want the speaker to know if the killer was the person talking to them at the moment ( ie companions or player ) setting the name as well, but this ensures that no matter who kills or talks, your module will work if those 3 ( or whatever ) hoodlums have been killed.

Not you can remove this code entirely in the on killed code, and put the code into the conversation the character is doing, with some thing like the following, this could be put into a conditional script, and solve the exact same problem.

You can use "gc_obj_valid" which i think already exists to test for your guards, but is mainly useful if you want to really test if they are all dead instead of having different convos based on how many are left alive. Lets assume your guards have the tag of "QuestGuard". This could be adjusted easily to test for guard 2 being alive, guard 3 by putting a number in GetObjectByTag(sTag) after sTag as i do in the example code below.

int StartingConditional(string sTag, int bAreaOnly, int nNth )
{
	object oObject;
	
	if ( nNth == 0 )
	{
		nNth = 1;
	}
	
	if (bAreaOnly == 0)
	{
		// Search module	
		oObject = GetObjectByTag(sTag, nNth);
	}
	else
	{
		// Search area from owner only
		oObject = GetNearestObjectByTag(sTag, OBJECT_SELF, nNth );
	}

	return GetIsObjectValid(oObject);
}


I kind of wonder what would happen if the player saw the given guard, used a clone, simulcrum type of spell on it, which ended up also using the original event and tag on the copied creature. Then proceeded to get that simulcrum killed, thus increasing the number killed above the number you were expecting. This could create rare conditions where the integer is higher than you expect, or that one of the guards is still alive but the count is equal to the number which expected when all are dead.

Storing it on the PC though id suggest if you happen be using a situation where they have to personally kill a certain type of creature, sort of like the kill 3 rabbits quest, but you could use a journal quest to do it instead. To make this work you'd actually want unlimited rabbits that are spawning, or enough so that a npc casting fireball does not block the quest. ( or make them plot to keep them alive until the player kills them ). Note that GetLastKiller() only works in the npc on death event per the lexicon, most of these functions are special purpose like that. The journal parameters will work regardless if its' a companion or a player doing the killing as well, and you'd have to set up 3 journal entries in the module for each number that have been killed.

Of course this is really the same code as what is being used for the local integer, its main difference is the feedback the player is getting, just another way to tackle this problem.

void main()
{
object oKiller = GetLastKiller();
int nInt;
nInt = GetJournalEntry("killedthemquest");
nInt += 1;
if ( nInt > 3 )
{
   nInt = 3; // limit to 3 only
}
AddJournalQuestEntry("killedthemquest", nInt, oKiller );
} 

Modifié par painofdungeoneternal, 27 octobre 2011 - 09:51 .


#37
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Pain is right, the quest state is the proper place to put this sort of information. Remember that you can use bits to encode different pieces of info in one number:
Three different NPCs that can be killed, one in the 1-place, second in the 2-place, third in the 4-place.
In binary/deci: 001/1, 010/2, 100/4.
All killed = 111/7, None Killed = 000/0, 2nd and third killed, 1st alive = 110/6.
For the first NPC, you add 1 to the quest state with they die, for the 2nd you add 2, and for the third you add 4.
So,
10 - No one killed
11 - 1st NPC killed
12 - 2nd NPC killed
13 - 1st and 2nd NPC killed
14 - 3rd NPC killed
15 - 1st and 3rd NPC killed
16 - 2nd and 3rd NPC killed
17 - 1st, 2nd, and 3rd NPC killed.

Somebody explained it better somewhere else, talking about damage types.

#38
MasterChanger

MasterChanger
  • Members
  • 686 messages
I was going to suggest that the GetFirstPC() debate be moved to a separate thread* from the conversation about local integers, but then I realized that the reason that I advocate not using GetFirstPC is the same reason I avoid global variables, and goto for that matter, even though they often work: their near-universal scope, while useful, weakens their specificity.

In introductory computer science courses, it's not uncommon to tell students to essentially pretend global-scope variables don't exist. But why not use them? Global variables are great in many cases, possibly even in the majority of cases. It's certainly a lot less work to use them than to correctly pass your parameters back and forth as local variables, pointers, reference variables, or what-have-you. As Shallina argues, "Better to start easy and have things working and then going to more difficult way of handling things."

But is it actually better? If you start with your most general tool, it will work in more cases than your more specific tools. But what about when it doesn't work? These situations must come up, because no tool is truly universal. If you hardly ever use your more specific tools, you may not know how to use them. You may have no idea that they even exist.

What's more, the more general the tool, the more likely you are to run into situations in which it could be used, but it shouldn't be used. Think again about global-scope variables. You can retrieve these variables and alter their value at any time from within any function. The compiler will faithfully follow your instructions. However, in doing this you destroy the integrity of that variable's value. So a general tool can often work without the operation having meaningful results.

A specific tool, on the other hand, will by defintion often not apply. Getting the last killer within an OnSpawn event handler or retrieving a local int on an object that doesn't have it set** will not return an interpretable value--that's good, because such a value would have no meaning.

This is the purpose of maintaining a list such as Pain's that tells you how to reference objects within different scripts. It takes the idea that you when you encounter a problem, you don't start by opening your toolbox. You start by identifying your goal or the purpose of what you want to do. Then you work backwards to find the tool that matches the purpose. This is in direct contrast to going through your tools one by one, figuring out what each one can do, and seeing whether it will work well enough for your purpose.

From this perspective, the most appropriate tool is the one that will give you your desired result and no more. This means starting from your most specific tool, deciding whether it applies, discarding it if it doesn't, and proceeding to the one that's only slightly less specific. It's a little like using the conversation editor: you put the most specific condition first and the logic will allow you to "fall through" until you've arrived at the appropriate node.

Sorry if this is all a bit rambly. The tl;dr*** version of this Wall of Text is that GetFirstPC and global variables will almost always work, but it's much easier to get fooled into thinking that working at all is the same as working correctly. With these most generic of tools, that isn't always the case, and is especially deceptive when someone is just starting out.

By the Maimed God, even my tl;dr version is long! :blink:

* Or not; I don't really think this is a debate that can be objectively resolved. There are reasons for and against, and each individual coder will make their own decisions accordingly.

** Pretend for a second that GetLocalInt() returning 0 is not an outcome that gives us information (it does, but this is for the sake of argument).

*** Too long; didn't read

#39
PJ156

PJ156
  • Members
  • 2 980 messages
Thank you both, there's more food for thought here. I wish I had grasped some of this in earlier mods.

I'm getting away with my testing because this is an SP mod designed for a designated character. I am not going to prescribe the character though so I can see how this might break. I am going to try to set it up again with a third party carrier for the int. An Ipoint probably.

Counting bad guys  is a neat trick but the advantage of adding to the integer is I can specify where they are. I have three scripts one a +1 one +2 and the other +4 so the integer can have 7 unique states that tell me exactly who is dead and where they were standing.

Thanks for the posts, as I said I am getting a lot out of this thread ...

PJ

[edit] Lol two more post while I wrote this. LotRS is suggesting the same as I have done.

Modifié par PJ156, 27 octobre 2011 - 10:34 .


#40
Dann-J

Dann-J
  • Members
  • 3 161 messages
If the count is just for the sake of the conversation nodes, then why not just give all three NPCs unique tags and use GC_Dead conditional checks in the possible player responses? There'd be no need for a new script of any kind then.

For instance, the conditional tab for one possible response would look something like this:

gc_dead c_badguy1
and gc_dead c_badguy2
and not gc_dead c_badguy3

And the response would be something like :

"I killed [badguy1] and [badguy2]"

#41
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages

Lugaid of the Red Stripes wrote...

Pain is right, the quest state is the proper place to put this sort of information. Remember that you can use bits to encode different pieces of info in one number:
Three different NPCs that can be killed, one in the 1-place, second in the 2-place, third in the 4-place.
In binary/deci: 001/1, 010/2, 100/4.
All killed = 111/7, None Killed = 000/0, 2nd and third killed, 1st alive = 110/6.
For the first NPC, you add 1 to the quest state with they die, for the 2nd you add 2, and for the third you add 4.
So,
10 - No one killed
11 - 1st NPC killed
12 - 2nd NPC killed
13 - 1st and 2nd NPC killed
14 - 3rd NPC killed
15 - 1st and 3rd NPC killed
16 - 2nd and 3rd NPC killed
17 - 1st, 2nd, and 3rd NPC killed.

Somebody explained it better somewhere else, talking about damage types.


I don't know that much about quests, but basically you want to do bitwise math on it if you are storing which one was killed in the variable. You'd then have to do quest entries for each possible combination. This seems like overkill but once you learn how this works and that the binary bits are flags hidden in integers it makes you much more capable.

ie in binary to integer, note that each column of 1's and 0's in the left binary column represents a living or dead NPC. So if the number is 010 that means the 2nd pc is dead, while 101 means the 1st and 3rd dead, and it would look to the human eye like the numbers 2 and 5, so you'd do 7 quest entries and on the 5th one you'd put in that larry and moe are dead and curly is still on the loose.

000 = 0
001 = 1
010 = 2
011 = 3
100 = 4
101 = 5
110 = 6
111 = 7

Then you'd make constants for each NPC, mainly so you don't have to deal with the issue, or you'd put a var on the NPC holding their constant of 1, 2 or 4 ( and it progresses after that as 8, 16, 32 and so forth.) or set up constants for each one.

NPC_NUMBER1 = 1 // 001 Curley
NPC_NUMBER2 = 2 // 010 Moe
NPC_NUMBER3 = 4 // 100 Larry

void main()
{
object oKiller = GetLastKiller();
object oKilled = OBJECT_SELF;
int nInt;
nInt = GetJournalEntry("killedthemquest");
nInt += 1;
if ( GetName( oKilled ) == "Curley" )
{
nInt = nInt | NPC_NUMBER1; // bitwise or merges two sets of bits
}
else if ( GetName( oKilled ) == "Moe" )
{
nInt |= NPC_NUMBER2; // same as above but same as += syntax
}
else if ( GetName( oKilled ) == "Larry" )
{
nInt |= NPC_NUMBER3;
}
AddJournalQuestEntry("killedthemquest", nInt, oKiller );
}

You can use the same logic as above to spot if a flag is set.

if ( nInt & NPC_NUMBER3 ) // note the single & there
{
// this returns true if NPC_NUMBER3 is inside nInt, which is 100, 110 and 101, the first ( hundreds in decimal ) column has to have a 1 in it 
}

Modifié par painofdungeoneternal, 27 octobre 2011 - 11:28 .


#42
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages

PJ156 wrote...

Thank you both, there's more food for thought here. I wish I had grasped some of this in earlier mods.

I'm getting away with my testing because this is an SP mod designed for a designated character. I am not going to prescribe the character though so I can see how this might break. I am going to try to set it up again with a third party carrier for the int. An Ipoint probably.

Counting bad guys  is a neat trick but the advantage of adding to the integer is I can specify where they are. I have three scripts one a +1 one +2 and the other +4 so the integer can have 7 unique states that tell me exactly who is dead and where they were standing.

Thanks for the posts, as I said I am getting a lot out of this thread ...

PJ

[edit] Lol two more post while I wrote this. LotRS is suggesting the same as I have done.


Use a waypoint instead.

This has much less overhead on the module, even an ipoint is noticed by the rendering of the area even though it does not add much, and you can use getwaypointbytag instead of getobjectbytag, if you have a lot of things in your module it does not have to go thru them all to find what you are looking for. ( the GetLocalInt, GetObjectByTag and the like actually loop thru all the objects in the module, or variables on the time, and when they find one that matches return it )

( or use the speaker of the conversation himself, which is already fetched when the convo happens, assuming you are not having to spawn him later on )

#43
PJ156

PJ156
  • Members
  • 2 980 messages

painofdungeoneternal wrote...

( or use the speaker of the conversation himself, which is already fetched when the convo happens, assuming you are not having to spawn him later on )


Good advice, I did that, it worked well and simplified things no end.

PJ

#44
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
Reading what you said about adding the +4, +2 and +1, you really should do the bitwise |= instead. This is a simple change, which won't change how your script works in any way, but will get you thinking about bits.

Not a deal breaker whether you do this or not, as the result would be the exact same, but the logic of what you are doing is more inline with bits already, and it would be more fault tolerant if you have crazy players using shadow simulcrum or other things no one is really likely to do.

Right now if you have a 1 in your integer, and add a 4 to it, you have 5.
int iInteger = 1;
iInteger += 4;
  // iInteger now is 5
// lets repeat
iInteger += 4;
// iInteger now is 9
If the above is run again it becomes 9, which would confuse your script if it happens over and over again. Again this works if the situation says this will never happen, but "assumptions" tend to be the downfall of many programmers. Most module makers in SP don't ever see what is actually going on when players are actually using their modules, and as a PW admin observing I am generally astounded by what those players come up with.

But if you do
int iInteger = 1;
iInteger |= 4;
// iInteger now is 5
iInteger |= 4;
// iInteger still now is 5

This is because the |= is forcing the 3rd bit, which is what you call a 4 in decimal math to be true.

Whenever you are using 1, 2, 4, 8, 16 types of numbers its better to use bits, and generally i set up constants soas to make it clear that bits are involved.

Whether you do bits or not to set them, you can use

if ( iInteger & 4 ) // this returns true if the iInteger is 4, 5, 6 or 7
{
// this is the pc that we added 4 to, assuming it only got added once
}

instead of testing for equality, you are testing if the 3rd bit ( 4 or 100 ) is set to TRUE or not.

Modifié par painofdungeoneternal, 27 octobre 2011 - 11:49 .


#45
kevL

kevL
  • Members
  • 4 052 messages

painofdungeoneternal wrote...

... as a PW admin observing I am generally astounded by what those players come up with.



"hey! watch this!!" Lol

that's like me jumpin down the hole in Paineel ..


yes, i got my corpse back (tks, for the bitwise P.)

.. it's getting clearer......

#46
Shallina

Shallina
  • Members
  • 1 011 messages
The thing is that global var or storing value in the PC is the way to go for event that need to be accessed from the whole campaign in a campaign wich has many different module.

The good way is to restrain as much as possible the "scope" of the variable you use, so you can make a script that can works for many encounter and not just one.

But when that scope is the whole game, then using global var is actually the good way for the event concerned.

Local VAr :
For exemple you want a script that check the number of creature killed in a area, it's possible to have a generic script that will store the number of killed creature in each area with the same "name" for a local int but stored in different area.

And then you can accès the total kill number of each area with a script that will loop the area and make the addition of those local int.

GlobalVar : you want to know if an event has been done at all time and what ever the module you are in.

Modifié par Shallina, 28 octobre 2011 - 06:20 .