July 03, 2024, 10:36:24

Author Topic: Scripting Issues  (Read 92562 times)

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #75 on: April 29, 2010, 19:47:54 »
Try this, it worked on my test range...

Code: [Select]
RULE event Exploded

condition E.ship:class=#cls_missile

:action

       //Record the location data for the explosion...

EposX:=E.ship:PositionX;
EposY:=E.ship:PositionY;
EposZ:=E.ship:PositionZ;

                        //And tell what is is...

Debug("X Coordinate = ",EPosX);
Debug("Y Coordinate = ",EPosY);
Debug("Z Coordinate = ",EPosZ);

:end //end action

END //end rule

Gave me valid data whenever a missile struck home  :)
Better to look the fool by asking, then prove them right with ignorance.

Offline jstubbles

  • Petty Officer
  • **
  • Posts: 169
  • Karma: 2
    • View Profile
    • http://www.ivassago.com
(No subject)
« Reply #76 on: May 02, 2010, 20:47:40 »
I'm having an issue right now where I'll tell a ship to engage a target, then the weapons power up part way, then stop. They do that over and over again, even though they are well within combat range of the weapon :( they eventually fire when they get even closer, but the AI fires long before my own craft would.

Their hitchancecat settings encompass both the combat and artillery range settings, but they still keep resetting each time, it's really odd. If I set them to manually fire, they'll fire without a problem

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #77 on: May 03, 2010, 01:41:02 »
Are you talking about long-distance weapons? try setting (if you haven't already) their sets to the ones corresponding to an artillery weapon: Sets 2 4 30 100 31 (or 32) 117 ;

Offline jstubbles

  • Petty Officer
  • **
  • Posts: 169
  • Karma: 2
    • View Profile
    • http://www.ivassago.com
(No subject)
« Reply #78 on: May 04, 2010, 04:20:58 »
They're combat weapons, not artillery weapons. In this case, they're missiles, which I'm not using as artillery. Problem is, if I give them a hitchange cat that only has settings for range 1, I cannot fire at range 2 (obviously), but the AI CAN fire at range 2 and I can do it if I manually fire them, which makes no sense at all.

Another funny issue I'm having right now is with the missile engines. For some reason, if I set the engine velocity factor to a value higher than 60, it makes both the flare and strip PULSE - even though I have pulsefactor set to 0 wherever possible.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #79 on: May 04, 2010, 23:15:34 »
Well, just to ask: when you say that you're only giving a hitchance cat for only 1, you meant that you left the other places as 0?

Guys, I've an interesting problem that's been keeping me for several hours...
In one of my missions I'm having the camera follow the trajectory of a missile as it heads towards a ship and then impacts on it, and what I've been trying to achieve is to move the camera to where the camboatview() cam was last at, the impact zone. My aim is to have a seamingless transition between that cam and the regular one (this is done in cinema mode. That's why I asked you if you could obtain the co-ordenates of a missile before it impacts the ship)

however, this is very tough since the only point of reference is the co-ordinates of the missile as it explodes, and you can't obtain it's co-ordinates a sec before (I know, a tick rule, but that's a bit too risky).
Using the ship where it collides as the 2 reference is the closest I've got, but it's far from ideal...

so... ideas?


EDIT: Man, I love this site.... solved :P
The tick rule was the answer, after all. It saved the missile postions as long as it was alive, every sec. And then, using the exploded rule (thanks Old Dragon) used a camMoveTo command, using the last known position of the missile from the tick rule as the "from" co-ordinates, and then I used the co-ordinates that the exploded rule gave to me as the "to", and using a handy explotion to shake the screen a bit and soften the transtion, worked like a charm.

EDIT: Either way, I have an other issue, how did you create a wreckyard again? I tried setting the wreck ships as asteroids, but that's far from ideal. And if I just leave them as objects  and then "wreck" them with behaviour:=2, the game crashes due to too many ships (currently have about 30 wrecks :P)
So how did you do that again, Old Dragon, if I may ask?

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #80 on: May 05, 2010, 00:15:00 »
Mine's the 'far from ideal' approach I'm afraid  :(

What I've done is to damage the ships I want to be wrecks (about 60 to 75 percent) and then turn them into 'asteroids' with 'Behaviour:=4;' command.

With that level of damage, the 'wrecks' yaw & roll with all the burn marks just as if you'd shot them all up yourself. But anymore damage than that and they won't respond to the command to change!
Better to look the fool by asking, then prove them right with ignorance.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #81 on: May 09, 2010, 21:17:34 »
Uhm... I'm sorry, but that didn't work out either... I still get the tairace.cpp (too many ships) error...

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #82 on: May 10, 2010, 14:25:53 »
Hmmm, not too sure then...

How many wrecks are you trying to create?

If you wish to, send me the relevant files and I'll see if I can spot something.
Better to look the fool by asking, then prove them right with ignorance.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #83 on: May 10, 2010, 21:19:36 »
better than that, could you write an small example of what you did?

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #84 on: May 11, 2010, 08:57:45 »
Certainly can. This is an excerpt from the actual rule of the campaign edition mission that does the work, as you can see, there really isn't much to it...

Code: [Select]
//List the ships we want to be wrecked...

SWrecks:=GetfreeSel();
SelectShips(SWrecks,S.race=#race_Wreck);
ExecList(SWrecks,

    //And make them damaged.

    S.this:Damage:=Rnd(60,75);

    //And turn them into asteroids...

    S.this:Behaviour:=4;

);
Better to look the fool by asking, then prove them right with ignorance.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #85 on: May 11, 2010, 20:37:52 »
odd... that's pretty similar of what I did... (well, almost identical, in fact...) how many wrecks did you place?

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #86 on: May 11, 2010, 23:46:45 »
Erm... about nineteen or twenty.
It's also worth mentioning that when that particular area is loaded, they're the only ships in the area to begin with, apart from the player that is. Any other objects that count towards the ship total are to be added by random(ish) scripts.

Could it be that you're trying to place all the ships/objects in the scene in one go?  And therefore exceeding the game limit?
Better to look the fool by asking, then prove them right with ignorance.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #87 on: May 12, 2010, 16:27:54 »
yeah... that's clearly it. I have about 40 or so wrecks flying arround :P

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #88 on: May 12, 2010, 23:45:06 »
The ship limit is about 28, isn't it?

Anyway, there actually is a way you can make any ship behave like an asteroid and not contribute to the ship limit right from the start. Copy & Pasteā„¢ the following snippet to the ENTITIES block at the bottom of your .mission file:

Code: [Select]
SHIP
Name "Ast.01.003"
Class #my_shipclass
Behaviour 4
Position 4934.08 -4970.09 4627.69
Orientation 8.22877 41.7865 -14.8206
END

Of course, replace the class, position and orientation as needed, preferably using the mission editor for both position and orientation unless you enjoy entering lots of numbers by hand ;)

You can use any shipclass this way, no matter if it's an asteroid, battleship or escape pod. They don't contribute to the amount of ships in the scene, so the game won't crash no matter how many of them you add (unless we're talking thousands, I guess).

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #89 on: May 12, 2010, 23:53:04 »
Hey Mularac,

May have a solution for you, unfortunately it does mean you've got some work to do.

The first version is the simple, no frills approach. What you need to do locate your 'wrecks' in the entities section (if you're in a modmission or in the .sobj files for campaigns) and do some editing...

1) Remove the 'race' entry.
2) Change the 'shiptype' to its 'class'.
3) Add the entry "Behaviour 4"

The ship/wreck shouldn't now count towards the ship total. On the plus side, you should now have your graveyard. Downside... the 'wrecks' will now just sit there, no rolling or damage and not particularly realistic.

Now my second version will look better (hopefully) but requires a bit more work.

First of all, do the above steps, then add this machine to your mission file...

Code: [Select]
MACHINE "Wrecker"

STATE Default

RULE event In

:action

//You'll need to list name and list any ship you want to be a wreck in here...

*******:=GetSceneObj("*******");
//(Repeat for each)

Wrecks:=GetFreeSel();
AddItem(Wrecks,*******);

//And call the second half

LocalEvent(Alter);

:END //end action

END //end rule

RULE event Alter

:action
//Pick and alter 'wreck'.

M.Change:=Pick(Wrecks);
M.Change:behaviour:=0;
M.Change:damage:=65;
M.Change:Behaviour:=4;

//Rinse and repeat if required...

RemoveItem(Wrecks,M.Change);
M.Change:=0;
If(AllNumOf(Wrecks)>0,LocalEvent(Alter));

:end //end action

END //end rule

END //end state

END //end machine

Now you'll need to fil in the first rule. Each wreck will need to be named and then manually added to the list I'm afraid. I did look into other ways of selecting them, but for one reason or another, they ended up as duds, so it's time to start typing.

My missions have a three to five second 'fade in' period (normally), so if the machine is triggered  to run straight away then the player will be none the wiser.

EDIT:

Just my luck, I start answering a post and someone beats me to it, lol  :D
Better to look the fool by asking, then prove them right with ignorance.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #90 on: May 13, 2010, 00:35:06 »
Arparso: Yes I know, I did that from the start (I in fact used the asteroid generator of the mission editor ranging from 3 or 4 shipclass and then I replaced those with my shipclases), I was looking for something better.
Old Dragon: Thanks a lot, I'll look into it when I have some time.

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #91 on: May 13, 2010, 19:32:47 »
I've made a few modifications to Old Dragons script to make it just a bit more flexible. Your typical shipwreck should look like this in the mission file:

Code: [Select]
SHIP
Name "Wreck1"
Class #my_shipclass
Race #race_Wrecks
Behaviour 4
Position 4934.08 -4970.09 4627.69
Orientation 8.22877 41.7865 -14.8206
END

It's important to define both a race and behaviour 4. If you leave out the behavior, the wreck will initially contribute to the ship limit and the game will crash, if there are too many. You won't even get to your SceneInit rule to change the behaviour, because the game will crash way before that.

The race is important to make selecting your wrecks easier and also to disable the default ship animation including blinking lights. For some reason I couldn't disable that on raceless ships... and a wreck with blinking position lights, rotating sections or simply glowing "windows" doesn't look much like a wreck. The downside is: as long as a race is specified for that wreck, you can't enable the animation again, which you might want to do on certain special wrecks the player is supposed to have a look at or something. But that's probably not the general case, so for all "normal" wrecks a race works just fine. Probably stick to a special "wreck race", so you don't accidently wreck the wrong ships.

Second part is Old Dragon's slightly modified machine:

Code: [Select]
MACHINE "Wrecker"

STATE Default
RULE event In
:action
// select all wrecks
Wrecks:=GetFreeSel();
Select(Wrecks, S.race = #race_Wrecks & S.behaviour = 4);

If(AllNumOf(Wrecks) > 0,
// make all wrecks visible to the player (and everyone else)
ExecList(Wrecks,
MakeFullyKnown(s.this);
FreezeReconState(s.this, 1);
);
// make each wreck "float" in space
LocalEvent(MakeFloat);
,
// leave state, if there were no wrecks at all
LeaveState();
);
:end
END

RULE event MakeFloat
:action
// randomly pick a wreck
E.Wreck := Pick(Wrecks);
// temporarely make it a normal ship and apply some damage
E.Wreck:behaviour := 0;
E.Wreck:damage := 65;
// make it a wreck again
E.Wreck:Behaviour:=4;

// remove current wreck from the list
RemoveItem(Wrecks,E.Wreck);
E.Wreck:=0;
// repeat above for all remaining wrecks and leave current state, if done
If(AllNumOf(Wrecks) > 0,
LocalEvent(MakeFloat);
,
LeaveState();
);
:end
END

END

END //end machine "Wrecker"

Selecting the wrecks is now a breeze as you just look for the "wreck race" and "behaviour 4" setting. Strangely, wrecks with a race won't be visible to the player immediately, so I added the MakeFullyKnown/FreezeReconState bit for every wreck. The rest of the machine is more or less the same, except for two changes:
  • I made "M.Change" from a global variable to a local event variable "E.Wreck", so it isn't visible in any other part of the mission script
  • I added LeaveState() after the machine has done its job to prevent it from ever running again (for example, if you use LocalEvent(MakeFloat) somewhere in a mission-level rule, you WILL call this machine as well, which you probably didn't want to... so LeaveState() works just as a safeguard here)
I had a quick test mission with a hundred wrecked Hecate-class destroyers in my FreeSpace mod, which worked really well. Even perfomance wasn't an issue with all these huge ships, probably because the 100+ blink lights on each ship weren't active and no AI was needed for them.

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #92 on: May 13, 2010, 20:07:08 »
Okay, small addendum:

The script somewhat fails, if you've got more than 256 wrecks. I tried it with 1000 and apart from the bad performance, quite a lot of the wrecks didn't float like they actually should. It turns out, they weren't picked up by the script, because the wreck list only selected the first 256 wrecks. Trying to raise the list's capacity using Dim(list, size) crashed the game for values above 256, so it seems Nexus only supports lists/selections with up to 256 items.

What a bummer... :(

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #93 on: May 27, 2010, 14:42:59 »
Little question, I'm trying to select all ships in the scene except the players and any possible stations/ platforms, etc. This is my current line...

Code: [Select]
SelectShips(MainList,Not(S.race=#race_Player)&HasDevType(S.this,S.Engine));
It all works exept for the 'S.Engine' part (I'm using the engines as a filter 'cause that's the one thing that a stationary object shouldn't require). Anyone got an idea on how to get the last part working?
Better to look the fool by asking, then prove them right with ignorance.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #94 on: May 28, 2010, 01:19:00 »
Did you try using inSet instead of s.engine? (sorry, I can't try anything right now, I'm writing from my linux partition)
Also, if that doesn't work a much uglier way could be this:

Code: [Select]
selectShips(mainList, s.this:race!=#race_player);  //select all the non-player ships
execlist(mainList,
selectDevices(1, s.this, InSet(s.this, 50)); //put in the list 1 all the devices that fall under the set 50 (engines)
If(AllNumOf(1)!=0, removeItem(mainList, s.this)); //and if that list isn't empty then remove that ship from the mainList (because it has at least one engine)
);

Sorry I didn't test... but it may work. And it's ugly as hell. So you should just wait to have Arparso tell you the way it's done :P

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #95 on: May 28, 2010, 01:30:51 »
Hi there Mularac,

I was kinda hoping to avoid sets if possible, trying to keep this script as independant as possible. If anyone modifies/creates their tactictypes then the script won't work too well (assuming that I can get it working to begin with  that is :P ).

But I'll keep that in mind  :)
Better to look the fool by asking, then prove them right with ignorance.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #96 on: May 28, 2010, 02:33:23 »
But the engines are to be placed on the 50 set, otherwise it won't work well at all, specially in campaign scripting.

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #97 on: May 28, 2010, 04:00:30 »
Instead of checking for Inset(), you could always replace that with S.Engine instead:

Code: [Select]
SelectShips(MainList, S.Race!=#race_player);  //select all the non-player ships
execlist(MainList,
E.Engines := GetFreeSel();
E.EngineCount := SelectDevices(E.Engines, S.This, S.Engine); //put in the list 1 all the devices that fall under the set 50 (engines)
If(E.EngineCount > 0, removeItem(MainList, s.this)); //and if that list isn't empty then remove that ship from the mainList (because it has at least one engine)
DeleteSelect(E.Engines);
);

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #98 on: May 28, 2010, 08:48:13 »
@ Mularac,

Hmmm, there's something I wasn't aware of :)

Thanks guys  :thumbsup:
Better to look the fool by asking, then prove them right with ignorance.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #99 on: May 28, 2010, 16:31:55 »
i don't know about the AI or anything else, but I know for a fact that the weapon and ship configuration screen handles the devices according to their sets (as to where to place the devices in each category and all).
But honestly i don't know if there's an other issue... but nexus has many hardcoded issues, so I don't know....
 

@Arparso:  Why did you use the E.EnginesCount variable? Isn't it enough by using the E.engines list?

-- Just corrected myself: it's more efficient to check a variable that use walk trough a list... that's why you used enginesCount, right?