December 22, 2024, 13:56:42

Author Topic: Scripting Issues  (Read 103405 times)

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #50 on: February 14, 2010, 11:27:27 »
... although debug("1",s.this), Debug("2",dev) and Debug("----------------The devices are:", dev) all do the same, more or less ;)

Do you want to enable both devices at the same time? Then the following should suffice:

Code: [Select]
SelectEx(s.device & s.owner=M.*ship* & (InSet(s.this,66)| InSet(s.this,42)),
EnableDevice(s.this, 1);
);

You can leave out the s.owner=M.*ship* part, if you want to enable all such devices on all ships simultaneously or replace it with s.owner:race=#race_whoever, if you're going to enable all such devices only for ships of a specific race.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #51 on: February 14, 2010, 16:46:15 »
yes, I do want to enable them, but not when the devices are selected. That code is part of a nice 647 line machine that handles a way to fix a ship's devices (it's one mission exculsive, that's way I set the "ship" parameter in the SelectDevices as only one scene object.
That machine works in a similar way as your warfare mod does it (that's from where I took the idea) a series of dialogs appear, you select the device you want to fix, that goes to a specific rule where the device in question is selected and then a timer appears, and when that timer is done the device is "fixed" (enabled).
The mechanics are: each dialog is connected to their special rule, where the device is selected and the time is set. And then the state is change with this information:

Code: [Select]
ChangeState(countdown, dev:=dev; E.time:=p.time);

that is common to pretty much all devices, where dev is the device and e.time is the time that would take to repair it. In the state "countdown", I give a StartCountdown rule with the time in question and when that is done a rule appears that pretty much all it does is to enable "dev" via the enabledevice command, and then returns to the previous state, so I can't have them enable in the same rule.
As for what old dragon said: yeah, I know that, and the reason while all of them were the same was for the sake of testing what the variable would look like in an out the execlist. However, placing the "changestate" rule inside the execlist wouldn't work either, only one of the devices got fixed.
Well... since there's only one device on the list that actually needs two devices to be fixed I'm gonna have to go with 'Plan B'; a small "if" command in the last rule that would detect that if dev belongs to that devices set, then it must also enable the other device I needed.

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #52 on: February 14, 2010, 18:30:05 »
How about adding the selected devices into a seperate list via the 'AddItem' command? And using the dev variable to select a command that would 'ExecList' the selected devices?

So the first rule of the new state would be like...

Code: [Select]
RULE       event In
                 :action
                             ChooseFirst(
                                       dev=1,
                                                  LocalEvent(RuleOne);
                                        ,
                                        dev=2,
                                                  LocalEvent(*****************);
                              ):
                  :end
END
RULE       event RuleOne
               :action
                            ExecList(1,
                                             //script whatever to happen here.
                            );
                :end
END

From those local events you can then dictate what will happen.  Is this any use?
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 #53 on: February 14, 2010, 19:32:07 »
I... don't think I understand you.
Here, I'll post a simplified version of my machine (not the 600 lines, as there's a lot of repetetive code I couldn't avoid, but it is still some good 200 lines... perhaps they'll help me make my point):

Code: [Select]
Machine "Fixing_Devices"

State Setup

Rule event in
:action
something_is_inside:=1;  //this is used to check if all the devices in a given set (military, non-military) are done or not.
if(m.first_time=0,
/*Here I divided the weapons, no use to show this...*/
m.first_time:=1;
LocalEvent(MainMenu);
);
:end
END

Rule event Selected
Condition E.ship=M.ac&m.Dialog_running!=1&Timer_on=0
:action
LocalEvent(mainmenu);
:end
END

Rule event MainMenu
:action
M.Dialog_running:=1;
ChooseFirst(
m.No_More_N_Devs = 1 & m.No_More_M_Devs = 1 & No_More_Devs = 0,
No_more_devs:=1;
Dialog("No_More_Devs",0,0);  //this dialog is show in case there're no more devices to fix
, m.No_More_N_Devs = 1 & no_more_devs = 0,
Dialog("First_Choice_military",0,0);  //this is the tree of non-military is all done
, m.No_More_M_Devs = 1 & no_more_devs = 0,
Dialog("First_Choice_no_military",0,0);  //idem but with the military done
, m.No_More_N_Devs = 0 & m.No_More_M_Devs = 0,
Dialog("First_Choice",0,0);   //when they're all incomplete.
);
:end
END

Rule event Cycle_normal
:action
m.military_cycle:=0;
ChooseFirst(
m.eng = 1 | m.eng_sec =1 & m.nav = 1 & m.sens = 1 & m.pgen = 1 & m.hyp = 0 & m.hyp_cycle = 0,
something_is_inside:=1;
Deletependingdialogs(1);
Dialog("fixing_hyp",0,0);  //this is the ultimate goal, repair the hyperdrive, and to do so you have to fix all of the above (engine, nav, sensors and pgen)
M.Dialog_running:=1;
, m.eng = 0 & m.eng_cycle = 0,
something_is_inside:=1;
Deletependingdialogs(1);
Dialog("fixing_eng",0,0);
M.Dialog_running:=1;
/*...*/
, m.pgen = 0 & m.pgen_cycle = 0,  //this is the part I'm interested in, the power generator
something_is_inside:=1;
Deletependingdialogs(1);
Dialog("fixing_pgen",0,0);
M.Dialog_running:=1;
/*...*/
, m.blank = 0,  //in case the player didn't choose anything
Deletependingdialogs(1);
M.Dialog_running:=1;
if(something_is_inside=1,
Dialog("blank_choice",0,0);
,
Dialog("No_More_N_Devs",0,0);
m.No_More_N_Devs:=1;
);
);
:end
END

Rule event Cycle_military
:action
m.military_cycle:=1;
ChooseFirst(
/* Pretty much the same as above, but with weapons and weapons generators */
, m.blank = 0,
Deletependingdialogs(1);
M.Dialog_running:=1;
if(something_is_inside=1,
Dialog("blank_choice",0,0);
,
Dialog("No_More_M_Devs",0,0);
m.No_More_M_Devs:=1;
);
);
:end
END

Rule event Re_Start
:action
LocalEvent(blanc);
LocalEvent(MainMenu);
:end
END

Rule event Blanc
:action
something_is_inside:=1;
M.Dialog_running:=0;
m.eng_cycle:=0;
m.pgen_cycle:=0; //these are the cycle variables, and in here we set them back to 0, as the whole cycle is re-starting.
:end
END

/* and all of these are the output of the player choosing to fix these devices */

Rule event eng
:action
SelectDevices(1, m.ac, s.this:devtype=#eng_b304);
Execlist(1,dev:=s.this);
M.eng:=1;
Debug("e.dev is", e.dev);
ChangeState(countdown, dev:=dev; E.time:=110);
:end
END

Rule event eng_sec
:action
SelectDevices(1, m.ac, s.this:devtype=#eng_b304); //#eng_b304_sec);
Execlist(1, dev:=s.this);
m.eng_sec:=1;
ChangeState(countdown, dev:=dev; E.time:=55;);
:end
END

/*...*/

Rule event pgen  ///this is the polemic rule, still not working...
:action
E.time:=250;
SelectDevices(1, m.ac,  InSet(s.this,66)| InSet(s.this,42));
Execlist(1,
debug("1",s.this);
Debug("----------------The devices are:", s.this);
ChangeState(countdown, dev:=s.this; E.time:=p.time);
);

:end
END

/*this is the cycle part, the one that enables the rolling of the dialog-options. Basically this works this way, when a dialog is called in the "cycle_***" rule, three options appear: "fix it","next" and "nothing right now", the fix it relates to the above rules, the next to the ones below and the nothing right now to the "blanc" rule. */

/*...*/

Rule event eng_Cycle
:action
//this event means that player didn't choose to repair this device, so we must clear it from the cycle list:
m.eng_cycle:=1;
LocalEvent(Cycle_normal);
:end
END

Rule event eng_sec_cycle
:action
//this event means that player didn't choose to repair this device, so we must clear it from the cycle list:
m.eng_sec_cycle:=1;
LocalEvent(Cycle_normal);
:end
END

/*...*/

Rule event pgen_cycle
:action
//this event means that player didn't choose to repair this device, so we must clear it from the cycle list:
m.pgen_cycle:=1;
LocalEvent(Cycle_normal);
:end
END

Rule event Fix_cycle  //this event is only fired if the dialog with the dialog with the options times out.
:action
if(m.military_cycle = 1,
Debug(m.military_cycle);
Delay(0,0.1,LocalEvent(cycle_military);,0);
,
Debug(m.military_cycle);
Delay(0,0.1,LocalEvent(cycle_normal);,0);
);
:end
END
END

State Countdown
Rule event in
:action
//in here we reset the cycle of all devices
M.Dialog_running:=0;
m.eng_cycle:=0;
/*...*/
m.pgen_cycle:=0;
/*...*/
StartCountDown(e.time, Repair);
m.fixing:=1;
Debug("dev is",dev);
:end
END

Rule event Repair
:action
Debug("event Repair", dev);
if(dev!=0 & engineering = 0,
EnableDevice(dev,1);
Debug("repairing", dev);
,
if( engineering = 1,
m.engineering:=1;
);
);
m.fixing:=0;
ChangeState(setup,0);
:end
END
END
END

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #54 on: February 14, 2010, 21:13:40 »
I've had a tinker and sent you an email Mularac, fingers crossed it helps.

What I've done is add this line...

Code: [Select]
AddItem(TBR,S.this);
to the execlist section of the 'PGen' rule and set the 'dev' value of the same rule to 999. I also modified the 'Repair' rule to read...

Code: [Select]
Rule event Repair
:action
Debug("event Repair", dev);
if(dev!=0 & engineering = 0 & dev!=999,
EnableDevice(dev,1);
Debug("repairing", dev);
,
if( engineering = 1,
m.engineering:=1;
);
);

If(dev=999 & engineering = 0,
ExecList(TBR,
EnableDevice(s.this,1);
Debug("repairing", s.this);
,
if( engineering = 1,
m.engineering:=1;
);
);
);
m.fixing:=0;
ChangeState(setup,0);
:end
END
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 #55 on: February 16, 2010, 00:51:58 »
A question: Anyone know how the devs managed to detect when a ship was disabled and add that to the winning conditions (instead of wrecking it)?

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #56 on: February 16, 2010, 11:37:18 »
Don't know how the devs did it, but it's certainly possible to detect disabled ships. The resulting script depends on your exact criteria of what disabling a ship actually means... one variant could be:

Code: [Select]
RULE event CO_DeviceDestroyed
:action
E.WorkingCriticalDevices := GetFreeSel();
Select(E.WorkingCriticalDevices, S.device & S.owner=E.ship & Not(S.destroyed) & (S.shield | S.Weapon | S.main | S.secondary | S.combat | S.stealth));
If(AllNumOf(E.WorkingCriticalDevices) = 0,
Debug(E.ship, "was disabled");
);
:end
END

After a device has been permanently destroyed the script checks, if there are any shields, weapons or engines left for the ship in question.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #57 on: February 16, 2010, 16:28:41 »
Great, thanks. It's funny, because I went trought the vanilla missions and couldn't find a thing....

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #58 on: February 25, 2010, 18:33:49 »
hey, anybody knows how to escape the " " in a dialog file? (for example, to write a dialog that involves, inside the text the use of the " ")

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #59 on: February 25, 2010, 22:16:22 »
I have no idea. If " doesn't work, use single quotation marks instead, I suppose.

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #60 on: February 25, 2010, 23:55:04 »
Use two single quotation marks to mimic the character. It may not look quite right in the actual dialog.ini file, but in the game you'd never tell it's two singles.
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 #61 on: March 02, 2010, 01:10:18 »
A simple question whose answer I'm already fearing: Is it possible to keep missiles on route to their target to not be vaporized when their mothership is destroyed/wrecked (can't really remember which one is it...)?

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #62 on: March 06, 2010, 14:56:35 »
hey, do you know if it is possible to determine a ship's relative size?
and on other factor, how does the "weight" variables work?

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #63 on: March 07, 2010, 21:40:54 »
Quote
hey, do you know if it is possible to determine a ship's relative size?
I only know the radius variable, which gives the radius of an invisible sphere enclosing the whole ship... it's a good approximation for the overall size of the ship, if the ship's design isn't too exotic.

Quote
and on other factor, how does the "weight" variables work?
Which weight variables?  ?(

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #64 on: March 07, 2010, 22:06:20 »
Quote
>   Choose(weight1, command1, weight2, command2, …., weightN, commandN);
It chooses randomly from N pieces of possibilities, according to the weight (’weight1’ .. ’weightN’). If every weight is 0, than it doesn’t do anything; implicitly, if only one weight is bigger than 0, than it will choose that line – with this you can virtually implement the SWITCH-CASE command that is known from C. ’Command’ here and everywhere else can contain several script commands that are separated by semicolons.

Quote
>   SelWeightMul(list, mul, condition);
Where the ’condition’ returns with 1, it multiplies their weight by ’mul’.

etc...

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #65 on: March 07, 2010, 22:26:03 »
Quote
Choose (weight1, command1, weight2, command2, …., weightN, commandN);

It chooses randomly from N pieces of possibilities, according to the weight (’weight1’ .. ’weightN’). If every weight is 0, than it doesn’t do anything; implicitly, if only one weight is bigger than 0, than it will choose that line
The weight basically represents the probability, that the following command(s) will get chosen by the game to get executed. Quick example:

Code: [Select]
Choose(
10,
Debug("First choice"),
5,
Debug("Second choice")
);
In this code snippet, it is 2x more likely, that the "First choice" gets executed instead of the "Second choice". The higher the weight, the more likely it is for the corresponding command(s) to get chosen and thus executed. It is still a random choice, which command gets executed - you just have some influence on their likeliness to happen.

Other weighted commands work similarly.

Offline Hyperion5

  • Recruit
  • *
  • Posts: 14
  • Karma: 0
    • View Profile
(No subject)
« Reply #66 on: April 03, 2010, 17:18:27 »
hmm, looking through all the problems and fixes here, really good ideas btw, i notice most are mostly scripting. has anyone tried alternate devices? quick mod from energy cell pobably buggy, but just for concept:

Code: [Select]
DEVICETYPE
Name "Shield_Capacitor0"
Category 4 //changed to 'shield' category, now governed by the ENERGYSYSTEM_SHIELD subsystem
Sets 24 60 62 66 100 126 ; //same device sets, still fits in energy cell hardpoint
Automatic //Automatic, stays on, so it's reserve count remains
MaxReserve 20000 //ADDs to Max reserve, stores until device deactivates (automatic device here, so until disabled)
Scanned 140
Hpmax 1100
RepairHP 10
Available
InstallRP 6
Info_Category ""
Info_Size ""
Info_Efficiency 6
Info_Emission 0
DEVICETYPE

In fact, one could probably re make the shield system as different parts with the right work: shield_cat1: Generators shield_cat2: Capacitors, shield_cat3: Projectors

Just a concept, but the current problem with that is shields are set as a universal value (the actual percent set in tacticsbase.ini, but the actual rule is in execlist.ini) It seems set to activate once a ships collective shield once energy reaches a set percentage so an actual shield capacitor currently wouldn't work too well for when shields have to drop.

you could check my thread (Modifications >>The ExecList?) i'm looking for help finding commands in that file.

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #67 on: April 04, 2010, 12:39:27 »
Just a quick question... does anyone know how to 'de-weaponise' the techscanner?  
At the moment, as soon as you scan something, it's classed as an enemy because you've 'fired' at it. To me this really kind of limits its use as a data recovery tool due to this outcome.
Better to look the fool by asking, then prove them right with ignorance.

Offline GeoModder

  • Chief Petty Officer
  • **
  • Posts: 279
  • Karma: 4
    • View Profile
    • http://
(No subject)
« Reply #68 on: April 04, 2010, 23:01:14 »
Can't you rescript it so that 'firing' the scanner makes an ally of the 'targeted' object under certain conditions? Like when engines are off or weapons not activated/loaded?

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #69 on: April 04, 2010, 23:57:45 »
you can't 'de-weaponise'  a weapon, but I think there might a small workarround. Just change the relation back to 'neutral' when the scanner "fires" (using the Fired event) or better even when the ship is 'hit' (can't remember the exact rule that you used there... but I'm possitive there was one). With a bit of luck, it won't be noticed by the player...

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #70 on: April 22, 2010, 02:13:05 »
Got a small question, people: is it there a way to have a ship fire a missile and if that ship get's destroyed the missile won't (if it is still travelling to the target)?

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #71 on: April 22, 2010, 22:17:17 »
Good question. Sadly I wouldn't know how to do that. :(

Offline jstubbles

  • Petty Officer
  • **
  • Posts: 169
  • Karma: 2
    • View Profile
    • http://www.ivassago.com
(No subject)
« Reply #72 on: April 24, 2010, 20:50:18 »
On the subject of missiles, does anybody know if you can prevent missiles from flying away from ships that about to explode? When a ship is in it's "final time" phase, my missiles are flying away from it, then swoop back in on the next target, once the "danger" is gone.... so annoying.

Offline jstubbles

  • Petty Officer
  • **
  • Posts: 169
  • Karma: 2
    • View Profile
    • http://www.ivassago.com
(No subject)
« Reply #73 on: April 26, 2010, 04:37:30 »
On top of my previous issue, I also seem to be having a problem when I use the same ship to battle between two different races. In this case, a cylon basestar. If I give civ_player a basestar and try to attack the basestar using the quick-combat buttons like "destroy hull" - nothing happens at all. I have to manually select and fire all weapons against the ship. Even then, it sometimes behaves irrationally, sometimes not firing at all even then.

Any ideas????

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #74 on: April 29, 2010, 01:27:02 »
Not atm, sorry. But I'll look into it.
As we're on the subject of missiles, does anyone know if it's possible to get the absolute co-ordinates of the point of impact? (highly unlikely. But I just had to ask)