I want a certain action to happen when a creature is slain.
When I put the script under the script section of the creature dialog (combat) but the script fires before combat.
Please help if you can. I cant find out where to place the code.
How to script this? [H5]
How to script this? [H5]
Last edited by Cyanight on 02 May 2008, 18:01, edited 1 time in total.
- Grumpy Old Wizard
- Round Table Knight
- Posts: 2205
- Joined: 06 Jan 2006
- Location: Tower Grump
Re: How to script this?
You might want to set it up as an objective. Click on View--> Map Properties tree and set up the objective there. Place the name of the script you want to fire under State Change Trigger-->Action-->Function name under the objective.Cyanight wrote:I want a certain action to happen when a creature is slain.
When I put the script under the script section of the creature dialog (combat) but the script fires before combat.
Please help if you can. I cant find out where to place the code.
Set up the objective to be initially active on day 1 but not visible. When the objective is completed the funcion in the state change trigger will be executed.
Download my Shadow Dreams map and look at the the objectives I set up. Some of them utilize the state change trigger.
Click here
GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."
You should use a thread for this. This is the RIGHT way. What GOW suggested, with all due respect (:)), is not. Here is an example:
--------------------------------------
function watchMonster()
while IsObjectExists("mymonster") do
sleep(10);
end;
-- Here add comands that must be executed after the monster named "mymonster" is slain.
end;
startThread(watchMonster);
--------------------------------------
P.S. name is a script name you define in object properties.
I can explain the script, if needed. Just ask
--------------------------------------
function watchMonster()
while IsObjectExists("mymonster") do
sleep(10);
end;
-- Here add comands that must be executed after the monster named "mymonster" is slain.
end;
startThread(watchMonster);
--------------------------------------
P.S. name is a script name you define in object properties.
I can explain the script, if needed. Just ask

- Grumpy Old Wizard
- Round Table Knight
- Posts: 2205
- Joined: 06 Jan 2006
- Location: Tower Grump
An objective works so I don't know why it would be considered a wrong way to trigger the message.Franzy wrote:You should use a thread for this. This is the RIGHT way. What GOW suggested, with all due respect (:)), is not. Here is an example:
Threads are fine as long as you don't do too many of them. They continuously use up resources whereas an objective does not. But you are free to trigger the message however you wish.
GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."
You see, game automatically creates a thread for every objective - they are nothing but macroses. So, when you use an objective, you also use a thread. But also you do a whole lot of other useless work - setting up triggers, hiding objective, etc. It's like driving from Las Vegas to Los Angelos via New York. You can do it, of course, but there are better ways.An objective works so I don't know why it would be considered a wrong way to trigger the message.
Besides, this is not the use of objective as it intended to be. So, doing it is wrong

Interesting, I learn something new everyday it seems.Franzy wrote: You see, game automatically creates a thread for every objective - they are nothing but macros.
@ Fanzy: You must have an inside track on things, eh?
rdeford, Mage Of Soquim
“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."
Ernest Holmes 1984
“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."
Ernest Holmes 1984
Who is online
Users browsing this forum: No registered users and 3 guests