Jump to content


How to Count amount of creatures


12 replies to this topic

#1 Domi

    Where is now your Troy, O Cassandra?

  • Gibberlings
  • 12295 posts
  • Location:Canada

Posted 26 July 2004 - 06:44 AM

What I am trying to do is to count how many ankhegs I kill on a certain map after the Ranger Gerde asks to kill no more than ten. So what I did was:

SetGlobal("AnkhegCount","FW4500",1) at the entry to the map (sets and is fine)

Then I appended the following block of script to all ankhegs in the area (they are special case of CRE and already have the following block:

IF
Die()
THEN
RESPONCE #100
SetGlobal("HelpGerde","GLOBAL",1)
END


IF
Global("AnkhegCount","FW4500",1)
GlobalGT("HelpGerde","GLOBAL",0)
Die()
THEN
RESPONCE #100
IncrementGlobal("AnkhegCount","FW4500",1)
END

Er... does not work. Any thoughts?
Faster. Faster. Faster would be better. -Mal Reynolds, Serenity
I understand that folks prefer code that works. -CamDawg, G3

#2 Grim Squeaker

    Utter Bastard

  • Gibberling Poobah
  • 3296 posts
  • Gender:Male
  • Location:Hovering around London

Posted 26 July 2004 - 07:10 AM

Why not give all the Ankhegs in that area a particular death variable (e.g. Foo) and just use the value of SPRITE_IS_DEADFOO?
"Leave me be, I don't want to argue.
I just get confused and I come all undone.
If I agree, well it's just to appease you,
'Cause I don't remember what we're fighting for."

#3 Domi

    Where is now your Troy, O Cassandra?

  • Gibberlings
  • 12295 posts
  • Location:Canada

Posted 26 July 2004 - 07:27 AM

Well, what if I kill some snkhegs *prior* to talking to Gerde. Will they still be counted by SPRITE_IS_DEAD ?
Faster. Faster. Faster would be better. -Mal Reynolds, Serenity
I understand that folks prefer code that works. -CamDawg, G3

#4 Domi

    Where is now your Troy, O Cassandra?

  • Gibberlings
  • 12295 posts
  • Location:Canada

Posted 26 July 2004 - 07:31 AM

Also, wheer can I find info on SPRITE_IS_DEAD? I did a quick search of IESDP, but did not find it :)
Faster. Faster. Faster would be better. -Mal Reynolds, Serenity
I understand that folks prefer code that works. -CamDawg, G3

#5 icelus

    Do you have a flag?

  • Modders
  • 1929 posts
  • Gender:Male
  • Location:Houston, Texas

Posted 26 July 2004 - 07:32 AM

Also, I don't know if it's just how it was typed her, or if it's how it is in the actual script file, but will the engine accept "RESPONCE" instead of "RESPONSE"? Although, come to think of it, if it didn't, I guess the script wouldn't compile at all...

#6 Domi

    Where is now your Troy, O Cassandra?

  • Gibberlings
  • 12295 posts
  • Location:Canada

Posted 26 July 2004 - 07:44 AM

yep, it is typed in the script correctly, I am just showing what I have there
Faster. Faster. Faster would be better. -Mal Reynolds, Serenity
I understand that folks prefer code that works. -CamDawg, G3

#7 Grim Squeaker

    Utter Bastard

  • Gibberling Poobah
  • 3296 posts
  • Gender:Male
  • Location:Hovering around London

Posted 26 July 2004 - 07:49 AM

Domi, on Jul 26 2004, 04:36 PM, said:

Also, wheer can I find info on SPRITE_IS_DEAD? I did a quick search of IESDP, but did not find it  :)
SPRITE_IS_DEAD# is a variable that is created for each DV. e.g. if Nalia has died then a check of Globals will show SPRITE_IS_DEADNALIA = 1. If you have multiple CREs with the same DV it will count them. So the obvious thing would be do would be Set the global of SPRITE_IS_DEADAREAANKHEGS to 0 when you start the quest (resetting the counter so it ignores any ankhegs killed before the quest begins).

Edited by Grim Squeaker, 26 July 2004 - 07:51 AM.

"Leave me be, I don't want to argue.
I just get confused and I come all undone.
If I agree, well it's just to appease you,
'Cause I don't remember what we're fighting for."

#8 Domi

    Where is now your Troy, O Cassandra?

  • Gibberlings
  • 12295 posts
  • Location:Canada

Posted 26 July 2004 - 07:50 AM

Neat. Thank you!
Faster. Faster. Faster would be better. -Mal Reynolds, Serenity
I understand that folks prefer code that works. -CamDawg, G3

#9 Grim Squeaker

    Utter Bastard

  • Gibberling Poobah
  • 3296 posts
  • Gender:Male
  • Location:Hovering around London

Posted 26 July 2004 - 07:53 AM

Domi, on Jul 26 2004, 04:55 PM, said:

Neat. Thank you!
Any time.
"Leave me be, I don't want to argue.
I just get confused and I come all undone.
If I agree, well it's just to appease you,
'Cause I don't remember what we're fighting for."

#10 Baronius

    Robed Bandit

  • Members
  • 447 posts
  • Location:Hungary

Posted 26 July 2004 - 08:29 AM

FW4500 is Firewine Bridge area, while FW1400 is the one where Gerde is, but I suppose you would like to measure the number on FW4500 then.

Although your script extension block isn't correct:

IF
Global("AnkhegCount","FW4500",1)
GlobalGT("HelpGerde","GLOBAL",0)
Die()
THEN 
RESPONSE #100
IncrementGlobal("AnkhegCount","FW4500",1)
END

...because it will never trigger once AnkhegCount exceeds 1.
I don't see why you use AnkhegCount as a variable in SetGlobal("AnkhegCount","FW4500",1)

A possible solution with AnkhegInit, if I am interpreting your concept correctly:
SetGlobal("AnkhegInit","FW4500",1)

IF
Global("AnkhegInit","FW4500",1)
GlobalGT("HelpGerde","GLOBAL",0)
Die()
THEN 
RESPONSE #100
IncrementGlobal("AnkhegCount","FW4500",1)
END


#11 Baronius

    Robed Bandit

  • Members
  • 447 posts
  • Location:Hungary

Posted 26 July 2004 - 08:31 AM

By the way Die() itself is very unreliable in BG1, but I suppose it works fine in Tutu due to the BG2 script system. If it wouldn't work reliably after all, use the area script to count the ankheg deaths.

#12 Domi

    Where is now your Troy, O Cassandra?

  • Gibberlings
  • 12295 posts
  • Location:Canada

Posted 26 July 2004 - 08:38 AM

I see what you are saying (and yep, the area was correct in the script, it's just me typing things by memory outsiude my modding den) it did not even increment to 2, just stayed on 1 (it should have) - so the script did not work at all.

Fortunately, Grim gave me a simpler solution than using Die(), I am going to test it tonight and see if it works :)

Edited by Domi, 26 July 2004 - 08:43 AM.

Faster. Faster. Faster would be better. -Mal Reynolds, Serenity
I understand that folks prefer code that works. -CamDawg, G3

#13 Baronius

    Robed Bandit

  • Members
  • 447 posts
  • Location:Hungary

Posted 26 July 2004 - 12:38 PM

Yeah, Die() is not the best solution for such a task.




Reply to this topic



  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users