673f9159304f0

673f91593156b
3 Guests are here.
 

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

673f915931b8dRoSoDude

673f915931bf6
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 »

673f915931d85voodoo47

673f915931dd6
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 »

673f915931e66RoSoDude

673f915931eb8
Yep, already taken care of that and more.

673f91593205aRoSoDude

673f9159320a8
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)?

673f915932161voodoo47

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

673f9159322d6RoSoDude

673f915932328
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 »
3 Guests are here.
but once you get to the later stages of the game, and choose your psi disciplines right, you can walk around laughing while everything around you just whimpers and dies.
Contact SMF 2.0.19 | SMF © 2016, Simple Machines | Terms and Policies
FEEP
673f91593325a