Casters and Statics or LOS

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

Moderator: POL Developer

Post Reply
Breg
New User
Posts: 27
Joined: Sat Dec 09, 2006 11:58 am

Casters and Statics or LOS

Post by Breg » Fri Sep 26, 2008 8:53 am

Having trouble with npc casters casting through Mountains and fences, If someone could give me the specific directories to edit or code to tweak it'd be appreciated I've looked and it stumped me.

User avatar
*Edwards
Forum Regular
Posts: 302
Joined: Fri Dec 28, 2007 11:19 pm
Location: Montreal, Canada

Re: Casters and Statics or LOS

Post by *Edwards » Fri Sep 26, 2008 12:53 pm

First I would suggest you to look in your npcdesc.cfg found in distro/config for your npc description. Then you'll find a script attached to your NPC that you may probably find in distro/scripts/ai. The just open the file and add a check when it calls the function for casting.

Something like:

Code: Select all

If( CheckLineOfSight( npc, victim ))
      CallYourFunctionHere();
endif

Breg
New User
Posts: 27
Joined: Sat Dec 09, 2006 11:58 am

Re: Casters and Statics or LOS

Post by Breg » Fri Sep 26, 2008 6:16 pm

Okay so none of my Ai Scripts call for this code and I would definately like to try it out, where would I insert in a script such as this?

Ai For Undead Spellcasters

Code: Select all

use os;
use uo;
use npc;
use util;
use cfgfile;

include "../pkg/npcs/main_ai/setup/setup";
include "include/attributes";
include "../pkg/npcs/main_ai/main/mainloop_killpcs_normal";
include "../pkg/npcs/main_ai/main/sleepmode_normal";
include "../pkg/npcs/main_ai/combat/fightmode_normal";
include "../pkg/npcs/main_ai/combat/closedistance_spellcaster";
include "../pkg/npcs/main_ai/combat/changeopponent_default";
include "../pkg/npcs/hostiles/undead/undead";
include "../pkg/npcs/npc_util";

const HALT_THRESHOLD := 13; // how close before he attacks?
drop_anchor();

program KillPlayers()
	if (!me.backpack)
		DoOnCreationSetup();
	endif
	DoStartupSetup();

	if (GetObjProperty(me, "frozen"))
		me.frozen := 1;
	endif

	post_combat();
	main_AI_loop();
endprogram

function process_combat_event(byref ev)

	SpellAttack(ev.source);

	case (ev.type)
		EVID_DAMAGED:
			if ( GetHp(me) < (GetStrength(me)/2))
				sleep(1);
				CastSpell(me, me,":misc_spells:gheal");
				if( me.poisoned )
					CastSpell(me, me, ":poison_spells:cure");
					CastSpell(me, ev.source, ":poison_spells:poison");
				endif
			endif
	endcase
endfunction

function SpellAttack(byref opponent)

	if (!GetObjProperty(me,"#lastspell"))
		SetObjProperty(me,"#lastspell",ReadGameClock() + 2);
	endif

	if (GetObjProperty(me,"#lastspell") > ReadGameClock() )
		return;
	endif

	if (RandomInt(3))
		sleep(1);
		cast_offensive_spell(me,opponent);
		SetObjProperty(me,"#lastspell",ReadGameClock() + 4);
	endif

endfunction

function in_combat_event_loop(byref opponent)

	if (!CheckLosAt(me, opponent.x, opponent.y, opponent.z))
	   look_around();

else
	SpellAttack(opponent);
	endif
endfunction

function prepare_for_fight(byref opponent)
	if (!GetObjProperty(me, "mr"))
		CastSpell(me,me,":misc_spells:reflect");
	endif

	DisableMainEvents();
	EnableCombatEvents();
endfunction

function post_combat()
	if ( GetHp(me) < (GetStrength(me)/2))
		CastSpell(me,me,":misc_spells:gheal");
	endif

	DisableCombatEvents();
	EnableMainEvents();

	SetWarMode( 0 );
	sleep(1);
	look_around();
endfunction

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

Re: Casters and Statics or LOS

Post by CWO » Sat Sep 27, 2008 4:25 pm

you need to check more than just the src. You need to check the include files too. Since a LOS check would logically be in the main loop and/or a fighting loop, you might want to check the include files that seem to be named appropriately...

include "../pkg/npcs/main_ai/main/mainloop_killpcs_normal";
include "../pkg/npcs/main_ai/combat/fightmode_normal";

cucciola3000
New User
Posts: 12
Joined: Fri Aug 25, 2006 8:06 am

Re: Casters and Statics or LOS

Post by cucciola3000 » Tue Feb 03, 2009 1:15 am

The problem was that LOS return True....

Post Reply