How to script this? [H5]

Maps and the art of mapmaking.
Cyanight
Leprechaun
Leprechaun
Posts: 28
Joined: 26 Dec 2006

How to script this? [H5]

Unread postby Cyanight » 02 May 2008, 03:27

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.
Last edited by Cyanight on 02 May 2008, 18:01, edited 1 time in total.

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Re: How to script this?

Unread postby Grumpy Old Wizard » 02 May 2008, 04:00

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.
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.

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."

Franzy
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 02 May 2008, 07:07

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 :)

User avatar
Akul
Round Table Hero
Round Table Hero
Posts: 1544
Joined: 06 Jan 2006

Unread postby Akul » 02 May 2008, 08:04

Could you please put a [H5] mark in the title of this tread? Or at least in the first post?
I am back and ready to... ready to... post things.

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Unread postby Grumpy Old Wizard » 02 May 2008, 12:36

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:
An objective works so I don't know why it would be considered a wrong way to trigger the message.

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."

Franzy
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 02 May 2008, 15:08

An objective works so I don't know why it would be considered a wrong way to trigger the message.
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.

Besides, this is not the use of objective as it intended to be. So, doing it is wrong :) And what if you need to monitor not one stack, but a whole lot of them? You will create a separate objectives for all of them?! That will look ugly. My way - you will only use 1 thread for all of them. So, it's simpler, it's NOT slower, it's more versatile, it's the way it should be done, it's BETTER.

User avatar
rdeford
Assassin
Assassin
Posts: 299
Joined: 17 Apr 2007
Location: Sequim, USA
Contact:

Unread postby rdeford » 02 May 2008, 19:43

Franzy wrote: You see, game automatically creates a thread for every objective - they are nothing but macros.
Interesting, I learn something new everyday it seems.

@ 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

Franzy
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 03 May 2008, 06:38

2rdeford

Well, there is a guy in Russian mapmakers forum, EyeGem, he is from H5 dev team. Game credits say he was responsible for scripts and UI programming. He is a great source of information. Unfortunately, we could not press on him enough to give up patch 3.1 release date :)


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 3 guests