Hi, me again!
Im sorry I am asking that much lately, but since Im really working a lot on my game the last days, there are normally questions coming up and I dont know what to do.
Since I didnt find anything on the web, I hope you can help me and the question isnt this stupidly easy (again) :wink:
So I have a NPC which from a certain point is following me. Which works fine, there is only one problem. I created that NPC in the right size for the place where it
was standing and disabled the room area scaling. But now, when it is following me, I HAVE to turn on the room area scaling. But it turns out it is much too small and should
be at least double the size. I know it is my mistake, I should have created him in the proper size like my main charakter. But I didnt, and since I already made walking, talking and idle view
for him it would be a pain to change all pictures and sprites.
So, now the real question: Is there a way to set the size of a charakter to a certain percentage? So that it can walk the walkable areas in the same size as my main charakter (that would
be at least 200%)?
Thank you very much :cheesy:
Use Scaling property:
cEgo.ManualScaling = true;
cEgo.Scaling = 50;
Quote from: Thesie on Sat 02/03/2013 21:08:29
Since I didnt find anything on the web
I suggest you study manual before searching in the web. All the basic stuff is there, really. Just open "Scripting" -> "Character functions and properties" section and read everything article by article. This also may help to know what possibilities are there.
Thanks for the quick answer!
I already played with the manual scaling, but thats not what I want. I want the NPC to obey the room scaling that I created, but I want it to be double the size.
So the NPC still scales down and up like the main charakter, but it is 200% big while main charakter is 100%. And when the main charakter is 50% of size
the NPC should be 100% and so on.... I dont know how to explain it, I hope you get it though ^^
Oh, sorry.
I see only one way to do this, is to check area scaling every tick, and apply a summ of scalings:
function repeatedly_execute()
{
int area_scaling = GetScalingAt(cEgo.x, cEgo.y);
cEgo.Scaling = 2 * area_scaling;
}
EDIT: lol, fixed formula.
Yes, thats more like it :smiley: But its not quite working. The first seconds when I enter a room with the NPC it is much to big or too small..
Maybe it saved the last size from the last room? Then after a while it suddenly changes the wanted size.
But it seems to me that its too complicated, because another problem is, when they walk into the distance and the room scaling is around 20,
the main charakter is in perfect size, and the NPC much too big.. I guess the character size doesnt go with the room scaling?
Maybe its for the best that I correct every sprite. That will take me hours, but at least it will be authenic.
Maybe someone comes up with another idea how to solve the problem, I am happy to try every one of them :) :smiley:
And thanks again to Crimson Wizard :cheesy:
Add this to the global script:
Character* scale_c;
float scale_factor = 2.0; // try 1.8 or other values
void scale_char() {
if (scale_c == null) scale_c = cNpc; // set character here
if (!scale_c.ManualScaling) scale_c.ManualScaling = true;
if (player.Room != scale_c.Room) return;
int area_scaling = GetScalingAt(scale_c.x, scale_c.y);
scale_c.Scaling = FloatToInt(scale_factor * IntToFloat(area_scaling));
}
// add this to rep_ex_always
scale_char();
// just the one line!
// this again outside other functions
function on_event(EventType event, int data) {
if (event == eEventEnterRoomBeforeFadein) {
scale_char();
}
}
Edit: code corrected... again
edit: and again
I tried that, but Im not really sure what to do exactly
I tried to put line 1 to 8:
- Above all global script, where it says: Line error (5), cannot assign initial value to global pointer
- Into the game_start function: it tells me that nested functions are not supported, although I checked for missing braces like 5 times and cant find any
Maybe I didnt change enough (I just changed the cNPC), thats what it looks like:
Character* scale_c = cGooli; // set character here
float scale_factor = 2.0; // try 1.8 or other values
void scale_char() {
if (player.Room != scale_c.Room) return;
int area_scaling = GetScalingAt(scale_c.x, scale_c.y);
scale_c.Scaling = FloatToInt(scale_factor * IntToFloat(area_scaling));
}
And when I try to run with line 11 to 17, it tells me undefined token scale_char. I didnt change anything here. Should I make a global variable for scale_char?
I guess I did a lot wrong, but this scripting is way over my head :grin:
Quote from: Thesie on Sun 03/03/2013 15:43:32
And when I try to run with line 11 to 17, it tells me undefined token scale_char. I didnt change anything here. Should I make a global variable for scale_char?
As commented in the original code, the line "scale_char();" has to be placed inside the rep_ex_always function. Did you do that?
Ah I put everything from line 11 into the rep_exec_always.. ok I changed that now. still I get the nested function error:
function game_start() {
cJonathan.SetIdleView(6, 8);
cVater.SetIdleView(10, 0);
cGooli.SetIdleView(11, 0);
Game.SpeechFont = eFontFontCustomOut;
Game.NormalFont = eFontFontCustom;
Character* scale_c = cGooli; // set character here
float scale_factor = 2.0; // try 1.8 or other values
void scale_char() {
if (player.Room != scale_c.Room) return;
int area_scaling = GetScalingAt(scale_c.x, scale_c.y);
scale_c.Scaling = FloatToInt(scale_factor * IntToFloat(area_scaling));
}
function on_event(EventType event, int data) {
if (event == eEventEnterRoomBeforeFadein && scale_c.Room == data) {
scale_char();
}
}
// Put the code all in a function and then just call the function.
// It saves cluttering up places like game_start.
initialize_control_panel();
// Use the KeyboardMovement module to, per default, replicate the standard
// keyboard movement of most Sierra games. See KeyboardMovement.txt for more info
KeyboardMovement.SetMode(eKeyboardMovement_Tapping);
}
function repeatedly_execute_always() {
// add this to rep_ex_always
scale_char();
}
still I dont know where to put the rest.. is game_start correct?
Edit: When I put the scripting outside of game_start, I dont get the nested function anymore, but instead I get "undefined symbol 'scale_c' "
I have edited my code above; sorry, I didn't remember that one cannot assign initial values to pointers outside of functions.
I always indent my code exactly; if a line isn't indented, it doesn't go into a functon; if it is already indented by 2, it's supposed to be inside a function.
Just paste the entire thing above rep_ex_always, then move what's now line 14 inside rep_ex_always.
If you want, you can move the "Character* scale_c;" line above game_start, then set it in there, instead of using the first line inside scale_char().
This is the error I am getting:
(http://s14.directupload.net/images/130303/x5hnbemc.jpg) (http://www.directupload.net)
I have no idea what is happening :grin:
Damn :-D
Replace the yellow line with
if (event == eEventEnterRoomBeforeFadein) {
I hate to say it, but now this error appears:
(http://s14.directupload.net/images/130303/o6h76nor.jpg) (http://www.directupload.net)
This happens when I want to change into the room the NPC is. But at least the game is now starting at all :grin:
I wish I could help somehow, but this stuff is clearly over my skills (for now, I hope someday Im as good as you :wink:)
Oh my. Next time I'm going to test everything before posting any code. :)
Put this in line 77:
scale_c.ManualScaling = true;
I am very very happy about your support, Khris!
Now its working! Thank you for your hassle, you saved me a loooot of work :smiley:
You're welcome, glad it's finally working :)