• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Spell that has a 50% to kill you and 50% to throw the spell

DestinationSer

@echo off
Joined
Mar 7, 2009
Messages
2,806
Solutions
1
Reaction score
676
Hi! I am wondering, how can I make a spell have 50% chance to kill you and a 50% to throw the spell when you cast it?
Heres the script
Code:
local time = 120 * 1000 -- 120 * 1000 = 2 min
local addShield = 200 -- how much shielding should be added
local addSword = 50 -- how much mana should be added


local wolf = {lookType = 54, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0}
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, time)
setConditionParam(condition, CONDITION_PARAM_SKILL_Shield, addShield)
setConditionParam(condition, CONDITION_PARAM_SKILL_SWORD, addSword)
setConditionParam(condition, CONDITION_PARAM_BUFF, TRUE)
setCombatCondition(combat, condition)

local speed = createConditionObject(CONDITION_HASTE)
setConditionParam(speed, CONDITION_PARAM_TICKS, time)
setConditionFormula(speed, 1.0, 996156, 1.0, 996156)
setCombatCondition(combat, speed)

local outfit = createConditionObject(CONDITION_OUTFIT)
setConditionParam(outfit, CONDITION_PARAM_TICKS, time)
addOutfitCondition(outfit, wolf)
setCombatCondition(combat, outfit)

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 0)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, time)
setCombatCondition(combat, exhaust)

function onCastSpell(cid, var)
return doCombat(cid, combat, var)
end
 
Try using math.random:

Code:
local time = 120 * 1000 -- 120 * 1000 = 2 min
local addShield = 200 -- how much shielding should be added
local addSword = 50 -- how much mana should be added


local wolf = {lookType = 54, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0}
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, time)
setConditionParam(condition, CONDITION_PARAM_SKILL_Shield, addShield)
setConditionParam(condition, CONDITION_PARAM_SKILL_SWORD, addSword)
setConditionParam(condition, CONDITION_PARAM_BUFF, TRUE)
setCombatCondition(combat, condition)

local speed = createConditionObject(CONDITION_HASTE)
setConditionParam(speed, CONDITION_PARAM_TICKS, time)
setConditionFormula(speed, 1.0, 996156, 1.0, 996156)
setCombatCondition(combat, speed)

local outfit = createConditionObject(CONDITION_OUTFIT)
setConditionParam(outfit, CONDITION_PARAM_TICKS, time)
addOutfitCondition(outfit, wolf)
setCombatCondition(combat, outfit)

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 0)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, time)
setCombatCondition(combat, exhaust)

function onCastSpell(cid, var)
local chance = math.random(1,2)
if chance == 1 then
return doCombat(cid, combat, var)
else
return doCreatureAddHealth(cid, -getCreatureHealth(cid))
end
 

Similar threads

Back
Top