Jump to content


Photo

Diffrence between LOCALS and GLOBAL


  • Please log in to reply
17 replies to this topic

#1 SConrad

SConrad

    I swear to drunk I'm not God

  • Administrator
  • 11148 posts

Posted 09 June 2004 - 06:05 AM

I'm kind of new to modding, but I'm currently working with a NPC (together with a couple of dedicated BGII-players) named Khadion (he'll turn out great, btw).

I just have one small question:

What is the difference between SetGlobal("something","LOCALS",X) and SetGlobal("something","GLOBAL",X)

Does it make any difference what you use?

Posted Image Khadion NPC mod - Team leader, head designer
Posted Image Hubelpot NPC mod - Team leader, coder
Posted Image NPC Damage - Coder
Posted Image PC Soundsets - Coder, voice actor
Posted Image Brythe NPC mod - Designer
Posted Image DragonLance TC - Glory of Istar - Designer
Posted Image The NPC Interaction Expansion Project - Writer for Cernd, Sarevok
Posted Image The Jerry Zinger Show - Producer

Iron Modder 5 - Winner


#2 Grim Squeaker

Grim Squeaker

    Fallen

  • Member
  • 1018 posts

Posted 09 June 2004 - 06:17 AM

A local variable (i.e. Set to LOCALS) only appears on the character in question. It also cannot be referenced in places other than dialogues/scripts belonging to that character. It's useful, for example with the Lovetalk variable. Aerie, Viconia and Jaheira all have one with exactly the same name, however as they are local it doesn't matter. However their romance active variables (AerieRomanceActive etc) are Global as other scripts need to check what setting they are at.
"You alone can make my song take flight..."

#3 SConrad

SConrad

    I swear to drunk I'm not God

  • Administrator
  • 11148 posts

Posted 09 June 2004 - 01:38 PM

Thanks very much!

I have another question, though...

I want the PC to be able to piss the NPC off, and when that happens I want my NPC to turn hostile and attack. So far no problems, but I also want a couple of other guys to show up and help the NPC. Here's the problem. Where do I put the CreateCreatureObject("***","***",0,0,0), to make this work?

In the .d-file? Or should I put it in a .bcs-file, and in that case, which one? My character's Default-, Override-, Class- or General-script? Or the Area-script?

Posted Image Khadion NPC mod - Team leader, head designer
Posted Image Hubelpot NPC mod - Team leader, coder
Posted Image NPC Damage - Coder
Posted Image PC Soundsets - Coder, voice actor
Posted Image Brythe NPC mod - Designer
Posted Image DragonLance TC - Glory of Istar - Designer
Posted Image The NPC Interaction Expansion Project - Writer for Cernd, Sarevok
Posted Image The Jerry Zinger Show - Producer

Iron Modder 5 - Winner


#4 -Ashara-

-Ashara-
  • Guest

Posted 09 June 2004 - 02:00 PM

what I usually do is to introduce a Global in D file, and then if the encounter happens in a certain area add the spawn and attack script to that Area on the condition that variable is set, and if not - to the NPC's override script on the same condition.

#5 SConrad

SConrad

    I swear to drunk I'm not God

  • Administrator
  • 11148 posts

Posted 09 June 2004 - 02:18 PM

I've already done that. But I don't think I tried with the override-script.

The .d-file looks like this, the PC can choose to attack my NPC (@40) or walk away and just piss him off, to be able to apologize later (@41):

IF ~~ THEN BEGIN Join_15
  SAY @39
  IF ~~ THEN REPLY @40 DO ~Enemy() 
                          SetGlobal("S#KHAattacked","GLOBAL",1)
                          SetGlobal("AttackedThieves","GLOBAL",1)
                          Attack(NearestEnemyOf(Myself))~
                          EXIT
  IF ~~ THEN REPLY @41 DO ~SetGlobal("S#KHApissed","GLOBAL",1)~ EXIT
END

Then I want to add this in a .bcs-file:

IF
  Global("S#KHAattacked","GLOBAL",1)
THEN
  RESPONSE #100
    CreateCreatureObject("S#SHTH","S#KHA",0,0,0)
    CreateCreatureObject("S#SHTH","S#KHA",0,0,0)
    CreateCreatureObject("S#SHTH","S#KHA",0,0,0)
    CreateCreatureObject("S#SHTH","S#KHA",0,0,0)
    CreateCreatureObject("S#SHTH","S#KHA",0,0,0)
    CreateCreatureObject("S#SHTH","S#KHA",0,0,0)
    CreateCreatureObject("S#SHTH","S#KHA",0,0,0)
    CreateCreatureObject("S#SHTH","S#KHA",0,0,0)
    CreateCreatureObject("S#SHTH","S#KHA",0,0,0)
    CreateCreatureObject("S#SHTH","S#KHA",0,0,0)
END

Should I then put this in the override-script or in the area-script? Does it make any difference? What I mean is that this conversation could only happen in on area anyway. Does it then make any difference?

Posted Image Khadion NPC mod - Team leader, head designer
Posted Image Hubelpot NPC mod - Team leader, coder
Posted Image NPC Damage - Coder
Posted Image PC Soundsets - Coder, voice actor
Posted Image Brythe NPC mod - Designer
Posted Image DragonLance TC - Glory of Istar - Designer
Posted Image The NPC Interaction Expansion Project - Writer for Cernd, Sarevok
Posted Image The Jerry Zinger Show - Producer

Iron Modder 5 - Winner


#6 -Ashara-

-Ashara-
  • Guest

Posted 09 June 2004 - 02:39 PM

If it is in a specific area, you can add it to the area script. If it is random, then it will need to go with the CRE or you need movements.

I am not that big on scripting, but you probably do not need AttackNearestEnemy() because when turned enemy he will use his default fighting scripts, whatever they are.

#7 SConrad

SConrad

    I swear to drunk I'm not God

  • Administrator
  • 11148 posts

Posted 09 June 2004 - 02:40 PM

Okay, thanks. I'll check if it works...

Posted Image Khadion NPC mod - Team leader, head designer
Posted Image Hubelpot NPC mod - Team leader, coder
Posted Image NPC Damage - Coder
Posted Image PC Soundsets - Coder, voice actor
Posted Image Brythe NPC mod - Designer
Posted Image DragonLance TC - Glory of Istar - Designer
Posted Image The NPC Interaction Expansion Project - Writer for Cernd, Sarevok
Posted Image The Jerry Zinger Show - Producer

Iron Modder 5 - Winner


#8 SConrad

SConrad

    I swear to drunk I'm not God

  • Administrator
  • 11148 posts

Posted 09 June 2004 - 03:28 PM

Well, that didn't turn out like I wanted to.

The creatures still won't spawn, I tried to put the code in both the area-script and the override script of the NPC.

And the NPC didn't attack when I removed the line AttackNearestEnemy(). Please don't tell me that it's something wrong with his default fighting script (what script is that, btw?). He went hostile, but didn't attack.

I should probably tell you that I have made two different scripts for him (the overridescript and the classcript), while using wtasight.bcs as default script. I've tried to put the code in both of the custom-made scripts, as well as extending the area-script.

If anyone also could tell me what all the different scripts a character can have are for (i.e. override, class, race, general and default), it would perhaps enlighten my head a little bit. (Can you actually express yourself that way? I have to check that with my English-teacher).

Posted Image Khadion NPC mod - Team leader, head designer
Posted Image Hubelpot NPC mod - Team leader, coder
Posted Image NPC Damage - Coder
Posted Image PC Soundsets - Coder, voice actor
Posted Image Brythe NPC mod - Designer
Posted Image DragonLance TC - Glory of Istar - Designer
Posted Image The NPC Interaction Expansion Project - Writer for Cernd, Sarevok
Posted Image The Jerry Zinger Show - Producer

Iron Modder 5 - Winner


#9 Idobek

Idobek

    Pocket Plane Gibberling

  • Member
  • 429 posts

Posted 09 June 2004 - 04:46 PM

IF

 Global("S#KHAattacked","GLOBAL",1)

THEN

 RESPONSE #100

   CreateCreatureObject("S#SHTH","S#KHA",0,0,0)

   CreateCreatureObject("S#SHTH","S#KHA",0,0,0)

   CreateCreatureObject("S#SHTH","S#KHA",0,0,0)

   CreateCreatureObject("S#SHTH","S#KHA",0,0,0)

   CreateCreatureObject("S#SHTH","S#KHA",0,0,0)

   CreateCreatureObject("S#SHTH","S#KHA",0,0,0)

   CreateCreatureObject("S#SHTH","S#KHA",0,0,0)

   CreateCreatureObject("S#SHTH","S#KHA",0,0,0)

   CreateCreatureObject("S#SHTH","S#KHA",0,0,0)

   CreateCreatureObject("S#SHTH","S#KHA",0,0,0)

END
Is "S#KHA" a death variable or a resref? It should be a death variable. If that doesn't work, ensure it is in your NPC's override script and use "Myself" as the object:
CreateCreatureObject("S#SHTH",Myself,0,0,0)


#10 Rastor

Rastor

    Yes, I really am a dragon. Yes, I am a jerk. Live with it.

  • Member
  • 2001 posts

Posted 09 June 2004 - 08:39 PM

I never do this in a script. I just use it in the d file and it works fine.

IF ~~ THEN BEGIN Join_15
 SAY @39
 IF ~~ THEN REPLY @40 DO ~Enemy() 
  CreateCreatureObject("S#SHTH",Myself,0,0,0)
  CreateCreatureObject("S#SHTH",Myself,0,0,0)
  CreateCreatureObject("S#SHTH",Myself,0,0,0)
  CreateCreatureObject("S#SHTH",Myself,0,0,0)
  CreateCreatureObject("S#SHTH",Myself,0,0,0)
  CreateCreatureObject("S#SHTH",Myself,0,0,0)
  CreateCreatureObject("S#SHTH",Myself,0,0,0)
  CreateCreatureObject("S#SHTH",Myself,0,0,0)
  CreateCreatureObject("S#SHTH",Myself,0,0,0)
  CreateCreatureObject("S#SHTH",Myself,0,0,0)
                         Attack(NearestEnemyOf(Myself))~
                         EXIT
 IF ~~ THEN REPLY @41 DO ~SetGlobal("S#KHApissed","GLOBAL",1)~ EXIT
END

Home of Kitanya, Improved Asylum, more...

Posted Image

#11 SConrad

SConrad

    I swear to drunk I'm not God

  • Administrator
  • 11148 posts

Posted 10 June 2004 - 01:47 AM

Ah, okay... S#KHA is NOT a deathvariable... That must have been the problem. I check and see if it works now...

Not that it matters, since the creature I want to spawn have the same deathvariable S#SHTH as its name S#SHTH.cre. But should the first CreateCreatureObject("S#SHTH",Myself,0,0,0) also be a deathvariable?

In that case, it doesn't make any sense, since different *.cre could have the same deathvarible....

Posted Image Khadion NPC mod - Team leader, head designer
Posted Image Hubelpot NPC mod - Team leader, coder
Posted Image NPC Damage - Coder
Posted Image PC Soundsets - Coder, voice actor
Posted Image Brythe NPC mod - Designer
Posted Image DragonLance TC - Glory of Istar - Designer
Posted Image The NPC Interaction Expansion Project - Writer for Cernd, Sarevok
Posted Image The Jerry Zinger Show - Producer

Iron Modder 5 - Winner


#12 SConrad

SConrad

    I swear to drunk I'm not God

  • Administrator
  • 11148 posts

Posted 10 June 2004 - 02:12 AM

Alright, it worked... But to my disappointment, they didn't attack. They turned hostile, alright, but didn't attack.

Now, there must be something wrong with the scripts. First I couldn't get the NPC to attack unless I wrote Attack(NearestEnemyOf(Myself)) in the .d-file. Now the spawned cretures won't attack. Which god damned script makes a creture attack??

Posted Image Khadion NPC mod - Team leader, head designer
Posted Image Hubelpot NPC mod - Team leader, coder
Posted Image NPC Damage - Coder
Posted Image PC Soundsets - Coder, voice actor
Posted Image Brythe NPC mod - Designer
Posted Image DragonLance TC - Glory of Istar - Designer
Posted Image The NPC Interaction Expansion Project - Writer for Cernd, Sarevok
Posted Image The Jerry Zinger Show - Producer

Iron Modder 5 - Winner


#13 Rastor

Rastor

    Yes, I really am a dragon. Yes, I am a jerk. Live with it.

  • Member
  • 2001 posts

Posted 10 June 2004 - 06:46 AM

Any of the scripts of the creature would make it attack.

Just put Attack(NearestEnemyOf(Myself) into a script block and throw it in at the top of the Override script.
Home of Kitanya, Improved Asylum, more...

Posted Image

#14 SConrad

SConrad

    I swear to drunk I'm not God

  • Administrator
  • 11148 posts

Posted 10 June 2004 - 09:47 AM

And what's the difference between that (Attack(NearestEnemyOf(myself))) and AttackReevaluate(NearestEnemyOf(Myself),30)?

Posted Image Khadion NPC mod - Team leader, head designer
Posted Image Hubelpot NPC mod - Team leader, coder
Posted Image NPC Damage - Coder
Posted Image PC Soundsets - Coder, voice actor
Posted Image Brythe NPC mod - Designer
Posted Image DragonLance TC - Glory of Istar - Designer
Posted Image The NPC Interaction Expansion Project - Writer for Cernd, Sarevok
Posted Image The Jerry Zinger Show - Producer

Iron Modder 5 - Winner


#15 Rastor

Rastor

    Yes, I really am a dragon. Yes, I am a jerk. Live with it.

  • Member
  • 2001 posts

Posted 10 June 2004 - 04:44 PM

Attack(NearestEnemyOf(Myself)) will cause the creature to keep attacking that target with its weapon until one of the two is dead.

AttackReevaluate causes the creature to attack and reevaluate the situation after the time specified, I believe the time is in 15ths of a second. Reevaluate meaning run through the script to see if any other conditions are true.
Home of Kitanya, Improved Asylum, more...

Posted Image

#16 SConrad

SConrad

    I swear to drunk I'm not God

  • Administrator
  • 11148 posts

Posted 10 June 2004 - 04:51 PM

Kinda obvious... And the variable 30 in
AttackReevaluate(NearestEnemyOf(Myself),30)
should mean 30 seconds, right?
EDIT: I saw that you wrote "believe the time is in 15ths of a second". What does that mean? (I guess it's my failing english again (aargh!), but I'm from Sweden, where we don't know how to speak complicated languages... ;) )

Thanks Rastor (and Idobek and domi and Grim) for all the help, btw!

Edited by SConrad, 10 June 2004 - 04:56 PM.

Posted Image Khadion NPC mod - Team leader, head designer
Posted Image Hubelpot NPC mod - Team leader, coder
Posted Image NPC Damage - Coder
Posted Image PC Soundsets - Coder, voice actor
Posted Image Brythe NPC mod - Designer
Posted Image DragonLance TC - Glory of Istar - Designer
Posted Image The NPC Interaction Expansion Project - Writer for Cernd, Sarevok
Posted Image The Jerry Zinger Show - Producer

Iron Modder 5 - Winner


#17 Rastor

Rastor

    Yes, I really am a dragon. Yes, I am a jerk. Live with it.

  • Member
  • 2001 posts

Posted 10 June 2004 - 06:09 PM

Kinda obvious... And the variable 30 in

 
AttackReevaluate(NearestEnemyOf(Myself),30)

should mean 30 seconds, right?


It actually means two seconds. What you need to do is to take the number that you put in there and divide it by 15 to get the number of seconds.
Home of Kitanya, Improved Asylum, more...

Posted Image

#18 SConrad

SConrad

    I swear to drunk I'm not God

  • Administrator
  • 11148 posts

Posted 11 June 2004 - 05:33 AM

Kinda obvious... And the variable 30 in

 
AttackReevaluate(NearestEnemyOf(Myself),30)

should mean 30 seconds, right?


It actually means two seconds. What you need to do is to take the number that you put in there and divide it by 15 to get the number of seconds.

Ah, now I see. Stupid me... ;)

Posted Image Khadion NPC mod - Team leader, head designer
Posted Image Hubelpot NPC mod - Team leader, coder
Posted Image NPC Damage - Coder
Posted Image PC Soundsets - Coder, voice actor
Posted Image Brythe NPC mod - Designer
Posted Image DragonLance TC - Glory of Istar - Designer
Posted Image The NPC Interaction Expansion Project - Writer for Cernd, Sarevok
Posted Image The Jerry Zinger Show - Producer

Iron Modder 5 - Winner