bank.inc

Here you can post threads requesting help on the official POL Ultima Online Emulator Core 096.
Note: Core 096 is no longer officially supported.

Moderator: POL Developer

Post Reply
cheech
New User
Posts: 8
Joined: Mon Apr 11, 2011 10:58 am

bank.inc

Post by cheech »

Having some errors, i can't figure out how to solve, actually im upgrading my scripts from pol095 to 096.7, so cept for the regular changes, mi experiecing some other errors, smoeone could help me please?

tryin to compile appraiser.scr

Code: Select all

use npc;
use basic;
use os;
use uo;

include "include/eventid";
include "include/sysevent";
include "include/randname";
include "include/utility";
include "include/client";
include "include/vetement";
include "include/npcbackpacks";
include "util/bank";
include "include/anchors";
include "include/dist";
include "include/skilllists";
include "include/begging";
include "include/objtype";
include "storage";

const MAX_SKILLS      := 48;     // There are currently 48 Skills.
const UOBJ_GOLDCOIN   := 0x0eed; // A gold coin
const UOBJ_METALCHEST := 0x0e7c; // A Metal Chest
const REACT_THRESHOLD := 2;

set_priority( 50 );

var me := Self();
var inv_rs, inv_fs, inv_pb, inv_1c;
var player, counter;

program appraiser()
  start_script("NPCKeeper", me);
  EnableEvents(SYSEVENT_ITEM_GIVEN);
  EnableEvents(EVID_NODE);
  var myanchor := GetObjProperty(me, "Anchor");
  if(myanchor)
    MoveCharacterToLocation(me, myanchor[1], myanchor[2], myanchor[3], MOVECHAR_FORCELOCATION);
  endif
  drop_anchor();
  var next_wander := ReadGameClock() + 10;
  var ev;
  var txt;
  while (1)
    ev := os::wait_for_event(120);
    if(ev)
      case(ev.type)
        EVID_NODE: txt := lower(ev.text);
		  if(txt["appraise"])
		    TurnToward(ev.source);
		    appraise(ev.source);
		  elseif((txt["buy"]) || (txt["sell"]))
		    PrintTextAbovePrivate(me, "I'm sorry, but you must go elsewhere to buy or sell.", ev.source);
		  endif
        SYSEVENT_ITEM_GIVEN:  processdeedsale(ev.source, ev.item);
      endcase
    endif
	if(ReadGameClock() >= next_wander)
	  begpurse(me);
      wander();
      if(coordist(me.x, me.y, myanchor[1], myanchor[2]) > 5)
        MoveCharacterToLocation(me, myanchor[1], myanchor[2], myanchor[3], MOVECHAR_FORCELOCATION);
      endif
      next_wander := ReadGameClock() + 30;
    endif
  endwhile
endprogram

function appraise(who)
  PrintTextAbovePrivate(me, "Target the item you want me to appraise", who);
  var trg := Target(who);
  if(!trg)
    PrintTextAbovePrivate(me, "changed your mind?", who);
    return;
  endif
  var checker := 0;
  foreach thing in EnumerateItemsInContainer(who.backpack)
    if(thing == trg)
      checker := 1;
      break;
    endif
  endforeach
  if(checker == 0)
    PrintTextAbovePrivate(me, "But you dont own that!", who);
    return;
  endif
  checker := 0;
  var deedarray := { 0x6019, 0x601a, 0x601b, 0x601c, 0x601d, 0x601e, 0x6020, 0x6021, 0x6022, 0x6023, 0x6024, 0x6025, 0x6026 };
  if(trg.objtype in deedarray)
    checker := 1;
  endif
  if(checker == 0)
    PrintTextAbovePrivate(me, "Im not interested in that!", who);
    return;
  endif
  var bankbox := FindBankBox(who);
  if(!bankbox)
    PrintTextAbove(me, "I cannot seem to find your bankbox!", who);
    return;
  endif
  var cnfg := ReadConfigFile(":housing:itemdesc");
  var amt := cnfg[trg.objtype].VendorSellsFor;
  PrintTextAbovePrivate(me,"I will give you " + amt + " gold coins for that deed.", who);
endfunction

function processdeedsale(who, trg)
  var checker := 0;
  var deedarray := { 0x6019, 0x601a, 0x601b, 0x601c, 0x601d, 0x601e, 0x6020, 0x6021, 0x6022, 0x6023, 0x6024, 0x6025, 0x6026 };
  if(trg.objtype in deedarray)
    checker := 1;
  endif
  if(checker == 0)
    PrintTextAbovePrivate(me, "Im not interested in that!", who);
    MoveItemToContainer(trg, who.backpack);
    return;
  endif
  var bankbox := FindBankBox(who);
  if(!bankbox)
    PrintTextAbovePrivate(me, "I cannot seem to find your bankbox!", who);
    MoveItemToContainer(trg, who.backpack);
    return;
  endif
  var cnfg := ReadConfigFile(":housing:itemdesc");
  var amt := cnfg[trg.objtype].VendorSellsFor;
  var holder;
  var goldarray := {};
  var chk := 0;
  while(amt > 0)
     holder := 0;
     if(amt > 60000)
       holder := CreateItemInContainer(bankbox, 0xeed, 60000);
       if(holder)
         goldarray.append(holder);
         amt := amt - 60000;
       else
         foreach thing in goldarray
           DestroyItem(thing);
         endforeach
         chk := 1;
         PrintTextAbovePrivate(me, "Your bank box is too full!", who);
         break;
      endif
    else
       holder := CreateItemInContainer(bankbox, 0xeed, amt);
       if(holder)
         if(!DestroyItem(trg))
           foreach thing in goldarray
             DestroyItem(thing);
           endforeach
           chk := 1;
           PrintTextAbovePrivate(me, "Your bank box is too full!", who);
         endif
         break;
       else
         foreach thing in goldarray
           DestroyItem(thing);
         endforeach
         chk := 1;
         PrintTextAbovePrivate(me, "Your bank box is too full!", who);
         break;
       endif
    endif
  endwhile
  if(chk == 0)
    PrintTextAbovePrivate(me, "The funds have been deposited in your bank box.", who);
  endif
endfunction
got this error:
Compiling: c:\pol096\scripts\ai\appraiser.src
Expected an identifier, got User Function FindBankBox instead.
Near: function FindBankBox( character )
File: C:/POL096/scripts/util/bank.inc, Line 17
File: C:/POL096/scripts/util/bank.inc, Line 17
Error reading function
File: C:/POL096/scripts/util/bank.inc, Line 17
Compilation failed.

and checking the include, i got a error on the function findbankbox(), it says that was spected an identifier, and got an user function instead, im newbie at scripting so im not sure what does it means, anyways follow the code:

Code: Select all

//
// bank.inc: var bankbox functions
//
// public functions:
//   FindBankBox( character)      returns World Bank bankbox for a character
//   WipeBankBox( character )     does what you might think.
//   OpenWorldBank()              returns handle to World Bank.
//

use os;

include "include/objtype";
include "util/bank";

var a := 1;

function FindBankBox( character )

	var worldbank := OpenWorldBank();
	var bank_obj_name := "Bankbox of " + character.serial;
	var bankbox := FindRootItemInStorageArea( worldbank, bank_obj_name );

	if (!bankbox)
		bankbox := CreateRootItemInStorageArea( worldbank, bank_obj_name, UOBJ_BANKBOX );
	endif

	// should never happen.  FIXME make sure and document that fact
	if (!bankbox)
		syslog( "Unable to find or create bankbox for " + character.serial );
	endif

	return bankbox;

endfunction

function WipeBankBox( character )

	var worldbank := OpenWorldBank();

	var bank_obj_name := "Bankbox of " + character.serial;

	return DestroyRootItemInStorageArea( worldbank, bank_obj_name );

endfunction

function OpenWorldBank()

	var bank := FindStorageArea( "World Bank" );
	if (!bank)
		bank := CreateStorageArea( "World Bank" );
	endif

	// this should not happen. FIXME, make sure and document that fact.
	if (!bank)
		syslog( "Unable to open or create world bank!" );
	endif

	return bank;

endfunction
error:
Compiling: c:\pol096\scripts\util\bank.inc
Expected an identifier, got User Function FindBankBox instead.
Near: function FindBankBox( character )
File: c:\pol096\scripts\util\bank.inc, Line 17
File: c:\pol096\scripts\util\bank.inc, Line 17
Error reading function
File: c:\pol096\scripts\util\bank.inc, Line 17
Compilation failed.

thnx for ur support.
cheech
New User
Posts: 8
Joined: Mon Apr 11, 2011 10:58 am

Re: bank.inc

Post by cheech »

btw, i got some error relationed to the "var" me,
start_script("NPCKeeper", me);
i decided to declare "me" as a var like this:

Code: Select all

    var me := self();
is it ok?
what you think about it?
cheech
New User
Posts: 8
Joined: Mon Apr 11, 2011 10:58 am

Re: bank.inc

Post by cheech »

didn't solve yet the first problem but i think i alrdy found-out the problem, i think the function was defined two times, in a way that causes error, im pretty busy right now ( im at work =p ) but soon as im free im try to fix that.

anyways thnx for viewing. >_<
cheech
New User
Posts: 8
Joined: Mon Apr 11, 2011 10:58 am

Re: bank.inc

Post by cheech »

cheech wrote:didn't solve yet the first problem but i think i alrdy found-out the problem, i think the function was defined two times, in a way that causes error, im pretty busy right now ( im at work =p ) but soon as im free im try to fix that.

anyways thnx for viewing. >_<
fail, i tried to rename the function and got the same error...
cheech
New User
Posts: 8
Joined: Mon Apr 11, 2011 10:58 am

Re: bank.inc

Post by cheech »

solved the first issue, i was tryin to compile includes, to check if its corret, and as it sould be, i did insert includes, inside of the includes lol, i just rcomved the includes, from the includes, and got it working properlly.

tnx CWO, i saw a topic where he solved it before.

my question about the seconds issue keeps running lol...

cya =D
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: bank.inc

Post by CWO »

Which one are you still having a problem with? The expected identifier, got user function or the NPCKeeper 'me' variable? And the first thing that jumps out at me on bank.inc is that it includes itself...

The conversion from 095 to 096 is going to be a long project... took me months... but thankfully the core bugs that I experienced are fixed in 096.7 (It was beta when I first started) :)
cheech
New User
Posts: 8
Joined: Mon Apr 11, 2011 10:58 am

Re: bank.inc

Post by cheech »

CWO wrote:Which one are you still having a problem with? The expected identifier, got user function or the NPCKeeper 'me' variable? And the first thing that jumps out at me on bank.inc is that it includes itself...

The conversion from 095 to 096 is going to be a long project... took me months... but thankfully the core bugs that I experienced are fixed in 096.7 (It was beta when I first started) :)
The expected identifier, got user function or - this issue i've alrdy fixed doing the steps from some other of ur topics, actually was two or more includes calling the same functio as u meant on that.

NPCKeeper 'me' variable, im not having trouble with the var, as a noob that i am, i just want to know if i did define it right, cause i was tryin to find some function that select the character or player dunno lol.

btw the fight.inc or packfight.inc is taking about 2 weeks now, theres 564567457454 function called from includes, btw there is no includes in there, so i need to find where is it the include, and if there is no function i need to find or try to write, so im having not the best time of my life lol...

btw, tnx u guys.
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: bank.inc

Post by CWO »

NPCKeeper from what I've seen, sets a name and generates loot. The version I have wants a reference to the NPC so the me := Self() is acceptable since that's exactly what it's looking for. Almost all AI scripts I've worked with has var me := Self;.
Post Reply