EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Custom (https://www.eqemulator.org/forums/forumdisplay.php?f=671)
-   -   Object Builder (https://www.eqemulator.org/forums/showthread.php?t=31508)

Zordana 06-20-2010 02:17 PM

Object Builder
 
Secrets has made a very very nice perl implementation!
http://www.eqemulator.org/forums/sho...d.php?p=188939


I created an Object Builder NPC - many thanks to Secrets for this great perlport!
Create an NPC with that perl code and Hail him!

Info:
When setting the model, you can skip the _ACTORDEF, it will be automatically added

Code:

sub EVENT_SAY {
       
        if (!$client->GetGM()) {
                $client->Message(15, "You have no access to object creation!");
                return;
        }
       
        if ($text =~ /Hail/) {
                $client->Message(15, "Object Creation Commandlist");
                $client->Message(15, "=============");
                $client->Message(15, "object dbdel [object_id]");
                $client->Message(15, "object dbsave [object_id]");
                $client->Message(15, "object create fromitem [itemid]");
                $client->Message(15, "object create frommodel [model]");
                $client->Message(15, "object list");
                $client->Message(15, "object set [object_id] location [x] [y] [z]");
                $client->Message(15, "object set [object_id] model [model]");
                $client->Message(15, "object set [object_id] type [0-255]");
                $client->Message(15, "object view [object_id]");
                $client->Message(15, "=============");
                $client->Message(15, "End of list");
                return;
        }
       
        @arguments = split(' ',$text);
        if ($arguments[0] ne "object") {
                return;
        }

       
        if ($arguments[1] eq "list") {
                my @objectList = $entity_list->GetObjectList();
                $client->Message(15, "Object list: ");
                $client->Message(15, "=============");
                foreach my $object (@objectList) {
                        $client->Message(15, GetObjectInfo($object));
                }
                $client->Message(15, "=============");
                $client->Message(15, "End of list");
        }
       
        if ($arguments[1] eq "view") {
                $obj = $entity_list->GetObjectByID($arguments[2]);
                if (!$obj) {
                        $client->Message(15, "Object with ID ".$arguments[2]." does not exist!");
                }
                else {
                        $client->Message(15, GetObjectInfo($obj));
                }
        }
       
        if ($arguments[1] eq "create") {
                if ($arguments[2] eq "frommodel") {
                        $model = BuildObjectModel($arguments[3]);
                        $entityId = quest::creategroundobjectfrommodel($model, $x, $y, $z, $h);
                        $client->Message(15, "Object created.");
                        $obj = $entity_list->GetObjectByID($entityId);
                        $client->Message(15, GetObjectInfo($obj));
                }
                if ($arguments[2] eq "fromitem") {
                        $itemid = $arguments[3];
                        $entityId = quest::creategroundobject($itemid, $x, $y, $z, $h);
                        $client->Message(15, "Object created.");
                        $obj = $entity_list->GetObjectByID($entityId);
                        $client->Message(15, GetObjectInfo($obj));
                }
        }
       
        if ($arguments[1] eq "set") {
                $entityId = $arguments[2];
                $obj = $entity_list->GetObjectByID($arguments[2]);
                if (!$obj) {
                        $client->Message(15, "Object with ID ".$arguments[2]." does not exist!");
                }
                else {
                        my $updated = false;
                        if ($arguments[3] eq "location") {
                                if ($arguments[6] eq "") {
                                        $client->Message(15, "Usage: set [ObjectID] location x y z");
                                }
                                else {
                                        $obj->SetX($arguments[4]);
                                        $obj->SetY($arguments[5]);
                                        $obj->SetZ($arguments[6]);
                                        $updated = true;
                                }
                        }
                        if ($arguments[3] == "model") {
                                if ($arguments[4] eq "") {
                                        $client->Message(15, "Usage: set [ObjectID] model modelname");
                                }
                                else {
                                        $obj->SetModelName(BuildObjectModel($arguments[4]));
                                        $updated = true;
                                }
                        }
                        if ($arguments[3] == "type") {
                                if ($arguments[4] eq "") {
                                        $client->Message(15, "Usage: set [ObjectID] type [0-255]");
                                }
                                else {
                                        $obj->SetType($arguments[4]);
                                        $updated = true;
                                }
                        }
                       
                       
                        if ($updated) {
                                $client->Message(15, "Object Updated.");
                                $client->Message(15, GetObjectInfo($obj));
                        }
                }
        }
       
        if ($arguments[1] eq "dbsave") {
                $entityId = $arguments[2];
                $obj = $entity_list->GetObjectByID($entityId);
                if (!$obj) {
                        $client->Message(15, "Object with ID ".$entityId." does not exist!");
                }
                else {
                        $newid = $obj->VarSave();
                        $client->Message(15, "Object saved to database: ID $newid");
                        $client->Message(15, GetObjectInfo($obj));
                }
        }       
        if ($arguments[1] eq "dbdel") {
                $entityId = $arguments[2];
                $obj = $entity_list->GetObjectByID($arguments[2]);
                if (!$obj) {
                        $client->Message(15, "Object with ID ".$arguments[2]." does not exist!");
                }
                else {
                        $newid = $obj->Delete();
                        $client->Message(15, "Object deleted from database");
                        $client->Message(15, GetObjectInfo($obj));
                }
        }               
}


sub GetObjectInfo {
        my $object = $_[0];
        my $seperator = " || ";
        return "Object: ".
        "id: ".$object->GetID()
        .$seperator.
        ($object->GetDBID() == 0 ? "not in db" : "dbid: ".$object->GetDBID())
        .$seperator.
        "type: ".$object->GetType()
        .$seperator.
        "model: ".$object->GetModelName()
        .$seperator.
        "location x,y,z, heading: ".int($object->GetX()).', '.int($object->GetY()).', '.int($object->GetZ()).", ".int($object->GetHeading())
        .$seperator.
        "icon: ".$object->GetIcon()
        .$seperator.
        "groundspawn: ".($object->IsGroundSpawn() ? "yes" : "no")
        ;
}
sub BuildObjectModel {
        my $model = $_[0];
        if (substr($model,length($model)-9,9) ne "_ACTORDEF") {
                $model = $model . "_ACTORDEF";
        }
        return $model;
}


Akkadius 09-11-2010 07:09 PM

Quote:

Originally Posted by Zordana (Post 189005)
Secrets has made a very very nice perl implementation!
http://www.eqemulator.org/forums/sho...d.php?p=188939


I created an Object Builder NPC - many thanks to Secrets for this great perlport!
Create an NPC with that perl code and Hail him!

Info:
When setting the model, you can skip the _ACTORDEF, it will be automatically added

Code:

sub EVENT_SAY {
       
        if (!$client->GetGM()) {
                $client->Message(15, "You have no access to object creation!");
                return;
        }
       
        if ($text =~ /Hail/) {
                $client->Message(15, "Object Creation Commandlist");
                $client->Message(15, "=============");
                $client->Message(15, "object dbdel [object_id]");
                $client->Message(15, "object dbsave [object_id]");
                $client->Message(15, "object create fromitem [itemid]");
                $client->Message(15, "object create frommodel [model]");
                $client->Message(15, "object list");
                $client->Message(15, "object set [object_id] location [x] [y] [z]");
                $client->Message(15, "object set [object_id] model [model]");
                $client->Message(15, "object set [object_id] type [0-255]");
                $client->Message(15, "object view [object_id]");
                $client->Message(15, "=============");
                $client->Message(15, "End of list");
                return;
        }
       
        @arguments = split(' ',$text);
        if ($arguments[0] ne "object") {
                return;
        }

       
        if ($arguments[1] eq "list") {
                my @objectList = $entity_list->GetObjectList();
                $client->Message(15, "Object list: ");
                $client->Message(15, "=============");
                foreach my $object (@objectList) {
                        $client->Message(15, GetObjectInfo($object));
                }
                $client->Message(15, "=============");
                $client->Message(15, "End of list");
        }
       
        if ($arguments[1] eq "view") {
                $obj = $entity_list->GetObjectByID($arguments[2]);
                if (!$obj) {
                        $client->Message(15, "Object with ID ".$arguments[2]." does not exist!");
                }
                else {
                        $client->Message(15, GetObjectInfo($obj));
                }
        }
       
        if ($arguments[1] eq "create") {
                if ($arguments[2] eq "frommodel") {
                        $model = BuildObjectModel($arguments[3]);
                        $entityId = quest::creategroundobjectfrommodel($model, $x, $y, $z, $h);
                        $client->Message(15, "Object created.");
                        $obj = $entity_list->GetObjectByID($entityId);
                        $client->Message(15, GetObjectInfo($obj));
                }
                if ($arguments[2] eq "fromitem") {
                        $itemid = $arguments[3];
                        $entityId = quest::creategroundobject($itemid, $x, $y, $z, $h);
                        $client->Message(15, "Object created.");
                        $obj = $entity_list->GetObjectByID($entityId);
                        $client->Message(15, GetObjectInfo($obj));
                }
        }
       
        if ($arguments[1] eq "set") {
                $entityId = $arguments[2];
                $obj = $entity_list->GetObjectByID($arguments[2]);
                if (!$obj) {
                        $client->Message(15, "Object with ID ".$arguments[2]." does not exist!");
                }
                else {
                        my $updated = false;
                        if ($arguments[3] eq "location") {
                                if ($arguments[6] eq "") {
                                        $client->Message(15, "Usage: set [ObjectID] location x y z");
                                }
                                else {
                                        $obj->SetX($arguments[4]);
                                        $obj->SetY($arguments[5]);
                                        $obj->SetZ($arguments[6]);
                                        $updated = true;
                                }
                        }
                        if ($arguments[3] == "model") {
                                if ($arguments[4] eq "") {
                                        $client->Message(15, "Usage: set [ObjectID] model modelname");
                                }
                                else {
                                        $obj->SetModelName(BuildObjectModel($arguments[4]));
                                        $updated = true;
                                }
                        }
                        if ($arguments[3] == "type") {
                                if ($arguments[4] eq "") {
                                        $client->Message(15, "Usage: set [ObjectID] type [0-255]");
                                }
                                else {
                                        $obj->SetType($arguments[4]);
                                        $updated = true;
                                }
                        }
                       
                       
                        if ($updated) {
                                $client->Message(15, "Object Updated.");
                                $client->Message(15, GetObjectInfo($obj));
                        }
                }
        }
       
        if ($arguments[1] eq "dbsave") {
                $entityId = $arguments[2];
                $obj = $entity_list->GetObjectByID($entityId);
                if (!$obj) {
                        $client->Message(15, "Object with ID ".$entityId." does not exist!");
                }
                else {
                        $newid = $obj->VarSave();
                        $client->Message(15, "Object saved to database: ID $newid");
                        $client->Message(15, GetObjectInfo($obj));
                }
        }       
        if ($arguments[1] eq "dbdel") {
                $entityId = $arguments[2];
                $obj = $entity_list->GetObjectByID($arguments[2]);
                if (!$obj) {
                        $client->Message(15, "Object with ID ".$arguments[2]." does not exist!");
                }
                else {
                        $newid = $obj->Delete();
                        $client->Message(15, "Object deleted from database");
                        $client->Message(15, GetObjectInfo($obj));
                }
        }               
}


sub GetObjectInfo {
        my $object = $_[0];
        my $seperator = " || ";
        return "Object: ".
        "id: ".$object->GetID()
        .$seperator.
        ($object->GetDBID() == 0 ? "not in db" : "dbid: ".$object->GetDBID())
        .$seperator.
        "type: ".$object->GetType()
        .$seperator.
        "model: ".$object->GetModelName()
        .$seperator.
        "location x,y,z, heading: ".int($object->GetX()).', '.int($object->GetY()).', '.int($object->GetZ()).", ".int($object->GetHeading())
        .$seperator.
        "icon: ".$object->GetIcon()
        .$seperator.
        "groundspawn: ".($object->IsGroundSpawn() ? "yes" : "no")
        ;
}
sub BuildObjectModel {
        my $model = $_[0];
        if (substr($model,length($model)-9,9) ne "_ACTORDEF") {
                $model = $model . "_ACTORDEF";
        }
        return $model;
}


This works very slick bro, great job.

Emmeric 10-07-2011 10:53 PM

I automatically get the "You have no access to object creation!" even though my account is set at 255.

:confused:

lerxst2112 10-08-2011 02:37 AM

#gm on first.

Emmeric 10-08-2011 01:45 PM

Always something simple with me.

Thanks, the Hail works now.

Maybe now that I have that working, I could get a bit of pointer. I type in #object list and it says Usage:#object ListAll(radius)

So I typed in #object ListAll 30
#object ListAll 300
#object ListAll(30)
#object ListAll(300)

All near the small bank in PoK with no results. Keeps reprinting: Usage:#object ListAll(radius)

I figured I would pick up a crate or that wheelbarrow behind the building, but not getting any list. I am assuming that the radius will only return those items in range so I would have to find an item I want to place in another zone and then use that ID where I want to place?

So what about my usage isn't working? :D

lerxst2112 10-08-2011 06:00 PM

If you're typing #object you're not using the NPC at all. Target the NPC and type 'object list'

As for the #object command, what the usage actually says is "Usage: #object List All|(radius)", which means you should type "#object list all", or "#object list 5000", depending on if you want to list all or just the ones within a certain distance from you.

Emmeric 10-08-2011 09:15 PM

Okay, that makes sense once you said it. I did as you said and received responses about nearby objects.

I chose one and attempted to use object view, but it just reads out details. I don't actually see anything. Dunno if it's a crate, a torch, a wheelbarrow, a chair... who knows.

Not knowing what I chose, I did an object create which appeared to do nothing, then did an object set of item id 8 at my coordinates which returned yellow text indicating I created object 8 at my coordinates, but groundspawn NO. Didn't see anything.

Knowing all my previous questions and noobness, is this beyond me? I could just be satisfied with shit the way it is and stop wasting people's time... Gimme your opinion.

revloc02c 10-10-2011 01:02 PM

Quote:

Originally Posted by Emmeric (Post 203820)
Knowing all my previous questions and noobness, is this beyond me? I could just be satisfied with shit the way it is and stop wasting people's time... Gimme your opinion.

Stick with it Emmeric, you can figure it out. When I first looked into EQEmu and asked about running my own server I had a hater tell me if I couldn't figure it out I shouldn't be doing it. Well I did figure it out and I've done a ton of other "figuring out" since then on EQEmu.

So back on topic: I haven't figured all this out yet, but I noticed it lists tradeskill objects. I did successfully use the NPC to create an augment pool. I was able to successfullly delete that pool but I had to zone before I saw the changes.

There is an object that I am trying to identify so I can delete it, but I haven't figured that out yet. It is a dagger in the guildlobby that was sticking into a message board. I found the message boards and deleted them, but now I have a dagger hanging in space. Kinda fun since it is just the right height when I run into it, it makes me duck.

(I'll post more when I figure stuff out, but don't hold you breath as I have limited EQEmu time and thus take a long time to work through things like this.)

Emmeric 10-10-2011 05:55 PM

Quote:

Originally Posted by revloc02c (Post 203855)

So back on topic: I haven't figured all this out yet, but I noticed it lists tradeskill objects.

Ahhh... that's why it showed nothing from nearby. I was expecting graphical objects like crates, benches, torches, rugs, etc.

Nuts, and I was hoping to make my fledgling custom merchant area look all busy with supplies and tents. :D

I guess... I can just use the Bazaar.


All times are GMT -4. The time now is 01:14 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.