665278190e1ac

665278190e71c
1 Guest is here.
 

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

665278190ed71RoSoDude

665278190edd8
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 »

665278190ef61voodoo47

665278190efb0
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 »

665278190f042RoSoDude

665278190f08e
Yep, already taken care of that and more.

665278190f234RoSoDude

665278190f283
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)?

665278190f32bvoodoo47

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

665278190f523RoSoDude

665278190f5b9
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.
What we got here is failure to communicate
Contact SMF 2.0.19 | SMF © 2016, Simple Machines | Terms and Policies
FEEP
665278190f6ad