Nexus Modding > Scripting
Scripting Issues
Mularac:
thanks guys, tomorrow afternoon I'm gonna get right into it :P
not today, though... got to prepare for a big exam tomorrow.
Arparso:
Even easier solution with no need for a tick event:
--- Code: --- MACHINE "ShieldPreserve"
STATE ShieldPreserve
RULE event In
:action
SelectEx(s.shield,
EnableActivateEvents(s.this, 1);
Debug("enabled 'activate' events for shield", s.this, "on", s.this:owner);
);
:end
END
RULE event DeviceActivated
:action
if(e.device:shield,
e.device:owner:ShieldIntegrity := e.device:owner:LastShieldIntegrity;
Debug("Activated shield,", E.device, "on", E.device:owner, "( restored last integrity", E.device:owner:LastShieldIntegrity, ")");
);
:end
END
RULE event DeviceDeactivated
:action
if(e.device:shield,
e.device:owner:LastShieldIntegrity := e.device:owner:ShieldIntegrity;
Debug("Deactivated shield", E.device, "on", E.device:owner, "with last integrity at", E.device:owner:LastShieldIntegrity);
);
:end
END
END
END
--- End code ---
When the shield gets deactivated (manually, per mission script or ship behaviour), it saves the ship's last known shield integrity in an object variable called "LastShieldIntegrity". Upon activating the shield again, this old shield integrity simply gets restored again. The script won't work for ships and/or shields, that aren't present at the start of the mission, though. You have to call EnableActivateEvents manually for each shield device, that gets spawned during the course of the mission - or else the script will simply ignore these additional shields.
The Old Dragon:
Could either,
a) A 'LongRangeArrived' rule to accomadate any later ships arriving by IP .
or
b) A 'DockOut' rule to cover those that get released from a mothership.
Be added to cover any late additions?
These rules could simply call for the 'In' rule to run again...
Arparso:
Sure, that'll work. I'm not sure about ships created using CreateShip(), though (like in my little Warfare mod experiment) - I don't think, that command triggers any events per default.
Mularac:
Probably not, unless you assign a GetSceneObj to those ship.
and a question, wouldn't that overide a previous and general ShieldIntegrity command issued to the ships with a given value? (like the one on SG:WB)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version