Author Topic: Naming variables  (Read 1730 times)

Offline Lu

  • Planewalker
  • *****
  • Posts: 750
  • Gender: Female
Naming variables
« on: June 17, 2005, 01:29:12 PM »
  Does anybody know if it's safe to use the same name as a death variable and for a global variable?

Offline SimDing0™

  • Back In Black
  • Global Moderator
  • Planewalker
  • *****
  • Posts: 3496
  • Gender: Male
  • Word Enhancer
Re: Naming variables
« Reply #1 on: June 17, 2005, 01:31:51 PM »
It should be. Death variables are stored with "SPRITE_IS_DEAD" preceding them, so there shouldn't be any interference.

Offline Avenger_teambg

  • Planewalker
  • *****
  • Posts: 399
Re: Naming variables
« Reply #2 on: June 22, 2005, 10:12:11 AM »
Unless he meant 'SPRITE_IS_DEADMYGLOBAL' :)

Offline Lu

  • Planewalker
  • *****
  • Posts: 750
  • Gender: Female
Re: Naming variables
« Reply #3 on: June 25, 2005, 09:43:26 PM »
   Can't speak for him, but I've surely never heard of the "SPRITE_IS_DEAD" thingy before, so thank you for the information
   Actually, my question was caused by a less philosophical problem. To make an NPC leave the party when she is dead,
 I use the following block in her script (assuming that the death variable is "A"):
   IF
     InPartyAllowDead(Myself)
     Dead("A")
   THEN
       SetGlobal("A","GLOBAL",1)  // need it for some other reasons
       LeaveParty()
   END
   Sometimes it works, but sometimes it doesn't
   Should I use instead of Dead("A") another trigger, like Die(), or HPLT(Myself,1), or (by what I've just learned)
    Global("SPRITE_IS_DEADA","GLOBAL",1)?

Offline Ghreyfain

  • Moderator
  • Planewalker
  • *****
  • Posts: 4705
  • Gender: Male
    • Pocket Plane Group
Re: Naming variables
« Reply #4 on: June 25, 2005, 11:32:15 PM »
Global("SPRITE_IS_DEAD") is the most reliable, I find.  Dead() doesn't include things like petrification, chunkification, ice... ification, and so one.  I think.  Actually, I'm not too too sure why Dead() sucks, but it does, so use the global.
Earn Money Sleeping.

Offline SimDing0™

  • Back In Black
  • Global Moderator
  • Planewalker
  • *****
  • Posts: 3496
  • Gender: Male
  • Word Enhancer
Re: Naming variables
« Reply #5 on: June 26, 2005, 05:01:26 AM »
But Dead() checks the global... sure you're not thinking of Die() or something? Or BG1.

Offline Ghreyfain

  • Moderator
  • Planewalker
  • *****
  • Posts: 4705
  • Gender: Male
    • Pocket Plane Group
Re: Naming variables
« Reply #6 on: June 26, 2005, 08:49:30 PM »
Oh, hmm, yeah, could be Die().  Die() sucks, and BG1 sucks because of chunktification not setting SPRITE_IS_DEAD, right?
Earn Money Sleeping.

Offline devSin

  • Planewalker
  • *****
  • Posts: 1632
  • Gender: Male
Re: Naming variables
« Reply #7 on: June 26, 2005, 09:05:39 PM »
My initial impression is that the script would tend not to work because the object is already dead. I'm not sure how it works for things in baldur.gam, but I don't think a non-existent object (a "no-corpse" creature, in this case) can be relied upon to execute their scripts. Have you tried externalizing the script (sadly, baldur.bcs may be the only place to go)?

Quote
petrification, chunkification, ice... ification
All these chunky deaths should remove the character from the party, though, right? So it's not really worth worrying about in this case.

Offline Lu

  • Planewalker
  • *****
  • Posts: 750
  • Gender: Female
Re: Naming variables
« Reply #8 on: June 27, 2005, 03:16:29 PM »
Quote
My initial impression is that the script would tend not to work because the object is already dead
   I had the same doubts before trying the script. But it works more often than not, so hopefully there's no need
 to add the block to baldur.bcs

Offline Vlasák

  • Planewalker
  • *****
  • Posts: 11
  • Gender: Male
Re: Naming variables
« Reply #9 on: July 01, 2005, 01:41:53 AM »
But Dead() checks the global... sure you're not thinking of Die() or something? Or BG1.

afaik from my testing, Die() works well in BG2(+ToB) - the only thing when it fails was the effect of Imprisonment...
Baldur's Gate II add-on CZ - TC from Dalelands
http://addoncz.gamestar.cz

English forums are opened!

Offline Avenger_teambg

  • Planewalker
  • *****
  • Posts: 399
Re: Naming variables
« Reply #10 on: July 03, 2005, 02:07:25 PM »
Dead(S:name*) checks the 'sprite_is_dead' variable
while
Dead(O:object*) checks the object.
The former is in pst, bg1, bg2, iwd the latter is in iwd2.

Die() is triggered only once at the moment of death, and the dead actor's scripts are getting stopped.
So the engine has exactly one AI cycle (i guess), to check on this trigger.
Probably that makes Die() unreliable.

I'm unsure how iwd2's function is working, it won't detect dead objects outside of a given area for sure.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: