FunkySwerve wrote...
My code compiles fine. Something you did wrong is the cause of your problems. I get the sense from your replies that you have a lot of confusion about scripting in general, so I'll go over this step-by-step. If you still don't understand, I can whip up a quick demo module.
First, this is the include. An include doesn't do anything, it's just a reference script for other scripts. It has no void main, and you can't compile it. It is compiled when you compile another script that references it. If you try to compile it, the bioware toolset will think it's a conditional and ask if you want to compile it as one. It isn't, and you shouldn't. Think of it as storage for custom functions. I'm going to leave a large space at the beginning and end of it, to make sure you don't accidentally include anything in it you shouldn't - the lack of code boxes in this forum is rephrehensible:
// This function will create the illusion of a placeable moving up to the sky. It
// will eventually destroy the placeable. fRate is the rate of Ascent, the amount
// of height to 'move' during each iteration of the function. fCeiling is the
// highest you want the placeable to go before deleting, and fInterval is the number
// of seconds between iterations of the function. I entered default values for them
// based on the script you had, but you can specify them as you like.
void StartPlaceableAscent(object oPlaceable, float fRate = 3.0, float fCeiling = 40.0, float fInterval = 6.0);
void DoPlaceableAscent(float fRate, float fCeiling, float fInterval) {
object oArea = OBJECT_SELF;//We AssignCommanded to the area, making it O.S.
object oRise = GetLocalObject(oArea, "RisingPlaceable");
location lLoc = GetLocation(oRise);
vector vVec = GetPositionFromLocation(lLoc);
vVec.z += fRate;
if (vVec.z > fCeiling) {//end pseudo if the next move would take us over the ceiling
DestroyObject(oRise);
DeleteLocalObject(oArea, "RisingPlaceable");
return;
}
//Since we didn't end the psuedo, we fire up the next iteration
DelayCommand(fInterval, DoPlaceableAscent(fRate, fCeiling, fInterval));
//The rest is simply creating the new, destroying the old
string sRes = GetResRef(oRise);
float fFace = GetFacingFromLocation(lLoc);
location lNew = Location(oArea, vVec, fFace);
DestroyObject(oRise);
//normally I would delay creation by a second or so to make it look more natural, but
//I'm trying to keep this simple
object oNew = CreateObject(OBJECT_TYPE_PLACEABLE, sRes, lNew);
SetLocalObject(oArea, "RisingPlaceble", oNew);
}
void StartPlaceableAscent(object oPlaceable, float fRate = 3.0, float fCeiling = 40.0, float fInterval = 6.0) {
object oArea = GetArea(oPlaceable);
SetLocalObject(oArea, "RisingPlaceable", oPlaceable);
AssignCommand(oArea, DoPlaceableAscent(fRate, fCeiling, fInterval));
}
That's it for the include. Save it place_rise_inc. I see you did that last time, but I want to ensure you have all of the include text, and nothing else.
Now, here is a script that uses that include. It could go in any event you choose. It gets the airship by tag, and issues the rise order. It will work on any placeable you target so long as it isn't static and it matches its palette version (which also cannot be static). You should make sure your airship's tag is correct (only the instance in the area, not the palette, matters for that), make sure both instance and palette version are nonstatic, and it will work.
[code]
[/code][code]#include "place_rise_inc"
void main() {
object oAirShip = GetObjectByTag("Airship1");
StartPlaceableAscent(oAirShip);
} /code]
[/code]
THIS script, the one that includes the include file, is the one you need to compile.
Now, here is another example, one in which different parameters are specified, instead of the defaults I built into the function:
[code]
[code]#include "place_rise_inc"
void main() {
object oAirShip = GetObjectByTag("Airship1");
StartPlaceableAscent(oAirShip, 1.0, 40.0, 3.0);
} /code]
Again, you would only compile this script, if you wanted to use it. Does that make things any clearer?
Funky
Hi again
Thanks a lot for going over and explaining how your code works.
You have helped me to understand it a lot better now indeed!
'>
The first code you made was just an include, (as you already said) so I put it in my scrip editor and saved it as
place_rise_inc as said before, and when it asked if I wanted to save it as a conditional, I chose
"No" since you said it wasn't.
I'm not too sure what a conditional script is to be honest. Is there any point to telling me what it is, or would it only confuse me further?
Anyway...... I borrowed the other very short scripts you made.
These 2 :
#include "place_rise_inc"
void main() {
object oAirShip = GetObjectByTag("Airship1");
StartPlaceableAscent(oAirShip);
}
#include "place_rise_inc"
void main() {
object oAirShip = GetObjectByTag("Airship1");
StartPlaceableAscent(oAirShip, 1.0, 40.0, 3.0);
}
I used them to test them out, and those are the ones which compile because they are referenced from the include you posted. So yeah..... I know how that works now, with your help.
Thanks. It was very helpful indeed!
'>
Okay.... now I'm still having an issue trying to get the airship to rise up to a high point, and it only stops quite low to the ground.... as usual. All the scripts from you and Fester Pot keep causing this to happen, and I don't understand why my airship won't rise a lot higher than I would like. It rises up, but It still stops at a low point, and I'm still not seeing the destroy effect at the last stop either.
'> (it might be in the first line somewhere, though I'm not completely sure)
I also changed to use just 1 airship placeable too, but I'm still getting this same problem.
*sigh!*
In your script, where you have :
StartPlaceableAscent(oAirShip, 1.0, 40.0, 3.0);Wouldn't those numbers have to be bigger perhaps? When you jumped to 40.0, I don't understand why you then went back down 3.0 again. If the middle number was 40.0, wouldn't the next one have to be (for e.g.) 50.0?
If you have a bit of time, please could you explain this?
Does the NwN 1 game engine have the capability for scripts to give the illusion of a placeable to rise
very high up, or not? I just don't understand why this is isn't going right for me!
*sigh!*Anyhow..... I appreciate all the help that you and Fester Pot have given me with the scrpts you have both written out.
It has definitely worked to some extent at least, and I cannot stress enough how greatful I am for it.
'>
Thanks again.
"MissJaded"B)
Modifié par MissJaded, 04 novembre 2010 - 06:29 .