Soulless
Super Moderator
Posts: 335
Likes Given: 29
Likes Received: 49 in 27 posts
Joined: Jun 2012
Reputation: 12
Ye Olde Sphere
|
RE: NPCS - Town stones
Deal! i need a proper system for the faction guards and smarter npcs.
Here is teh bulk of the system, the omitted stuff is the defs and some of it is cosmetic stuff, like the story line and npcs and such. but you can see from this, its just a simple system that has both the factions vie for control over towns. the guards attack each other and players who are members of the opposite faction.
Code:
[dialog d_faction_selection]
50, 50
nomove
noclose
page 0
resizepic 85 15 5054 455 455
gumppic 35 -5 10440 99
gumppic 508 -5 10441 38
page 1
resizepic 220 19 2620 184 37
resizepic 225 25 3000 175 25
resizepic 325 190 5054 150 195
resizepic 160 190 5054 150 195
dtext 250 25 100 Race Selection Menu
dhtmlgump 100 60 430 125 0 1 Welcome, <src.name>. On this server you will select a race for your character, certain aspects and abilities your character may have will be affected by this decision. The races are split into two seperate factions, <def0.faction_1_name> and <def0.faction_2_name>, the factions are at war with each other. They freely and openly have combat with each other through out the realm. This is an irreversible property once selected, so please ensure the race you decide upon is one you will continue to enjoy as you play. Below are the current available races, click on one to view that races specific details.
for 1 8
dtext 180 201 063 <def0.faction_1_name>
dtext 350 201 026 <def0.faction_2_name>
if (<def0.race_<eval <local._for>>_faction>==1)
local.good_races += 1
else (<def0.race_<eval <local._for>>_faction>==2)
local.evil_races += 1
endif
button <eval (170*<def0.race_<eval <local._for>>_faction>)> <eval (210+(20*((<local._for>)-<local.<qval (<def0.race_<eval <local._for>>_faction>==1)?evil:good>_races>)))> 1209 1210 1 0 <eval (<local._for>+1)>
dtext <eval ((190-<qval <def0.race_<eval <local._for>>_faction>==2?10:0>)*<def0.race_<eval <local._for>>_faction>)> <eval (206+(20*((<local._for>)-<local.<qval (<def0.race_<eval <local._for>>_faction>==1)?evil:good>_races>)))> 1152 <def0.race_<eval <local._for>>>
endfor
[dialog d_faction_selection button]
onbutton=0
src.dialogclose d_faction_selection
src.sdialog d_faction_selection
onbutton=1,9999
src.dialogclose d_faction_selection
src.sdialog d_race_detail <eval (<argn>-1)>
[dialog d_race_detail]
50, 50
nomove
noclose
page 0
resizepic 85 15 5054 455 455
gumppic 35 -5 10440 <qval (<def0.race_<eval <argn1>>_faction>==1)?99:38>
gumppic 508 -5 10441 <qval (<def0.race_<eval <argn1>>_faction>==1)?99:38>
page <argn1>
resizepic 220 19 2620 184 37
resizepic 225 25 3000 175 25
dtext 250 25 <qval (<def0.race_<eval <argn1>>_faction>==1)?063:026> <def0.race_<argn1>> Overview //100 <def0.race_<argn1>> Overview
gumppic 100 65 2224
dtext 120 62 <qval (<def0.race_<eval <argn1>>_faction>==1)?063:026> Description
dhtmlgump 100 80 215 300 0 1 <def0.<def0.race_<argn1>>_description>
gumppic 320 65 2224
dtext 340 62 <qval (<def0.race_<eval <argn1>>_faction>==1)?063:026> Racial Traits
dhtmlgump 320 80 215 300 0 1 <def0.<def0.race_<argn1>>_traits>
button 310 428 210 211 1 0 <eval <argn1>+1>
dtext 335 426 <qval (<def0.race_<eval <argn1>>_faction>==1)?063:026> I wish to become a <def0.race_<argn1>>
button 95 428 210 211 1 0 1
dtext 120 426 <qval (<def0.race_<eval <argn1>>_faction>==1)?063:026> Main Menu
[dialog d_race_detail button]
onbutton=0
src.dialogclose d_race_detail
src.dialog d_faction_selection
onbutton=1
src.dialogclose d_race_detail
src.sdialog d_faction_selection
onbutton=2,9999
src.dialogclose d_race_detail
src.sysmessage @0482 You have selected the <def0.race_<eval (<argn1>-1)>> race, congratulations!
src.tag0.faction=<eval <def0.race_<eval (<argn1>-1)>_faction>>
src.tag0.race=<eval (<argn1>-1)>
src.tag.name.suffix " the <def0.race_<eval (<argn1>-1)>>"
src.events=+e_race
if !(<var0.faction1>)
serv.newitem i_town_stone
new.p=5376 1086
new.name <def0.faction_1_name>
new.color 063
new.update
var.faction1=<new.uid>
endif
if !(<var0.faction2>)
serv.newitem i_town_stone
new.p=5376 1085
new.name <def0.faction_2_name>
new.color 026
new.update
var.faction2=<new.uid>
endif
ref1=<var0.faction1> //make sure to remove the character from either faction if he's a part of either one...
ref2=<var0.faction2>
ref1.resign <src.uid>
ref2.resign <src.uid>
ref<eval <def0.race_<eval (<argn1>-1)>_faction>>.JoinAsMember <src.uid> //add player to correct faction
ref1.declarewar <ref2.uid> //make sure both factions are at war with each other
ref2.declarewar <ref1.uid>
[itemdef i_town_sigil]
id=i_virtstone_7
name=Town Sigil
type=t_sign_gump
on=@create
attr=attr_move_never
timerf 1,setup_new_sigil
on=@click
message @<qval <src.tag0.faction>==<tag0.factioncontrol>?044:02b> <region.name> Sigil [<def0.faction_<eval <tag0.factioncontrol>>_name>] [<qval <tag0.corrupting>?Corrupt:Pure>]
return 1
on=@dclick
if (<src.flags>&statf_dead)
src.sysmessage Your ghostly hand passes through the object.
return 1
endif
if (<src.distance <uid>>>3)
src.sysmessage You can't reach that.
return 1
endif
if (<tag0.factioncontrol>==<src.tag0.faction>) && !(<tag0.corrupting>)
message Your faction already has total control over this sigil.
return 1
endif
if (<tag0.factioncontrol>==<src.tag0.faction>) && (<tag0.corrupting>)
serv.allclients faction_announcement,<src.tag0.faction>,The <def0.faction_<eval <src.tag0.faction>>_name> has purified the <region.name> sigil.
tag0.corrupting=
more1=
timer=
return 1
endif
if (<tag0.factioncontrol>!=<src.tag0.faction>) && (<tag0.corrupting>==<src.tag0.faction>)
message Your faction is already in the process of corrupting this sigil.
return 1
endif
if (<tag0.factioncontrol>!=<src.tag0.faction>)
serv.allclients faction_announcement,<src.tag0.faction>,The <src.name> is corrupting the <region.name> sigil.
tag0.corrupting=<src.tag0.faction>
more1=<eval (60*<def0.corrupt_time>)>
timer=1
return 1
endif
on=@timer
if (<tag0.corrupting>) && (<more1>)
if (<more1><=10)
say @023 <eval <more1>>
elseif (<more1>==60) || (<more1>==120) || (<more1>==180) || (<more1>==240) || (<more1>==300)
serv.allclients faction_announcement,<tag0.corrupting>,The <def0.faction_<eval <tag0.corrupting>>_name> will control <region.name> in <eval (<more1>/60)> minutes.
endif
more1 -= 1
timer 1
return 1
endif
if (<tag0.corrupting>)
tag0.factioncontrol=<tag0.corrupting>
var0.<region.name>_control=<tag0.factioncontrol>
serv.allclients faction_announcement,<tag0.factioncontrol>,The <def0.faction_<eval <tag0.factioncontrol>>_name> now controls <region.name>.
color=<def0.faction_<eval <tag0.factioncontrol>>_color>
link.color=<def0.faction_<eval <tag0.factioncontrol>>_color2>
tag0.corrupting=
return 1
endif
[function faction_announcement]
sysmessage @<qval <tag0.faction>==<argv[0]>?044:02b> <argv[1]>
[function setup_new_sigil]
serv.newitem i_sigil_Pedistal
new.p=<p>
nudgeup 18
link=<new.uid>
[itemdef i_sigil_pedistal]
id=i_gravestone_17
name=Sigil Pedistal
type=t_spawn_char
on=@click
message @<qval <var0.<region.name>_control>==<src.tag0.faction>?044:02b> <region.name> Sigil Pedistal
return 1
on=@create
attr=attr_move_never
amount=<def0.sigil_guards>
more spawn_faction_guards
morep 1 5 10
timer=1
on=@dclick
if (<var0.<region.name>_control>==<src.tag0.faction>)
src.dialog d_faction_menu
return 1
else
message Your faction does not control this region, you can not use this!
return 1
endif
Guard Stuff
Code:
[events e_faction_guards]
on=@click
adjust_guard_noto
//adjust_guard_outfit
on=@npcseenewplayer
adjust_guard_noto
adjust_guard_outfit
attack_enemies
on=@npclookatchar
adjust_guard_noto
adjust_guard_outfit
//attack_enemies
[function spawn_faction_guard]
serv.newnpc { c_faction_knight 1 c_faction_spearman 1 c_faction_bowman 1 c_faction_mage 1 }
new.adjust_guard_outfit
new.p=<p>
[function adjust_guard_outfit]
local.layer=0
while <local.layer><=24
if (<local.layer>==21) || (<local.layer>==16) || (<local.layer>==11)
local.layer += 1
else
if (<findlayer.<local.layer>.type>==t_armor) || (<findlayer.<local.layer>.type>==t_armor_Leather) || (<findlayer.<local.layer>.type>==t_shield)
findlayer.<local.layer>.color <def0.faction_<eval <var0.<region.name>_control>>_color>
elseif (<findlayer.<local.layer>.type>==t_clothing)
findlayer.<local.layer>.color <def0.faction_<eval <var0.<region.name>_control>>_color2>
endif
local.layer += 1
endif
endwhile
findlayer.25.color <def0.faction_<eval <var0.<region.name>_control>>_color2>
[function adjust_guard_noto]
if (<src.tag0.faction>!=<var0.<region.name>_control>)
tag0.override.noto.<src.uid>=5
else
tag0.override.noto.<src.uid>=
endif
[function attack_enemies]
if (<src.tag0.faction>!=<var0.<region.name>_control>) && (<src.isplayer>)
serv.log attack
endif
[spawn 99999]
defname=spawn_faction_guards
category=Spawn Groups
subsection=Factions
description=Faction Guards
id=c_faction_knight
id=c_faction_bowman
id=c_faction_spearman
id=c_faction_mage
|
|
07-12-2012 06:15 PM |
|
|
Soulless
Super Moderator
Posts: 335
Likes Given: 29
Likes Received: 49 in 27 posts
Joined: Jun 2012
Reputation: 12
Ye Olde Sphere
|
RE: NPCS - Town stones
here's my AI as of now. i feel like the weapon selection part could be simplified, but i wanted to make the npc as brilliant as possible. incase the project grows and he ends up looting random weapons/shields. checks for the strongest damage weapon + skill of npc factors into weapon selection. if the best weapon is 1 handed the npc then looks for the best shield in its bag and equips it. its missing a ranged weapon selection process but has a spot for it. the rest is stuff i gutted from the npc_ai script in the addon from the SCP pack.
as a side note, does anyone know how to make it so that an NPC will walk from one spot on the map to another. like say from britain graveyard to britain bank, id like him to run the whole way. anyone know how to do that?
Code:
[defname custom_ai_settings]
fearofdeath 60
healself 60
[events e_custom_AI]
on=@gethit
if ((<body>==c_man) || (<body>==c_woman)) && (<memoryfindtype.memory_war_targ>)
if (<distance <memoryfindtype.memory_war_targ.link.uid>> < 3) //equip the best melee weapon i can find, enemy is close range
ref1=<uid>
ref2=<findlayer.1.uid> //if i have a weapon in my hand start with it
if (strmatch(t_weapon*,<findlayer.2.type>) && (<findlayer.2.type>!=t_shield) && (<findlayer.2.type>!=t_weapon_bow) && (<findlayer.2.type>!=t_weapon_xbow)
ref2=<findlayer.2.uid> //if i'm holding a two hand weapon start with that (not a shield or ranged weapon)
endif
forcont <findlayer.21.uid> 1
if (strmatch(t_weapon*,<type>) && (<type>!=t_weapon_arrow) && (<type>!=t_weapon_bolt) && (<type>!=t_weapon_bow) && (<type>!=t_weapon_xbow)
if !(<ref2>) //if i'm not holding any weapons start with the first on you find in my bag
ref2=<uid>
endif
if <eval (<damavg <dam>>+(<ref1.<serv.skill.<skill>.key>>/10))> > <eval(<damavg <ref2.dam>>+(<ref1.<serv.skill.<ref2.skill>.key>>/10))>
ref2=<uid> //if this weapon is best so far that i have skill in, keep it in mind
endif
endif
endfor
if (<ref2>!=<findlayer.1.uid>) && (<ref2>!=<findlayer.2.uid>)
ref1.equip <ref2> //equip the best weapon ive got (skill accounted for also)
endif
if (!<findlayer.2.uid>) || !(strmatch(t_weapon*,<findlayer.2.type>) //now that i'm holding my best weapon, if it's one handed see if i have a shield
ref2= //clear reference 2
if (<findlayer.2.type>==t_shield)
ref2=<findlayer.2.uid>
endif
forcont <findlayer.21.uid> 1
if (<type>==t_shield) //if i don't have a shield equipped start with first one found in bag
if !(<ref2>)
ref2=<uid>
endif
if (<damavg <armor>> > <damavg <ref2.armor>>)
ref2=<uid> //if this shield is the best so far, keep it in mind
endif
endif
endfor
if (<ref2>)
ref1.equip <ref2> //equip the best shield ive got
endif
endif
elseif (<distance <memoryfindtype.memory_war_targ.link.uid>> > 3)
return 0//i'm being attacked at range, if i have a bow or crossbow, equip it
endif
endif
if (<hits> < <eval (<str>*<def0.fearofdeath>)/100>)
//if !(<findid.i_potion_heal>)
if (<src.uid> != <uid>)
act = <src.uid>
flee 20
tag0.fleeing = 1
damage <argn1> <argn2> <uid>
return 1
endif
//endif
endif
//heal myself with a potion if i have one, when im below 'def.healself'% health
if (<hits> <= <eval (<maxhits>*<def0.healself>)/100>)
if (<findid.i_potion_heal>)
findid.i_potion_heal.useitem
return 0
endif
endif
//heal myself with magic if im able, when im below 'def.healself'% health
if (<hits> <= <eval (<maxhits>*<def0.healself>)/100>)
if (<cancast s_greater_heal>)
npccast s_greater_heal,<uid>
endif
endif
//dispell conjured/summoned pets that are attacking me
if (<src.flags>&statf_conjured)
if (<mana> > <serv.spell.s_dispel.manause>)
src.spelleffect s_dispel,1500
src.sound snd_spell_dispel
mana -= <serv.spell.s_dispel.manause>
endif
endif
//attack the person dealing the most damage to me
local.mosthits = 0
local.most_dangerous_enemy = 0
for n 0 <eval <attacker> -1 >
if (<attacker.<dlocal.n>.dam> > <local.mosthits>) && (<canseelos <attacker.<dlocal.n>>>)
local.mosthits = <attacker.<dlocal.n>.dam>
local.most_dangerous_enemy = <attacker.<dlocal.n>>
endif
endfor
attack <local.most_dangerous_enemy>
on=@npcactfight
if (<tag0.fleeing>)
argn = -1
endif
[function damavg]
return <eval ((<argv[0]>+<argv[1]>)/2)>
[chardef c_icedragon]
name=IceDragon
id=c_man
dam=15,20
armor=//20
tevents=e_custom_ai
category=Custom
subsection=NPCs
description=IceDragon
on=@create
npc=brain_human
color=colors_skin
str={151 165}
dex={151 165}
int={151 165}
swordsmanship=100.0
tactics=100.0
magicresistance=100.0
healing=100.0
itemnewbie=i_hair_ponytail
color=colors_hair
itemnewbie=i_beard_goatee
color=match_hair
on=@npcrestock
item=i_platemail_gloves
item=i_platemail_helm
item=i_platemail_arms
item=i_platemail_gorget
item=i_platemail_chest
item=i_platemail_leggings
item=i_halberd
item=i_cape
color=0386
item=i_tunic
color=020
item=i_kilt
color=0386
item=i_potion_heal
item=i_potion_heal
(This post was last modified: 07-13-2012 02:16 AM by Soulless.)
|
|
07-13-2012 02:15 AM |
|
|
Anarch Cassius
Master
Posts: 273
Likes Given: 19
Likes Received: 10 in 9 posts
Joined: Mar 2012
Reputation: 2
|
|
07-13-2012 02:14 PM |
|
|