Jump to content

GLOBALS, LOCALS in non-bater scripts


lroumen

Recommended Posts

After an illness of a few months, I am finally back up to the task of modding again.

 

I intend to improve my first mod, a kit combination which allows the player to change between a bard and a thief at will (hosted at misc in shs). Two other features in this kit are that I give the player the option to chose thieving bonuses when you level up as a bard and I fix the spell slots which you do not get when you level up as a thief. To do this I need a few checks that are always triggered in order to keep track of the players right for skill bonuses, spell slot regeneration and class changing.

 

To accomplish this, I originally patched the baldur.bcs and baldur25.bcs with a few blocks which trace a global that actionoverrides the player to changeclass into the thief or bard form. Although it works, Jarno and The_Bigg (and others like Wisp I believe) indicated that it is better to use an invisible creature to accomplish this, which is a fair comment to the mod of a first-time IE coder.

Another thing is that I should make it better usable for player1, player2, player3, etc, and make the use of LOCALS instead of GLOBALs and Myself instead of Player[1-6]. However, this is where I run into problems.

 

The parts that I intend to patch into the baldur.bcs or baldur25.bcs are much shorter now with the use of globals and Myself calls. However, upon testing nothing is initiated and I do not know where I am going wrong.

 

I try to patch the following bit into baldur25.bcs as a test but where do I go wrong? Not everything works as I would anticipate.

 

Test 1. Fails

IF
  OR(2)
  Kit(Myself,LRswitch)
  Kit(Myself,LRswitchthief)
  !Global("LRLVL1","LOCALS",8)
  Level(Myself,8)
THEN
  RESPONSE #100
  SetGlobal("LRLVL1","LOCALS",8)
END

 

Test 2. Fails

IF
  OR(2)
  Kit(Player1,LRswitch)
  Kit(Player1,LRswitchthief)
  !Global("LRLVL1","LOCALS",8)
  Level(Player1,8)
THEN
  RESPONSE #100
  SetGlobal("LRLVL1","LOCALS",8)
END

 

Test 3. Fails.

IF
  OR(2)
  Kit(Myself,LRswitch)
  Kit(Myself,LRswitchthief)
  !Global("LRLVL1","LOCALS",8)
  Level(Myself,8)
THEN
  RESPONSE #100
  ActionOverride(Myself,SetGlobal("LRLVL1","LOCALS",8))
END

 

Test 4. Works. So Using Myself in Baldur25.bcs does not work and I have to actionoverride to get LOCALS to work?

IF
  OR(2)
  Kit(Player1,LRswitch)
  Kit(Player1,LRswitchthief)
  !Global("LRLVL1","LOCALS",8)
  Level(Player1,8)
THEN
  RESPONSE #100
  ActionOverride(Player1,SetGlobal("LRLVL1","LOCALS",8))
END

 

Test 5. This works of course

IF
  OR(2)
  Kit(Player1,LRswitch)
  Kit(Player1,LRswitchthief)
  !Global("LRLVL1","GLOBAL",8)
  Level(Player1,8)
THEN
  RESPONSE #100
  ActionOverride(Player1,SetGlobal("LRLVL1","GLOBAL",8))
END

 

But now the Followup of test 4. It fails. So how are LOCALS checked if you put them in the baldur25.bcs then?

IF
  Global("LRLVL1","LOCALS",8)
  !Global("LRLVL2","LOCALS",1)
THEN
  RESPONSE #100
  ActionOverride(Player1,SetGlobal("LRLVL2","LOCALS",1))
END

 

I think I'm a bit stuck. I first redesigned my whole code to find out that somewhere with the Myself bits and the LOCALS bits I fail. If that stays true, I'd have to do a whole lot more patching and the only thing that will improve is that I do not actionoverride myself to change the class but actionoverride myself to summon an invisible creature who changes my class (which is more like an aestetics fix since there's safety code in the class changing anyway).

 

Or is there a trick that allows me to execute a script right after someone leveled up other than (IF level(x) THEN RESPONSE #100 etc END)? Perhaps I could overcome these problems in another fashion.

 

Thanks in advance

Link to comment

Locals only work from individual actors' scripts. You need to use DPLAYER, DPLAYER2, DPLAYER3 scripts.

 

Or is there a trick that allows me to execute a script right after someone leveled up
Yes - apply a spell from kit's CLAB that summons a spy creature.
Link to comment

Thanks Ardanis. :thumbsup:

dplayer is not activated when the AI is turned off though. I'd like the class changing to be active even if party AI is not. I'll try to implement it in dplayer to see if everything works though.

 

The spy creature from the CLAB sounds interesting, but I do not think it will work in this case. My kit can switch between thief and bard and upon using the ChangeClass() command, the entire CLAB of the new class is read and applied or executed (or was it ClassChange()... doesn't matter for the discussion).

So I think that whenever I change class I summon the spy creature(s). Hmmm.. maybe with some strange checking in the script...

 

So what about Myself then. Does that work only in dplayer as well?

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...