[project1dev] Re: destroyed houses and freeing up their built variable

  • From: Alan Wolfe <alan.wolfe@xxxxxxxxx>
  • To: project1dev@xxxxxxxxxxxxx
  • Date: Sun, 6 Jun 2010 00:02:57 -0700

Ok Kent, I was checking it out and here's the order stuff happens.

#1 - when a mob is despawned (due to Mob_despawn, level change etc) what it
does is just set a flag "ReadyForDespawn"
#2 - there is a time during the main loop of the game where it loops through
all the mobs and removes any that are ready for despawn.  It has to do it
like this instead of destroying them right away because if it's calling
"Tick" for every mob in a loop and some of the mobs kill themselves, that
makes the index used in the loop no longer valid, because the list of mobs
would change (get smaller) if one killed itself.  Basically imagine a
removing elements from an array while doing a for loop over the array.  bad
idea right? anyways...
#3 - when a mob is ACTUALLY being destroyed (during #2), it first kills the
"OnKill" script command.  This is the callback that you get when a mob is
killed (ie BuildingDead).
#4 - it waits til that on kill script is done doing whatever it needs to do
before actually destroying the mob and removing it from the list.   That
means you can do whatever you want and it wont be destroyed until you are
done.

So... your plan SHOULD work where you set a property on the model to store
the mob id, and then you can get that mob id property and send the mob
messages to get information from it.

On Sat, Jun 5, 2010 at 10:57 PM, Alan Wolfe <alan.wolfe@xxxxxxxxx> wrote:

> yeah for sure... let me think about it.
>
> for what its worth i think you get the message that a mob died BEFORE it
> dies, and can still send messages to it.
>
> i'll double check that to make sure that path would work ok
>
>
> On Sat, Jun 5, 2010 at 10:55 PM, Kent Petersen <kentkmp@xxxxxxxxx> wrote:
>
>> Currently I am having an issue detecting which house died when it dies.
>> The mob death script runs but that function is unable to detect what the
>> tile and house index # the blow up house had. This is vital information for
>> setting the correct house variable back to 0. I was trying to do something
>> with send messages to the mob to pull out the value. This attempt is not
>> working and I think its because the mob despawns and then I try to send a
>> command to it.
>>
>> So, I want the ability to be able to pass variables to the script that
>> runs when a mob dies.
>>
>> Unless you have another good idea?
>>
>> Another thought I had was using the model property to set a property for
>> "TilePos" and "IndexPos" and then check the value of those when the house
>> dies but I think it's going to lead to the same problem of having the model
>> despawn and not being able to send commands to it.
>>
>
>

Other related posts: