Unable to ride animals

Report core bugs regarding the Ultima Online Emulator Core release (version 097). You can attach your Core Dump. One bug per post.

Moderator: POL Developer

Locked
dbagr
New User
Posts: 6
Joined: Wed Apr 25, 2007 2:15 am

Unable to ride animals

Post by dbagr »

Hello people,

I downloaded yesterday the pol-core-097-2007-04-15-RC3-Coregina.zip,
the 097-BasicSetup.zip and 097-Converted.zip all for Windows.

Compiled all scripts and start the POL.

Now I'm unable to ride animals.

Could you help me ?
Pierce
Forum Regular
Posts: 420
Joined: Thu Feb 02, 2006 8:33 am

Post by Pierce »

Assuming that the scripts you use are containing the handling to ride an animal, it sounds to me that you did not uoconvert the tiledata or something went wrong with this conversion.
Try uoconvert tiles again and copy the tiles.cfg into the config directory. Then restart the server.
dbagr
New User
Posts: 6
Joined: Wed Apr 25, 2007 2:15 am

Post by dbagr »

Thanks ...
I tried your suggestion but it didn't work...

Other Ideas ?

Another thing... My SpellBook contains only Clumsy repeated more and more time.

Ciao
FreeSoul
Master Poster
Posts: 90
Joined: Sat Feb 04, 2006 9:14 am
Location: Aman

Post by FreeSoul »

check declaration of spellbok in itemdesc.cfg

should be:

Code: Select all

Spellbook 0x0EFA
{
    Name                Spellbook
    desc                spellbook
//(...)
    SpellType            Magic
}
dbagr
New User
Posts: 6
Joined: Wed Apr 25, 2007 2:15 am

Post by dbagr »

I heve the following in the itemdesc.cfg:
-
Container 0x0EFA
{
Name Spellbook
desc spellbook
OnInsertScript scrollInsert
Gump 0xFFFF
MinX 40
MaxX 60
MinY 20
MaxY 80
Newbie 1
BlocksCastingIfInHand 0
RequiresAttention 0
VendorSellsFor 22
VendorBuysFor 11
weight 1
CanInsertScript ::canInsert
OnInsertScript ::onInsert
CanRemoveScript ::canRemove
OnRemoveScript ::onRemove
}
FreeSoul
Master Poster
Posts: 90
Joined: Sat Feb 04, 2006 9:14 am
Location: Aman

Post by FreeSoul »

change container to spellbook and add
SpellType Magic
dbagr
New User
Posts: 6
Joined: Wed Apr 25, 2007 2:15 am

Post by dbagr »

FreeSoul wrote:change container to spellbook and add
SpellType Magic
Thanks....it works.

Any Ideas for RIDE ?
FreeSoul
Master Poster
Posts: 90
Joined: Sat Feb 04, 2006 9:14 am
Location: Aman

Post by FreeSoul »

i have to see your tamed.src
and uoconvert.cfg :)
dbagr
New User
Posts: 6
Joined: Wed Apr 25, 2007 2:15 am

Post by dbagr »

Thanks the both codes for you..

uoconvert.cfg:

Code: Select all

LOSOptions
{
    UseNoShoot        0
    LOSThroughWindows 0
}

StaticOptions
{
    MaxStaticsPerBlock        1000
    WarningStaticsPerBlock    1000
    ShowIllegalGraphicWarning 1
}

TileOptions
{
    ShowRoofAndPlatformWarning 1
}

MultiTypes
{
	Boats 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17
	
	Houses 0x64 0x65 0x66 0x67 0x68 0x69 0x6a 0x6b 0x6c 0x6d 0x6e 0x6f 0x70 0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7a 0x7b 0x7c 0x7d 0x7e 0x7f 0x87 0x8c 0x8d 0x96 0x98 0x9a 0x9c 0x9e 0xa0 0xa2 0x1f4 0x1f5 0x1f6 0x3e8 0x3e9 0x3ea 0x3eb 0x7d0 0x7d1 0x7d2 0x7d3 0x7d4 0x7d5 0x7d6 0x7d7 0xbb8 0xfa0 0xfa1 0xfa2 0xfa3 0xfa4 0xfa5 0xfa6 0xfa7 0xfa8 0xfa9 0xfaa 0xfab 0xfac 0x1388 0x13ec 0x13ed 0x13ee 0x13ef 0x13f0 0x13f1 0x13f8 0x13f9 0x13fa 0x13fb 0x13fc 0x13fd 0x13fe 0x1404 0x1405 0x1406 0x1407 0x1408 0x1409 0x140a 0x140b 0x1410 0x1411 0x1412 0x1413 0x1414 0x1415 0x1416 0x1417 0x1418 0x141c 0x141d 0x141e 0x141f 0x1420 0x1421 0x1422 0x1423 0x1424 0x1425 0x1428 0x1429 0x142a 0x142b 0x142c 0x142d 0x142e 0x142f 0x1430 0x1431 0x1432 0x1435 0x1436 0x1437 0x1438 0x1439 0x143a 0x143b 0x143c 0x143d 0x143e 0x143f 0x1442 0x1443 0x1444 0x1445 0x1446 0x1447 0x1448 0x1449 0x144a 0x144b 0x144f 0x1450 0x1451 0x1452 0x1453 0x1454 0x1455 0x1456 0x1457 0x145c 0x145d 0x145e 0x145f 0x1460 0x1461 0x1462 0x1463 0x1469 0x146a 0x146b 0x146c 0x146d 0x146e 0x146f 0x1476 0x1477 0x1478 0x1479 0x147a 0x147b 
	
	Stairs  0x1d4c 0x1db0 0x1db1 0x1db2 0x1db3 0x1db4 0x1db5 0x1db6 0x1db7 0x1db8 0x1db9 0x1dba 0x1dbb 0x1dbc 0x1dbd 0x1dbe 0x1dbf 0x1dc0 0x1dc1 0x1dc2 0x1dc3 0x1dc4 0x1dc5 0x1dc6 0x1dc7 0x1dc8 0x1dc9 0x1dca 0x1dcb 0x1dcc 0x1dcd 0x1dce 0x1dcf 0x1dd0 0x1dd1 0x1dd2 0x1dd3 0x1dd4 0x1dd7 
}

Mounts
{
	Tiles  0x3ea2 0x3e98 0x3e9f 0x3ea0 0x3ea1 0x3ea6 0x3ea3 0x3ea4 0x3ea5 0x3ea7 0x3ea8 0x3ea9 0x3eb0 0x3eb2 0x3eb3 0x3eb4 0x3eb8 0x3eaa 0x3eab 0x3eac 0x3ead 0x3eba 0x3ebb 0x3ebc 0x3ebd 0x3ebe 0x3eb3 0x3e90 0x3e91 0x3e92 0x3e94
}
tamed.src:

Code: Select all

use npc;
use os;
use uo;
use cfgfile;
use vitals;
use storage;

include "include/eventID";
include "include/attributes";
include "include/sysEvent";
include "include/NPCBackpacks";
include "include/NPCCast";
include "include/randName";
include "include/dist";
include "include/snooping";

set_priority(5);

const  HALT_THRESHOLD := 15;
const  SYSEVENT_ALL_GUARD_CMD := 0x13;

Const me := Self();
var npccfgfile     := ReadConfigFile("npcdesc");
var dmgsound       := npccfgfile[me.npctemplate].damagedsound;
var hit            := npccfgfile[me.npctemplate].attackhitsound;
var idlesnd1       := npccfgfile[me.npctemplate].idlesound1;
var idlesnd2       := npccfgfile[me.npctemplate].idlesound2;
var FLAME_STRENGTH := npccfgfile[me.npctemplate].flamestrength;
var caster := 0;
var spells;
var firebreather;
var mypack := FindPack(me.serial);
var orneriness := npccfgfile[me.npctemplate].orneriness;
var masterserial := GetObjProperty(me, "master");
var saywords := 0;
var master;
var chaseloop := 0;
var guarding :=0;
var following := 0;
var nextwatch := ReadGameClock();
var happiness := CInt(GetObjProperty(me,"happiness"));
var waittime := 120;
var LAST_BREATH := ReadGameClock();
if((!happiness)||(happiness == error))
  happiness := 100;
  SetObjProperty(me,"happiness", 100);
endif

program TamedAI()
  Detach();
  var time := ReadGameClock();
  SetObjProperty(me,"countercheck", time);
  var parms := {};
  parms[1] := me;
  parms[2] := time;
  start_script(":taming:happyCounter", parms);
  master := SystemFindObjectBySerial(masterserial, SYSFIND_SEARCH_OFFLINE_MOBILES);
  if(!master)
    ApplyRawDamage(me, GetHP(me)+ 1);
    return;
  endif
  me.setmaster(master);
  if(me.name["<random>"])
    SetName(me, RandomName(me));
  endif
  if(!happiness)
    happiness := 10;
  endif
  if(!orneriness)
    orneriness := 0;
  endif
  if(!me.backpack)
    var newbackpack := CreateItemAtLocation(5288, 1176, 0, 0xe75,1);
    EquipItem(me, newbackpack);
  endif
  SetAnchor(me.x, me.y, 20, 0);
  var npccfg := ReadConfigFile("npcdesc");
  if(npccfg[me.npctemplate].spell)
    caster := 1;
    spells := GetConfigStringArray(npccfg[me.npctemplate], "spell");
  endif
  if(FLAME_STRENGTH)
    firebreather := 1;
  endif
  SetWarMode(0);
  SetObjProperty(me, "serial", me.serial);
  MainAILoop();
endprogram

function FindPack(myserial)
  var mybank := OpenTamedStorageAreas();
  var bank_obj_name := "Bankbox  " + Hex(myserial);
  var bankbox := FindRootItemInStorageArea(mybank, bank_obj_name);
  if(!bankbox)
    if((me.graphic == 0x123)||(me.graphic == 0x124))
      bankbox := CreateRootItemInStorageArea(mybank, bank_obj_name, 0x966b);
    else
      bankbox := CreateRootItemInStorageArea(mybank, bank_obj_name, UOBJ_BANKBOX);
    endif
  else
    if(((me.graphic == 0x123)||(me.graphic == 0x124))&&((me.backpack).objtype == UOBJ_BANKBOX))
      DestroyItem(bankbox);
      bankbox := CreateRootItemInStorageArea(mybank, bank_obj_name, 0x966b);
    endif
  endif
  return bankbox;
endfunction

function MainAILoop()
  var ev;
  var evtext;
  nextwatch := ReadGameClock();
  var happytimer := 0;
  var sleeper := 0;
  var mhp;
  EnableMainEvents();
  while(GetHp(me)> 0)
    happiness := GetObjProperty(me,"happiness");
    mhp := GetHp(me);
    if(GetObjProperty(me, "onhold"))
      HoldLoop("onhold");
    elseif(GetObjProperty(me, "stabled"))
      HoldLoop("stabled");
    elseif(GetObjProperty(me, "mounted"))
      HoldLoop("mounted");
    else
      if(happiness < 10)
        release();
      endif
      ev := os::wait_for_event(waittime);
      case(ev.type)
        SYSEVENT_SPEECH:        ProcessSpeech(ev);
        SYSEVENT_ENGAGED:       Fight(ev.source);
        SYSEVENT_DAMAGED:       if(GetHp(me)< mhp)
                                  if(ev.source)
                                    Fight(ev.source);
                                  endif
                                  PlaySoundEffect(me,dmgsound);
                                endif
        SYSEVENT_DOUBLECLICKED: if((ev.source == master) or (ev.source.cmdlevel > 2))
                                  OpenMyPack();
                                else
                                  snoop(ev.source, me);
                                endif
        SYSEVENT_ITEM_GIVEN:    if(ev.source == master)
                                  TakeItem(ev);
                                endif
        EVID_ALL_ATTACK_CMD:    Fight(ev.target);
        EVID_ALL_FOLLOW_CMD:    following := ev.target;
        SYSEVENT_ALL_GUARD_CMD: guarding := ev.target;
                                PrintTextAbove(me,"*guarding " + guarding.name + "*");
      endcase
      if(master.dead)
        dismountme(master);
      endif  
      if(following)
        waittime := 0;
        Follow();
      elseif(guarding)
        waittime := 7;
        Guard();
      else
        waittime := 120;
        EraseObjProperty(me,"#flees");
      endif
    endif
  endwhile
endfunction

function HoldLoop(type)
  disablemainevents();
  EnableTameEvents();
  var ev, happiness;
  while(GetObjProperty(me, type))
    if(type == "mounted")
      happiness := GetObjProperty(me, "happiness");
      ev := os::wait_for_event(60);
      if(happiness < 10)
        release();
      endif
    else
      ev := os::wait_for_event(300);
    endif
    case(ev.type)
      EVID_WAKEUP:         EraseObjProperty(me, type);
    endcase
  endwhile
  EnableMainEvents();
endfunction

function Fight(opponent)
  var oldfollowing := following;
  var flees := 0;
  SetDexterityMod(me, 0);
  following := 0;
  if(opponent == me)
    return;
  endif
  TurnToward(opponent);
  SetOpponent(opponent);
  var nextbreath := ReadGameClock();
  var ev;
  var loops := 0;
  var waittime := 0;
  while((opponent) && (!opponent.dead || !opponent.hidden || !opponent.concealed)&&(dist(me,opponent)< 15))
    if(!CloseDistance(opponent))
      loops := loops + 1;
      waittime := 0;
    else
      if(!CheckLineOfSight(me, opponent))
        loops := loops + 1;
      endif
      waittime := 1;
    endif
    ev := wait_for_event(waittime);
    case(ev.type)
      EVID_ALL_ATTACK_CMD:     opponent := ev.target;
                               SetOpponent(opponent);
      EVID_ALL_FOLLOW_CMD:     following := ev.target;
      SYSEVENT_ALL_GUARD_CMD:  guarding := ev.target;
                               PrintTextAbove(me,"*guarding " + guarding.name + "*");
      SYSEVENT_SPEECH:         ProcessSpeech(ev);
      SYSEVENT_ENGAGED:
      SYSEVENT_DAMAGED:        if(ev.source == opponent)
                                 PlaySoundEffect(me,dmgsound);
                               endif
                               if(ev.source)
                                 if(ev.source != opponent)
                                   if((!CheckLineOfSight(me, opponent))||(RandomInt(8)==1))
                                     opponent := ev.source;
                                     SetOpponent(opponent);
                                   endif
                                 endif
                                 TurnToward(opponent);
                               endif
      EVID_PEACEMADE:          SetWarMode(0);
                               opponent := 0;
                               following := oldfollowing;
                               return;
      SYSEVENT_DOUBLECLICKED:  if((ev.source == master) or (ev.source.cmdlevel > 2))
                                 OpenMyPack();
                               else
                                 snoop(ev.source, me);
                               endif
    endcase
    if(master.dead)
       dismountme(master);
    endif 
    if(following)
      SetWarMode(0);
      opponent := 0;
      return;
    endif
    if(firebreather and caster)
      if(LAST_BREATH <= ReadGameClock())
        if((CheckLineOfSight(me, opponent)) and (dist(me, opponent) <= 15))
          if(RandomInt(4) == 1)
            cast_meteor(opponent);
          else
	        cast_offensive_spell(me,opponent);
          endif
          LAST_BREATH := Cint(ReadGameClock() + (RandomInt(4) + 4));
        endif
      endif
    elseif(caster)
      if(LAST_BREATH <= ReadGameClock())
        if((CheckLineOfSight(me, opponent)) and (dist(me, opponent) <= 15))
          cast_offensive_spell(me, opponent);
          LAST_BREATH := Cint(ReadGameClock() + (RandomInt(4) + 4));
        endif
      endif
    elseif(firebreather)
      if(LAST_BREATH <= ReadGameClock())
        if(RandomInt(4)== 1)
          cast_meteor(opponent);
        endif
        LAST_BREATH := Cint(ReadGameClock() + (RandomInt(4) + 4));
      endif
    endif
    if(loops > 30)
      flees := flees + 1;
      if(flees > 4)
        flee(opponent);
      endif
      return;
    endif
  endwhile
  SetWarMode(0);
  opponent := 0;
  following := oldfollowing;
endfunction

function CloseDistance(opponent)
  case ( Distance(me, opponent))
    1:
    0:       return 1;
    default: if(!RunToward(opponent))
               return 1;
             else
               return 0;
             endif
  endcase
endfunction

function Transfer()
  if(GetObjProperty(me, "summoned"))
    return;
  endif
  SendSysMessage(master, "Transfer " + me.name + " to whom?");
   var whom := Target(master, TGTOPT_NOCHECK_LOS);
  if(!whom)
    SendSysMessage(master, "Canceled");
    return;
  endif
  if(!whom.acctname)
    printtextabove(me, "your pet refuses to accept that as a master.");
    return;
  endif
  if(whom == master)
    printtextabove(me, "you are already my master.");
    return;
  endif
  var npccfgfile := ReadConfigFile("npcdesc");
  var tameskill  := CInt(npccfgfile[me.npctemplate].tameskill);
  var mastaming  := GetEffectiveSkill(master, SKILLID_TAMING);
  var maslore    := GetEffectiveSkill(master, SKILLID_ANIMALLORE)/5;
  var tgttaming  := CInt(GetEffectiveSkill(whom, SKILLID_TAMING));
  var tgtlore    := CInt(GetEffectiveSkill(whom, SKILLID_ANIMALLORE)/5);
  happiness := GetObjProperty(me, "happiness");
  if(tgttaming <(tameskill - 50))
    PlaySoundEffect(me, dmgsound);
    if(!orneriness)
      orneriness := 1;
    endif
    happiness := happiness - orneriness;
    if(happiness < 10)
      release();
    else
      SetObjProperty(me, "happiness", happiness);
      SendSysMessage(master, "That person has no chance of controlling this beast!");
      return;
    endif
  endif
  var dif  := CInt(tameskill -((mastaming/10)+ maslore));
  var diff := CInt((tameskill-20)-((tgttaming/10)+ tgtlore));
  if(dif < 1)
    dif := 1;
  endif
  if(diff < 1)
    diff := 1;
  endif
  var tsm  := CInt(RandomInt(40)+(mastaming + 40));
  var tst  := CInt(RandomInt(40)+(tgttaming + 40));
  if(tsm > dif)
    if(tst < diff)
      PlaySoundEffect(me, dmgsound);
      happiness := happiness - orneriness;
      if(happiness < 10)
        release();
      else
        SetObjProperty(me, "happiness", happiness);
        SendSysMessage(master,"your pet refuses to accept " + whom.name + " as a master");
        return;
      endif
    else
      PlaySoundEffect(me, hit);
      SetObjProperty(me, "master", whom.serial);
      PrintTextAbove(me, me.name + " accepts " + whom.name+ " as its new master");
      RestartScript(me);
    endif
  else
    PlaySoundEffect(me, dmgsound);
    happiness := happiness - orneriness;
    SetObjProperty(me, "happiness", happiness);
    if(happiness < 10)
      release();
    else
      SendSysMessage(master,"your pet refuses to listen to you");
      return;
    endif
  endif
endfunction

function release()
  if((GetObjProperty(me,"onhold")) or (GetObjProperty(me,"stabled")))
    return;
  endif
  var char;
  var mounted_char;
  var onchars := EnumerateOnlineCharacters();
  if(GetObjProperty(me,"summoned") == 1)
    if(GetObjProperty(me,"mounted") == 1)
      char := GetObjProperty(me,"mounted_on");
      foreach person in onchars
        if(person.serial == CInt(char))
          mounted_char := person;
          break;
        endif
      endforeach
      dismountme(mounted_char);
    endif
    PlayStationaryEffect(me.x, me.y, me.z, FX_SMOKE, 0xa, 0xa);
    MoveObjectToLocation(me,5288, 1176, 0,MOVEOBJECT_FORCELOCATION);
    ApplyRawDamage(me, GetHp(me)+ 3);
  else
    if(GetObjProperty(me,"mounted"))
      char := GetObjProperty(me,"mounted_on");
      foreach person in onchars
        if(person.serial == CInt(char))
          mounted_char := person;
          break;
        endif
      endforeach
      dismountme(mounted_char);
    endif
    me.script := npccfgfile[me.npctemplate].script;
    PrintTextAbove(me, me.name + " has decided it is better off without a master.");
    me.setmaster(0);
    EraseObjProperty(me, "master");
    EraseObjProperty(me, "serial");
    EraseObjProperty(me, "script");
    EraseObjProperty(me, "happiness");
    EraseObjProperty(me, "mounted");
    EraseObjProperty(me, "mounted_on");
    SetAnchor(me.x,me.y,10,1);
    SetHpRegenRate(me ,(100)* 12);
    RestartScript(me);
  endif
endfunction

function dismountme(who)
  var mount := GetEquipmentByLayer(who, 25);
  me.facing := who.facing;
  MoveObjectToLocation(me, master.x, who.y, who.z, MOVEOBJECT_FORCELOCATION);
  EraseObjProperty(me, "mounted");
  EraseObjProperty(me, "mounted_on");
  DestroyItem(mount);
endfunction

function Fetch()
  var tobj := Target(master);
  if(tobj.container)
    PlaySoundEffect(me, dmgsound);
    return;
  endif
  var times := 0;
  while((Distance(me, tobj)> 1)&&(times <= 5)&& CheckLineOfSight(me,tobj))
    if(!walktoward(tobj))
      sleepms(100);
      times := times + 1;
    else
      times := 0;
    endif
  endwhile
  if(Accessible(me,tobj))
    PlaySoundEffect(me, hit);
    MoveItemToContainer(tobj, mypack);
    while((Distance(me, master)> 1)&&(times <= 5)&& CheckLineOfSight(me,master))
      if(!walktoward(master))
        sleepms(100);
        times := times + 1;
      else
        times := 0;
      endif
    endwhile
    MoveObjectToLocation(tobj, me.x, me.y, me.z, MOVEOBJECT_FORCELOCATION);
  else
    PlaySoundEffect(me, dmgsound);
  endif
endfunction

function Get()
  var tobj := Target(master);
  if(tobj.container)
    PlaySoundEffect(me, dmgsound);
    return;
  endif
  var times := 0;
  while((Distance(me, tobj)> 1)&&(times <= 5)&& CheckLineOfSight(me,tobj))
    if(!walktoward(tobj))
      sleepms(100);
      times := times + 1;
    else
      times := 0;
    endif
  endwhile
  if(Accessible(me,tobj))
    PlaySoundEffect(me, hit);
    MoveItemToContainer(tobj, mypack);
  else
    PlaySoundEffect(me, dmgsound);
  endif
endfunction

function drop()
  var myitems;
  foreach myitems in EnumerateItemsInContainer(mypack)
    if(myitems.container.serial == mypack.serial)
      MoveObjectToLocation(myitems, me.x, me.y, me.z,0);
      sleepms(100);
    endif
  endforeach
endfunction

function speak()
  if(RandomInt(1)+1 == 1)
    PlaySoundEffect(me, idlesnd1);
  else
    PlaySoundEffect(me, idlesnd1);
  endif
endfunction

function OpenMyPack();
  if((me.graphic == 0x123)||(me.graphic == 0x124))
    if(Distance(me, master)> 2)
      return;
    endif
    foreach item in EnumerateItemsInContainer(mypack)
      if(item.container == me.backpack)
        MoveItemToContainer(item, me.backpack);
      endif
    endforeach
    SendOpenSpecialContainer(master, mypack);
    return;
  else
    if(Distance(me, master)> 1)
      return;
    endif
    var alreadymounted := GetEquipmentByLayer(master, 25);
    if(alreadymounted)
      return;
    endif
    var mounttype := 0;
    case(me.graphic)
      0xcc: mounttype := 0x3ea2;
      0xc8: mounttype := 0x3e9f;
      0xe2: mounttype := 0x3ea0;
      0xe4: mounttype := 0x3ea1;
      0xdc: mounttype := 0x3ea6;
      0xd2: mounttype := 0x3ea3;
      0xda: mounttype := 0x3ea4;
      0xdb: mounttype := 0x3ea5;
    endcase
    if(mounttype)
      if(MoveObjectToLocation(master,me.x,me.y,me.z,0))
        master.facing := me.facing;
        var mount := CreateItemAtLocation(5228, 1182, 0, 0xf021,1);
        if(Cint(GetObjProperty(me, "summoned")) == 1)
          SetObjProperty(mount, "summoned", 1);
        endif
        mount.color := me.color;
        MoveObjectToLocation(me, 5228, 1182, 0, MOVEOBJECT_FORCELOCATION);
        mount.graphic := mounttype;
        EquipItem(master,mount);
        SetObjProperty(mount,"serial", me.serial);
        SetObjProperty(me,"mounted", 1);
        SetObjProperty(me,"mounted_on", master.serial);
        guarding := 0;
        following := 0;
      endif
    endif
  endif
endfunction

function TakeItem(ev)
  var npccfg := ReadConfigFile("npcdesc");
  var foodtype := npccfg[me.npctemplate].food;
  if(!foodtype)
    foodtype := "all";
  endif
  var cfg := ReadConfigFile("::food");
  var elem := FindConfigElem(cfg,foodtype);
  var foodarray := GetConfigStringArray(elem,"food");
  if(CStr(ev.item.objtype)in foodarray)
    PlaySoundEffect(me, CInt(0x3b)+ RandomInt(3));
    DestroyItem(ev.item);
    PrintTextAbovePrivate(me,"your pet looks happier.", master);
    SetObjProperty(me,"happiness", 100);
    return;
  endif
  if((me.graphic == 0x123)||(me.graphic == 0x124))
    if(!MoveItemToContainer(ev.item, mypack))
      say("*your pet cannot hold that item*");
      return;
    else
      PlaySoundEffect(me,0x49);
    endif
  else
    var yourpack := ev.source.backpack;
    MoveItemToContainer(ev.item,yourpack);
  endif
endfunction

function Guard()
  if(nextwatch <= ReadGameClock())
    nextwatch := ReadGameClock()+ 7;
    if(RandomInt(8)==1)
      PrintTextAbove(me,"*guarding " + guarding.name + "*");
    endif
    foreach mob in ListHostiles(guarding, 9, 0);
      Fight(mob);
      return;
    endforeach
  endif
  if((!GetStrength(guarding))||(guarding.dead)||(dist(me,guarding)> 15))
    guarding := 0;
  endif
endfunction

function Follow()
  var d := Distance(me, following);
  if(d <= 2)
    waittime := 1;
  elseif(d > 15)
    following := 0;
    waittime := 120;
  elseif(d > 6)
    if(GetObjProperty(me, "Pause"))
      waittime := 2;
    else
      var ma := 200 - CInt(GetDexterity(me));
      SetDexterityMod(me, CInt(GetDexterityMod(me))+ ma);
      RunToward(following);
      SetDexterityMod(me, CInt(GetDexterityMod(me))- ma);
      waittime := 0;
    endif
  else
    if(GetObjProperty(me, "Pause"))
      waittime := 2;
    else
      var ma := 200 - CInt(GetDexterity(me));
      SetDexterityMod(me, CInt(GetDexterityMod(me))+ ma);
      walktoward(following);
      SetDexterityMod(me, CInt(GetDexterityMod(me))- ma);
      waittime := 0;
    endif
  endif
  if(guarding)
    Guard();
  endif
endfunction

function ProcessSpeech(ev)
  if(ev.source.serial != masterserial)
    return;
  endif
  if(!master)
    RestartScript(me);
  endif
  var evtext := lower(ev.text);
  var mename := lower(me.name);
  if(evtext[mename + " kill"] || evtext[mename + " attack"] || evtext["all kill"] || evtext["all attack"])
    var what := Target(master, TGTOPT_HARMFUL + TGTOPT_CHECK_LOS);
    if(what)
      if(what == ev.source)
        return;
      elseif(evtext["all kill"] || evtext["all attack"])
        if(obediencecheck()== 0)
          return;
        endif
        AllCommand(EVID_ALL_ATTACK_CMD, what);
      else
        if(obediencecheck()== 0)
          return;
        endif
        Fight(what);
      endif
    endif
  elseif(evtext[mename + " stop"] || evtext["all stop"])
    if(obediencecheck()== 0)
      return;
    endif
    guarding := 0;
    following := 0;
  elseif((evtext[mename + " come"])||(evtext["all come"]))
    if(obediencecheck()== 0)
      return;
    endif
    var done := 0;
    chaseloop := 0;
    while(done == 0)
      chaseloop := chaseloop +1;
      done := CloseDistance(ev.source);
      if(chaseloop > 25)
        done :=1;
      endif
    endwhile
  elseif(evtext[mename + " follow"])
    if(obediencecheck()== 0)
      return;
    endif
    if(evtext["follow me"])
      following := ev.source;
    else
      var what := Target(master, TGTOPT_CHECK_LOS);
      if(what)
        following := what;
      endif
    endif
  elseif(evtext["all follow"])
    if(obediencecheck()== 0)
      return;
    endif
    if(evtext["follow me"])
      following  := ev.source;
    else
      var what := Target(master, TGTOPT_CHECK_LOS);
      if(what)
        AllCommand(EVID_ALL_FOLLOW_CMD, what);
      endif
    endif
  elseif(evtext[mename + " transfer"] ||(evtext["all transfer"]))
    Transfer();
  elseif(evtext[mename + " release"] ||(evtext["all release"]))
    release();
  elseif(evtext[mename + " guard me"])
	guarding := ev.source;
	PrintTextAbove(me,"Im guarding you.");
  elseif(evtext[mename + " guard"])
    say("Who should I guard?");
    var what := Target(master, TGTOPT_HELPFUL + TGTOPT_CHECK_LOS);
	if(what.isA(POLCLASS_UOBJECT))
      guarding := what;
	  PrintTextAbove(me,"Im guarding " + guarding.name);
	endif
  elseif(evtext["all guard me"])
	guarding := ev.source;
	PrintTextAbove(me,"Im guarding you");
  elseif(evtext["all guard"])
    say("Who should I guard?");
	var what := Target(master, TGTOPT_HELPFUL + TGTOPT_CHECK_LOS);
	if(GetHp(what))
      AllCommand(SYSEVENT_ALL_GUARD_CMD, what);
	endif
  elseif(evtext[mename + " fetch"])
    if(obediencecheck()== 0)
      return;
    endif
    Fetch();
  elseif(evtext[mename + " get"])
    if(obediencecheck()== 0)
      return;
    endif
    Get();
  elseif(evtext[mename + " drop"])
    if(obediencecheck()== 0)
      return;
    endif
    drop();
  elseif(evtext[mename + " speak"]  ||(evtext["all speak"]))
    if(obediencecheck()== 0)
      return;
    endif
    speak();
  endif
endfunction

function AllCommand(evtype,what)
  var mobs := ListMobilesNearLocation(master.x, master.y, master.z, 9);
  var eve array;
  eve.+type := evtype;
  eve.+source := me;
  eve.+target := what;
  SendEvent(me, eve);
  foreach mob in mobs
    if(GetObjProperty(mob, "master")== me.master.serial)
      SendEvent(mob, eve);
    endif
  endforeach
endfunction

function cast_meteor(opponent)
  var base := Cint(((FLAME_STRENGTH * GetHp(me)) / GetMaxHp(me)) / 2);
  var dmg :=  RandomInt(base) + base;
  PerformAction(me,0x0c);
  PlaysoundEffect(me, 0x16b);
  sleep(3);
  PlayMovingEffect(me, opponent, 0x36d4, 10, 1, 1);
  ApplyRawDamage(opponent, dmg);
endfunction

function flee(opponent)
  var numflees := GetObjProperty(me,"#flees");
  if(numflees)
    if(numflees > 5)
      MoveObjectToLocation(me,5288,1176,0,MOVEOBJECT_FORCELOCATION);
      SetObjProperty(me,"guardkill",1);
      ApplyRawDamage(me, GetMaxHp(me)+ 3);
    else
      numflees := numflees + 1;
    endif
  else
    numflees := 1;
  endif
  SetObjProperty(me,"#flees",numflees);
  var runs := 0;
  while((Distance(me, opponent)< 20)&&(runs < 50))
    RunAwayFrom(opponent);
    runs := runs +1;
    wait_for_event(0);
  endwhile
  RestartScript(me);
endfunction

function obediencecheck()
  var arry := { 0xcc, 0xc8, 0xe2, 0xe4, 0x123, 0x124, 0xd2, 0xdb };
  if(me.objtype in arry)
    return 1;
  endif
  var maslore    := GetEffectiveSkill(master, SKILLID_ANIMALLORE)/5;
  var mastaming  := CInt(GetEffectiveSkill(master, SKILLID_TAMING)+ maslore);
  var checkvalue := CInt(mastaming - 20);
  happiness := GetObjProperty(me, "happiness");
  var happybonus := happiness/10;
  checkvalue := checkvalue + happybonus;
  var defiance :=(orneriness * 20)-30;
  if(defiance < 1)
    defiance := 1;
  endif
  defiance := defiance + petcount();
  var finaldefiance := CInt(defiance + RandomInt(40));
  if(GetObjProperty(me, "summoned")== 1)
    return 1;
  elseif(finaldefiance > checkvalue)
    PlaySoundEffect(me, dmgsound);
    happiness := happiness - orneriness;
    SetObjProperty(me, "happiness",(happiness-1));
    if(happiness < 10)
      release();
    endif
    return 0;
  else
    PlaySoundEffect(me,hit);
    if(happiness < 10)
      release();
      return 0;
    endif
    return 1;
  endif
endfunction

function petcount()
  var npccfg := ReadConfigFile("npcdesc");
  var pets := 0;
  var mobs := ListMobilesNearLocation(me.x,me.y,me.z,8);
  foreach mob in mobs
    if((mob.script == "tamed")&&(GetObjProperty(mob,"master")==masterserial))
      if(GetObjProperty(mob, "summoned"))
        pets := pets + 0;
      else
        pets := pets+5;
      endif
    endif
  endforeach
  return pets;
endfunction

function EnableTameEvents()
  EnableEvents(EVID_WAKEUP);
endfunction

function EnableMainEvents()
  EnableEvents(SYSEVENT_SPEECH, 8);
  EnableEvents(SYSEVENT_ENGAGED);
  EnableEvents(SYSEVENT_DAMAGED);
  EnableEvents(SYSEVENT_DOUBLECLICKED);
  EnableEvents(SYSEVENT_ITEM_GIVEN);
  EnableEvents(EVID_PEACEMADE);
endfunction

function disablemainevents()
  DisableEvents(SYSEVENT_SPEECH);
  DisableEvents(SYSEVENT_ENGAGED);
  DisableEvents(SYSEVENT_DAMAGED);
  DisableEvents(SYSEVENT_ITEM_GIVEN);
  DisableEvents(EVID_PEACEMADE);
endfunction
Pierce
Forum Regular
Posts: 420
Joined: Thu Feb 02, 2006 8:33 am

Post by Pierce »

Where did you try to mount a ride with that tamed.src?
On the britannia map (id0) or e.g. on the ilshenar map (id2)?

If it was e.g. ilshenar the reason it failed is, that your tamed.src
contains no realm support. You should check especially the
MoveObjectToLocation lines for the missing realm parameter.

e.g. change the line in the dismount function:

Code: Select all

MoveObjectToLocation(me, master.x, who.y, who.z, MOVEOBJECT_FORCELOCATION); 
to

Code: Select all

  MoveObjectToLocation( me, master.x, master.y, master.z, master.realm, MOVEOBJECT_FORCELOCATION);
dbagr
New User
Posts: 6
Joined: Wed Apr 25, 2007 2:15 am

Post by dbagr »

Thanks... but it doesn't work.

I changed the line in the dismountme(who) function:


Code: Select all

function dismountme(who)
  var mount := GetEquipmentByLayer(who, 25);
  me.facing := who.facing;
  MoveObjectToLocation( me, master.x, master.y, master.z, master.realm, MOVEOBJECT_FORCELOCATION);
  EraseObjProperty(me, "mounted");
  EraseObjProperty(me, "mounted_on");
  DestroyItem(mount);
endfunction
Pierce
Forum Regular
Posts: 420
Joined: Thu Feb 02, 2006 8:33 am

Post by Pierce »

The dismount function was only an example. You need to check all MoveObjectToLocation lines for the realm parameter.
Locked