You can read and reply to posts and download all mods without registering.
We're an independent and non-profit fan-site. Find out more about us here.
// ================================================================================// RSD: Adapted from ZylonBane's starterReplace script to replace objects in maps// Specify "Archetype" "rsdAmmo" "rsdCondition" "rsdBroke" in Editor/Design Noteclass 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 Noteclass 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); }}