Hello,
Here is my first attempt at creating a simple AI. Can someone peruse it for me and see if my syntax is ok. Not sure if im grasping the DBC language fully but the maths work in Excel
function npc_attributes (strength,intellegence,wisdom,stamina,charisma,hearing,vision,action,voice,stimuli
hitpoints = strength + stamina)
motivation = action + stimuli + charisma
pain_level = hitpoints / motivation
attack_percent=(hitpoints - motivation)/pain felt
damage = (strength + intellegence)* wisdom + action
attack_noticed (hearing + vision + stimuli) + (pain_level *2) - damage
well_flee (attack_noticed +pain_level) / attack_percent
will_attack(100 -will_flee)
attack_action_noticed = RND(100)
if attack_action_noticed < attack_noticed
attack_action_taken =1
endif
if attack_action_taken =1
he_will_flee = rnd(100)
endif
if he_will_flee < Well_flee
True_action_taken = "flee"
else
True_action_taken = "attack"
endif
endfunction True_action_taken, hitpoints
`helpfile, you pass the following to this function for the npc
` strength 50-300
` intellegence 20-200
` wisdom 1-50
` stamina 20 -70
` charisma 1 -100
`hearing 1 -100
`vision 10-20
`action 1-10
`voice 1-10
`stimuli 1-10
`as you can see these values determine if an attack was recognised and what
`action to take if it was. I checked all these numbers and the lower the number
` the less likely the npc will run. if the numbers are high in fact at the highest
` the npc will attack 99.33091667 percent and flee .669083333
` while at the lowest npc will flee 27.33830846 and attack 72.66169154
` This is my first AI attempt, and if you RND the functionvalues, youll get some interesting effects
` just be leary of the values,
` being this is my first attempt. if someone wants to point out my mistakes
` in syntax.
` plus this doesnt leave but 2 actions, But if this is a good start I can expand.
` not sure if the syntax is right..
` voice is there for the extra function. like if you check hitpoints, the likelyhood
` the npc will call out and based on the voice variable, whether its heard by neighboring npcs
` then you can do a charisma check to see if the other npcs will respond.And if so how.
` thats why i left the voice variable in there. future expansion.
` also looking at the code I can see another function to be called from this one and
` break the code down a little further. but again. I have no NPC to check it with so
` if someone has the time and willingness.
` thanks
` manta01
Thanks again,
Manta01
Signature? Signature? we dont need no stupid Signatures.