View Single Post
  #2  
Old 01-19-2008, 11:48 AM
zeiksz2
Fire Beetle
 
Join Date: Oct 2007
Posts: 20
Default mob fizzle

well to make mobs fizzle you are to insert some code - since there is no way a mob to fizzle normally there is nothing in yet

into mob::CheckFizzle
Code:
	//after player code we should have always 5% to fizzle
	//rest is kinda unimportant here, since mobs have always max skill points
	if (MakeRandomInt(1,100) <= 5) return false;
	return true;
you can play with lowering the success rate by checking the spell level too (saying that you fizzle more on lower levels).

this is not enough you are to insert a line too into mob::CastSpell
Code:
	// check for fizzle
	// note that CheckFizzle itself doesn't let NPCs fizzle,
	// but this code allows for it.
	if(slot < MAX_PP_MEMSPELL && !CheckFizzle(spell_id))
	{
		int fizzle_msg = IsBardSong(spell_id) ? MISS_NOTE : SPELL_FIZZLE;
		InterruptSpell(fizzle_msg, 0x121, spell_id);
		
		uint32 use_mana = mana_cost / 4;
		mlog(SPELLS__CASTING_ERR, "Spell casting canceled: fizzled. %d mana has been consumed", use_mana);
		
		// fizzle 1/4 the mana away
		SetMana(GetMana() - use_mana);

******** extra start

		//if NPC fizzles...
		if (IsNPC()) CastToNPC()->AI_Event_SpellCastFinished(false, slot);

******** extra end

		return(false);
	}
inserted all of that block here so you can find it easier
Reply With Quote