Fire at the Warehouse script

Post » Fri Jan 22, 2010 7:56 pm

Hi!

I want to write a script to attach it on a barrel, so, when activated, if you have the torch, the warehouse will begin to burn
The script has to be attached yo a barrel of oil on a warehouse. When you activate it, if you have a torch, the oil will turn into fire, giving you a entry journal. If you have not, a message box will pop up to say you need a torch. When exit the warehouse. When passed 2 days, the warehouse has to be with fire and rocks, simulating the destroy effect... I even know from where to start...can you help me, please?


Lots of thanks!
User avatar
AnDres MeZa
 
Posts: 3349
Joined: Thu Aug 16, 2007 1:39 pm

Post » Fri Jan 22, 2010 5:03 pm

[I suggested that Dagoth Murdock put this as a public thread so that other people could benefit from my suggestions/guide/thing if they are considering a similar thing; rather than just keep it limited to a pm.]

This is fairly advanced stuff youre trying to do now. This situation cannot be controlled by one script, it will require MANY scripts. Its almost too complex to try and explain in one reply.. but i'll see what i can do. Im not sure you'll be able to just jump into this and get it to work, and to be honest im too busy to constantly help out, your probably better off bringing this to the attention of the community who can give more consistent advice. There are one or two things of this process that are a little hazy in my mind too, so i might not get it right, since its been a little while since ive done it

1. This will need to be controlled by journals. Lets assume youve used the Quest/Journal id: DM_Fire. This is the id that appears in the quests list. Then you'll set up the stages of that quest and I suggest seperating them out like this (at a minimum):

Spoiler
[Mission tells you to set fire to barrel] 10
[You set fire to barrel, need to run away] 20
[Fire will have worked, go back now] 30
[The building is destroyed] 40

These are the stages i will use in the scripts, so if you change this or add things in before them, change everything accordingly.

2. The first part will require a unique barrel in the Activators list; not a static item. You can do this by seeing what mesh the barrel uses in the Static list, then creating a new Activator in the Activator list and, by using the CS disk with the data files, sort through until you find the Barrel mesh. This means you will have a barrel that you can attach a script to, which is what we want. When it is made call it something like DM_Barrel. [im just using DM as an example, you should always use your own prefix for new items in your mods; for example i use "alx_". But you need something different to other people, preferably. DM_ is good.

3. Now you need to find an actual fire which i suspect are in the Activators list, but if they arent, and are instead in the Static list, simply make a new Activator just like the barrel and recreate the fire as an activator. I highly suspect there will already be a fire item in the Activator list somewhere. Rename it DM_BarrelFire or something.

4. Now, you need to make the Undamaged Building. Unfortunately this is where things get very complex. Instead of using the Static building components like you would use in any other building, you need to make new Activator equivilents. So if you were going to use one of the Hlaalu Building exteriors, you must check out what mesh/model it uses, and then recreate a new Activator using that mesh in the Activator list. This is tedious so make sure your building isnt too complex on the exterior. We do this because we have very little control over Static items and Activators are the only way to do this. This process will take some time so be slow and methodical, dont make any mistakes. When all the components are in the Activator list you want construct your building wherever you want the way you want it. Also take this time to make a new Interior Cell and do that part. The Interior can be whatever you want and be built normally, because we can control interiors much easier.

5. Now, unfortunately we have to do it all again for what you want the damaged exterior to look like. If you are using the Imperial models (making an Inperial building) then this whole mod would be much easier bacuse there are already 'destroyed' components so its easier to make the building look destroyed. Think of Fort Frostmoth after the werewolf attack -> infact this is exactly what we are trying to recreate. When the Destroyed Building components are all in the Activator list, make the destroyed building next to the Undamaged Building and when it is done select it and SLIDE the building over the other. This will look silly, with two buildings in the one spot, overlapping and such, but if everything works well, only one building should be visible at one stage. When the old building is destroyed, it will dissappear and the new destroyed on will appear, making it look like it was damaged, etc.

6. Now, inside the interior cell, place the Barrel somewhere and ontop if it, as if it were on fire, place the Fire. What will happen, is that when you light the barrel, the fire will be enabled and will appear, looking as though you just set it on fire. One other thing regarding the Doors in and out. Feel free to set up a normal door exiting from the Interior cell, but DONT set up a door going inside the building. Instead, recreate the Door you want as an Activator and we'll get back to that stage later on. Place this Activator door object on the outside as you would normally, but dont set it to travel inside (not that you would be able to anyway), we'll get back to this.

6. Ok thats the ground work done, now we need to knock up some scripts. I admit that i suspect you are not ready for this (no offence) so i can foresee that you will just plow through this without any understanding, just blind faith. I guess thats a shame but do try and look at what your doing and writing and learn from it. Look at the scripts and try and see what it being programmed [tip of the day ^_^ lol]. So, anyway:

a. The script for the Barrel:
Spoiler
Begin DM_Barrel_SCRIPT

if ( OnActivate == 1 )
if ( GetJournalIndex DM_Fire == 10 )
if ( Player->GetItemCount "torch" >= 1 )
Journal DM_Fire 20
PlaySound "Torch Out"
MessageBox "You set fire to the oil! You should run away back to (somewhere) before someone finds you!" "Ok"
Return
elseif ( Player->GetItemCount "torch" < 1 )
MessageBox "You need a torch to set fire to this barrel"
Return
endif
elseif ( GetJournalIndex DM_Fire < 10 )
MessageBox "This barrel is full of flammable oil"
Return
endif

endif

End


b. The script for the fire:
Spoiler
Begin DM_Fire_Script

if ( GetDisabled == 0 )
if ( GetJournalIndex DM_Fire < 20 )
Disable
endif
elseif ( GetDisabled == 1 )
if ( GetJournalIndex DM_Fire >= 20 )
if ( GetSoundPlaying "fire" == 0 )
PlayLoopSound3DVP "fire", 1.0, 1.0
endif
Enable
endif
endif

if ( GetJournalIndex DM_Fire < 10 )
return
endif

End


c. Below is the script that you must attach to every Activator component of the Undamaged Building (except the Activator Door):
Spoiler
Begin DM_Undamaged_Script

if ( GetJournalIndex DM_Fire >= 30 )
Disable
endif

End


d. Below is the script to attach to every Activator component of the Damaged Building.
Spoiler
Begin DM_Damaged_SCRIPT

if ( GetDisabled == 0 )
if ( GetJournalIndex DM_Fire < 30 )
Disable
endif
endif

if ( GetDisabled == 1 )
if ( GetJournalIndex DM_Fire >= 30 )
Enable
endif
endif

End


7. Ok so thats the majority of easy script work done. From here things can be done in MANY different ways. Lets first deal with the entry door. The door will not be a traditional door, because it must dissappear when the building is destroyed, yet still work as a door before. So i simply include a teleport script inside the one used for the Undamaged Building. Now this is where things get tricky for you because you must determine the coordinates of the space just inside the door of the Interior Cell where you want to appear (asif you went thru the door like normal). I do this by placing something like a North Marker where i want to teleport, then double clicking and writing down the X, Y, and Z coordintes. When you do this, simply put these numbers in their spot in the script below. Lets also assume your interior cell id is "Interior Cell". Whatever you name it will need to replace this in the script below.

Spoiler
Begin DM_Door_SCRIPT

if ( OnActivate == 1 )
PlaySound "mysticism area"
Player->PositionCell, 743 (xcoord), 4085 (ycoord), 249 (zcoord), 90 (this is rotation, use whatever the North Marker does), "Interior Cell"
endif

if ( GetJournalIndex DM_Fire >= 30 )
Disable
endif

End


8. Now we need to make it so that the building only burns down when the player isnt looking. I suggest that you make it so the players has to run back to the quest giver, report the fire and then is sent back (to do whatever). That means you will have dialogue with the Journal condition for DM_Fire at 20 (after you set the fire) for the quest giver to make him say something like "oh good its on fire, now please go back". And then in the conditions box put "Journal DM_Fire 30". This should trigger all the scripts and make the buildings change over, also denying you access to the interior from now on (cos its burned down i guess).

And after that i dont know what else you need in the quest.

Wow that took a while to write down. And who knows, i might be wrong about some stuff, or maybe i do it the hard way, who knows! ^_^ This system works for me. Hopefully you can work your way through this and make it work for your needs.
User avatar
Sxc-Mary
 
Posts: 3536
Joined: Wed Aug 23, 2006 12:53 pm

Post » Fri Jan 22, 2010 10:44 pm

Great work!! I understood all scripts, except the fire script and the coordinates script, how they work? If you ( or anybody) have time, can you explain them, please? thanks!!
User avatar
Matt Bee
 
Posts: 3441
Joined: Tue Jul 10, 2007 5:32 am

Post » Fri Jan 22, 2010 3:37 pm

Oh i missed an endif off the Fire script; should be this:

Spoiler
Begin DM_Fire_Script

if ( GetDisabled == 0 )
if ( GetJournalIndex DM_Fire < 20 )
Disable
endif
elseif ( GetDisabled == 1 )
if ( GetJournalIndex DM_Fire >= 20 )
if ( GetSoundPlaying "fire" == 0 )
PlayLoopSound3DVP "fire", 1.0, 1.0
endif
Enable
endif
endif
endif

if ( GetJournalIndex DM_Fire < 10 )
return
endif

End

[man i hate using spoiler to show code. Loses the indent's which make scripts so pretty ^_^ but then it takes up less room and doesnt actually effect the end result. meh]

What this script does is basically governs when you can see the fire. Before the fire is set, it is disabled, when the fire is lit, it becomes enabled. Also, when the fire is enabled, it starts a sound loop which plays the "Fire" sound. So you not only see fire, but now you can hear it too ^_^ Reading back over what i put, im 90% sure the fire should still work fine once used as an Activator.. its been a while since ive had to use an animated object in an enabling/disabling situation. Should work........... :whistling:

The coordinates script will disable the door once the building has burnt down. The coordiantes part is used to teleport the player into the Interior Cell (just like a normal door effectivly does). However instead of placing a pink door marker like normal, we need to give those coordinates to the script, so it know where to send us.

If you are having trouble finding the coordinates of the entry (ie where you would normally place the pink marker) just find a static item called North Marker, place it in the cell and position it as if it were a pink door marker. This is just so you can double click on it and write down the coordinates for the item which should be in the bottom left of the box (if memory serves me right). Once done you can delete it unless you going to place a North Marker inside the cell anyway, which you should.

Is this helpful? Try and be as specific as possible with queries, so i can jump straight at the problem.
User avatar
butterfly
 
Posts: 3467
Joined: Wed Aug 16, 2006 8:20 pm

Post » Fri Jan 22, 2010 4:01 pm

Sorry fot not being specific, I was refering to these lines:

if ( GetDisabled == 0 ) I know this controls the disabling of objects, but, how it works?

And, about the script line by line:

if ( GetDisabled == 0 )
if ( GetJournalIndex DM_Fire < 20 )
Disable
endif
-------- If the object is not disabled, AND you have that journal index (DM_fire < 20) the object will be disabled?
elseif ( GetDisabled == 1 )
if ( GetJournalIndex DM_Fire >= 20 )
if ( GetSoundPlaying "fire" == 0 )
PlayLoopSound3DVP "fire", 1.0, 1.0
endif
----------If the object is disabled( because you have dm_fire >=20), stop playing the fire sound?
Enable
-------- Enable...what? fire?
endif
endif
endif

----
Also, When will be activated this script? When will appear the flames?

Thanks! Under the script parts I didn′t understand I wrote a ------ with a comment about it
User avatar
xemmybx
 
Posts: 3372
Joined: Thu Jun 22, 2006 2:01 pm

Post » Fri Jan 22, 2010 7:18 pm

GetDisabled reports whether the object the script is attached to is currently disabled or not. So the script goes like this:
; Initially, all objects are enabled, and all quests are at stage 0if ( GetDisabled == 0 )	if ( GetJournalIndex DM_Fire < 20 )	; for the first moment you are in the same cell with the fire, both conditions are matched and the fire gets disabled		Disable				; GetDisabled is checked so that Disable would run only once and not every frame	endifelseif ( GetDisabled == 1 )	if ( GetJournalIndex DM_Fire >= 20 )	; after the initial frame and until the barrel is ignited, only one condition is matched		PlayLoopSound3D "fire"		; once the barrel is ignited, the fire gets enabled and starts to emit sound		Enable	endif					; afterwards, GetDisabled is again 0, but DM_Fire>=20 doesn't let the fire be disabled againendif

User avatar
Budgie
 
Posts: 3518
Joined: Sat Oct 14, 2006 2:26 pm

Post » Sat Jan 23, 2010 5:05 am

Yep, what Kir said.

Also, the script doesnt stop playing the fire sound which isnt a problem because it will only play if you are in the cell. The Enabling thing makes the fire appear once the barrel is on fire.
User avatar
Celestine Stardust
 
Posts: 3390
Joined: Fri Dec 01, 2006 11:22 pm

Post » Sat Jan 23, 2010 12:01 am

But, how knows the script where to place the fire?
User avatar
Klaire
 
Posts: 3405
Joined: Wed Sep 27, 2006 7:56 am

Post » Sat Jan 23, 2010 12:20 am

Oh, no you have to physically place the fire ontop of the barrel asif it was already on fire. But the script will make sure its invisible until you light the barrel on fire, then it will magically appear! :D
User avatar
Kortniie Dumont
 
Posts: 3428
Joined: Wed Jan 10, 2007 7:50 pm


Return to III - Morrowind