Modding Rundown: PY Scripts

Started by Teancum, April 19, 2007, 06:04PM

Previous topic - Next topic
April 19, 2007, 06:04PM Last Edit: February 22, 2022, 08:34AM by Teancum
PY Scripts are basic scripts that can be opened in notepad.  Here's a basic rundown of functions that can be used.

============================================================================================
beATeamPlayer("character", "TRUE" )

Causes an NPC to fight alongside your team.

===========================================================================================
strcatstr("string1", "string2")

Combines two strings.  The following code would create "Hawkeye Rocks" as a string if Hawkeye were the first playable character of the four active characters.

heroName = GetHeroName('_HERO1_')
strcatstr(heroName, " Rocks")

===========================================================================================
unlockCharacter('name','costume') **Note, in XML1, the verb is charUnlock()

We'll use XML2 Deadpool as an example.

Here's how it works.  If you want to unlock a character for playing, you would enter unlockCharacter('deadpool', ' ').  This will unlock him and his default costume.

If you want to unlock a specific costume (XML2 only) for a character, you specify it.  You can figure out what they are by looking in the herostat.  Look for skin_[name].  The [name] part is what we need.  So in this case we can use unlockCharacter('deadpool','astonishing').  You can also unlock specific costume sets only by using unlockCharacter('','costume').  So for Age Of Apocalypse costumes it would be unlockCharacter('name','aoa')

This also works on characters you haven't unlocked yet.  They will stay locked until you unlock them, but these skins will be unlocked when you unlock the character.  And all you'd need to do is stick this in any script that runs before the first extraction point.  Technically you can put it anywhere, but it makes sense to put it before the first point so all skins are unlocked the first time you can change teams.

NOTE: We haven't figured out how to unlock costumes with this command in MUA yet

===========================================================================================
loadMapStartGame()

Loads the map defined as the start of the story

===========================================================================================
setSkin("name", "igb number")

Sets a character to have a specific model.  Looking in the IGB list we know that Luke Cage is 157.  His first skin is 01, so we'd use:
setSkin("LukeCage", "15701")

===========================================================================================
setInvulnerable("name", "TRUE/FALSE" )

Pretty self explanatory.  Sets invulnerability for a character on or off.

Example: setInvulnerable("LukeCage", "FALSE" )

===========================================================================================
display ( "TEXT" )

Displays text on the screen.  Does not work

===========================================================================================
Definition of specific static values

"_HERO1_" --First hero slot
"_HERO2_" --Second hero slot
"_HERO3_" --Third hero slot
"_HERO4_" --Fourth hero slot
"_OWNER_" --Performs verb on whoever called it
"_ACTIVATOR_" --Similar to _OWNER_, but used when you activate something.  (A good example is picking up a focus upgrade)
"_ACTIVE_HERO_" -- Name explains itself, it's the character the player currently uses.

===========================================================================================
loadZone("map", "spawn point in map" )

Loads a specific map zone. If the second parameter is specified, party will spawn at that spawn area. An example of this is in the X-Mansion in XML1. If the player uses the secret elevator in the classroom, the script can specify to spawn in the corresponding section on the 2nd floor or subbasement.

===========================================================================================
killEntity("name")

Kills a specific entity

===========================================================================================
setDangerRoomSuccess( )

Self explanatory.  However in MUA this applies to the Simulator.  The simulator is the Danger Room, just with a different name in-game.

===========================================================================================
cameraReset( )

Resets the camera (after a cutscene presumably)

===========================================================================================
awardReputation("name", integer [number of points] )

Awards reputation to specified character.  If name is empty, applies to all

===========================================================================================
setRecallActive("TRUE/FALSE")

Turn the ability to use the portal on/off

===========================================================================================
triviaMenu( )

Loads the trivia menu

===========================================================================================
reviewMenu( )

Loads the review menu

===========================================================================================
setScale("name", float )

Sets the scale of a character, model or effect to whatever value float is.  (Float values can have decimals for those who don't know)

===========================================================================================
setNoCollide("name", "TRUE/FALSE" )

Sets whether you collide with something

===========================================================================================
awardXPToPlayable(integer)

Awards XP to all playable characters (untested on NPCs with playable=true added)

===========================================================================================
allowConvIfName("_ACTIVATOR_", "name" )

Allows special conversations to be used if the activating charcter = name

===========================================================================================
awardAchievement()

Awards an achievement.  Only used on Xbox 360's Live! system

===========================================================================================
allowConversation("TRUE/FALSE")

Sets whether a conversation is allowed

===========================================================================================
setInvisible("name", "TRUE/FALSE")

Sets whether an entity is invisible

===========================================================================================
setHealth("name", integer)

Self explanitory -- setEnergy("name", integer) works the same

===========================================================================================
setAllAiActive("TRUE/FALSE") & setAiActive("name", "TRUE/FALSE")

Turns AI on/off

===========================================================================================
getConversationActive( )

Checks to see if a conversation is running.  Returns 1 for yes, 0 for no

===========================================================================================
lockCharacter(name, "SKIN" )

Locks a specific character

===========================================================================================
setUnderWater(0/1)

Sets whether we are underwater are not.  1 for yes, 0 for no.  If yes, characters behave like they're underwater.  By default you are not underwater.

===========================================================================================
setDangerRoomFailed()

Sets failure for the Simulator/Danger Room

===========================================================================================
loadMapKeepTeam("map")

Loads a map, but does not allow you to change your team

===========================================================================================
loadMapAddTeam(map)

Loads map, but allows you to change your team

===========================================================================================
loadDangerRoomCourse(map) (XML2) & loadSimulatorComicMission() (MUA)

Loads a Danger Room / Simulator map

===========================================================================================
addSimulatorScore(integer)

Adds a score to the sim

===========================================================================================
randomInt(num1, num2)

Returns a random integer between (and including) the values of num1 and num2.  For example, randomInt(1, 5) will return 1,2,3,4 or 5.

===========================================================================================
GetHealth('name')

Get's a character's current health

===========================================================================================
GetHealthMax('name')

Get's a character's max health allowed

===========================================================================================
SetHealth('name')

Set's a character's current health

===========================================================================================
SetHealthMax('name')

Set's a character's max health allowed

===========================================================================================
heroNoTarget("TRUE/FALSE")

Should the hero target someone?

===========================================================================================

setFollowingHero("character", "TRUE/FALSE" )

Sets a character to follow the player.  A good example is Dr Strange in Mandarin's palace (before you unlock him)

===========================================================================================

spawnEffect("[entity]", "[effect]", " [x/y/z] ", " [p/y/r] " )

Spawns an effect on an entity.  Example: spawnEffect("cyclops_scripted", "powers/mystique_morph", " 0.000 0.000 0.000 ", " 0.000 0.000 0.000 " )

May 15, 2007, 03:03PM #1 Last Edit: August 15, 2008, 06:31AM by Teancum
More verbs
===========================================================================================
alive("[entity]")

Checks to see if someone is alive.  Example: alive("spiderman") would see if Spidey's alive

===========================================================================================
cameraShake(4.000, 3.000 )

Vibrates the screen.  The two numbers represent how big and long the vibration is.

===========================================================================================
vibrate("ENTITY", "RUMBLE", 0.200, 2.200 )

Vibrates the screen controller (if enabled)

===========================================================================================
gameover("[something from strings.engb]")

Brings up the Game Over menu, with text that says why from strings.engb.  For instance: GAME OVER - Innocents were killed

===========================================================================================

lockControls(float)

Locks the controls for a specified amount of time.  Example: lockControls(0.100 ) locks the controls for 1/10 of a second

===========================================================================================
dropWeapon("[entity]", "TRUE/FALSE" )

Makes a character drop a weapon.

===========================================================================================
strcatint("[variable]", integer)  --There are other math functions too.  Still looking at them.

Subtracts a integer from a game variable

===========================================================================================

waittimed([float])

Force the script to wait for a specified amount of time.  Example: waittimed( 0.500 ) makes the game wait 1/2 second

===========================================================================================

createPopupDialogXml('dialog name')

Runs a dialog, like "Enter the X-Jet" yes/no

===========================================================================================
ChangeActivatingHero('name')

Swaps the hero specified with whomever activated the script (see yes_swap.py in /scripts/act2/mephisto)

===========================================================================================
setActivator()

Manually sets the activator

Example:

SetActivator("_HERO1_") --Now the hero in slot 1 is the 'activator'
ChangeActivatingHero("punisher") --Now the Punisher takes the place of whoever was in slot 1.

This is useful because you can force four specific characters to be played.  Further research shows that the change is not always immediate.  Sometimes it can take 10-15 seconds to change.

===========================================================================================
soundToPlay

Forces a sound to play (usually used in a conversation)

===========================================================================================
sound("PLAY_SOUND", "[sound]", "", "" )

Play a sound via script.  Example: sound("PLAY_SOUND", "zone_shared/effects/myst_power", "", "" )

===========================================================================================
getEntityIDFromSpawnSlot

Information needed.  Semi-self explanitory

===========================================================================================
unlockHardDifficulty()

Self Explanitory

===========================================================================================
isActorOnTeam('name')

Checks to see if an actor is on your team


===========================================================================================
spawnInventoryItem('name')

Spawns 'name' from items.engb

===========================================================================================
setHudVisible(TRUE/FALSE)

Turn on/off the HUD.  Useful for 'pretty' screenies.

===========================================================================================
dangerRoomMenu() also try openmenu('danger_room')

Loads the danger room.  *might* load the XML2 main-menu style Danger Room

===========================================================================================
controlNPC(name)

Changes control over to 'name', which comes from npcstat.engb

===========================================================================================
cameraFade(0.000, 0.000 )

gets rid of the black screen that shows up after you load a level without this defined yet.  Possibly used in conjunction with the startblack = true ; setting in a level's engb.

===========================================================================================
permanentStatBoost('name','stat')

Raises a hero stat (skill, body, focus...) For Example: permanentStatBoost('_HERO1_','skill') Gives whoever is in the first character slot 1 new skill point.  If name is empty, applies to all

===========================================================================================
levelUp(heroID,numoflevels)

The first argument is the id of the hero you want to level up. So if you want, say to give 10 levels to your first hero, the code would be:

hero1 = getID("_HERO1_" )
levelUp(hero1, 10 )

  If name is empty, applies to all

===========================================================================================
faceEntity('name', 'entity')

Makes a character face someone/something.  Example: faceEntity('_ACTIVATOR_', 'blackwidownpc')

===========================================================================================
iadd([variable name], [number])

Adds a number to a specified game variable.  Example: iadd(deadgrunts, 1 )

cool list teancum, thanks.  Not having delved into the Mandarin mod, I'm not sure how a .py script gets used.  Can someone give me a quick sum up?  I'd just like to do a simple script to add XP so I don't have to start on normal and spend 3 hours in the simulator getting heroes up to lvl 30 w /o using power points. 

All you should need to do is add the line:

awardXPToPlayable(num)

to any script that runs on the helicarrier (Act 0).  Replace 'num' with the amount of XP you want to award.  I'm not sure how much you need to get to level 30, but you could just put that number in there. 

ill sit down and do the math on that one, i need practice for vegas :p.  i'll start checking it out

thanks

took all of 2 attempts... it's 1000000 to get all characters to level 30

thanks for the help!

August 06, 2007, 10:31PM #6 Last Edit: August 06, 2007, 10:34PM by Norrin Radd
cameraFade(0.000, 0.000 )

gets rid of the black screen that shows up after you load a level without this defined yet.
When i didnt add this line in the level's py script the level would load, but the screen was completely black until i added this line

edit:
im not sure if this darkness at the beginning of loading a level has anything to do with
   startblack = true ;
defined in the eng file

So I posted the unlockCharacter verb wrong.  The first part is right, but in MUA, the skin variable (second part) is different somehow.

unlockCharacter('name','costume')

I think in MUA you have to do one of two things to unlock a specific costumes.  If you look at the Ghost Rider swap script you get a clue.  So it's either going to be one of two ways to unlock a fourth costume:

unlockCharacter('hawkeye','SKIN_04')

-or-

unlockCharacter('hawkeye','_04')

...because in the Ghost Rider script it uses unlockCharacter("ghostrider","SKIN").  Can anyone test this?  I'm away from my PC until Sunday night due to the holiday.

(Incidentally you can use " or '.  It doesn't matter)

It's a random fact that probably was already found by someone, but could you guys check whether the script scripts/act2/strange/hulk_warmup.py exists in the PC version? It, and a few of its fellows, describes a scene, as you'd expect, where during a common dialogue the player-controlled character provokes a currently-off-the-team Hulk to deck them. I just want to know whether it's something that got dumped during the PSP port's making, or something that was in there from the start. I just don't have the PC version installed and don't currently posess the hard drive space to do so.

Because if it's a PSP-only thing, then it'd be worth scanning the other PSP level FBs in search of those other snippets of how Hulk was planned to be.

Crimson Dynamo says:
In Soviet Russia, the games mod YOU!

If anyone needs any art for icons or portraits, feel  free to ask, I'll see what I can do.

I don't see
Quote from: Noelemahc on March 31, 2008, 05:08AM
scripts/act2/strange/hulk_warmup.py
in my files of the PC version

Neato. Too bad the actual dialogue lines are missing from that script, only the actions and effects are intact. There are also standard-issue dialogue scripts, but those are zero-size :(
scripts/act2/strange/talk_hulk_post.py<bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00>script<bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:f9><bh:00><bh:00><bh:00># Generated by BehavEd
# ( "This is a post script" )
cameraFade(1.000, 0.150 )
waittimed ( 0.150 )
faceEntity("hulk", "hulk_look" )
playanim (  "EA_ZONE8", "hulk", "LOOP", "" )
cameraReset( )
waittimed ( 0.150 )
cameraFade(0.000, 0.150 )

scripts/act2/strange/hulk_smash.py<bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00>script<bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00> <bh:04><bh:00><bh:00># Generated by BehavEd
# ( "The player has pissed off hulk" )
startCutScene("FALSE", "FALSE" )
cur_health = getHealth("_ACTIVATOR_" )
max_health = getHealthMax("_ACTIVATOR_" )
damage = fmul(0.300, max_health )
damage_applied = fmul(-0.300, max_health )
# ( "******************Check of the player will die if damage******************" )
playanim (  "EA_ZONE17", "hulk", "", "smash_pc" )
waittimed ( 0.150 )
spawnEffect("_ACTIVATOR_", "base/hit/hit_blocked", " 0.000 0.000 60.000 ", " 0.000 0.000 0.000 " )
waitsignal ( "smash_pc" )
if cur_health \<= damage
     # ( "The player dies" )
     setHealth("_ACTIVATOR_", 1 )
else
     new_health = iadd(cur_health, damage_applied )
     setHealth("_ACTIVATOR_", new_health )
endif
playanim (  "EA_ZONE12", "_ACTIVATOR_", "", "ko" )
waittimed ( 2.000 )
# ( "This will prevent the player from pissing off Hulk" )
setGameFlag("strange", 19, 0 )
setWaypointPath("hulk", "hulk_return", 1 )
endCutScene("FALSE", "TRUE" )
waittimed ( 1.000 )
playanim (  "EA_ZONE8", "hulk", "", "smash_pc" )

scripts/act2/strange/hulk_warmup.py<bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00>script<bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00>~<bh:01><bh:00><bh:00># Generated by BehavEd
# ( "This sets up hulk to hit the player" )
lockConversationControls("TRUE" )
playanim (  "EA_ZONE11", "hulk", "", "roar" )
waitsignal ( "roar" )
playanim (  "EA_ZONE13", "_ACTIVATOR_", "LOOP", "" )
playanim (  "EA_ZONE15", "hulk", "", "start" )
waittimed ( 0.050 )
playanim (  "EA_ZONE16", "hulk", "LOOP", "" )
lockConversationControls("FALSE" )

Crimson Dynamo says:
In Soviet Russia, the games mod YOU!

If anyone needs any art for icons or portraits, feel  free to ask, I'll see what I can do.

is there another way to replace/change the activator to another character? changeActivatingHero("name") doenst work on XML2, so i was hoping someone knew of another way to replace the activator or even the _HERO1_
Please search the forum before asking a question. I dont answer
PMs about modding, those questions should be posted in a public thread.
What im currently working on: http://marvelmods.com/forum/index.php?topic=2275.0
My mods are mine to booster/update, I will not give anybody permission to do it

I've been trying to modify the files in Marvel - Ultimate Alliance\scripts\ to modify a little a few things.
I made all sorts of change and had no effect! I tried the "right" modification, "wrong" modifications to try to force an error, and got nothing! It is as if I hadn't changed anything!!
Can someone help me? Or at least give me some hint on why is this happening?


July 28, 2008, 07:04AM #14 Last Edit: July 28, 2008, 07:12AM by xkcd
Since it is my first script I was trying to do something very simple: when u meet dum dum on Omega Base for the first time, I wanted the players to win some exp points, so I added
awardXPToPlayable(1000)
to the end of meet_dum_dum.py
Actually I tried a lot of other things also, since I can program in python. Bu nothing worked! Even changing the name of the conversation to start (for testing) had no effect.