DOH, Thanks WindowsKiller, I see what your talking about, I did put the bracket in the wrong place, it should be on the first line. Thats what I get for programming at 3AM... thanks again. that Bracket goes up one level.. Here's the new code fixed per the comments. 3 mistakes thats not too bad for a First attempt i guess, not as good as 0 though *smiles* And thanks 'theComet' I meant them to be strings. oops thats 4 mistakes drat!!
One question, is it possible to return an complete Array from a function? or is it one and only one return variable? IE can you return an array that your Dim'd in your function like this
dim arrayname(2)
`assign strings to each array member
endfunction arrayname
would that work or would i get an undefined error
Thanks again.
Manta01
updated code below renamed to accurately describe function.
function npc_Attack_no_attack (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
`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
Signature? Signature? we dont need no stupid Signatures.