コード例 #1
0
int LuaSpell_GetEntry(lua_State * L, Spell * sp)
{
	if(sp == NULL)
		RET_NIL(true);

	lua_pushinteger(L, sp->GetSpellProto()->Id);
	return 1;
}
コード例 #2
0
ファイル: FunctionSpell.cpp プロジェクト: WowDevs/Sandshroud
int LuaSpell_Cast(lua_State * L, Spell * sp)
{
    if(sp == NULL)
        RET_NIL(false);

    bool check = CHECK_BOOL(L, 1);
    sp->cast(check);
    return 1;
}
コード例 #3
0
int LuaGlobalFunctions_ToLower(lua_State * L)
{
	std::string oldstring = luaL_checkstring(L,1);
	if (!oldstring.size())
		RET_NIL(true);

	lua_pushstring(L, HEARTHSTONE_TOLOWER_RETURN(oldstring).c_str());
	return 1;
}
コード例 #4
0
int LuaGlobalFunctions_GetPlayer(lua_State * L)
{
	const char * plName = luaL_checkstring(L,1);
	Player * plr = objmgr.GetPlayer(plName);
	if (plr == NULL || !plr->IsInWorld())
		RET_NIL(true);

	Lunar<Unit>::push(L, TO_UNIT(plr));
	return 1;
}
コード例 #5
0
int LuaGlobalFunctions_GetTaxiPath(lua_State * L)
{
	uint32 path = luaL_checkint(L, 1);
	TaxiPath * tp = sTaxiMgr.GetTaxiPath(path);
	if(tp == NULL)
		RET_NIL(true);

	Lunar<TaxiPath>::push(L, tp);
	return 1;
}
コード例 #6
0
int LuaGlobalFunctions_SendWorldMessage(lua_State * L)
{
	const char * message = luaL_checkstring(L,1);
	uint32 MsgType = luaL_checkint(L,2);
	if(!message || !MsgType)
		RET_NIL(true);

	if (MsgType == 1)
		sWorld.SendWorldWideScreenText(message);
	else if (MsgType == 2)
		sWorld.SendWorldText(message);
	return 1;
}
コード例 #7
0
ファイル: FunctionSpell.cpp プロジェクト: WowDevs/Sandshroud
int LuaSpell_GetTarget(lua_State * L, Spell * sp)
{
    if(sp == NULL)
        RET_NIL(true);

    if (sp->GetUnitTarget())
    {
        Lunar<Unit>::push(L, sp->GetUnitTarget());
        return 1;
    }
    else if (sp->GetItemTarget())
    {
        Lunar<Item>::push(L,sp->GetItemTarget());
        return 1;
    }
    else if (sp->GetGameObjectTarget())
    {
        Lunar<GameObject>::push(L, sp->GetGameObjectTarget());
        return 1;
    }
    else
        RET_NIL(true);
}
コード例 #8
0
ファイル: FunctionSpell.cpp プロジェクト: WowDevs/Sandshroud
int LuaSpell_GetCaster(lua_State * L, Spell * sp)
{
    if(sp == NULL)
        RET_NIL(true);

    if (sp->u_caster) //unit caster
    {
        Lunar<Unit>::push(L, sp->u_caster);
        return 1;
    }
    else if (sp->g_caster) //gameobject
    {
        Lunar<GameObject>::push(L, sp->g_caster);
        return 1;
    }
    else if (sp->i_caster) //item
    {
        Lunar<Item>::push(L, sp->i_caster);
        return 1;
    }

    RET_NIL(true);
}
コード例 #9
0
int LuaGlobalFunctions_GetPlayersInMap(lua_State * L)
{
	Player * ret = NULL;
	uint32 count = 0;
	lua_newtable(L);
	uint32 mapid = luaL_checkint(L,1);
	MapMgr * mgr = sInstanceMgr.GetMapMgr(mapid);
	if (mgr == NULL)
		RET_NIL(true);

	for (PlayerStorageMap::iterator itr = mgr->m_PlayerStorage.begin(); itr != mgr->m_PlayerStorage.end(); ++itr)
	{
		count++,
		ret = (*itr).second;
		lua_pushinteger(L,count);
		Lunar<Unit>::push(L,((Unit*)ret));
		lua_rawset(L,-3);
	}

	if(!count)
		RET_NIL(true);
	return 1;
}
コード例 #10
0
int LuaGlobalFunctions_ReloadTable(lua_State * L)
{
	const char * TableName = luaL_checkstring(L,1);
	if (!stricmp(TableName, "spell_disable"))
	{
		objmgr.ReloadDisabledSpells();
	} 
	else if (!stricmp(TableName, "vendors"))
	{
		objmgr.ReloadVendors();
	}
	else
	{
		if (!stricmp(TableName, "items"))					// Items
			ItemPrototypeStorage.Reload();
		else if (!stricmp(TableName, "creature_proto"))		// Creature Proto
			CreatureProtoStorage.Reload();
		else if (!stricmp(TableName, "creature_names"))		// Creature Names
			CreatureNameStorage.Reload();
		else if (!stricmp(TableName, "gameobject_names"))	// GO Names
			GameObjectNameStorage.Reload();
		else if (!stricmp(TableName, "areatriggers"))		// Areatriggers
			AreaTriggerStorage.Reload();
		else if (!stricmp(TableName, "itempages"))			// Item Pages
			ItemPageStorage.Reload();
		else if (!stricmp(TableName, "npc_text"))			// NPC Text Storage
			NpcTextStorage.Reload();
		else if (!stricmp(TableName, "fishing"))				// Fishing Zones
			FishingZoneStorage.Reload();
		else if(!stricmp(TableName, "teleport_coords"))		// Teleport coords
			TeleportCoordStorage.Reload();
		else if (!stricmp(TableName, "graveyards"))			// Graveyards
			GraveyardStorage.Reload();
		else if (!stricmp(TableName, "worldmap_info"))		// WorldMapInfo
			WorldMapInfoStorage.Reload();
		else if (!stricmp(TableName, "zoneguards"))
			ZoneGuardStorage.Reload();
		else if (!stricmp(TableName, "command_overrides"))	// Command Overrides
		{
			sComTableStore.Dealloc();
			sComTableStore.Init();
			sComTableStore.Load();
		}
		else
			RET_NIL(true);
	}

	return 1;
}
コード例 #11
0
ファイル: FunctionSpell.cpp プロジェクト: WowDevs/Sandshroud
int LuaSpell_GetSpellState(lua_State * L, Spell * sp)
{
    if(sp == NULL)
        RET_NIL(true);

    /*
    SPELL_STATE_NULL      = 0,
    SPELL_STATE_PREPARING = 1,
    SPELL_STATE_CASTING   = 2,
    SPELL_STATE_FINISHED  = 3,
    SPELL_STATE_IDLE      = 4
    */
    lua_pushinteger(L, sp->getState());
    return 1;
}
コード例 #12
0
ファイル: FunctionSpell.cpp プロジェクト: WowDevs/Sandshroud
int LuaSpell_ResetVar(lua_State * L, Spell * sp)
{
    if (sp == NULL)
        RET_BOOL(false);

    const char* var = luaL_checkstring(L,1);
    if (var == NULL)
        RET_BOOL(false);

    int subindex = luaL_optint(L,2,0);
    if (subindex < 0)
        RET_BOOL(false);

    SpellEntry * proto = sp->GetSpellProto();
    if (proto == NULL)
        RET_NIL(false);

    LuaSpellEntry l = GetLuaSpellEntryByName(var);
    if (!l.name)
        RET_BOOL(false);

    switch (l.typeId) //0: int, 1: char*, 2: bool, 3: float
    {
    case 0:
        GET_SPELLVAR_INT(proto, l.offset,subindex) = GET_SPELLVAR_INT(sp->m_spellInfo,l.offset,subindex);
        lua_pushboolean(L, 1);
        break;
    case 1:
        GET_SPELLVAR_CHAR(proto, l.offset,subindex) = GET_SPELLVAR_CHAR(sp->m_spellInfo,l.offset,subindex);
        lua_pushboolean(L, 1);
        break;
    case 2:
        GET_SPELLVAR_BOOL(proto, l.offset,subindex) = GET_SPELLVAR_BOOL(sp->m_spellInfo,l.offset,subindex);
        lua_pushboolean(L, 1);
        break;
    case 3:
        GET_SPELLVAR_FLOAT(proto, l.offset,subindex) = GET_SPELLVAR_FLOAT(sp->m_spellInfo,l.offset,subindex);
        lua_pushboolean(L, 1);
        break;
    default:
        RET_BOOL(false);
        break;
    }
    return 1;
}
コード例 #13
0
ファイル: FunctionAura.cpp プロジェクト: h4s0n/Sandshroud
int LuaAura_SetVar(lua_State * L, Aura * aura)
{
	TEST_AURA_RET();
	const char* var = luaL_checkstring(L,1);
	int subindex = 0;
	if (lua_gettop(L) == 3)
		subindex = luaL_optint(L,2,0);

	if (!var || subindex < 0)
		RET_BOOL(false);

	int valindex = 2;
	if(subindex)
		valindex++;

	SpellEntry * proto = aura->m_spellProto;
	if(proto == NULL)
		RET_NIL(true);

	LuaSpellEntry l = GetLuaSpellEntryByName(var);
	if (!l.name)
		RET_BOOL(false);

	switch (l.typeId) //0: int, 1: char*, 2: bool, 3: float
	{
	case 0:
		GET_SPELLVAR_INT(proto,l.offset,subindex) = luaL_checkinteger(L, valindex);
		lua_pushboolean(L, 1);
		break;
	case 1:
		strcpy(GET_SPELLVAR_CHAR(proto,l.offset,subindex), luaL_checkstring(L, valindex));
		lua_pushboolean(L, 1);
		break;
	case 2:
		GET_SPELLVAR_BOOL(proto,l.offset,subindex) = CHECK_BOOL(L, valindex);
		lua_pushboolean(L, 1);
		break;
	case 3:
		GET_SPELLVAR_FLOAT(proto,l.offset,subindex) = (float)luaL_checknumber(L, valindex);
		lua_pushboolean(L, 1);
		break;
	}
	return 1;
}
コード例 #14
0
ファイル: FunctionTaxi.cpp プロジェクト: Refuge89/Hearthstone
int LuaTaxi_AddPathNode(lua_State * L, TaxiPath * tp)
{
	if(tp == NULL)
		RET_NIL(false);

	uint32 mapid = luaL_checkint(L, 1);
	float x = CHECK_FLOAT(L, 2);
	float y = CHECK_FLOAT(L, 3);
	float z = CHECK_FLOAT(L, 4);
	uint32 index = luaL_optnumber(L, 5, tp->GetNodeCount());

	TaxiPathNode* tpn = new TaxiPathNode();
	tpn->mapid = mapid;
	tpn->x = x;
	tpn->y = y;
	tpn->z = z;
	tp->AddPathNode(index, tpn);
	return 1;
}
コード例 #15
0
int LuaGlobalFunctions_GetPlayersInZone(lua_State * L)
{
	Player * ret = NULL;
	uint32 count = 0;
	lua_newtable(L);
	uint32 zoneid = luaL_checkint(L,1);
	objmgr._playerslock.AcquireReadLock();
	HM_NAMESPACE::hash_map<uint32, Player*>::const_iterator itr;
    for (itr = objmgr._players.begin(); itr != objmgr._players.end(); itr++)
	{
		if ((*itr).second->GetZoneId() == zoneid)
		{
			count++,
			ret = (*itr).second;
			lua_pushinteger(L,count);
			Lunar<Unit>::push(L,((Unit*)ret));
			lua_rawset(L,-3);
		}
	}
	objmgr._playerslock.ReleaseReadLock();
	if(!count)
		RET_NIL(true);
	return 1;
}
コード例 #16
0
int LuaGlobalFunctions_PerformIngameSpawn(lua_State * L)
{
	uint32 spawntype = luaL_checkint(L, 1);
	uint32 entry = luaL_checkint(L, 2);
	uint32 map = luaL_checkint(L, 3);
	float x = CHECK_FLOAT(L, 4);
	float y = CHECK_FLOAT(L, 5);
	float z = CHECK_FLOAT(L, 6);
	float o = CHECK_FLOAT(L, 7);
	uint32 faction = luaL_checkint(L, 8); //also scale as percentage
	uint32 duration = luaL_checkint(L, 9);
	uint32 equip1 = luaL_optint(L, 10, 1);
	uint32 equip2 = luaL_optint(L, 11, 1);
	uint32 equip3 = luaL_optint(L, 12, 1);
	//13: instance id
	uint32 save = luaL_optint(L, 14, 0);
	if(x && y && z && entry)
	{
		if (spawntype == 1) //Unit
		{ 
			CreatureProto *p = CreatureProtoStorage.LookupEntry(entry);
			CreatureInfo *i = CreatureNameStorage.LookupEntry(entry);
			if (p == NULL || i == NULL)
				RET_NIL(true);

			MapMgr *mapMgr = sInstanceMgr.GetMapMgr(map);
			if (mapMgr == NULL)
				RET_NIL(true);

			int32 instanceid = luaL_optint(L, 13, mapMgr->GetInstanceID());
			CreatureSpawn * sp = new CreatureSpawn();
			sp->entry = entry;
			sp->id = objmgr.GenerateCreatureSpawnID();
			sp->x = x;
			sp->y = y;
			sp->z = z;
			sp->o = o;
			sp->emote_state = 0;
			sp->flags = 0;
			sp->factionid = faction;
			sp->stand_state = 0;
			sp->phase = 1;
			sp->vehicle = p->vehicle_entry > 0 ? true : false;
			sp->Bytes = NULL;
			sp->ChannelData = NULL;
			sp->MountedDisplay = NULL;

			Creature * pCreature = NULL;
			if(sp->vehicle)
			{
				pCreature = TO_CREATURE(mapMgr->CreateVehicle(entry));
				TO_VEHICLE(pCreature)->Load(sp, mapMgr->iInstanceMode, NULL);
			}
			else
			{
				pCreature = mapMgr->CreateCreature(entry);
				pCreature->Load(sp, mapMgr->iInstanceMode, NULL);
			}

			pCreature->m_loadedFromDB = true;
			pCreature->SetFaction(faction);
			pCreature->SetInstanceID(instanceid);
			pCreature->SetMapId(map);
			pCreature->m_noRespawn = true;
			pCreature->PushToWorld(mapMgr);
			if (duration>0) 
				pCreature->Despawn(duration,0);
			if (save)
				pCreature->SaveToDB();
			Lunar<Unit>::push(L,TO_UNIT(pCreature));
		}
		else if (spawntype == 2) //GO
		{ 
			GameObjectInfo *n = GameObjectNameStorage.LookupEntry(entry);
			if (n == NULL)
				RET_NIL(true);

			MapMgr *mapMgr = sInstanceMgr.GetMapMgr(map);
			if (mapMgr == NULL)
				RET_NIL(true);

			int32 instanceid = luaL_optint(L, 13, mapMgr->GetInstanceID());

			GameObject *go = mapMgr->CreateGameObject(entry);
			go->SetInstanceID(instanceid);
			go->CreateFromProto(entry,map,x,y,z,o);

			// Create spawn instance
			GOSpawn * gs = new GOSpawn;
			gs->entry = go->GetEntry();
			gs->facing = go->GetOrientation();
			gs->faction = go->GetFaction();
			gs->flags = go->GetUInt32Value(GAMEOBJECT_FLAGS);
			gs->id = objmgr.GenerateGameObjectSpawnID();
			gs->scale = go->GetUInt32Value(OBJECT_FIELD_SCALE_X);
			gs->x = go->GetPositionX();
			gs->y = go->GetPositionY();
			gs->z = go->GetPositionZ();
			gs->state = go->GetByte(GAMEOBJECT_BYTES_1, 0);
			gs->phase = 0;

			go->m_spawn = gs;
			go->PushToWorld(mapMgr);
			if (duration)
				sEventMgr.AddEvent(go,&GameObject::ExpireAndDelete,EVENT_GAMEOBJECT_UPDATE,duration,1,EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
			if (save)
				go->SaveToDB();
			Lunar<GameObject>::push(L,go);
		}
		else
			RET_NIL(true);
	}
	else
		RET_NIL(true);
	return 1;
}