Daxtreme Posted June 27, 2019 Share Posted June 27, 2019 (edited) Hey guys, I have this small problem with a creature. I gave her MINHP1.itm for quest purposes but when a certain state has been reached, I want to remove MINHP1 It's a VERY simple script and yet... it doesn't work. So first the creature is created in dimension door during a cutscene CreateCreatureDoor("mage18z",[738.419],S) Then I try to remove MINHP1 with this, which is in the OVERRIDE script for mage18z completely at the top: IF OnCreation() Global("TSFired","LOCALS",1) THEN RESPONSE #100 SetGlobal("test","GLOBAL",12) DestroyItem("MINHP1") // No such index END MINHP1 never gets removed. Now I've tried switching TSFired from local to global to check it in-game with console, and it says it's equal to 1 before mage18z gets created, so the condition should be ok. Moreover, the test global I'm setting.... it's never set to 12, ever. Which means it never gets to the RESPONSE #100 in the first place! Anyone knows what's going on? Maybe OnCreation() never runs because the creature was created in a cutscene? Thanks! Edited June 27, 2019 by Daxtreme Quote Link to comment
CamDawg Posted June 27, 2019 Share Posted June 27, 2019 Cutscenes pause individual creature scripts, and OnCreation is only true on the script pass when they're spawned. I'd just add the destruction of the MINHP1 item to the cutscene script itself. Quote Link to comment
DavidW Posted June 27, 2019 Share Posted June 27, 2019 I’m not entirely sure why OnCreation() didn’t fire, but in any case it’s a bit fragile and I tend to avoid it. As a general rule, your code is more robust if, when a block is supposed to fire once, the condition enforcing that can be guaranteed to be set only when the thing the block is supposed to do happens. In this case, a simple way to do it is to replace OnCreation() with HasItem(Myself,”MINHP1”) (assuming you don’t want to give it back later, that is!) Quote Link to comment
Daxtreme Posted June 27, 2019 Author Share Posted June 27, 2019 Thanks! Definitely what I'm gonna do. Or could I set a LOCALS variable? Does its value transfer between each version of the CRE, or applies just to 1 instance? Quote Link to comment
CamDawg Posted June 27, 2019 Share Posted June 27, 2019 LOCALS are per-instance, so spawning a new version means no LOCALS carry over. If you wanted to keep it in the creature's script, this would work: IF HasItem("MINHP1",Myself) Global("TSFired","LOCALS",1) THEN RESPONSE #100 SetGlobal("test","GLOBAL",12) DestroyItem("MINHP1") // No such index END Quote Link to comment
Daxtreme Posted June 28, 2019 Author Share Posted June 28, 2019 Thanks, works flawlessly! Quote Link to comment
Jarno Mikkola Posted June 28, 2019 Share Posted June 28, 2019 7 hours ago, Daxtreme said: Thanks, works flawlessly! That might... but checking for a LOCALS and then setting a GLOBAL is definitely not the brightest of ideas. But like DavidW said... it's not even needed, as just checking the item itself does things well... or if the LOCALS triggers it, then you don't need to check for the item. As you should either check for the item... or the LOCALS and append that LOCALS... or use a GLOBAL. So an example would be: IF Global("TSFired","LOCALS",1) THEN RESPONSE #100 SetGlobal("TSFired","LOCALS",2) DestroyItem("MINHP1") // No such index END Quote Link to comment
Daxtreme Posted June 29, 2019 Author Share Posted June 29, 2019 Yeah I corrected that LOCALS vs GLOBAL part. IF HasItem("MINHP1",Myself) // No such index Global("TSFired","GLOBAL",1) THEN RESPONSE #100 DestroyItem("MINHP1") // No such index Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.