Aller au contenu

Photo

I changed my scripts from localInt's to globalInt's...help


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

#1
dickel

dickel
  • Members
  • 72 messages
<t e x t a r e a>/*   Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.c...=4683&id=625    */

//Put this script OnDeath
void main()
{

object oPC = GetLastKiller();

while (GetIsObjectValid(GetMaster(oPC)))
   {
   oPC=GetMaster(oPC);
   }

if (!GetIsPC(oPC)) return;

AddJournalQuestEntry("quest_warehtheft", 121, oPC, TRUE, FALSE);

int nInt;
nInt = GetGlobalInt("1st3quests");

nInt += 1;

SetGlobalInt("1st3quests", nInt);

object oTarget;
oTarget = GetObjectByTag("crea_ellyjojon");

AssignCommand(oTarget, ActionStartConversation(oPC, "con_ellyjojon"));

}< / t e x t a r e a >


above is a script that i am/was using that I modified slightly recently, when I discovered that GlobalInt's don't need a specific pc to place them on. I thought this was a great thing, because my module is using SOZ party creation and is intended to be multiplayer. So I don't want integers placed on specific pc's only.
I really can't script, but the initial script that worked, had "GetLocalInt(oPC, "1st3quests") and SetLocalInt(oPC, "1st3quests", nInt)
I changed them both to Global int's instead and removed the paramaters asking for 'oPC'. The script compiled properly so I presumed it worked. However now, when the creature the above script is placed on dies (on death script), the PC no longer receives the journal entry update and i'm fairly sure the global int is the problem.
Is there something i'm missing about globalInt's?
Can I make an infinite number of random named ones?
as in-
GetGlobalInt("AmazingGlobalIntOfGodliness+1") and set it to whatever number i want?
(bad example just above, becaues its pretty long. You get the point though?)

Also to clarify. My idea was to add 1 to the global int "1st3quests" at a specific point (the end more than likely) of the first 3 quests. Once this global int reaches 3, then a specifc cutscene is accessible that moves the story forward beyond the first 3 quests. :) help please.

Modifié par dickel, 25 mars 2011 - 12:54 .


#2
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Maybe try to save the variables to the Module itself? You can then get the variable from anywhere inside the same module.

#3
dickel

dickel
  • Members
  • 72 messages
i thought that's what it did when you created a new variableString?
if not, how would i do that Knightus?

#4
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Are you sure that's the only change you made? Changing the integer being set as global shouldn't have anything to do with the player's journal not being updated. Unless, as your script is laid out, the last killer was not a PC. If the player's journal is not being updated, which happens before any integers being stored anywhere, then you likely have some other problem. Are you sure that this script is still on the creatures OnDeath event? Is the conversation still firing? Do you actually have a node for this quest numbered 121?

Modifié par GhostOfGod, 25 mars 2011 - 03:54 .


#5
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
Did you perhaps change the campaign setting that keeps all player journals synchronized? First thing I would check. I don't think the variable is the problem.

#6
dickel

dickel
  • Members
  • 72 messages
As far as I can tell, the script has stopped working since I manually changed the local to global int's in the script. Everything GhostofGod and Kaldor mentioned has being double checked. It's all still the same as far as I can tell....I'll keep looking. Most likely i've made an obvious mistake somewhere.

#7
dickel

dickel
  • Members
  • 72 messages
Ok. So if I place the module starting location in the area that the above script is in and the fight takes place, the on death script seems to work fine. i.e- the pc's get the journal entry and I presume(at this stage) the Global int.

However, if I start from the modules intended start location and play through up to that point (takes me about 20 minutes each time....moan :) ), then for some reason the on death script doesnt seem to work.

My new theory/hunch/suspicion is that perhaps the onHeartbeat scripts I have on various npc's in the module up to that point, could be interrupting this script from firing? Is this possible?

I really probably shouldn't have added various npc's with onHeartbeat scripts around my main town area. I did it to try and create some variance and ambient like life. Some of them use Uncle FB's scripted waypoint animations. It seems to run fine on my computer, but no idea if it would be worse on an older machine.
I have even placed an NPC (somewhat recently) that has an onHeartbeat script that fires the facial animation smile emo....i've given it stoneskin and called it a statue. I've also given it a knife that a rogue can 'steal'.
Looking at the animation times, smiling_emo is about 0.3 of a second. Is this a really bad idea for me to put it on a heartbeat? i.e- would this script be firing over and over and over again, even after ive left the area containing the creature in question?
If so, i'm thinking maybe it is interrupting the on death script that i need (mentioned at top of post)

Modifié par dickel, 26 mars 2011 - 03:50 .


#8
dickel

dickel
  • Members
  • 72 messages
Also, if onHeartbeat script do keep firing, even after a player has left the area they are in, then i'll have to somehow add scripts onEnter and onExit to spawn and despawn each npc that uses it...that's what i'm thinking anyway.

Thoughts please.

#9
El Condoro

El Condoro
  • Members
  • 148 messages
From experience every heartbeat script fires all the time (every 6 seconds) whether a PC is in the area or not. Therefore, what I do is set a local int on the area OnEnter when a PC enters the area and all heartbeats in the area check that the integer is not zero. If it is zero the HB does not fire (it still fires, of course, just doesn't get past that first check). My areas have world map transitions that are all-party, so they also set the integer back to zero when the PCs exit.

For a more PW, and I'm pretty sure this has been discussed and this may not be the best approach, you could have an area HB script that iterates (while statement) through all objects in an area and if a PC is found (GetIsPC) will set an integer. All other HBs in the area check that integer as I've mentioned above and don't fire unless a PC has been found.

#10
diophant

diophant
  • Members
  • 116 messages
As the whole local/global int stuff is after the journal entry, it should not affect it. However, the first thing I would test is if it works again when you undo the change, i.e., use local ints again.

When you played your mod from the beginning, did you ever have to save and reload? Global ints work different than local ints, they are stored in a global database. If you save, later set a global int, then die and load the old savegame, the global int is still set (although you did not reach the point in the game where you set it). If you use a local int, it is stored in the savegame itself, so it is not set in this case. Therefore, global ints should only be used to write some info when you go from one module in your campaign to another, and read it immediately when you loaded the new module. The other way to transport info between modules is by storing them as local variables on the player.

#11
diophant

diophant
  • Members
  • 116 messages
@ El Condoro: AFAIK, heartbeat fires every 6 seconds if a PC is in the area, every 30 seconds otherwise. Still, it is good to make a check at the beginning of the heartbeat scripts if they are necessary at all.

#12
dickel

dickel
  • Members
  • 72 messages
Ah awesome Diophant, that was definately something I didnt know about with global ints. As far as the loading of my module while getting up to that point. I did save the game once to get up to that point, but no dying or reloading.
Thanks also to El Condoro.

#13
dickel

dickel
  • Members
  • 72 messages
Ok. Took several hours, but i've got it working again now.
First I switched all the global int variables back to local int's and tested to see if that worked. No luck the script still didnt fire.
So next I deleted the above mentioned 'statue' and voila! it worked...i'm guessing that naughty npc statue was to blame for all my troubles. :) Lesson learnt though. I wont be making any more of them.