About Store Forum Documentation Contact



Post Reply 
interactive objects and trigger lines
Author Message
dertar Offline
Member

Post: #1
interactive objects and trigger lines
I just began looking into tutorials of esenthel and i really like the clean structure and well given examples.

If anyone is already deeper inside Coding/Handling,
how much effort/coding is involved for a interaction where the player can

1. Drop 1st Pillar-Object
1. Drop 2nd Pillar-Object
2. If the distance between Pillar-Objects isnt too far, a kind of Trigger-Line is created between those objects.
3. If an npc crosses the Trigger-line, some event is triggered.

Asking because i am aiming at a multiplayer game, where the known rpg interactions (talk to npc, hit skill button, open door) are moved to a more interactive level. or better, i dont dream of creating a big world full of repeating quests/npc/items, but more of some tiny "arcade" like elements, that give "fun"/"creativity" in exploring the world.
03-07-2012 05:01 PM
Find all posts by this user Quote this message in a reply
dertar Offline
Member

Post: #2
RE: interactive objects and trigger lines
I finally worked through several of the tutorials.
But i somehow cant attach a Custom Parameter to a dynamical created Object. Am I doing sth wrong here?

The item seems to be created correctly into the extended class (Item, GAME::Item). But i cant set/initialize the custom parameters.


Quote:...
STRUCT(Item , Game::Item) // extend items to include item Icons, and parameters
//{
Str name;
Byte type;
Flt power;
// manage
void create(Game::ObjParams &obj);
Item();
};

Item::Item()
{
T.actor.group( OBJ_ITEM );
}
void Item::create(Game::ObjParams &obj)
{
super::create(obj);
// now setup custom parameters from 'obj'
if(Param *par=obj.findParam("name" ))name =par->asText();
if(Param *par=obj.findParam("power"))power=par->asFlt ();
T.actor.group( OBJ_ITEM );
}
...
...

Game::ObjParams objs; // set object parameters objs=*Game::Objs.ptrRequire("obj/item/misc/barrel2/barrel2.obj");
objs.matrix.setScalePos(1.0f, T.pos());
objs.type(true, "OBJ_ITEM");

Param param;
param.name="name";
param.value.s="Myname";
objs.params.add(param);

Param paramd;
paramd.name="power";
paramd.value.f=10;
objs.params.add(paramd);

Game::Obj *newObj = Game::World.objCreateNear(objs,Matrix(objs.scale(),T.pos()));
...
...
...
if(Physics.sweep(ball,tpos, &phys_hit2)) // test for obstacles in 1 meter range, test door actor groups only
{

if(Door *door=CAST(Door, phys_hit2.obj)) // if it's a door
{ D.text(0, 0.7f, S+"IS DOOR "+ door->type() );
D.text(0, 0.6f, S+"Obj TYpe: " + door->type()) ;
door->open(); // automatically open the door
}

if(Item *itempointer=CAST(Item, phys_hit2.obj)) // if it's a item
{ D.text(0, 0.7f, S+"IS Item " + itempointer->type + " " + itempointer->name);
D.text(0, 0.6f, S+"Itempos"+itempointer->pos()+" itempower "+itempointer->power+" itemname"+itempointer->name);
}

}
03-13-2012 03:11 AM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #3
RE: interactive objects and trigger lines
Just going to say I don't think that you need to set the actor.group if you are using standard enum identifiers in the editor, unless overloading with custom type.

I think "find" and "get" param is case sensitive?
I also think
if(Param *par=obj.findParam("name" ))name =par->asText(); can be reduced to
name = obj.findParam("")->asText();
(This post was last modified: 03-13-2012 04:17 AM by Zervox.)
03-13-2012 04:14 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #4
RE: interactive objects and trigger lines
You need to call sortParams. Another option is to just set item->name and item->type after dynamically creating the object.
03-13-2012 05:09 AM
Find all posts by this user Quote this message in a reply
dertar Offline
Member

Post: #5
RE: interactive objects and trigger lines
Thanks a lot for your Hints! I need to look for the function/handling of creating custom params on existing object.

Have found another Thread with <alike> problem:
http://www.esenthel.com/community/showth...p?tid=1114

With a lot of testing and rewriting, i finally got a working example.
Dynamic Object Creation, with a String, a Integer, a Float Variables.
But the Object Itself can be loaded from a obj file.

You wouldnt believe that the String Handling took me some hours.
Its different from numeric Values Handling.


Quote:STRUCT(Itemd , Game::Item) // extend items to include item Icons, and parameters
//{
Str name;
Byte type;
Flt power;
Int health;
ImagePtr icon;
// manage
Itemd();
void create(Game::ObjParams &obj);
// io methods
virtual void save(File &f);
virtual Bool load(File &f);
virtual UInt drawPrepare();
};
Itemd::Itemd()
{
name=0;
power=3;
health=3;
}
void Itemd::create(Game::ObjParams &obj)
{
super::create(obj);

// now setup custom parameters from 'obj'
if(Param *par=obj.findParam("power"))power=par->asFlt ();
if(Param *par=obj.findParam("name")) name=par->value.s;
if(Param *par=obj.findParam("health"))health=par->asInt ();
}

...

if(Kb.bp(KB_U)) // on space
{
Game::ObjParams &obj=*Game::Objs("obj/item/misc/barrel/0.obj");
/*obj="obj/item/misc/barrel/0.obj"; */
obj.matrix.setScalePos(1.0f, T.pos());
obj.type(true, "OBJ_ITEM");

Param param1 = obj.params.New();
param1.name="health";
param1.asInt();
param1.value.i=Int(100);
obj.params.add(param1);
obj.sortParams();

Param param3 = obj.params.New();
param3.name="power";
param3.asFlt();
param3.value.f=5.1;
obj.params.add(param3);
obj.sortParams();

Str mya("CUSTBARREL1");
Param param2 = obj.params.New();
param2.name="name";
param2.value.s+=mya;
obj.params.add(param2);
obj.sortParams();

Itemd sii;sii.create(obj);
Game::Obj *newObj=(Game::World.objCreateNear(obj,Matrix(obj.scale(),T.pos())));
}
(This post was last modified: 03-14-2012 02:54 AM by dertar.)
03-13-2012 10:13 AM
Find all posts by this user Quote this message in a reply
dertar Offline
Member

Post: #6
RE: interactive objects and trigger lines
And finally a picture from the result.
I sweep Objects in Front of the Player and Put Parameter to Screen.


Attached File(s) Image(s)
   
03-14-2012 03:00 AM
Find all posts by this user Quote this message in a reply
Post Reply