Post
by Vaptor » Fri Oct 10, 2008 7:05 am
// by vaptor
// numbers are limited to 23 digits
// strings are long enough to work with this
//
// storage formats
//
// item ID - howmany,
//for error prevention look for the dash also so we don't pick a amount by accident
//
// issue can't seem to pin down a method that won't be a lag causeing dissassembly if i use strings
//
// work around i can use 2 or more sets of int variables. Int values are integer numbers in the range -2147483648 to 2147483647, in other words signed 32 bit values.
//
class ItemManager extends object Abstract;
//////
////////////////////////////////////////////////////////////////////////////////
var class< WeaponModifier > EffectClasses[54]; // template for the default list
struct ArtifactInventory
{
var int itemset1;
var int itemset2;
var int itemset3;
var int itemset4;
var int itemset5;
var int itemset6;
};
Static function Class<WeaponModifier> TranslateITEM(int itemposition, ArtifactInventory Playerinv)
{
local int hold;
local Class<WeaponModifier> selecteditem;
//main conversion to get the class
// decide which item set has what the user selected and hold on to that
Hold=class'itemmanager'.static.Howmany(itemposition,playerinv);
// get the classtype
selecteditem=class'itemmanager'.static.Convert(Itemposition);
if(hold > 0)
{
Return selecteditem;
}
return(Class'noWeaponModifier'); // only give this if theres 0 of it
}
// howmany function is probly going to be used on the hud so its seperated here
static function int Howmany(int itemposition, ArtifactInventory Playerinv)
{
local float casehack,posthack;
local int typehack,tophack; // dissasemble the number in a way that avoids problems
local int finalhack;
local int holding; //contains the inventory set
local int realpos;
if (itemposition < 11)
{
holding=Playerinv.itemset1;
realpos=itemposition - 1;
}
else if (itemposition < 21)
{
holding=Playerinv.itemset2;
realpos= itemposition - 11;
}
else if (itemposition < 31)
{
holding=Playerinv.itemset3;
realpos= itemposition - 21;
}
else if (itemposition < 41)
{
holding=Playerinv.itemset4;
realpos= itemposition - 31;
}
else if (itemposition < 51)
{
holding=Playerinv.itemset5;
realpos= itemposition - 41;
}
else
{
holding=Playerinv.itemset6;
realpos= itemposition - 51;
}
//useing only 9 of 10 numbers for realpos allows me to get away with this
if(realpos > 0)
{
casehack=holding*(10^-realpos); //type is the number in the tens digit rando is the ones
}
else
{
casehack=holding;
}
realpos+=1; //add one on to move past the desired value
posthack=holding*(10^-realpos);
//now remove the top after reduceing
tophack=int(casehack);
typehack=int(casehack); // now it should remove numbers after the decimal (works)
finalhack=(typehack-(tophack*10)); //get the single digit for this item
Return Finalhack; // this is the single digit number result
}
// get the class from a stored array , this can not be a config entry must be present in compile
// items in position 10 , 20 ,30 ,40 and 50 must not exceed 2 else the entire system might get rounded
Static Function Class<WeaponModifier> Convert(int ItemID)
{
//todo return the correct class for the powerup effect functions change the number in the database to the class containing effect code
if(ItemID > -1)
{
Return (Default.Effectclasses[ItemID] ); // keep the list of powerup classes in this file due to restrictions that cause static functions to be prohibited from reading data that is not present at compile time and limited to defaults when its not replicated
}
else
{
return 0; //if a error happened we get this
}
}
////////////////////////////////////////////////////////////////////////////////
//current weapon changes will include holding the powerups as a definded interger array with members matching the class array defined in this class
// mostly purpose of this class is to act as a handler for communication between a weapon of power and weapon modifiers
// makes up for not actually keeping the object this way we can fake the items in the inventory list and reduce chances players will get the get crashes from powerup count after we revise it
//rpgstat revision i have in mind will show the weapon modifers that have a value of 1 or higher on the list of useable items
//
////////////////////////////////////////////////////////////////////////////////
//=====================================================================
// function does most everything like appling poision damage or knock back and even healing effects to
//=====================================================================
Static function GetEffectforitem(weaponofpower CurrentWeapon, int itemnumber,int powerlevel, Optional Pawn Victim) // useing optional will not throw errors if the effect does not do damage dies before this runs for any reason
{
if(currentweapon != none)
{
if(itemnumber > -1) // it should never be -1 if it is something is not working correctly
{
//process effects is a function that has a vital role we use converttoclass to get the file that does the effect of the powerup in question this is executed instead to replace sorting though the inventory over and over for the same effects , so this works faster with less cpu
if(victim == none)
{
currentWeapon.ProcessEffects(class'itemmanager'.static.(itemnumber),powerlevel); // this effect has no victim
}
else
{ // note: currentweapon is the Weapon of power in use that has acess to the rpg alterations and the holder of the weapon
CurrentWeapon.ProcessEffects(convertToclass(itemnumber),powerlevel,Victim); // both functions execute the effect code directly in the weaponofpower itself makes it easyer to acess ingame stuff from there. point of execution might need to be changed from the weapon only if it dosen't work out for some unexpected reason.
}
}
}
}
//=======================================================================================
// the third function is just to do adding powerups and checking should be done in the weapon of power but new functions need added there
//
// class'weaponofpower' is the child of class'rpgweapon' just to remind you which class Needs new code
//
// function ChangeModifier(int Powerup_ID,int mode)
// {
// Switch(mode) // mode 0 is add item to effect list
//
// }
//=======================================================================================
static function int ResetWeaponslots(Rpgstatsinv ActiveRpgdata, weaponofpower currentWeapon, ArtifactInventory Playerinv)
{
if(ActiveRpgdata != none) // found the datastorage actor that rpg uses to keep the ingame active player data , also used for send recieve of commands that require client involvement at some point
{
// CRAP this is a problem but current method is just as costly requires me to break down and compare how many player has on weapon and how many in inventory plus chuck out any extra that go over inventory limitations
// notice item old based inventory has this bug also it often will hold more in inventory when they unloaded a weapon than they are allowed to pickup
}
}
static function bool addtoweapon( Rpgstatsinv ActiveRpgdata, weaponofpower currentWeapon, int itemfromList)
{
if(ActiveRpgdata != none) // found the datastorage actor that rpg uses to keep the ingame active player data , also used for send recieve of commands that require client involvement at some point
{
if(ActiveRpgdata.haswopitem(Itemfromlist)) // use rpgstatsinv on the local player to check if he actually has any of that item stored as data only
{
if(currentweapon != none) //safeguard against lag
{
if(currentWeapon.HasSpaceforitem(Itemfromlist) ) // check if weapon has empty slots and if the powerup is allowed include checks for similar powerups that prevent use of others. for superspeed powerup we can't allow another speed powerup
{
currentWeapon.changemodifier(ItemFromList,0); // tell the weaponofpower class that holds powerup data to add this item to its active effects list that we need to add
Return True; // make sure to subtract 1 from this item in inventory
}
else
{
Return False; // nope can't add the item by returning false we can use this function to trigger a message also if we want to saying can't add to weapon
}
}
}
Return False;
}
////////////////////////////////////////////////////////////////////////////////
// some examples class'poisionmodifier' is by no means a valid name it probly needs packages too in the name
//=========================
defaultproperties
{
Effectclasses[0]=class'PoisionModifier'
Effectclasses[1]=class'PoisionModifier'
Effectclasses[2]=class'PoisionModifier'
Effectclasses[3]=class'PoisionModifier'
Effectclasses[4]=class'PoisionModifier'
Effectclasses[5]=class'PoisionModifier'
Effectclasses[6]=class'PoisionModifier'
Effectclasses[7]=class'PoisionModifier'
Effectclasses[8]=class'PoisionModifier'
Effectclasses[9]=class'PoisionModifier'
Effectclasses[10]=class'PoisionModifier'
Effectclasses[11]=class'PoisionModifier'
Effectclasses[12]=class'PoisionModifier'
Effectclasses[13]=class'PoisionModifier'
Effectclasses[14]=class'PoisionModifier'
Effectclasses[15]=class'PoisionModifier'
Effectclasses[16]=class'PoisionModifier'
Effectclasses[17]=class'PoisionModifier'
Effectclasses[18]=class'PoisionModifier'
Effectclasses[19]=class'PoisionModifier'
Effectclasses[20]=class'PoisionModifier'
Effectclasses[21]=class'PoisionModifier'
Effectclasses[22]=class'PoisionModifier'
Effectclasses[23]=class'PoisionModifier'
Effectclasses[24]=class'PoisionModifier'
Effectclasses[25]=class'PoisionModifier'
Effectclasses[26]=class'PoisionModifier'
Effectclasses[27]=class'PoisionModifier'
Effectclasses[28]=class'PoisionModifier'
Effectclasses[29]=class'PoisionModifier'
Effectclasses[30]=class'PoisionModifier'
Effectclasses[31]=class'PoisionModifier'
Effectclasses[32]=class'PoisionModifier'
Effectclasses[33]=class'PoisionModifier'
Effectclasses[34]=class'PoisionModifier'
Effectclasses[35]=class'PoisionModifier'
Effectclasses[36]=class'PoisionModifier'
Effectclasses[37]=class'PoisionModifier'
Effectclasses[38]=class'PoisionModifier'
Effectclasses[39]=class'PoisionModifier'
Effectclasses[40]=class'PoisionModifier'
Effectclasses[41]=class'PoisionModifier'
Effectclasses[42]=class'PoisionModifier'
Effectclasses[43]=class'PoisionModifier'
Effectclasses[44]=class'PoisionModifier'
Effectclasses[45]=class'PoisionModifier'
Effectclasses[46]=class'PoisionModifier'
Effectclasses[47]=class'PoisionModifier'
Effectclasses[48]=class'PoisionModifier'
Effectclasses[49]=class'PoisionModifier'
Effectclasses[50]=class'PoisionModifier'
Effectclasses[51]=class'PoisionModifier'
Effectclasses[52]=class'PoisionModifier'
Effectclasses[53]=class'PoisionModifier'
Effectclasses[54]=class'PoisionModifier'
Effectclasses[55]=class'PoisionModifier'
Effectclasses[56]=class'PoisionModifier'
Effectclasses[57]=class'PoisionModifier'
Effectclasses[58]=class'PoisionModifier'
Effectclasses[59]=class'PoisionModifier'
Configuration= //still needs one
}