17 #include "../../bscript/berror.h" 18 #include "../../bscript/bobject.h" 19 #include "../../bscript/impstr.h" 20 #include "../../clib/rawtypes.h" 21 #include "../containr.h" 23 #include "../item/item.h" 24 #include "../mobile/charactr.h" 25 #include "../multi/boat.h" 26 #include "../polclass.h" 27 #include "../poltype.h" 28 #include "../realms.h" 29 #include "../realms/realm.h" 30 #include "../reftypes.h" 31 #include "../uconst.h" 33 #include "../uobject.h" 34 #include "../uoexhelp.h" 35 #include "../uworld.h" 42 using namespace Bscript;
45 using namespace Items;
55 if ( !(
getUObjectParam( exec, 0, obj ) && getParam( 1, x ) && getParam( 2, y ) &&
57 getParam( 5, flags ) ) )
59 return new BError(
"Invalid parameter" );
63 return new BError(
"Realm not found." );
64 else if ( !realm->
valid( x, y, z ) )
65 return new BError(
"Invalid coordinates for realm." );
68 return internal_MoveCharacter( static_cast<Character*>( obj ), x, y, z, flags, realm );
70 return internal_MoveBoat( static_cast<Multi::UBoat*>( obj ), x, y, z, flags, realm );
72 return new BError(
"Can't move multis at this time." );
74 return internal_MoveContainer( static_cast<UContainer*>( obj ), x, y, z, flags, realm );
76 return internal_MoveItem( static_cast<Item*>( obj ), x, y, z, flags, realm );
78 return new BError(
"Can't handle that object type." );
86 Item* walkon_item =
nullptr;
90 if ( newrealm !=
nullptr )
92 if ( !newrealm->
walkheight( x, y, z, &newz, &supporting_multi, &walkon_item,
true,
94 return new BError(
"Can't go there" );
100 if ( newrealm ==
nullptr || oldrealm == newrealm )
111 if ( chr->
client !=
nullptr )
113 chr->
realm = newrealm;
119 return new BLong( 1 );
121 return new BError(
"Can't go there" );
132 return new BError(
"Position indicated is impassable" );
140 boat->
realm = newrealm;
142 s8 deltaz =
static_cast<s8>( z - boat->
z );
146 bool ok = boat->
move_xy( x, y, flags, oldrealm );
147 return new BLong( ok );
155 BObjectImp* ok = internal_MoveItem( static_cast<Item*>( container ), x, y, z, flags, newrealm );
159 if ( newrealm !=
nullptr && oldrealm != newrealm )
173 if ( chr ==
nullptr || !chr->
can_move( item ) )
174 return new BError(
"That is immobile" );
176 if ( item->
inuse() && !is_reserved_to_me( item ) )
178 return new BError(
"That item is being used." );
182 item->
realm = newrealm;
185 item->
realm = oldrealm;
188 return new BError( message );
205 item->
realm = oldrealm;
206 return new BError(
"Invalid location selected" );
217 if ( chr_owner ==
nullptr )
218 if ( controller_.get() != nullptr )
219 chr_owner = controller_.get();
224 item->
realm = oldrealm;
225 return new BError(
"Could not remove item from its container." );
227 else if ( item->
orphan() )
229 return new BError(
"Item was destroyed in CanRemove script" );
234 item->
realm = oldrealm;
235 return new BError(
"Item cannot be unequipped" );
238 return new BError(
"Item was destroyed in Equip script" );
243 return new BError(
"Item was destroyed in OnRemove script" );
251 item->
x = oldroot->
x;
252 item->
y = oldroot->
y;
255 item->
realm = oldrealm;
257 item->
realm = newrealm;
260 move_item( item, x, y, static_cast<signed char>( z ), oldrealm );
262 if ( multi !=
nullptr )
266 return new BLong( 1 );
void on_remove(Mobile::Character *chr, Items::Item *item, MoveType move=MT_PLAYER)
Bscript::BObjectImp * mf_MoveObjectToLocation()
const std::string & value() const
void send_remove_character_to_nearby(const Character *chr)
void add_item_to_world(Items::Item *item)
bool check_unequip_script()
bool isa(BObjectType type) const
virtual UObject * toplevel_owner() POL_OVERRIDE
bool walkheight(unsigned short x, unsigned short y, short oldz, short *newz, Multi::UMulti **pmulti, Items::Item **pwalkon, bool doors_block, Core::MOVEMODE movemode, short *gradual_boost=nullptr)
bool check_unequiptest_scripts(Mobile::Character *chr)
const unsigned POLCLASS_BOAT
bool move_character_to(Mobile::Character *chr, unsigned short x, unsigned short y, short z, int flags, Realms::Realm *oldrealm)
const unsigned POLCLASS_MULTI
virtual void register_object(UObject *obj)
virtual bool script_isa(unsigned isatype) const
static bool navigable(const MultiDef &, unsigned short x, unsigned short y, short z, Realms::Realm *realm)
const unsigned POLCLASS_ITEM
std::string tostring(const Bscript::BTokenType &v)
const unsigned POLCLASS_CONTAINER
void notify_left(Mobile::Character &wholeft)
Bscript::BObjectImp * internal_MoveContainer(Core::UContainer *container, Core::xcoord x, Core::ycoord y, Core::zcoord z, int flags, Realms::Realm *newrealm)
void setrealm(Item *item, void *arg)
Core::UContainer * container
const unsigned POLCLASS_MOBILE
void send_remove_object_to_inrange(const UObject *centerObject)
void move_item(Item *item, UFACING facing)
void adjust_traveller_z(s8 delta_z)
const int MOVEITEM_FORCELOCATION
ref_ptr< Items::Item > ItemRef
void remove_objects_inrange(Network::Client *client)
Bscript::BObjectImp * internal_MoveItem(Items::Item *item, Core::xcoord x, Core::ycoord y, Core::zcoord z, int flags, Realms::Realm *newrealm)
bool getUObjectParam(Executor &exec, unsigned param, UObject *&objptr)
const int MOVEITEM_IGNOREMOVABLE
bool check_can_remove_script(Mobile::Character *chr, Items::Item *item, MoveType move=MT_PLAYER)
Realms::Realm * find_realm(const std::string &name)
bool can_move(const Items::Item *item) const
const MultiDef & multidef() const
bool valid(unsigned short x, unsigned short y, short z) const
Bscript::BObjectImp * internal_MoveCharacter(Mobile::Character *chr, Core::xcoord x, Core::ycoord y, Core::zcoord z, int flags, Realms::Realm *newrealm)
Mobile::Character * GetCharacterOwner()
bool move_xy(unsigned short x, unsigned short y, int flags, Realms::Realm *oldrealm)
Bscript::BObjectImp * internal_MoveBoat(Multi::UBoat *boat, Core::xcoord x, Core::ycoord y, Core::zcoord z, int flags, Realms::Realm *newrealm)
virtual void for_each_item(void(*f)(Item *item, void *a), void *arg)