CrossCut Games Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Puzzling brains trigger.

 
Post new topic   Reply to topic    CrossCut Games Forum Index -> Creator
View previous topic :: View next topic  
Author Message
Wombat140



Joined: 12 May 2009
Posts: 516
Location: Lancashire, UK

PostPosted: Thu Dec 20, 2012 12:59 pm    Post subject: Puzzling brains trigger. Reply with quote

This is what Thorin and Gandalf in the "Hobbit" tome currently have for brains triggers! Can you work out what it does, exactly? What is there meant to be about this that "CombatTarget Closest" wouldn't do?

Code:
' We haven't found any targets
' yet - flag that we haven't.
Let Local.ByteA = Global.False
' initialize closest to 255 distance,
' so that anything will be closer than
' that
Let Local.IntegerA = Pos.255
' some slight trickery to read distances
' using the RangeToTarget property
' without constantly setting CreatureTarget
Set CreatureTarget = CreatureNow
' scan through encounter for the closest target
' that is neither friendly nor inanimate
ForEach CreatureA In EncounterNow
If CreatureA.Health < Pos.1
' skip the dead
Branch Pos.20
EndIf
If CreatureA.IsFriendly = Global.True
' skip friendly
Branch Pos.20
EndIf
If CreatureA.IsInanimate = Global.True
' skip inanimate
Branch Pos.20
EndIf
If CreatureA.RangeToTarget < Local.IntegerA
' current best target - save range
Let Local.IntegerA = CreatureA.RangeToTarget
' save pointer
Set CreatureB = CreatureA
' flag that we got one
Let Local.ByteA = Global.True
EndIf
If Pos.1 = Pos.0
' skip point - clean endif
Label Pos.20
EndIf
Next
' did we get one?
If Local.ByteA = Global.True
' got one - target it and attack
Set CreatureTarget = CreatureB
CombatAttackWithWeapon
Else
' didn't get one - back off
CombatMove AwayFrom Closest
EndIf
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    CrossCut Games Forum Index -> Creator All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group