Hello all,
to begin with, I am perfectly aware I post this in the wrong subforum, but somehow it won't let me post this in Toolset - Scripting.
I have a (hopefully) simple problem giving Items to the hero on initializing my game. What I want, is to give the oppurtunity to load from another module (got that far) and then give some equipment if the player makes a new character (figured I'd do that with if(getLevel(oHero) == 1)). Didn't even get there, I have trouble giving the items.
This script, first of all, runs fine, but allows no import and starts the level with some tranquill-like char.
When I edit this script to just allow character generation (not even import yet yet) and use the same line of code after, it doesn't work: pastebin.com/wVJ3NZs9 .
Here's the strange thing: since the item is a gift (made it a gift to test), the turorial windows appears with information on gifts when the item is added. In the second code, it does that, but the item is nowhere to be found in the inventory. I thought this was due to the EquipItem() part (gifts are not equipable, doh), but I've tried various ways and all gave the same result..
Again, I'm terribly sorry for contaminating the forum in this way, but it wouldn't allow me to post elsewhere and I really need help.
*I don't know exactly what includes contain what functions, so to be sure I used these 4 (I still want to add import).
I hope someone can be of aid!
Regards
Script problem
Débuté par
Markus430
, août 15 2011 02:02
#1
Posté 15 août 2011 - 02:02
#2
Posté 15 août 2011 - 03:30
You need to register your game to post in the other sub-forums.
#3
Posté 15 août 2011 - 04:43
That's probably because the chargen is cleaning out the character completely including inventory. and chargen is runned through a ser of event that acure after you have given the item.
#4
Posté 15 août 2011 - 07:28
That would be strange taken this language is based on C. Secondly, the gift tutorial tab still comes up at game start, I guess the chargen is then already done. Also, the first script has chargen too.
#5
Posté 15 août 2011 - 09:28
In your second script calling StartCharGen raises an event to start the character generation process and then you equip an item on the player flagged as a gift triggering the gift tutorial plot flag and its events. After your script has completed the events it raised are processed and that initiates the character generation process.
During the character generation process the player's character is updated to reflect their choice of race, class and background. As a result the equipment is constantly being removed and replaced: Chargen_InitInventory is called for each of those changes and it calls Chargen_ClearInventory; Chargen_ClearInventory promptly deletes the character's equipment and including your gift item.
Conversely in your first script calls the various Chargen_* functions directly so the choice of race, class and background (and their associated equipment updates) have been completed before you equip the gift item.
The solution is to wait until the character generation process is complete. You could use the EVENT_TYPE_CHARGEN_END event (but be aware it fires on level up too) or you could use an appropriate area event in your first area or do it via an NPC conversation.
During the character generation process the player's character is updated to reflect their choice of race, class and background. As a result the equipment is constantly being removed and replaced: Chargen_InitInventory is called for each of those changes and it calls Chargen_ClearInventory; Chargen_ClearInventory promptly deletes the character's equipment and including your gift item.
Conversely in your first script calls the various Chargen_* functions directly so the choice of race, class and background (and their associated equipment updates) have been completed before you equip the gift item.
The solution is to wait until the character generation process is complete. You could use the EVENT_TYPE_CHARGEN_END event (but be aware it fires on level up too) or you could use an appropriate area event in your first area or do it via an NPC conversation.
Modifié par Sunjammer, 15 août 2011 - 10:12 .
#6
Posté 15 août 2011 - 10:46
Wow! Thanks a lot!
I will use EVENT_TYPE_CHARGEN_END, and put the give items in an if(getLevel(oHero) == 1), see if that works
.
Will update!
I will use EVENT_TYPE_CHARGEN_END, and put the give items in an if(getLevel(oHero) == 1), see if that works
Will update!
#7
Posté 15 août 2011 - 11:35
You're a genius Sunjammer! It works fine now 
Do have another issue though... In my new code, I want to make the char lvl 30, but when I make it possible to import a module later, I want to give the xp needed to get from that chars level to lvl 30, So I have these lines:
int nXP = RW_GetXPNeededForLevel(30) - GetExperience(oHero);
RewardXP(oHero, nXP, TRUE, TRUE);
But it doesn't work.. Filling in a random int instead of nXP in the RewardXP function does work.
The script.
I hope you can help me out again!
Do have another issue though... In my new code, I want to make the char lvl 30, but when I make it possible to import a module later, I want to give the xp needed to get from that chars level to lvl 30, So I have these lines:
int nXP = RW_GetXPNeededForLevel(30) - GetExperience(oHero);
RewardXP(oHero, nXP, TRUE, TRUE);
But it doesn't work.. Filling in a random int instead of nXP in the RewardXP function does work.
The script.
I hope you can help me out again!
#8
Posté 15 août 2011 - 11:55
The vanilla Origins exptable 2da only goes up to level 25 so RW_GetXPNeededForLevel(30) will return 0 (as there is no row 30). Assuming the character has either 0 or 1 xp you are either doing nothing or imposing a 1xp penalty.
Try testing your code with a more modest increase, for example, only levelling up to 20 and if that works you can always try extending exptable up to level 30 or settle for playing the game at level 25.
Try testing your code with a more modest increase, for example, only levelling up to 20 and if that works you can always try extending exptable up to level 30 or settle for playing the game at level 25.
Modifié par Sunjammer, 15 août 2011 - 11:55 .
#9
Posté 16 août 2011 - 12:07
Argh, why are the answers always so obvious? xD
Is there any way to use the awakenings XP table? That should go to 30 and beyond...
Is there any way to use the awakenings XP table? That should go to 30 and beyond...
#10
Posté 16 août 2011 - 07:23
I simply fixed that by downloading a new exptable that went up to lvl 50 and putting it in my override folder, did the job
.
Now however, I ran into new trouble! I wanted to check on which class a hero is, but there doesn't seem to be a Getclass(); function.
Googling got me this page about save files and stat properties. I found the GetCreatureProperty function in the documentation and made it into this script:
if(FloatToInt(GetCreatureProperty(oHero, 27, PROPERTY_VALUE_CURRENT)) == 1) { //Warrior EquipItem(oHero, UT_AddItemToInventory(R"gen_im_wep_mel_lsw_saw.uti")); }
27 for the property ID (class), and PROPERTY_VALUE_CURRENT because the explanation on this wasn't too clear.
I can think of a few reasons for this not too work, but how do I get the class of a character?
Hope your genioussity helps me out again! [a]
Now however, I ran into new trouble! I wanted to check on which class a hero is, but there doesn't seem to be a Getclass(); function.
Googling got me this page about save files and stat properties. I found the GetCreatureProperty function in the documentation and made it into this script:
if(FloatToInt(GetCreatureProperty(oHero, 27, PROPERTY_VALUE_CURRENT)) == 1) { //Warrior EquipItem(oHero, UT_AddItemToInventory(R"gen_im_wep_mel_lsw_saw.uti")); }
27 for the property ID (class), and PROPERTY_VALUE_CURRENT because the explanation on this wasn't too clear.
I can think of a few reasons for this not too work, but how do I get the class of a character?
Hope your genioussity helps me out again! [a]
#11
Posté 16 août 2011 - 09:04
The nice and fluffy way to get a character's class is to include core_h and use either GetCreatureCoreClass or GetCreatureCurrentClass but essentially all they are doing is:
EDIT: loving the forums desire to force "class" into lower case
FloatToInt(GetCreatureProperty(oCreature, PROPERTY_SIMPLE_CURRENT_CLASS))
EDIT: loving the forums desire to force "class" into lower case
Modifié par Sunjammer, 16 août 2011 - 09:21 .
#12
Posté 16 août 2011 - 09:23
Lol, you are an invaluable help!
I don't get how I couldn't find this in documentation and the wiki's though.. or how I should have pieced this together.. How is anyone supposed to learn this system just by the documentation and wiki (to which the obvious reply is 'they won't have to, theres a forum')? Even though they're familiar with OOP and/or C programming...
Anyway, thanks again multi. I noticed your recent status update, so if there's any more questions, I'll ask
!
I don't get how I couldn't find this in documentation and the wiki's though.. or how I should have pieced this together.. How is anyone supposed to learn this system just by the documentation and wiki (to which the obvious reply is 'they won't have to, theres a forum')? Even though they're familiar with OOP and/or C programming...
Anyway, thanks again multi. I noticed your recent status update, so if there's any more questions, I'll ask
#13
Posté 17 août 2011 - 12:15
For those interested: pastebin.com/602eFBxE .
Comments are welcome
Comments are welcome
Modifié par Markus430, 17 août 2011 - 12:16 .





Retour en haut






