• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Cast a spell on hit

Holloweye

New Member
Joined
Jul 13, 2007
Messages
52
Reaction score
4
So I have been working with a attribute for items that will give you a certen % of chance to cast a spell. It look like this in the items.xml:
Code:
<item id="2380" article="a" name="hand axe">
	<attribute key="weight" value="1800" />
	<attribute key="spellOnHit" value="Light" chance="50" />
	<attribute key="defense" value="6" />
	<attribute key="attack" value="5" />
	<attribute key="weaponType" value="axe" />
</item>
So each time you hit a monster/player you have 50% chance to cast a utevo lux for free(no mana cost). And your character dose it automaticly. Well lets come to the problem... I have everything with the attributes and such ready. Its when I try to call the spell the server freeze this is how it looks like:
Code:
for(int32_t i = SLOT_FIRST; i < SLOT_LAST; ++i)
{
	if(Item* item = getInventoryItem((slots_t)i))
	{
            if(item->getSpellChanceOnHit() > 0 && item->getSpellChanceOnHit() <= 100)
            {
                 if(g_spells->getInstantSpellByName(item->getSpellNameOnHit()) != NULL)
                 {   
                       (g_spells->getInstantSpellByName(item->getSpellNameOnHit()))->playerCastInstant(this,"");
                 }
            }
      }
}
Note: I haven't added the random procentage yet just because iam testing.

I have been trying with castSpell() function also. But same effect.

Thanks for help :)
 
I want to do it only in C++ no LUA scripting. I have been trying some. I have made it so it dont crash anymore.. its a start :).
 
Back
Top