6742f97724f50

6742f977272d3
1 Guest is here.
 

Topic: Changing Player Starting Inventory
Page: « 1 [2]
Read 2329 times  

6742f97727af2RoSoDude

6742f97727b6c
Nice one. Sure beats my newbie effort, functional as it was. I'll be adapting this further.

EDIT: Simple extension to allow for general object replacement with support for setting a gun object's ammo, condition, and broken status:
Code: [Select]
// ================================================================================
// RSD: Adapted from ZylonBane's starterReplace script to replace objects in maps
// Specify "Archetype" "rsdAmmo" "rsdCondition" "rsdBroke" in Editor/Design Note
class rsdObjectReplace extends SqRootScript {
// spawn new object and destroy this one
function OnSim() {
local archetype = getParam("Archetype", "Object");
local obj = Object.Create(archetype);
Object.Teleport(obj, Object.Position(self), vector());
if (ShockGame.ValidGun(obj)) {
updateGunProps(obj); //RSD: update ammo, condition, broken status
}
Object.Destroy(self);
}

// update the gun ammo, condition, and broken status
function updateGunProps(obj) {
local baseClip = Property.Get(obj, "BaseGunDesc", "Setting 0: Clip");
local ammo = getParam("rsdAmmo", baseClip);
local cond = getParam("rsdCond", 100);
local broke = getParam("rsdBroke", 0);
Property.Set(obj,"GunState", "Ammo", ammo);
Property.Set(obj,"GunState", "Condition (%)", cond);
if (broke == 1) {
Property.SetSimple(obj,"ObjState", 1); //1 is "Broken" enum
}
else {
Property.SetSimple(obj,"ObjState", 0); //0 is "Normal" enum
}
}

// fetch a parameter or return default value
function getParam(key, defVal) {
return key in userparams() ? userparams()[key] : defVal;
}

// set string to archetype value, otherwise archetype name
function setString(obj, prop, def) {
local val = Property.Get(Object.Archetype(obj), prop);
Property.SetSimple(obj, prop, val ? val : def);
}

// replace all spaces with underscores
function fixStringName(txt) {
local i, c;
local txt2 = "";
for (i = 0; i < txt.len(); i++) {
c = txt.slice(i, i + 1);
txt2 += c == " " ? "_" : c;
}
return txt2;
}
}

// ================================================================================
// RSD: Adapted from ZylonBane's starterReplace script to add ammo, condition parameters
// Specify "Archetype" "StringName" "rsdAmmo" "rsdCondition" "rsdBroke" in Editor/Design Note
class rsdStarterReplace extends rsdObjectReplace {
// spawn new object and destroy this one
function OnSim() {
local objName = Object.GetName(self);
Object.SetName(self, "");
local archetype = getParam("Archetype", "Object");
local stringName = getParam("StringName", fixStringName(archetype));
local obj = Object.Create(archetype);
Object.Teleport(obj, Object.Position(self), vector());
Object.SetName(obj, objName);
setString(obj, "ObjName", stringName);
setString(obj, "ObjLookS", stringName);
setString(obj, "ObjShort", stringName);
if (Object.InheritsFrom(obj, "Weapon")) {
setString(obj, "Sett1", stringName);
setString(obj, "Sett2", stringName);
setString(obj, "SHead1", stringName);
setString(obj, "SHead2", stringName);
}
if (ShockGame.ValidGun(obj)) {
updateGunProps(obj); //RSD: update ammo, condition, broken status
}
Object.Destroy(self);
}
}
« Last Edit: 19. April 2020, 07:42:43 by RoSoDude »

6742f97727d2bvoodoo47

6742f97727d7c
also, if you are planning to turn this into a full mod (I'm assuming you do), don't forget to scatter a few prisms around med/eng/hydro (either tweq-poping them out of junk items, or NVCreateAndLink with a Contains link linking them to corpses and other containers), maybe even make the med2 replicator sell them instead of grenades (and perhaps spawn the gun with a full clip).

the gun is not of much use without ammo. or with it, for that matter.
« Last Edit: 19. April 2020, 18:01:19 by voodoo47 »

6742f97727e15RoSoDude

6742f97727e6e
Yep, already taken care of that and more.

6742f97728013RoSoDude

6742f9772805e
I'm attempting to make an Alternate Start mod that allows the player to skip character creation and start with a handful of cyber modules instead. One solution that mostly works is attaching CharGenYear=2 to The Player (-384) and adding the ChooseMission script on the level exit trigger (along with destination properties) to replace the action of the ChooseService script and thus skip station.mis entirely (I can then remove any stats or skills on arrival at medsci later).

However, when I spawn in medsci.mis, I don't have the nanites, cyber modules, PDA, or keycard icons in my MFD, and picking up those items in the world treats them as actual objects in my inventory. I poked around and discovered the five missing objects -- Fake Nanites (-1271), PDA soft (-500), fakekeys (-77), FakeCookie (-1435), and compass HUD (-3643). I found that their container type is 2147483647. When I try to add them to the player's inventory via a script that runs at the start of medsci, the icons are still missing, but now I can't pick up these objects at all.

Is there any known fix for correctly getting these five items into the player's inventory (say, in best practices for FM development), or should I seek some other method of skipping character creation (I thought of simply moving the level exit trigger in station.mis to right where you spawn, but that didn't seem to work)?

6742f97728138voodoo47

6742f97728186
check the Minstrel, it's one of the few FMs that drops the player into a level just like that.
Acknowledged by: RoSoDude

6742f977282b8RoSoDude

6742f97728310
Went a different direction with it by moving some tripwires.

Anyone know what object the psi power (and psi tier) metaproperties get added to when they're unlocked? I assumed it'd be the player object, but that doesn't appear to be the case.

EDIT: I figured it out. For the sake of posterity, here's what's going on. My original theory that the psi power metaproperties get added to the player when they are unlocked was simply wrong. Instead, the player's current unlocked psi powers are controlled by the "Player: Psi Powers" and "Player: Psi Powers 2" properties, with unique integer identifiers for every combination of tiers and powers unlocked. If you're really curious about a specific combination you could write a script to output these property values, but for my part all I needed to know is that the base state (nothing unlocked) has both properties set to 0.
« Last Edit: 23. February 2021, 06:29:54 by RoSoDude »
1 Guest is here.
when I get to the bottom I go back to the top of the slide
Contact SMF 2.0.19 | SMF © 2016, Simple Machines | Terms and Policies
FEEP
6742f97728fd5