Casters and Statics or LOS
Moderator: POL Developer
Casters and Statics or LOS
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.
Re: Casters and Statics or LOS
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:
Something like:
Code: Select all
If( CheckLineOfSight( npc, victim ))
CallYourFunctionHere();
endif
Re: Casters and Statics or LOS
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
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
Re: Casters and Statics or LOS
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";
include "../pkg/npcs/main_ai/main/mainloop_killpcs_normal";
include "../pkg/npcs/main_ai/combat/fightmode_normal";
-
- New User
- Posts: 12
- Joined: Fri Aug 25, 2006 8:06 am
Re: Casters and Statics or LOS
The problem was that LOS return True....