Psylixiri
Member
|
convert objparams
look i'm trying to increase the param health of the goblin depending the level of the player but i don't know why it doesnt work
Code:
Game::ObjParamsPtr goblin=Game::Objs.ptrRequire("Obj/Chr/Fantasy/Goblin/0.obj"); // get goblin parameter
Params *par=goblin.findParam("health" ))health =par->asFlt(50);
but i get that error
Code:
1>c:\game_project\Esenthe RPG 2\source\game.cpp(486) : error C2039: 'findParam' : is not a member of 'EE::CacheElmPtr<TYPE,CACHE>'
1> with
1> [
1> TYPE=EE::Game::ObjParams,
1> CACHE=_Objs
1> ]
do u know another way to set a param value?
must i make a whole new monster from scratch using code to be able to change that value?
(This post was last modified: 11-18-2011 07:23 PM by Psylixiri.)
|
|
11-18-2011 07:10 PM |
|
TBJokers
Member
|
RE: convert objparams
Actually you're doing it wrong, Umh. There's a tutorial for this, for getting "name" and value. I think it's dynamically parameters.. anyways i feel nice so what you do..
Code:
Struct(Goblin, Game::Chr)
//{
Int Health; // Health as an int
virtual void create(Game::ObjParams &?Goblin?);
Goblin();
If i'm right you need to add save and load here too.. but i'm not sure..
};
Game::ObjMemx< Goblin> Monsters; //storing everything..
void Goblin::create(Game::ObjParams &?Goblin?){
super::create(?Goblin?);
if(Param *par=?Goblin?.findParam("Health"))Health=par->asFlt(50); //Will now find the Parameter Health and make it as float , 50;
}
And maybe,
Goblin::Chr(){
Health = 50;
}
Now to see if this works i think we can print it ingame..
void Draw()
{
REPA(Monsters){
Goblin &?Goblin? =Monsters[i];
Vec2 screen=PosToScreen(Goblin.pos()); // convert world position to screen position
D.text(screen, Goblin.Health);
}
This code wont work, This is just an example how to do it. Basically what you do is creating a Structure for your Object, Making an int Health;
Then you make it save and load it.
And in the function you make it look for the Health parameter in Goblin obj in the game. And then changes it to flt 50?, And then for saftly you can draw the monster health, So that you can see if it works. Take a look in the tutorials folder.. If this doesn't explain it that good.
Man, it's always that semicolon...
(This post was last modified: 11-18-2011 08:28 PM by TBJokers.)
|
|
11-18-2011 08:27 PM |
|
Psylixiri
Member
|
RE: convert objparams
ok.. but now i wonder how to set a mesh to an obj..in the tutorial we don't see anything that browse the directory
and i'm confuse on how to set a mesh to an obj
|
|
11-18-2011 08:51 PM |
|
TBJokers
Member
|
RE: convert objparams
In Game Basics -08 - Custom Parameters it searches through all objs for the name or the lets say health. Though if you go into the editor and go to "World editor" And drag your normal .3ds or what file it is into the WE, It will convert you an Obj file and Mesh. Kinda all files needed. You can also create an obj file on another way.. It's through the settings there somewhere. But yes..
All i do to get it clean, Is to spawn my monster myself.. so i know the Obj is there. And that is also in an tutorial..
Game::ObjParamsPtr obj=Game::Objs.ptrRequire("obj/item/misc/barrel/0.obj");
Game::World.objCreate(*obj, Matrix(obj->scale(), Vec(16,8,16)));
//Edit
As you do the STRUCT, you fill it out with either Game::Chr or Game::item or Game::Static or what you want, And if you now do lets say, Game::Item, It looks in Item typ set i guess?
Man, it's always that semicolon...
(This post was last modified: 11-18-2011 09:10 PM by TBJokers.)
|
|
11-18-2011 09:06 PM |
|