Error compiling statement

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
westrupp
Adept Poster
Posts: 87
Joined: Wed Aug 01, 2007 3:07 am
Location: Brazil
Contact:

Error compiling statement

Post by westrupp » Mon Aug 17, 2009 7:44 pm

Error compiling statement at C:/pol/scripts/ai/combat/fight.inc, Line 46
Error compiling statement at C:/pol/scripts/ai/combat/fight.inc, Line 41
Error in function 'Fight', File: C:/pol/scripts/ai/combat/fight.inc, Line 46

Code: Select all

function Fight( opponent )

	if ((opponent.cmdlevel > 0) || (opponent.serial == me.serial))
        	SetWarMode(0);
        	opponent := 0;
		return;
	endif

	if (opponent.npctemplate == "humuc")
        	SetWarMode(0);
        	opponent := 0;
		return;
	endif

	var oldprio := set_priority(50);

	SetOpponent( opponent );
    	prepare_for_fight( opponent );
	TurnToward( opponent );

	if ( GetObjProperty( me, "keywordbattlecry") )
		say( GetObjProperty( me, "keywordbattlecry") );
	endif

	var loops := 0;
	var steps := 0;
    	var ev;
	var waittime := 0;
	var randomruns := 0;
	var oldx := opponent.x;
	var oldy := opponent.y;
	var oldd := Distance(me,opponent);
	var cd;

	var wasmoving:=1;

    while ( (opponent) && not
	    (opponent.dead || opponent.hidden || opponent.concealed) &&
	    (Distance(me,opponent) < 20) )

	cd := CloseDistance( opponent );
	case ( cd )
	0:
		//Closedistance returned 0, which means the mob needs to move
		wasmoving := 1;
		loops := loops + 1;
		steps := steps + 1;
		waittime := 0;
		if ( ( oldx >= (opponent.x-1) && (oldx <= opponent.x+1)) &&
		     ( oldy >= (opponent.y-1) && (oldy <= opponent.y+1)) && (oldd > 1) )
			//our opponent hasn't moved much but we did, so:
			if ( (steps > 4) && (oldd <= Distance(me,opponent)) )
				//after 4 steps we're not closing in, so lets do something else:
				randomruns := randomruns + 1;
				if ( runrandom(opponent, randomruns) )
					PeaceMade();
					return;
				endif
				oldd := Distance(me,opponent);
				steps := 0;
				if ( randomruns > 5 )
					//screw it, we can't get to him
					flee(opponent);
				endif
			else
				//if we're closing in, lets reset the distance and steps
				if ( Distance(me,opponent) < oldd )
					steps := 0;
					oldd := Distance(me, opponent);
				endif
			endif
		else
			//we moved, but so did our opponent, so lets chase him longer:
			oldx := opponent.x;
			oldy := opponent.y;
			steps := 0;
			if ( loops > 50 )
				//screw it, we can't catch him
				flee(opponent);
			endif
		endif
	1:
		//Closedistance returned 1, which means the mob doesn't need to move
		//unless he can't see his opponent
		if (wasmoving) TurnToward(opponent); endif
		wasmoving := 0;

		steps := 0;
		randomruns := 0;
		if ( CheckLineOfSight(me,opponent) )
			loops := 0;
			waittime := 1;
			EraseObjProperty(me,"#flees");
		else
			loops := loops +1;
			waittime := 1;
			RunTowardLocation(me.x+(Random(3)-1), me.y+(Random(3)-1));
		endif		
	2:
		//closedistance returned 2, which means the mob was peacemade:
		PeaceMade();
		return;
	3:
		//closedistance returned 3, which means the mob is running away
		loops := 0;//closedistance maintains its own runaway counter
		steps := 0;
		randomruns := 0;
		waittime := 0;
		wasmoving := 1;
	endcase

	in_combat_event_loop(opponent);

	ev := wait_for_event( waittime );
	case (ev.type)
		SYSEVENT_DAMAGED:
                         if((ev.source.npctemplate) and (CheckLineOfSight(me, ev.source)))
                            opponent := ev.source;
			  		        SetOpponent(opponent);
					        TurnToward(opponent);
                          elseif((distance(me, ev.source) < distance(me, opponent)) || (!CheckLineOfSight(me, opponent)) || (!opponent))
					        opponent := ev.source;
			  		        SetOpponent(opponent);
					        TurnToward(opponent);
                          elseif(RandomInt(3)==1)
					        opponent := ev.source;
			  		        SetOpponent(opponent);
					        TurnToward(opponent);
                          endif
		SYSEVENT_ENGAGED:
			if (ev.source)
			  process_combat_event(ev);
			  if (Random(6)==1)
				if ((!ev.source.npctemplate) || (ev.source.script == "tamed") )
					opponent := ev.source;
			  		SetOpponent( opponent );
					TurnToward( opponent );
				endif
			  endif
			endif
                EVID_PEACEMADE:
			PeaceMade();
			return;
	endcase
    SleepMS( 25 );
    endwhile

    post_combat();
     
endfunction

Tomi
POL Developer
Posts: 475
Joined: Tue Feb 21, 2006 5:08 pm

Re: Error compiling statement

Post by Tomi » Tue Aug 18, 2009 11:50 am

Code: Select all

opponent.serial == me.serial
me is not declared

Post Reply