Цитата(RL_ka @ 7.11.2014, 3:33)

Слабое место: если в момент задержки, между началом хила и окончанием, чар выйдет в логаут по какой-то причине, то HealSelf на нём навсегда останется равной еденице и твой скрипт перестанет работать.
В этом случае нужно обязательно прописать в logon и reconnect скрипты стирание этой проперти.
ps. В случае, если Attach удовлетворит всем твоим потребностям, то подобные "костыли" будут не нужны
на самом деле хотелось поэкспериментировать с пропертисами )))
с аттачем все работает как надо:
Код
use uo;
use os;
use util;
use math;
include "include/itemUtil";
include ":attributes:attributes";
include ":classes:classes";
include ":death:resurrection";
include ":equipment:protections";
include ":timedscripts:timedScripts";
program textcmd_BandageSelf( who )
if( who.dead )
return 0;
endif
if (who.attached)
SendSysMessage(who, "You are already doing something else.");
return 0;
endif
var bandage;
foreach item in ( EnumerateItemsInContainer( who.backpack ) )
if (item.objtype == 0xEE9)
bandage := item;
endif
endforeach
if (!bandage)
SendSysMessage(who, "You have no bandages....");
return 0;
endif
Attach(who);
if( who.poisoned )
CureSelf( who, bandage );
else
HealPatient( who, bandage );
endif
endprogram
function CureSelf( who, bandage )
if( !SubtractAmount( bandage, 2 ))
SendSysMessage( who, "You don't have enough bandages." );
return 0;
else
SendSysMessage( who, "You start to cure yourself." );
endif
var vital := AP_GetVital( who, HITS ),
delay := 10;
while( Cint( delay ))
Sleep( 1 );
delay -= 1;
if( who.dead || !who.poisoned )
SendSysMessage( who, "You have lost your concentration." );
return 0;
elseif( AP_GetVital( who, HITS ) < vital )
if( !SubtractAmount( bandage, 2 ))
SendSysMessage( who, "You don't have enough bandages." );
SendSysMessage( who, "You couldn't cure yourself." );
return 0;
else
SendSysMessage( who, "Yours fingers slip..." );
CreateItemInBackpack( who, 0x0e20, 1 );
vital := AP_GetVital( who, HITS );
endif
endif
endwhile
var current_poison := CInt( GetObjProperty( who, "#PoisonedLevel" ));
if( !current_poison )
SendSysMessage( who, "That is not poisoned." );
return 0;
endif
var bonus := CInt( GetMobileProtection( who, "HealingIncrease" ));
if( bonus )
bonus := CInt( bonus * 5 );
endif
var difficulty := CInt(( current_poison * 25 ) + 15 ),
healing := AP_GetSkill( who, HEALING );
if( SkillCheck( who, HEALING, CInt( difficulty )) > 0 || healing >= CInt( difficulty - bonus ))
SendSysMessage( who, "You cured level "+current_poison+" poison." );
TS_LowerDuration( who, "DefaultPoison", -1 );
else
SendSysMessage( who, "You couldn't cure yourself!" );
endif
CreateItemInBackpack( who, 0x0e20, 2 );
return 1;
endfunction
function HealPatient( who, bandage )
var max_vital := AP_GetStat( who, STRENGTH ),
vital := AP_GetVital( who, HITS );
if( CInt( vital ) >= CInt( max_vital ))
SendSysMessage( who, "This patient don't have a bruise!" );
return 0;
elseif( !SubtractAmount( bandage, 1 ))
SendSysMessage( who, "You don't have enough bandages." );
return 0;
else
SendSysMessage( who, "You start to heal yourself." );
endif
var delay := 7;
while( Cint( delay ))
Sleep( 1 );
delay -= 1;
if( CInt( vital ) >= CInt( max_vital ))
SendSysMessage( who, "This patient don't have a bruise!" );
return 0;
elseif( AP_GetVital( who, HITS ) < vital )
if( !SubtractAmount( bandage, 1 ))
SendSysMessage( who, "You don't have enough bandages." );
SendSysMessage( who, "You couldn't heal yourself." );
return 0;
else
SendSysMessage( who, "Yours fingers slip..." );
CreateItemInBackpack( who, 0x0e20, 1 );
vital := AP_GetVital( who, HITS );
endif
endif
endwhile
var difficulty := CInt( AP_GetStat( who, STRENGTH ) - AP_GetVital( who, HITS ));
if( difficulty > 65 )
difficulty := 65;
endif
if( SkillCheck( who, HEALING, difficulty ) > 0 )
var heal := HL_GetAmount( who );
SendSysMessage( who, "You heal "+heal+" damages." );
HealDamage( who, heal );
else
SendSysMessage( who, "You couldn't heal yourself." );
endif
CreateItemInBackpack( who, 0x0e20, 1 );
return 1;
endfunction
function HL_GetAmount( who )
var heal_skill := CInt( AP_GetSkill( who, HEALING ) / 10 );
var anat_skill := CInt( AP_GetSkill( who, ANATOMY ) / 15 );
var heal := RandomDiceRoll( CInt( heal_skill )+"d4+"+CInt( heal_skill )) + RandomDiceRoll( "1d8+2" ) + CInt( anat_skill );
var bonus := CInt( GetMobileProtection( who, "HealingIncrease" ));
if( bonus )
heal *= CDbl(( bonus * 0.1 ) + 1 );
endif
if( GetObjProperty( who, WARRIOR ))
heal *= ClasseBonus( who, WARRIOR );
endif
return CInt( heal );
endfunction