コード例 #1
0
ファイル: abjuration.cpp プロジェクト: RealmsMud/RealmsCode
void Exit::doDispelMagic(BaseRoom* parent) {
    bringDownTheWall(getEffect("wall-of-fire"), parent, this);
    bringDownTheWall(getEffect("wall-of-thorns"), parent, this);

    // true we'll show, false don't remove perm effects
    removeEffect("concealed", true, false);
}
コード例 #2
0
	//------------------------------
	bool MaterialCreator::createAndAssingMaxMaterial( const DocumentImporter::NodeMaterialBindingsPair& materialBindingPair )
	{
		const DocumentImporter::MaterialBindingVector& materialBindings = materialBindingPair.materialBindings;
		INode* maxNode = materialBindingPair.maxNode;

		if ( materialBindings.size() == 0 )
			return true;

		const COLLADAFW::UniqueId& geometryUniqueId = getUniqueIdByObjectINode( maxNode );
		assert( geometryUniqueId.isValid() );

		// calculate largest material id
		int largestMaterialId = 0;
		DocumentImporter::MaterialBindingVector::const_iterator it = materialBindings.begin();

		for ( ; it != materialBindings.end(); ++it)
		{
			int materialId = (int)it->getMaterialId();
			largestMaterialId = materialId;
		}

		if ( !materialBindings.empty() )
		{
			if ( materialBindings.size() == 1 )
			{
				const COLLADAFW::MaterialBinding& materialBinding = materialBindings[0];
				const COLLADAFW::Effect* effect = getEffect(materialBinding);
				if ( !effect )
					return true;
				Mtl* newMaterial = getMaxMaterial(*effect, materialBinding, geometryUniqueId);
				maxNode->SetMtl( newMaterial );
			}
			else
			{
				MultiMtl * multiMaterial = NewDefaultMultiMtl();
				multiMaterial->SetNumSubMtls( largestMaterialId + 1 );
				String multiMaterialName = String(maxNode->GetName()) + "-MultiMaterial";
				multiMaterial->SetName(multiMaterialName.c_str());

				it = materialBindings.begin();
				for ( ; it != materialBindings.end(); ++it)
				{
					const COLLADAFW::MaterialBinding& materialBinding = *it;
					const COLLADAFW::Effect* effect = getEffect(materialBinding);
					if ( !effect )
						continue;
					Mtl* newMaterial = getMaxMaterial(*effect, materialBinding, geometryUniqueId);
					multiMaterial->SetSubMtl( materialBinding.getMaterialId(), newMaterial);
				}
				maxNode->SetMtl( multiMaterial );
			}
		}
		return true;
	}
コード例 #3
0
bool
OfxOverlayInteract::onOverlayKeyDown(TimeValue time,
                                     const RenderScale & renderScale,
                                     ViewIdx view,
                                     Key key,
                                     KeyboardModifiers /*modifiers*/)
{

    EffectInstancePtr effect = getEffect();
    EffectInstanceTLSDataPtr tls = effect->getOrCreateTLSObject();
    EffectActionArgsSetter_RAII actionArgsTls(tls, kOfxInteractActionKeyDown, time, view, renderScale
#ifdef DEBUG
                                              , /*canSetValue*/ true
                                              , /*canBeCalledRecursively*/ true
#endif
                                              );

    ThreadIsActionCaller_RAII actionCaller(toOfxEffectInstance(effect));

    OfxRGBAColourD pickerColor;
    bool hasPicker = hasColorPicker();
    if (hasPicker) {
        pickerColor = colorToOfxColor(getLastColorPickerColor());
    }

    QByteArray keyStr;
    OfxStatus stat = keyDownAction( time, renderScale, view,hasPicker ? &pickerColor : /*colourPicker=*/0, (int)key, keyStr.data() );

    if (stat == kOfxStatOK) {
        return true;
    }


    return false;
}
コード例 #4
0
void
OfxOverlayInteract::drawOverlay(TimeValue time,
                                const RenderScale & renderScale,
                                ViewIdx view)
{

    EffectInstancePtr effect = getEffect();
    EffectInstanceTLSDataPtr tls = effect->getOrCreateTLSObject();
    EffectActionArgsSetter_RAII actionArgsTls(tls, kOfxInteractActionDraw,  time, view, renderScale
#ifdef DEBUG
                                              , /*canSetValue*/ true
                                              , /*canBeCalledRecursively*/ false
#endif
                                              );

    ThreadIsActionCaller_RAII actionCaller(toOfxEffectInstance(effect));

    OfxRGBAColourD pickerColor;
    bool hasPicker = hasColorPicker();
    if (hasPicker) {
        pickerColor = colorToOfxColor(getLastColorPickerColor());
    }

    drawAction(time, renderScale, view, hasPicker ? &pickerColor : /*colourPicker=*/0);

}
コード例 #5
0
STDMETHODIMP CDropTargetController::Drop(IDataObject * obj, DWORD dwKeys, POINTL ptl, DWORD *pEffect)
{
	HWND hwnd = 0;

	if (ReadHdropData(obj))
	{
		VARIANT_BOOL handled;
		MessageSenderImpl<IDropTargetController>::HandleMessage(0, getEffect(dwKeys, pEffect), 0, 0, &handled);
	} else if (ReadAveDropData(obj, &hwnd))
	{
		VARIANT_BOOL handled;
		MessageSenderImpl<IDropTargetController>::HandleMessage((UINT)hwnd, getEffect(dwKeys, pEffect), 0, 0, &handled);
	}

	return S_OK;
}
コード例 #6
0
	void SonicXNFile::createObjectSection() {
		SonicXNObject *section=new SonicXNObject(getTexture(), getEffect(), getBones());
		section->setHeader(header_object);
		section->setFileMode(file_mode);
		section->setBigEndian(big_endian);
		sections.push_back(section);
	}
コード例 #7
0
bool
OfxOverlayInteract::onOverlayFocusLost(TimeValue time,
                                       const RenderScale & renderScale,
                                       ViewIdx view)
{

    EffectInstancePtr effect = getEffect();
    EffectInstanceTLSDataPtr tls = effect->getOrCreateTLSObject();
    EffectActionArgsSetter_RAII actionArgsTls(tls, kOfxInteractActionLoseFocus, time, view, renderScale
#ifdef DEBUG
                                              , /*canSetValue*/ true
                                              , /*canBeCalledRecursively*/ true
#endif

                                              );

    ThreadIsActionCaller_RAII actionCaller(toOfxEffectInstance(effect));

    OfxRGBAColourD pickerColor;
    bool hasPicker = hasColorPicker();
    if (hasPicker) {
        pickerColor = colorToOfxColor(getLastColorPickerColor());
    }


    OfxStatus stat;
    stat = loseFocusAction(time, renderScale, view, hasPicker ? &pickerColor : /*colourPicker=*/0);
    if (stat == kOfxStatOK) {
        return true;
    }


    return false;
}
コード例 #8
0
ファイル: Pass.cpp プロジェクト: AllenPestaluky/GamePlay
Pass* Pass::clone(Technique* technique, NodeCloneContext &context) const
{
    Effect* effect = getEffect();
    GP_ASSERT(effect);
    effect->addRef();
    Pass* pass = new Pass(getId(), technique, effect);
    RenderState::cloneInto(pass, context);
    return pass;
}
コード例 #9
0
ファイル: Effecting.cpp プロジェクト: Ryxali/SpaceSumo
void Effecting::onCollide(Collideable* other)
{
	switch(other->getType())
	{
	case enttype::PLAYER:
		static_cast<SpaceManImp*>(other)->addEffect(getEffect());
		break;
	default:
		break;
	}
}
コード例 #10
0
ファイル: Effect.cpp プロジェクト: 7h30n3/hyperion
PyObject* Effect::wrapAbort(PyObject *self, PyObject *)
{
	Effect * effect = getEffect();

	// Test if the effect has reached it end time
	if (effect->_timeout > 0 && QDateTime::currentMSecsSinceEpoch() > effect->_endTime)
	{
		effect->_abortRequested = true;
	}

	return Py_BuildValue("i", effect->_abortRequested ? 1 : 0);
}
コード例 #11
0
ファイル: AdminCommands.cpp プロジェクト: armm77/AscEmu
//.admin castall
bool ChatHandler::HandleAdminCastAllCommand(const char* args, WorldSession* m_session)
{
    if (!args)
    {
        RedSystemMessage(m_session, "No spellid specified.");
        return true;
    }

    uint32 spell_id = atol(args);
    auto spell_entry = sSpellCustomizations.GetSpellInfo(spell_id);
    if (!spell_entry)
    {
        RedSystemMessage(m_session, "Spell %u is not a valid spell!", spell_id);
        return true;
    }

    for (uint8 i = 0; i < 3; ++i)
    {
        if (spell_entry->getEffect(i) == SPELL_EFFECT_LEARN_SPELL)
        {
            sGMLog.writefromsession(m_session, "used learn spell stopped %u", spell_id);
            RedSystemMessage(m_session, "Learn spell specified.");
            return true;
        }
    }

    sGMLog.writefromsession(m_session, "used castall command, spellid %u", spell_id);

    PlayerStorageMap::const_iterator itr;
    objmgr._playerslock.AcquireReadLock();
    for (itr = objmgr._players.begin(); itr != objmgr._players.end(); ++itr)
    {
        Player* player = itr->second;
        if (player->GetSession() && player->IsInWorld())
        {
            if (player->GetMapMgr() != m_session->GetPlayer()->GetMapMgr())
            {
                sEventMgr.AddEvent(static_cast< Unit* >(player), &Unit::EventCastSpell, static_cast< Unit* >(player), spell_entry, EVENT_PLAYER_CHECKFORCHEATS, 100, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
            }
            else
            {
                Spell* spell = sSpellFactoryMgr.NewSpell(player, spell_entry, true, 0);
                SpellCastTargets targets(player->getGuid());
                spell->prepare(&targets);
            }
        }
    }
    objmgr._playerslock.ReleaseReadLock();

    BlueSystemMessage(m_session, "Casted spell %u on all players!", spell_id);
    return true;
}
コード例 #12
0
ファイル: HeroBonus.cpp プロジェクト: DavidZeni/vcmi
ui32 IBonusBearer::Speed( int turn /*= 0*/ , bool useBind /* = false*/) const
{
	//war machines cannot move
	if(hasBonus(Selector::type(Bonus::SIEGE_WEAPON).And(Selector::turns(turn))))
	{
		return 0;
	}
	//bind effect check - doesn't influence stack initiative
	if (useBind && getEffect (SpellID::BIND))
	{
		return 0;
	}

	return valOfBonuses(Selector::type(Bonus::STACKS_SPEED).And(Selector::turns(turn)));
}	
コード例 #13
0
bool
OfxOverlayInteract::onOverlayPenMotion(TimeValue time,
                                      const RenderScale & renderScale,
                                      ViewIdx view,
                                      const QPointF & viewportPos,
                                       const QPointF & pos,
                                       double pressure,
                                       TimeValue /*timestamp*/)
{

    OfxPointD penPos;
    penPos.x = pos.x();
    penPos.y = pos.y();
    OfxPointI penPosViewport;
    penPosViewport.x = viewportPos.x();
    penPosViewport.y = viewportPos.y();
    OfxStatus stat;


    EffectInstancePtr effect = getEffect();
    EffectInstanceTLSDataPtr tls = effect->getOrCreateTLSObject();
    EffectActionArgsSetter_RAII actionArgsTls(tls, kOfxInteractActionPenMotion, time, view, renderScale
#ifdef DEBUG
                                              , /*canSetValue*/ true
                                              , /*canBeCalledRecursively*/ true
#endif
                                              );

    ThreadIsActionCaller_RAII actionCaller(toOfxEffectInstance(effect));

    OfxRGBAColourD pickerColor;
    bool hasPicker = hasColorPicker();
    if (hasPicker) {
        pickerColor = colorToOfxColor(getLastColorPickerColor());
    }

    stat = penMotionAction(time, renderScale, view, hasPicker ? &pickerColor : /*colourPicker=*/0, penPos, penPosViewport, pressure);

    if (stat == kOfxStatOK) {
        return true;
    }


    return false;
}
コード例 #14
0
	void SonicXNFile::setFileMode(XNFileMode target_file_mode) {
		SonicXNObject  *object=getObject();
		SonicXNTexture *texture=getTexture();
		SonicXNEffect  *effect=getEffect();
		SonicXNBones   *bones=getBones();
		SonicXNMotion  *motion=getMotion();

		file_mode = target_file_mode;

		setHeaders();

		if (info) {
			info->setHeader(header_info);
			info->setFileMode(file_mode);
		}

		if (object)  {
			object->setFileMode(file_mode);
			object->setHeader(header_object);
		}
		if (texture) {
			texture->setFileMode(file_mode);
			texture->setHeader(header_texture);
		}
		if (effect)  {
			effect->setFileMode(file_mode);
			effect->setHeader(header_effect);
		}
		if (bones)   {
			bones->setFileMode(file_mode);
			bones->setHeader(header_bones);
		}
		if (motion)  {
			motion->setFileMode(file_mode);
			motion->setHeader(header_motion);
		}

		if (offset_table) offset_table->setFileMode(file_mode);
		if (footer) footer->setFileMode(file_mode);
		if (end) end->setFileMode(file_mode);
	}
コード例 #15
0
STDMETHODIMP CDropTargetController::DragEffect(DWORD dwKeys, POINTL ptl, DWORD * pEffect)
{
	// The mouse should be over a particular overlay for the controller to respond.
	DWORD selEffect = getEffect(dwKeys, pEffect);

	if (selEffect == DROPEFFECT_NONE)
	{
		*pEffect = DROPEFFECT_NONE;
		return S_OK;
	}

	IOverlay *pOverlay = 0;
	get_Overlay(&pOverlay);
	DWORD pEff = DROPEFFECT_NONE;
	POINT local = {ptl.x, ptl.y};
	long hWnd;
	model->get_hWnd(&hWnd);
	::ScreenToClient((HWND)hWnd, &local);

	if (pOverlay != NULL)
	{
		ISimpleOverlay2 *pOverlay2 = 0;
		pOverlay->QueryInterface(__uuidof(ISimpleOverlay2), (void**)&pOverlay2);
		if (pOverlay2)
		{
			VARIANT_BOOL d = false;

			pOverlay2->HitTest((short)local.x, (short)local.y, &d);
			if (d)
			{
				pEff = selEffect;
			}

			pOverlay2->Release();
		}
	}

	*pEffect = pEff;

	return S_OK;
}
コード例 #16
0
void
OfxOverlayInteract::onViewportSelectionUpdated(const RectD& rectangle, bool onRelease)
{
    OfxEffectInstancePtr effect = toOfxEffectInstance(getEffect());
    if (!effect) {
        return;
    }
    KnobIPtr foundSelKnob = effect->getKnobByName(kNatronOfxImageEffectSelectionRectangle);
    if (!foundSelKnob) {
        return;
    }

    KnobIntPtr isIntKnob = toKnobInt(foundSelKnob);
    if (!isIntKnob) {
        return;
    }
    
    double propV[4] = {rectangle.x1, rectangle.y1, rectangle.x2, rectangle.y2};
    effect->effectInstance()->getProps().setDoublePropertyN(kNatronOfxImageEffectSelectionRectangle, propV, 4);
    isIntKnob->setValue(onRelease ? 2 : 1);
}
コード例 #17
0
void
OfxOverlayInteract::onViewportSelectionCleared()
{
    OfxEffectInstancePtr effect = toOfxEffectInstance(getEffect());
    if (!effect) {
        return;
    }
    KnobIPtr foundSelKnob = effect->getKnobByName(kNatronOfxImageEffectSelectionRectangle);
    if (!foundSelKnob) {
        return;
    }

    KnobIntPtr isIntKnob = toKnobInt(foundSelKnob);
    if (!isIntKnob) {
        return;
    }


    double propV[4] = {0, 0, 0, 0};
    effect->effectInstance()->getProps().setDoublePropertyN(kNatronOfxImageEffectSelectionRectangle, propV, 4);
    isIntKnob->setValue(0);
}
コード例 #18
0
 bool PercussionChoice::fromXElementImpl( std::ostream& message, xml::XElement& xelement )
 {
     if( xelement.getName() == "glass" )
     {
         myChoice = Choice::glass;
         return getGlass()->fromXElement( message, xelement );
     }
     
     if( xelement.getName() == "metal" )
     {
         myChoice = Choice::metal;
         return getMetal()->fromXElement( message, xelement );
     }
     
     if( xelement.getName() == "wood" )
     {
         myChoice = Choice::wood;
         return getWood()->fromXElement( message, xelement );
     }
     
     if( xelement.getName() == "pitched" )
     {
         myChoice = Choice::pitched;
         return getPitched()->fromXElement( message, xelement );
     }
     
     if( xelement.getName() == "membrane" )
     {
         myChoice = Choice::membrane;
         return getMembrane()->fromXElement( message, xelement );
     }
     
     if( xelement.getName() == "effect" )
     {
         myChoice = Choice::effect;
         return getEffect()->fromXElement( message, xelement );
     }
     
     if( xelement.getName() == "timpani" )
     {
         myChoice = Choice::timpani;
         return getTimpani()->fromXElement( message, xelement );
     }
     
     if( xelement.getName() == "beater" )
     {
         myChoice = Choice::beater;
         return getBeater()->fromXElement( message, xelement );
     }
     
     if( xelement.getName() == "stick" )
     {
         myChoice = Choice::stick;
         return getStick()->fromXElement( message, xelement );
     }
     
     if( xelement.getName() == "stick-type" )
     {
         myChoice = Choice::stickType;
         return getStickType()->fromXElement( message, xelement );
     }
     
     if( xelement.getName() == "stick-material" )
     {
         myChoice = Choice::stickMaterial;
         return getStickMaterial()->fromXElement( message, xelement );
     }
     
     if( xelement.getName() == "stick-location" )
     {
         myChoice = Choice::stickLocation;
         return getStickLocation()->fromXElement( message, xelement );
     }
     
     if( xelement.getName() == "other-percussion" )
     {
         myChoice = Choice::otherPercussion;
         return getOtherPercussion()->fromXElement( message, xelement );
     }
     
     MX_BAD_ELEMENT_FAILURE( PercussionChoice );
 }
コード例 #19
0
ファイル: Effect.cpp プロジェクト: 7h30n3/hyperion
PyObject* Effect::wrapSetColor(PyObject *self, PyObject *args)
{
	// get the effect
	Effect * effect = getEffect();

	// check if we have aborted already
	if (effect->_abortRequested)
	{
		return Py_BuildValue("");
	}

	// determine the timeout
	int timeout = effect->_timeout;
	if (timeout > 0)
	{
		timeout = effect->_endTime - QDateTime::currentMSecsSinceEpoch();

		// we are done if the time has passed
		if (timeout <= 0)
		{
			return Py_BuildValue("");
		}
	}

	// check the number of arguments
	int argCount = PyTuple_Size(args);
	if (argCount == 3)
	{
		// three seperate arguments for red, green, and blue
		ColorRgb color;
		if (PyArg_ParseTuple(args, "bbb", &color.red, &color.green, &color.blue))
		{
			std::fill(effect->_colors.begin(), effect->_colors.end(), color);
			effect->setColors(effect->_priority, effect->_colors, timeout, false);
			return Py_BuildValue("");
		}
		else
		{
			return nullptr;
		}
	}
	else if (argCount == 1)
	{
		// bytearray of values
		PyObject * bytearray = nullptr;
		if (PyArg_ParseTuple(args, "O", &bytearray))
		{
			if (PyByteArray_Check(bytearray))
			{
				size_t length = PyByteArray_Size(bytearray);
				if (length == 3 * effect->_imageProcessor->getLedCount())
				{
					char * data = PyByteArray_AS_STRING(bytearray);
					memcpy(effect->_colors.data(), data, length);
					effect->setColors(effect->_priority, effect->_colors, timeout, false);
					return Py_BuildValue("");
				}
				else
				{
					PyErr_SetString(PyExc_RuntimeError, "Length of bytearray argument should be 3*ledCount");
					return nullptr;
				}
			}
			else
			{
				PyErr_SetString(PyExc_RuntimeError, "Argument is not a bytearray");
				return nullptr;
			}
		}
		else
		{
			return nullptr;
		}
	}
	else
	{
		PyErr_SetString(PyExc_RuntimeError, "Function expect 1 or 3 arguments");
		return nullptr;
	}

	// error
	PyErr_SetString(PyExc_RuntimeError, "Unknown error");
	return nullptr;
}
コード例 #20
0
	SonicXNSection *SonicXNFile::readSection(File *file) {
		string identifier="";
		file->readString(&identifier, 4);

		if (identifier == header_info) {
			info = new SonicXNInfo();
			info->setHeader(header_info);
			info->setFileMode(file_mode);
			info->setBigEndian(big_endian);
			info->read(file);
			info->goToEnd(file);
			
			for (size_t i=0; i<info->getSectionCount(); i++) {
				SonicXNSection *section=readSection(file);
				if (section) {
					section->goToEnd(file);
					sections.push_back(section);
				}
			}
		}
		else if (identifier == LIBGENS_XNSECTION_HEADER_OFFSET_TABLE) {
			offset_table = new SonicXNOffsetTable();
			offset_table->setHeader(LIBGENS_XNSECTION_HEADER_OFFSET_TABLE);
			offset_table->setFileMode(file_mode);
			offset_table->setBigEndian(big_endian);
			offset_table->read(file);
			offset_table->goToEnd(file);
		}
		else if (identifier == header_texture) {
			SonicXNTexture *section=new SonicXNTexture();
			section->setHeader(header_texture);
			section->setFileMode(file_mode);
			section->setBigEndian(big_endian);
			section->read(file);
			return section;
		}
		else if (identifier == header_effect) {
			SonicXNEffect *section=new SonicXNEffect();
			section->setHeader(header_effect);
			section->setFileMode(file_mode);
			section->setBigEndian(big_endian);
			section->read(file);
			return section;
		}
		else if (identifier == header_object) {
			SonicXNObject *section=new SonicXNObject(getTexture(), getEffect(), getBones());
			section->setHeader(header_object);
			section->setFileMode(file_mode);
			section->setBigEndian(big_endian);
			section->read(file);

			return section;
		}
		else if (identifier == header_bones) {
			SonicXNBones *section=new SonicXNBones();
			section->setHeader(header_bones);
			section->setFileMode(file_mode);
			section->setBigEndian(big_endian);
			section->read(file);
			return section;
		}
		else if (identifier == header_motion) {
			SonicXNMotion *section=new SonicXNMotion();
			section->setHeader(header_motion);
			section->setFileMode(file_mode);
			section->setBigEndian(big_endian);
			section->read(file);
			return section;
		}
		else if (identifier == LIBGENS_XNSECTION_HEADER_FOOTER) {
			footer=new SonicXNFooter();
			footer->setHeader(LIBGENS_XNSECTION_HEADER_FOOTER);
			footer->setFileMode(file_mode);
			footer->setBigEndian(big_endian);
			footer->read(file);
			footer->goToEnd(file);
			return footer;
		}
		else if (identifier == LIBGENS_XNSECTION_HEADER_END) {
			end=new SonicXNEnd();
			end->setHeader(LIBGENS_XNSECTION_HEADER_END);
			end->setFileMode(file_mode);
			end->setBigEndian(big_endian);
			end->read(file);
			end->goToEnd(file);
			return end;
		}

		return NULL;
	}
コード例 #21
0
ファイル: item.c プロジェクト: ChrisAubuchon/bard
void convertItems(void)
{
	cnvList_t	*il;
	btitem_t	*b;
	uint32_t	i;

	il = itemList_new();
	for (i = 0; i < 127; i++) {
		b = btitem_new();

		b->name = bts_strcpy(itemName[i]);
		debug("Item: %s\n", b->name->buf);
		b->macro = bts_strcpy(itemName[i]);
		str2macro(b->macro->buf);

		if (i < 22)
			b->shopCount = -1;
		else
			b->shopCount = 0;

		b->type = itemType[i] & 0x0f;
		b->eclass = itemEClass[i] & 0x0f;
		b->spAttack = itemType[i] >> 4;
		b->canUse = (itemSpell[i] != 0);

		b->ieffect = getEffect(i);

		b->hasCharges = (itemCount[i] != 0xff);
		b->maxCount = (itemCount[i] == 0xff) ? 0 : itemCount[i];

		b->combat = IFBIT(itemEffect[i], 0x80, 1, 0);

		b->dmgBonus = itemDmgAc[i] >> 4;
		b->acBonus = itemDmgAc[i] & 0x0f;

		if (b->type == 1) {
			b->ndice = NDICE(itemDmgDice[i]);
			b->die = DIEVAL(itemDmgDice[i]);
		}

		b->canEquip.warrior = IFBIT(itemEquipMask[i], 0x80, 1, 0);
		b->canEquip.paladin = IFBIT(itemEquipMask[i], 0x04, 1, 0);
		b->canEquip.rogue = IFBIT(itemEquipMask[i], 0x10, 1, 0);
		b->canEquip.bard = IFBIT(itemEquipMask[i], 0x08, 1, 0);
		b->canEquip.hunter = IFBIT(itemEquipMask[i], 0x02, 1, 0);
		b->canEquip.monk = IFBIT(itemEquipMask[i], 0x01, 1, 0);
		b->canEquip.conjurer = IFBIT(itemEquipMask[i], 0x40, 1, 0);
		b->canEquip.magician = IFBIT(itemEquipMask[i], 0x40, 1, 0);
		b->canEquip.sorcerer = IFBIT(itemEquipMask[i], 0x40, 1, 0);
		b->canEquip.wizard = IFBIT(itemEquipMask[i], 0x20, 1, 0);
		b->canEquip.archmage = IFBIT(itemEquipMask[i], 0x20, 1, 0);

#if 0
		if (itemSpell[i] == 0) {
			b->targetted = 0;
		} else {
			b->targetted = ((spellAttr[itemSpell[i]] & 7) < 4);
		}
#endif

		b->value = getValue(itemValue[i]);

		uint8_t spell = itemSpell[i];
		printf("%d: %d\n", i, spell);
		if (spell) {
			getTargetting(itemSpell[i], &b->targetting);
			if (spell > 111) {
				debug("spell = %d\n", spell);
				b->action = getSummonEffect(spell);
			} else {
				b->action = getSpellAction(spell);
			}

			if (spell < 79) {
				b->use = USE_CASTSPELL;
			} else if (spell < 96) {
				b->use = USE_BREATH;
			} else if ((spell == 96) || (spell == 97)) {
				b->use = USE_MAKELIGHT;
			} else if (spell < 112) {
				bteAttack_t	*ba;

				ba = btEffect_attack(b->action->effect);
				ba->fireString = useWeap[spell - 98];
			} else {
				b->use = USE_FIGURINE;
			}
		}

		cnvList_add(il, b);

	}

	itemList_to_json(il, mkJsonPath("items.json"));
	shopList_to_json(il, mkJsonPath("garthinv.json"));
	cnvList_free(il);

	
#if 0
	/*
	 * This block of code generates IDC commands to define an
	 * enum of all of the item names for IDA
	 */
	printf("static main() {\n");
	printf("auto eid;\n");
	printf("eid = GetEnum(\"itemName\");\n");
	for (i = 0; i < 127; i++) {
		btstring_t *buf;

		buf = bts_strcpy(itemName[i]);
		str2macro(buf->buf);
		printf("AddConstEx(eid, \"item_%s\", %d, -1);\n",
			buf->buf, i+1);
		bts_free(buf);
	}
	printf("}");
#endif

}
コード例 #22
0
ファイル: Effect.cpp プロジェクト: 7h30n3/hyperion
PyObject* Effect::wrapSetImage(PyObject *self, PyObject *args)
{
	// get the effect
	Effect * effect = getEffect();

	// check if we have aborted already
	if (effect->_abortRequested)
	{
		return Py_BuildValue("");
	}

	// determine the timeout
	int timeout = effect->_timeout;
	if (timeout > 0)
	{
		timeout = effect->_endTime - QDateTime::currentMSecsSinceEpoch();

		// we are done if the time has passed
		if (timeout <= 0)
		{
			return Py_BuildValue("");
		}
	}

	// bytearray of values
	int width, height;
	PyObject * bytearray = nullptr;
	if (PyArg_ParseTuple(args, "iiO", &width, &height, &bytearray))
	{
		if (PyByteArray_Check(bytearray))
		{
			int length = PyByteArray_Size(bytearray);
			if (length == 3 * width * height)
			{
				Image<ColorRgb> image(width, height);
				char * data = PyByteArray_AS_STRING(bytearray);
				memcpy(image.memptr(), data, length);

				effect->_imageProcessor->process(image, effect->_colors);
				effect->setColors(effect->_priority, effect->_colors, timeout, false);
				return Py_BuildValue("");
			}
			else
			{
				PyErr_SetString(PyExc_RuntimeError, "Length of bytearray argument should be 3*width*height");
				return nullptr;
			}
		}
		else
		{
			PyErr_SetString(PyExc_RuntimeError, "Argument 3 is not a bytearray");
			return nullptr;
		}
	}
	else
	{
		return nullptr;
	}

	// error
	PyErr_SetString(PyExc_RuntimeError, "Unknown error");
	return nullptr;
}
コード例 #23
0
ファイル: abjuration.cpp プロジェクト: RealmsMud/RealmsCode
void Creature::doDispelMagic(int num) {
    EffectInfo* effect=0;
    std::list<bstring> effList;
    std::list<bstring>::const_iterator it;

    // create a list of possible effects
    effList.push_back("anchor");
    effList.push_back("hold-person");
    effList.push_back("strength");
    effList.push_back("haste");
    effList.push_back("fortitude");
    effList.push_back("insight");
    effList.push_back("prayer");
    effList.push_back("enfeeblement");
    effList.push_back("slow");
    effList.push_back("weakness");
    effList.push_back("prayer");
    effList.push_back("damnation");
    effList.push_back("confusion");

    effList.push_back("enlarge");
    effList.push_back("reduce");
    effList.push_back("darkness");
    effList.push_back("infravision");
    effList.push_back("invisibility");
    effList.push_back("detect-invisible");
    effList.push_back("undead-ward");
    effList.push_back("bless");
    effList.push_back("detect-magic");
    effList.push_back("protection");
    effList.push_back("tongues");
    effList.push_back("comprehend-languages");
    effList.push_back("true-sight");
    effList.push_back("fly");
    effList.push_back("levitate");
    effList.push_back("drain-shield");
    effList.push_back("resist-magic");
    effList.push_back("know-aura");
    effList.push_back("warmth");
    effList.push_back("breathe-water");
    effList.push_back("earth-shield");
    effList.push_back("reflect-magic");
    effList.push_back("camouflage");
    effList.push_back("heat-protection");
    effList.push_back("farsight");
    effList.push_back("pass-without-trace");
    effList.push_back("resist-earth");
    effList.push_back("resist-air");
    effList.push_back("resist-fire");
    effList.push_back("resist-water");
    effList.push_back("resist-cold");
    effList.push_back("resist-electricity");
    effList.push_back("wind-protection");
    effList.push_back("static-field");

    effList.push_back("illusion");
    effList.push_back("blur");
    effList.push_back("fire-shield");
    effList.push_back("greater-invisibility");

    // true we'll show, false don't remove perm effects

    // num = -1 means dispel all effects
    if(num <= -1) {
        for(it = effList.begin() ; it != effList.end() ; it++)
            removeEffect(*it, true, false);
        return;
    }

    int numEffects=0, choice=0;
    while(num > 0) {
        // how many effects are we under?
        for(it = effList.begin() ; it != effList.end() ; it++) {
            effect = getEffect(*it);
            if(effect && !effect->isPermanent())
                numEffects++;
        }

        // none? we're done
        if(!numEffects)
            return;
        // which effect shall we dispel?
        choice = mrand(1, numEffects);
        numEffects = 0;

        // find it and get rid of it!
        for(it = effList.begin() ; it != effList.end() && choice ; it++) {
            effect = getEffect(*it);
            if(effect && !effect->isPermanent()) {
                numEffects++;
                if(choice == numEffects) {
                    removeEffect(*it, true, false);
                    // stop the loop!
                    choice = 0;
                }
            }
        }

        num--;
    }
}