Major Warning: This draft documentation was generated from the comments in the source code (using progrutils.documentPyFile()), under the principle that poor documentation is better than no documentation. The only intervention was done to remove code specific to attributes (and yes, the code structure itself is as messy as that :P ). In case of ambiguity, please refer to the code itself.
By Dr Mike 2000
with contributions from C4, CatWhoWalksByHimself, Épiméthée, Kuertee, M25, Shazam, Stumpy, SouperIan and TaskMasterX
the range at which various powers kick in
EP costs for certain activities
strength/chance of effects
not included in FF API, but makes code more readable
Ep. 2006-08-22: made accessible without doing a from ffx import * or prefixing with the ffx. module; added PCSTATE_DEAD; regrouped
heroes with AI_DestroyAI applied DONT flag as OC_CHARACTER! using this fixes it!
some weird numbers used by the FF engine... (FWIW, this number is also hex 0x40000000 or octal 010000000000 -Ep. 2006-06-15.)
gender
FFX secondary states
collection of 'fake' attributes forced by script
materials
- Material 11 is neutral and weights the same as flesh (FFvsTTR's other neutral material), hence the repetition of "flesh" here.
- Dark Matter (material 12): hidden material:
- defenseless against crushing, piercing, energy, fire, radiation, electricity, acid and cold
- weak against mental and mystical
- Ectoplasm (material 13): hidden material:
- defenseless against crushing, piercing, energy, electricity and acid
- weak against mental and mystical
- normal against fire, radiation and cold
- Setting Object_SetAttr(char, 'material' x) to a value above 13 tends (?)
to make the character completely immune to these two damage types.
Mission_SetAttr("FFX_RULES_WHOAMI",FFX_RULES_WHOAMI)
Global_RegisterAttr('team',0) # Ep. 2006-07-21: Obsolete; to be removed
Global_RegisterAttr('brawler',0) # Ep. 2006-08-28: Obsolete; to be removed
weapons:
called when the user picks up a weapon
changed for character-specific attributes such as Latent Mutant
Ep 2006-07-17:
- added detection of built-in attributes; to disable, set ffxOnly=1
- Note that the built-in "fast healing" (for example) and the scripted "fasthealing" aren't considered as one attribute to keep
overhead low, since the attribute is used constantly in the FFX update loops.
Ep. 2006-08-19
- An attribute used to be set for the whole template in parseLogFile; it's now set here at the character level only.
Consequently, the templateOnly parameter has been removed.
Ep. 2006-09-10: Added check to prevent error on non-characters.
For other attribute-related functions, see the CHARACTER ATTRIBUTES MANIPULATION section under FFQ.
def FFX_GetTemplate(char, verbose=0):
if complex>2000:
return ffxSaved[complex-2001][0]
strips off '_mp' at the end
given a name returns a unique integer ID
given an ID form store template, returns the original template name
if complex>2000:
return ffxSaved[complex-2001][0]
if Object_GetPrimaryState(obj)==15:
Object_SetAttr(obj,'health',0)
relative costs for special powers that trigger an event:
empathy, cloak, displace in that order
based on the cost of swappable state attacks ---
mental attacks
mystical attacks
other
stun carriers - now rarer and more costly than in FF1
non-resistable
HYPNO: 24-36
NORMAL: 8-24
WEAK: 6-20
STUN: 4-16
put overrides in here for more interesting stuff than just metal/stone all the time
template=getTransmute(source,char)
if Object_GetPrimaryState(char)!=PCSTATE_EXILE:
Object_SetPrimaryState(char,PCSTATE_EXILE,4*intensity,0)
special function for pan's transmutations
removes the portrait but keeps the character ticking as a real live AI
returns if they have a portrait or not
RegTimer('keepRallied',1,0,char)
print 'setting extra knockback up'
the tuples stored in here are template, mass and material
if the object isnt throwable, mass gets listed as :
char - object name of old form
template - template to morph into
proprotional - whether to scale or retain maximum Health
hasPortrait - true if triggered from a custom command, ie the character is controllable
if hasAttribute(char,'butterfingers'):
Ep. 2006-07-22: Updated forFFvsTTR new states... Oops - the function was not used at all anyway.
Ep. 2006-07-17: added string parameter
stumpy 2006-12-30: changed types to powertypes to avoid having a global with the same name as the module types.
!Ep 2006-02-05
!Ep 2006-02-05
Code developped for Apfarmakis - not available through the Control Center; left only as reference for eventual further developments
for use with Dr Mike's Nocturnal attribute
increases strength, health, invulnerability and energy
tries to prevent a character from being frozen in a specific animation after using AI_Animate()
summoned and then free of their own accord
Clean up PA AI goals if target is KOed. Only called for M25_USE_AI set.
Ep 2006-09-06 made less verbose
Ep 2006-02-05 isMinupeUp() variant on request of apfarmakis
Ep 2006-02-05 Added check for the object existence to the is..() functions below
Kuertee 2006-07-30 added default empty string to char os that these checks don't error when only 1 parameter is sent
Ep. 2006-09-05
Ep. 2006-09-05
other is...() secondary state functions available under FFQ object identification helpers section
electricalSources=(): moved to ffxextras.py
Kuertee 2006-07-30 - added "if char != '' and..." so that it doesn't return error when only 1 parameter is sent
stumpy 2007-01-10: added check that health is half that of tested object, so that we only compare with the original.
Ep. 2006-08-28: changed name from isAlive() to avoid confusion
as this functiondoesn't detect if the object is currently alive;
what it detects is if the object is a living entity (vs. a prop or a dumb machine)
see the magicBeings customization tuple in ffxextras.py
see the nazis customization tuple in ffxextras.py
Ep 2006-02-05 Symbiote/Parasite customisation additions
returns 1 only if the object has the symbiote attribute and if both the object and the char are the same subtype of symbiote
returns 1 only if the object has the parasite attribute and if both the object and the char are the same subtype of parasite
!Ep 2006-02-05 used by FFX_SYMBIOTE_CUSTOM
Characters with the attributes in the specialAttribs tuple will have custom commands on special objects
Default is specialAttribs=('scientist','finetk','magnetic','telepathy')
Cf. ffxcustoms.py.
miracle functions:
restore the command to boost strength (or become unstoppable) again
gives a character 50% chance of getting an additional hero point once, up to a max of 4 hero points.
added Ep FFX 3.2 alpha 2006-04-27; updated 2006-09-17
side effects
event.object is the character
event.user is the power index (1 to 5)
!Ep 2006-02-05 default state for Speed Force
fires off a last shot
increases strength as damage is taken
spawns a nearby creature on death or in response to damage
Ep 2006-0-07: teleport multiple times around your initial position, making you harder to hit
Note that this stops previous movement requests.
Mission_StatusText('hiders=%d'%(Mission_GetAttr('hiders')))
print 'adding command %s to %s'%(command,char)
print 'removing command %s from %s'%(command,char)
print 'adding command %s to %s'%(command,char)
print 'removing character command %s from %s'%(command,char)
reg 21 against all characters who havent been done so far
stumpy 2007-01-02: we need to clear the FFX attrib for character
objects when they are destroyed so that they will be re-registered
if the same names are used for another spawned character. We ay do
that sort of re-using of object names in FFX and some campaign
missions definitely do it (e.g. the wraiths and subterrestrials in
the main campaign). (This may also be necessary for non-character
objects, but I am holding off on that to keep regObjectDestroy sinks
low.)
Ep. 2006-08-23: Changed to use FFvsTTR's Mission_GetObjects()
Note that much of this section is obsolete
Ep. 2006-08-23: Added to replace the hard-coded ffxextras.builtinHeroes tuple
Returns a list of characters in objects.dat with the GAME_OBJ_HERO class.
returns 1 for first hero above, 2 for second etc.
or custom template number for custom recruits
gets the template which this character started the mission with
takes number above and turns it back into a template
hero may be pickled by explosive/laser
hero may be in form_X after shapeshifting/mimicking
STRANGERS SPECIFIC - hero may be penny/alculbus separated
ALERT! DIFFERENT ORDER OF VARIABLES FROM regTimer!
see also RegTimer2 under the STUMPY HELPERS section toward the end of this file ###!
This doesn't register the start of a movement, but rather its end
Special movements like speeding bullet don't register.
the mysterious reg-21 triggers when the power specified is used by character on target
used everywhere for destroying temporary objects
used everywhere for destroying temporary objects
!
print 'damage4:%d'%(damage4)
print 'Message broadcast: %d %d %d %d'%(type,param1,param2,param3)
calculate the force required to push a character a certain distance
print 'ffx_tp2:char=%s'%(char)
makes a character physically ineffectual
initilaises a base cutscene
returns a custom character by voice ID
determines if a character has a given trait by name
returns a custom character by voice ID
Probably obsolete! everything done automatically on startup should either be here, under the "else:" statement
or called directly outside any function
Functions related to FFX attributes. This section should probably be moved elsewhere in the file
and regrouped with similar functions.
The following removed FFX 3.2.0.1 Ep. 2: Obsolete due to individual attribute setting by default.
FFX_ATTR_BY_TEMPLATE = [] #lists FFX attributes for each template in the current mission
FFX_ATTR_SPECIAL_CASES = [] #lists additional FFX attributes for those characters who gained attributes not in their template
Used by FFX initialisation for all characters of the templates
def saveFFXAttributesForTemplate(template, attribute):
use this to add an attribute to a specific character AND register it so hasAttribute() returns the true state
ripped from initAttribsForChar()
Changed FFX 3.2 alpha: changed the Latent Mutant specific elements
def initNewAttribForChar(char, newAttrib, update = 0):
For characters gaining attributes during the mission (ex.: Latent Mutant)
def saveFFXAttributesForCharacter(char, attribute):
get the FFX attributes of this character's template
def getFFXAttributesForTemplate(char):
get the FFX attributes specific to this character
attributes need to have been initialized using initNewAttribForChar()
(using simply init[attribute name](char) won't work)
def getFFXAttributesForCharacter(char):
does the character have chacter-specific FFX attributes?
attributes need to have been initialized using initNewAttribForChar()
(using simply init[attribute name](char) won't work)
Added FFX 3.2
def hasFFXAttributesForCharacter(char):
remove attribute from the list for the character
note: this does not disable the attribute, only the indication that the character has it
def removeFFXAttributesForCharacter(char, attribute):
Added FFX 3.2
Attributes which are not part of the template must be initialized with this function instead of being called directly!
Returns whether the attribute was succesfully added or not. If the attribute was already present, the call is considered successful.
Added FFX 3.2
Attributes must be removed with this function instead of being called directly with the remove parameter!
To know which attributes are removable, use getRemovableAttributes() from the progrutils module.
Returns whether the attribute was succesfully removed or not. If the attribute wasn't found, the call is considered successful.
! TO DO: Obsolete since FFX 2.6!
FFX attributes (including simulated built-ins) which SHOULD be safe to add after startup.
Guess what? Not all attributes have been tested. :P
Notes:
-Put in a function to avoid wasting more memory.
-Combos are always considered unsafe.
-Some attributes, while "safe", may wreck the game (ex.: borrowedtime), while others (ex.: groupteleport)
are useless to most characters; these are denoted by a 1 instead of a 2.
-Currently, no attribute is marked as removable.
-The incompatible attribute sublist is basically to avoid initialising an attribute if the character already
has one from this sublist.
-The scripted version of attribute may be assigned to a character already having the original, since
built-in attributes can't be detected.
-May eventually be used (in FFX 2.6 or post FF2) as the basis for a Counter-Measure attribute ;)
! TO DO: Obsolete since FFX 2.6!
returns the following array:
["attribute name", cost, safe to initialize by in-game script only (0=no, 1=yes, but should be avoided, 2=yes), removable (0=no, 1=yes), ["incompatible attribute1", "incompatible attribute2", "etc."]]
! TO DO: Obsolete since FFX 2.6!
Check if the attribute within the current set (from getAllFFXAttr()) can be added to the character
Used with those attributes which are possibly scripted versions of built-ins before using
Mission_StatusText("@ATTRIB_%s"%string.upper(attrib)) to get the display name of the attribute.
Changed FFX 3.2: use reverse=1 to get the ffx name of a scripted attribute form the built-in name
Returns true if the attribute name corresponds to a scripted version of a built-in one
Note that for built-in attributes with spaces in the name, it returns false, even if there's a
scripted version, because the scripted name has no spaces. You can use getOriginalNameOfAttrib(attrib,reverse=1)
to get the name without spaces.
Get a tuple of all scripted attributes
Note that for built-in attributes with spaces in the name, it returns the scripted version's name,
i.e., without the spaces. Use getOriginalNameOfAttrib(attrib) to get the original name
Added FFX 3.2 Please update as needed!
return true if given attrib is one of the game's built-in character attributes
returns the list of character attributes for this object
charAttr: if set to 1, all FFX attributes for this characterwill be added to the returned list, including
those added with addFFXAttrib() and not present in the template
templateAttr: if set to 1, the default attributes for the template will be added to the returned list
ignoreBought: if set to 0, only already purchased template attributes will be added to the returned list
returns the list of character attributes specific to this object and not found in the template.
ignoreBought: if set to 0, unpurchased template attributes will be ignored from the comparison
Detects if an attribute can be removed before adding it.
Syntax example:
myVariable = isAttributeRemovable('heroic')
Note:
-This will generate an ff.log/console error message for attributes which try to access character properties.
This is intentional.
To know which attributes are removable, use getRemovableAttributes() from the progrutils module.
Checks if each of the attributes of a combo are removable.
in FFvsTTR, PowerNull for shields only doesn't work anymore, hence this workaround.
Turns the world red
char, string and float are ignored for this function
Turns the world blue
char, string and float are ignored for this function
Turns the world into colored wireframe
char, string and float are ignored for this function
Turns the terrain and non ambiant objects invisibles
char, string and float are ignored for this function
Shows physics displacement bubbles around moving objects
char, string and float are ignored for this function
TEMP! This needs to be replaced with more modern code based on M25 new system.
gives AI to a spawned oc_controllable character
basically a copy of FFX code
v1.4
-made the AI follow the nearest hero when idle
v1.5
-failsafes added for work with skirmish mode time travelers
used by FFQ_independantAI() and FFQ_givesAI()
cshelper code, modified to find the nearest hero which is NOT the calling character
finds if the target is on higher ground than the character while not flying
Ep. 2006-08-25: Updated for FFX 3.x
Note: other generic functions have been moved to the generalutils module
exclude from a first string array any entry of the second array contained in the first
characters of any entry of the first
example:
loadedTemplates=["eve_extra","minute_man_extra","mm_dupe"]
disallowedTemplates=["minute_man"]
allowedTemplates=[]
allowedTemplates=excludeFrom(loadedTemplates,disallowedTemplates)
will give
allowedTemplates=["eve_extra","mm_dupe"]
same, but more specific and useful: with names of active game objects as targets using templates as excludes
instead of excluding, allow only if from list
same, but more specific and useful: with names of active game objects as targets using templates as includes
Convert a 3-element tuple of numbers to a string and vice-versa, rounded down to one decimal
see also generalutils.sequenceToString() for a less specialized implementation
Updated FFX 3.2: Made faster
Reduce EP by a specified amount and return 1 if the character has no energy left
Allows to add or remove health safely by checking for minHealth and maxHealth.
Added FFX 2.5
kills a character after x seconds
Added FFX 2.5
IMPORTANT!: using the noFade() function is *very* *dangerous*: The game apparently checks if the object state = dead to determine the
character's behaviour and eventually fade him. However, he is considered alive for Object_IsAlive() and possibly both alive and dead
for RegDeath(). If some code checks for dead characters, it will return a false negative on a character under noFade()! If a persistent
RegDeath() is set on character and you call noFade() on him, the game will stall!
Bottom line: Don't use it.
Prevents an already dead civilian, minion or police class character from fading, as the noFade object attribute doesn't work in FFvsTTR
duration: if set to 0: infinite; if set to a positive value, character will start fading a few seconds after the time is up.
To disable, set FFX_ObjectSetAttr(char, 'noFade', 0)
(Note that the original Object_GetAttr(char, 'noFade') is left alone.
Added 3201Ep3
Gives the character the selected secondary state.
By default, duration is permanent. ADDED: duration set to 1000 secs, because flag isn't supposed to work,
according to the scripting docs.
To remove state, set duration to 0.
cshelper default duration for states is usually 10.
Updated in FFX 3.0
Notes:
-Irradiate and Acid Burn have a built-in set duration. This function doesn't attempt to work around that.
Shorthands for the generic function above
Changed FFX 3.0:
-Added FFvsTTR states
-Repaired is...() functions, as they were all broken...
-Removed functions redundants with those done by Dr Mike
the FFvsTTR built-in state, not the FFX one...
Set shield = 1 to prevent use of an active defence for the duration
Updated FFX 3.0
removeShield(): see under BREACH section
isBreached(): see under BREACH section
Notes:
-Irradiate and Acid Burn have a built-in set duration. This function doesn't attempt to work around that.
Notes:
-Irradiate and Acid Burn have a built-in set duration. This function doesn't attempt to work around that.
set generic states; can't be detected
cshelper default duration for states is usually 10.
updated Rally (OBJSTATE_ATTACKBONUS) to take into account attackBonus... :P
make all heroes invulnerable
1 to turn on, 0 to turn off
remember the starting position of your heroes one second after the beginning of the mission
2.0
returns the starting position tuple of the selected hero. If not found, return the (-1,-1,-1) tuple.
def FFQ_getMapSize():
Obsolete! Use Stumpy's datfile.Mission_GetMapExtents(MissionFileName='') for the *exact* map extents
modified from original ArrowBaddie()
Get the character name as displayed to the user (ex: 'el_diablo' for the engine is displayed as 'el diablo')
For use with Mission_StatusText(); won't work correctly for print commands.
Updated FFX 3.0:
-strings.dat lookup now require @ as identifier
Updated FFX 3.2:
-simplified
since I had some problems with regDeaths(), here's a team-based alternative
Relative orientation detection/conversion
Added FFX 2.5
Returns character orientation in radians (instead of the FF Object_GetOrientation()'s more esoteric format)
EDIT: Useless! Object_GetOrientation() is broken
accepts one number whose value is between -pi/2 and pi/2
used with Object_GetOrientation(char)[1] or FFQ_ObjectGetOrientation(char)
EDIT: Useless! Object_GetOrientation() is broken
angles are in radians
Based on Dr Mike's distanceSq(), but ignores the Z-axis and requires positions instead of objects
Added FFX 3.0
light sources detection
used by stealthy attribute
Added FFX 2.5
Updated FFX 3.05 alpha
see notes under stealthy attribute
returns light-emitting templates whose health is above 14 (light-emitting streetlights break under 15 health)
or any existing bonfire
ripped from FFX Telepathic Scan
added FFX 2.5
play an FX at fixed intervals with full tracking on spine
if repeat is set to a value greater than -1, the effect will repeat only x times after the first
if the Object is a character, effect will stop on death
Added FFX 2.5
Can the character lift this object?
"bonus" is a positive or negative integer added to strength for the comparison
The sum of strength and bonus shouldn't be superior to 11. Any value higher will always return true
Changed FFX 3.2: redone to use getMaxMassToLift(), which checks Heavy Lifter. Replaced hard-coded
mass list with getMaxLiftableMasses(), as it's more exhaustive and has more than single-decimal precision.
list of masses by strength level, ripped from Stumpy's Heavy Lifter code
the following is from testing, accurate to within attribute storage precision
Added FFX 3.2
What strength is the minimum to lift this object?
Added FFX 3.2
What is the maximum mass this character can lift?
Heavy Lifter bonus is calculated.
Added FFX 3.2
creates a "tiggot" related to an existing character on a specified position and returns his name
ripped from Telekinetic
Replaces the never-implemented command of the same name in the FF scripting manual. (Note that this becomes more important in FFvsTTR,
because we can spawn customs and because they then retain their template name instead of being renamed to 'custom_xxx_nn'.)
Given object name, returns non zero if it is a custom hero, otherwise returns 0.
Added FFX 3.2
stumpy 2006-08-26: easier with direct reference to 'isCustom' key
Returns 1 if attribute exists (even if its value is zero), 0 otherwise
Added FFX 2.5
Teleport an object (including a character, of course) to a position. The object will conserve its current heading
(i.e., the second number from the Object_GetOrientation(object) tuple), unless you set heading= to a non-zero value.
Added FFX 3.2. This is similar to FFX_Teleport(), except that a single marker is used and that object orientation
is preserved and modifiable.
Returns the name of a marker which can be reused to avoid creating different markers every time you need one.
Added FFX 3.2
Rationale: Prevents duplicate custom commands for persistent custom actions and allows to know the existing commands
by checking WRAPPER_REGISTERED_CUSTOM_COMMANDS.
IMPORTANT: setting oneShot=1 prevent checking for duplicates. It is suggested that you use instead oneShot=0 and call
FFQ_MissionRemoveCustomAction() manually in the resulting function. Ex.:
FFQ_MissionCustomAction('CUSTOM_SAYHELLO', char, target, 'sayHelloWorld', 250, 0)
def sayHelloWorld(target, char):
FFQ_MissionRemoveCustomAction(CUSTOM_SAYHELLO', char, target)
for the additional character states identification function, see "object modification functions" above
warning! similarly to the cshelper functions, the is[Class] functions don't return 1 if true, but the class number
Tries to determine if the character is a clone of either a hero, a villain or a minion class character.
Will not work on clones of same class characters generated by M25 scripted AIs if M25_DOUBLE_CLONE_HP,
exceptif the character has the M25 clone attribute
is set to 1 (which is the default value).
Changed FFX 3.0:
-baseMaxHealth now applies to template, not object
Changed FFX 3.2:
-now checks first if the character has been set as a clone by M25 AI
Is the character a clone of a VILLAIN template?
Note that clones of MINIONS won't register here!
modified FFX 2.5; skirmish customs won't cause an unhandled exception anymore
much slower, but works in skirmish; isEvilClone(obj) will automatically use this function in skirmish
Is the character a clone of a HERO template?
Note that clones of POLICES won't register here!
added FFX 2.5
much slower, but works in skirmish; isHeroClone(obj) will automatically use this function in skirmish
is the character a lure?
added FFX 3.2
is the character a special FFX object?
added FFX 3.2
is the object a powerup/canister?
added FFX 3.2
are the 2 characters on the same side (both good or evil)?
returns 1 for minions & villains / team 2 or more
assigns the character to a team even if not using M25AI
returns the team
Changed FFX 3.05 alpha: new version added back in FFX
! Dr, I hope the new version is kasher with M25 new AI system, because Empathic Friendship depends on this
Changed FFX 3.2: added the possibility of ignoring special characters such as tiggots
checkLiving: if at 1, k.o.'ed characters won't be returned
lures: if set to 1, lures will be returned among the characters
specialCharacters: if set to 0, tiggots, etc., won't be returned
modified FFX 2.5; you can now choose to ignore clones of villains by setting the argument clones = 0
also corrected a stupid indent error
modified FFX 2.5; you can now choose to include clones of villains by setting the argument clones = 1
Changed FFX 3.2: optimized code; special characters are now ignored
same as CSHelper, but checks if alive
changed FFX 3.0: ffq_civilian_disguise template is ignored
same as CSHelper, but checks if alive
Changed FFX 3.0: by default, limey lures are ignored
get all characters of the corresponding FFX voice-based "gender"
Changed FFX 3.0: by default, limey lures are ignored
parameter needs to be one of:
FFX_GENDER_UNKNOWN=-1
FFX_GENDER_OPPOSITE=0
FFX_GENDER_MALE=1
FFX_GENDER_FEMALE=2
FFX_GENDER_ANIMAL=3
FFX_GENDER_ROBOT=4
FFX_GENDER_ALIEN=5
FFX_GENDER_GOOD=0
FFX_GENDER_EVIL=32
Changed FFX 3.0: by default, limey lures are ignored IF team tagging is not enabled.
(If team tagging is enabled, lures are part of team 0, like civilians and special objects.)
finds all others charaters on the same M25 AI team as the selected character
or, if not using M25 AI, the members of the same side (hero/police vs villain/minion0.
Added FFX 3.2 alpha
hacked from cshelper.getNearestHero()
Changed FFX 3.0:
-by default, limey lures are ignored IF team tagging is not enabled.
(If team tagging is enabled, lures are part of team 0, like civilians and special objects.)
-Patched a few bugs...
finds the nearest character from any enemy team; to search for a specific team
(other than the 0 one), set the team = x variable
Changed FFX 3.0: by default, limey lures are ignored IF team tagging is not enabled.
(If team tagging is enabled, lures are part of team 0, like civilians and special objects.)
finds the nearest static or dynamic vehicle; tanks are ignored
Added FFX 2.5
finds the nearest object or character, projectiles excepted
Added FFX 3.2
finds the nearest projectile
Added FFX 3.2
stumpy 2006-08-26: A couple efficiency tweaks:
1) save some compute time using distance squared, which sorts the same
2) the char's pos doesn't change, so keep it outside the loop and compute
it just once.
finds nearby projectiles
Added FFX 3.2
Among the projectiles near the character, gets the one(s) which might have been fired by him?
Notes:
- This is strictly heuristic (i.e., guess); it might get both false negatives and false positives.
As such, this should be used only on projectiles which have just
been fired before the character has a chance to do another move.
- To be more effective, this would need to add face (of char) to back (of projectile) and parallel
(side-by-side + flying shooter above/ground shooter below) shooting (maybe using comparative getMyProbableProjectiles())
- Hooks in MLOG('ranged') or MLOG('controller') could be combined with it to make that function to make it much more accurate.
Added FFX 3.2
finds near characters from any enemy team; to search for a specific team
(other than the 0 one), set the team = x variable
adaptated from cshelper getNearBaddies
Changed FFX 3.0: by default, limey lures are ignored IF team tagging is not enabled.
(If team tagging is enabled, lures are part of team 0, like civilians and special objects.)
finds all characters from any enemy team; to search for a specific team
(other than the 0 one), set the team = x variable
Changed FFX 3.0: by default, limey lures are ignored IF team tagging is not enabled.
(If team tagging is enabled, lures are part of team 0, like civilians and special objects.)
finds either all other heroes & polices for heroes & polices classes or all other villains & minions for villains & minions
to include the calling character himself in the list, set removeObject = 0
Changed FFX 3.0: by default, limey lures are ignored
finds near allies
adaptated from cshelper getNearBaddies
Changed FFX 3.0: by default, limey lures are ignored
finds either all other villains & minions for heroes & polices classes or all other heroes & polices for villains & minions
Changed FFX 3.0: by default, limey lures are ignored
finds near enemies
adaptated from cshelper getNearBaddies
Changed FFX 3.0: by default, limey lures are ignored
finds near civilians, except ffq_civilian_disguise template
added FFX 3.0
Tries to guess the 2D position of an object in x seconds.
Can also be used to guess the facing of a MOVING object.
Results can be read after 0.1 sec. by using the following commands:
FFX_ObjectGetAttr(obj,'guessedPos_x')
FFX_ObjectGetAttr(obj,'guessedPos_y'
IMPORTANT:
-there is a 0.1 second delay between the time the function is called and the time a value is returned
-z coordinate isn't given, since future value can't be estimated correctly
Added in FFX 2.5
Returns the nearest object to the reference object from a list or a list-generating function.
If 2 results are nearest ex-aequo, only one is returned.
Added FFX 2.5
Changed FFX 3.2: returns an emplty string if the list is empty instead of throwing an exception.
returns a list re-ordered by distance to an object from a list of targetm objects
Added FFX 3.2
Get the character's average resistance/weakness to a type of damage from his attributes and material,
plus active and passive defences.
Returns the damage multiplier (i.e. 1.0 if no resistance or weakness, 2.0 if weak, 4.0 if defenceless,
0.0 if completely impervious, 0.75 if somewhat resistant, etc.)
Parameters:
- passive=1 includes passive defences in the calculation
- active=1 includes active defences
- attribs=1 includes both FFX and built-in attributes
- states=1 includes attributes (such as Tough Guy) which protect only against the state alteration part
of some damage types (ex. cold or radiation). This parameter has no effect when checking state
alteration-only damage types.
- material=1 includes the character's material inherent resistances
Notes/bugs:
- This detects only resistance to specific damage types. Attributes which allow to resist to multiple
damage types (such as Temporary Invulnerability or Body Aura) are ignored.
- Adaptative attribute is ignored, since the actual resistances can't be determined.
- Adaptative (active) attribute current resistances are detected correctly.
- Characters suffering from non-Adaptative (active) genetic damage will report incorrect values,
as genetic damage can't be detected.
- For active and passive defences, special attack type is ignored, since there is no in-game UI for
it. The resistance multiplier is based on the sum of each type of attack blocked.
- Since active defences are either on or off, their weight in the overall resistances is arbitrarily based
on duration, energy cost and number of levels purchased, in addition to the types of attacks blocked.
- Only the first active and the first passive defences are detected.
- Some defences may not be detected correctly with older version of chardata.py.
- Powers are accounted only if they are starting attributes or have been purchased.
- material 12: hidden material: dark matter
- defenseless against crushing, piercing, energy, fire, radiaton, electricity, acid and cold
- weak against mental and mystical
- material 13: hidden material: ectoplasm
- defenseless against crushing, piercing, energy, electricity and acid
- weak against mental and mystical
- normal against fire, radiation and cold
Detect secondary state changes
uses FFvsTTR's new EVENT_CHARACTER_SEC_STATE_CHANGED, which has no cshelper wrapper.
Added FFX 3.2
Detect secondary state change, because some secondary states don't register.
Note: Please use regSecondaryState2() above instead, as it's faster, less quirky and offers more parameters.
If regSecondaryState2() proves to support correctly all states, regSecondaryState() will be made obsolete.
Added FFX 2.5
Detect if a condition involving a variable or an attribute becomes true
Alternative method for prolonged damage states
Advantage:
-doesn't use memory needlessly
-no risk (?) of damage being triggered a second time before the function is called.
Disadvantages:
-slower
-if the prolonged damage state isn't powerful enough to damage, it won't trigger the function;
-also, if the character health gets higher, damage may not register. EDIT: repaired!
Added FFX 2.5
Pseudo-event registration of new characters. This has a latency of up to 1.0 sec.
Spawned characters' FFX attributes initialisation is started before this event is fired.
Calling regCharacterInitialized() from def OnPostInit() should register characters present at startup.
You should use only one of the three following parameters: object, template and objectClass.
To detect any new character, leave all three parameters
Note that your registered function will still have to check whether the character should be processed or not
(i.e, is it a special hidden object such as a tiggot, disguise, etc.)
Added FFX 3.2
stumpy 2006-09-25: I've renamed the 'spawned' parts of these functions and
variable to initialized, to avoid confusing with the spawn sinks in mlogreader.
code ripped off Stumpy's mlogreader.regAnimation()
Cancel a CHAR_INITIALIZED_EVENT sink for a particular callback function and the corresponding object/template/objectClass parameter
code ripped off Stumpy's mlogreader.cancelAnimationCallbackSink()
used by initialiseChar(), which is called each 1.0 sec. by FFX.
code ripped off Stumpy's mlogreader.HandleAnimationCallbacks()
This is simply a copy of Stumpy's class from mlogreader module
Note: while the format was kept the same for potential compatibility, eventType=FLIGHT_START_EVENT
was changed to eventType=66 (the value of mlogreader.FLIGHT_START_EVENT) to avoid creating two
versions of the same global variable.
stumpy 2006-09-24: modified to make distinct from other pseudo events
Added FFX 3.2
This is simply a slightly modified copy of Stumpy's function from mlogreader module
snaps the camera to the first living character from a list
modified from the original cshelper function look()
scrolls the camera to the first living character from a list
modified from the original cshelper function lookTo()
ripped off Dr. mike's turnAllTo(), which works on customs only
Changed FFX 3.2.0 alpha :added a random delay to make it look more natural
turn all customs to given point (eg speaker)
ripped off Dr. mike's moveAllTo(), which works on customs only
maybe range should be randomized
move all customs to given point
mutually exclusive dialogue calls; if optional speech returns a result, don't play the next dialogue(s)
used when you want a character to say something if he's in the mission, and if not, use another speech instead
example: Microwave says something if he's in the mission; if he isn't, Liberty Lad speaks instead, if he's there;
if not, use optionalForceSpeak() to have a character in the mission or not (such as Microwave), speak a different line.
if you don't want to force a speech if there is no one, you can use only a succession exclusiveOptionalSpeak() and,
after the last one, add the following line to your cutscene script:
call this function first
call this function last if there is another step in the cutscene after
call this function last if it's the last step of the cutscene
Currently used by Invulnerable, Temporary Invulnerability and Tough Guy 2
For questions and comments, please go to
http://freedomreborn.net/phpbb/viewtopic.php?t=2579
Allows you to pass as many variables of any type that you want through by packing them into a tuple
and using str() or repr() to convert that tuple into a string. Then just unpack the tuple string in
the callback function using eval().
If you use one or more modules frequently, there might be an efficiency improvement in adding it to
the tryfirst list.
Syntax example:
Energize our valiant spaceman in three seconds
RegTimer2('Object_SetSecondaryState', 3.0, ('spiff',SCSTATE_ENERGIZED,10))
will execute this function with these arguments after the 3 seconds:
Object_SetSecondaryState('spiff',SCSTATE_ENERGIZED,10)
Note:
Python doesn't recognize one-element tuples as such and read directly the element inside, unless there
is a trailing comma. So if you use a single element as parameter in arglist, please add the comma after
or add a dummy variable. (Of course, you could also use the standard RegTimer, either alone, if you know
that there is always only one element in the tuple or, otherwise, with missionobjvar.Mission_SetVar() or
missionobjvar.Object_SetVar().)
For questions and comments, please go to
http://freedomreborn.net/phpbb/viewtopic.php?t=21640
NOTE:
These two functions try to read the mission.dat file of the current map, which should work with most
mods and Danger Room missions. However, maps from the main FF campaign (either in campaign mode or while
replaying a campaign episode in the Danger Room) usually won't have a readable mission.dat (see details
below). To counter this, both functions will use an alternate method which doesn't rely on reading
mission.dat. As such, the results may vary somewhat.
Reading mission.dat: an explanation
For these functions to work, there must actually be a mission.dat (or base.dat) file in the mission
folder for whatever mission is running. I think that's usually true (at least in all the mods I've
seen), but keep in mind that it is possible to distribute a mod with these files compressed (zipped)
into .ff files that the engine decompresses internally (I assume) without putting the DAT file anywhere
nice. That's what the main campaign does and you have to unzip the missions.ff file manually if you want
to experiment with those missions using these functions.
Related info available in datfiles.py
Get the approximate size of the map by finding the min and max positions of stuff on the map
stumpy: Find the base maximum health the object would have, *before* any FFX modifications
FFX_OVERHEATED_CUSTOM=[
["default","effect_ffx_flames","ffx_overheated"],
["types","EFX","XExplosion"],
]
FFX_ENVCONTROLA_CUSTOM=[
["default","ffx_earth_control2","CUSTOM_MAGMAVENT","ffx_geovent","ffx_firestorm"],
["types","DDummy Power","CCommand","OObject","XExplosion"],
]
TODO - write this out to nexuscmd.py?
comd="def %s(target,char): SetCustomEntryByName(target,char,'%s',%d)"%(fn,arrayName,index)
print comd
exec comd
spawns, writes out template to log file (even for customs) and aligns with obj
FFX_ObjectSetAttr(res,'_x',set[1][0])
FFX_ObjectSetAttr(res,'_y',set[1][1])
FFX_ObjectSetAttr(res,'_z',set[1][2])
FFX_ObjectSetAttr(res,'_src',Object_GetAttr(char,'ffxID'))
RegTimer('checkForProjEnd',0.1,0,fn,res)
RegTimer('checkForProjEnd',0.01,0,fn,res)
def hextocrystalliseG(event):
grenadehit(event.string,event.object,'hextocrystallise')
Mission_StatusText('non-existant')
Mission_StatusText('dead')
Mission_StatusText('one of us')
print '%s is a threat'%(obj)
Mission_StatusText('arrowing %s'%(obj))
option for increasing invulnerablity for Pain Response (Defense Mechanism)
option for increasing strength AND invulnerablity for Pain Response (Defense Mechanism)
New Side Effect Option that has a 25% chance of Mental Blanking the User ###