- Home /
CharacterSave Statistics
Im currently working on stats in my game... Im trying to have it very simple atm... I am a new at javascript and my friends said this was a good place to go... Basically im working on two scripts. The CharacterSave.js and my npc.js.
The character save has this in it... (Please note im new to javascript so far its all variables...)
//Player Experience var playerXP : GUIText; static var xpGain;
// Player Inventory var inventoryGui : GUITexture; var currentBags : i1.0; var bagSpace = 25.0; // Controlling the Weapon var hasWeaponOn = false; var canThrow = false; var rangeWeapon = false; var weaponDMG = 10.0; var weaponSpeed = 2.0;
class CharacterSavePlayerSave { var attack : int; var strength : int; var defence : int; var archery : int; var magic : int; var health : int; var Firemaking : int; var WoodCutting : int; var mining : int; var smelting : int; var crafting : int; }
var PlayerSave: CharacterSavePlayerSave = CharacterSavePlayerSave();
class CharacterSavePlayerQuest { var questComplete : int; var questIncomplete : int; var questCurrentlyOn : int; var questRewards : int; var questUnavailable;
}
var PlayerQuest: CharacterSavePlayerQuest = CharacterSavePlayerQuest();
function Update () { }
As you can see it doesn't have much other than variables... well it only has variables. At the top of the coding you will see it says static var xpGain; I was planning on making a variable in the npc.js saying var xpGive : int; and once i attach it to a npc i could simply set the xp after killing it what i want it to give... So far i have nothing in npc.js. I just want to know where i should start off at to get an enemy to give me xp. Than i could have another script to add it up in var playerXP...
Thanks in advance to anyone who could help...
Answer by ckfinite · Oct 11, 2010 at 01:56 AM
Try building a relation ship of "who killed who". Then, have the onKilled event get the player, and add the xpGain.
Pseudocode:
on NPC killed:
killer.playerXP += xpGain
Your answer
Follow this Question
Related Questions
Simple EXP Script In Javascript 0 Answers
Pause online game 1 Answer
How can I zoom out my Field of View slowly? 1 Answer
Have script detect which collider 2 Answers
auto run key 1 Answer