Today on Apolyton POLYCAST #58 (PROMO #9) MODCAST #23 CIVCON '09 ANNOUNCED: AUGUST 7-9, 2009 TRI-LEAGUE #27 BTS TEAM D.G.: ENGAGE NOW
Apolyton Civilization Site Forums
main | civ4 | col | civrev | galciv2 | alt | civ3 | civ2 | ctp2 | smac | about | polycast
- Order Civilization IV: Colonization (Amazon US)/(UK) -
- Order Civilization: Revolution [360] (Amazon US)/(UK) | [PS3] (US)/(UK) | [DS] (US)/(UK) -
ApolytonPLUS | register | new posts | pm (-/-) | members
faq | news | civgroups (news) | hall of fame | downloads | upload | plus | store | search
Apolyton Civilization Site Forums : Powered by vBulletin version 2.0.3 Apolyton Civilization Site Forums > Civilization IV > Civ4 Creation > Anyone available to do some modding scripts?
Page: Print | Email | Subscribe | Report News       0 votes -  average
19.Jul: A RELIGIOUS REVIEW
18.Jun: BTS PATCH 3.17 OUT NOW!!!
15.Apr: RTW ADDON PACK 2 AVAILABLE NOW
CivGroups
Civilization IV Creators (96): Not a Member - Join

bottom of page
  - CIVILIZATION 4 (C&B) $49.95 - CIVILIZATION 4 (EB) $49.99 - CIVILIZATION 4 (AMZ) $49.99
Author
Thread    < Last Thread     Next Thread > Post New Thread     Post A Reply
Grandpa Troll

PolyCast TeamApolytoners Hall of Fame
Immortal Factotum
Livin La Vida Kitty Kat
Jul 2000
time: 23:06
24-05-2008 22:22
edit | quote
#1 | report |
Anyone available to do some modding scripts? Browse Apolyton AD-FREE


Maybe the incorrect word, but in Call To Power a few good folks donated a little (or a lot) to make me some scripts for SLIC

Then I would tweak as i needed.

What I had was like a granary and it produced "X" public works for each POP Count.


What i was wondering here was if it is possible to have such to maybe produce (spawn) a unit of choice for a building of choice, as in CIV III Conquests, when ya made a scenario you could spawn a Calvary every "X" turns say for a Barracks


Ok, thanks in advance if it is possible!

Gramps

LDiCesare
GalCiv Apolyton EmpireCivilization IV Creators
King
Ashes
Jan 2001
time: 04:06
25-05-2008 17:16
edit | quote
#2 | report |
Support Apolyton buy from Amazon


You'd like a building to spawn a unit every X turns?
Do you use vanilla/warlords/BtS? There might be some python commands that don't work the same in all versions.

LDiCesare
GalCiv Apolyton EmpireCivilization IV Creators
King
Ashes
Jan 2001
time: 04:06
25-05-2008 17:38
edit | quote
#3 | report |
Got spare money?


That looks farily simple actually. There are certainly nicer ways to do it, but create a directory for your mod, and put a .py file there, something like:
Mods\GrandpaTroll\Assets\Python\GrandpaTrollEventM
anager.py

In that file (beware tabs/whitespaces), write something like this:
-Edit - I'll attach the file in a moment, I wanted to put plain text but with the tabs gone it's useless-...
-Edit 2- I'll attach it if I can make it work...

Last edited by LDiCesare on 25-05-2008 at 18:28

Grandpa Troll

PolyCast TeamApolytoners Hall of Fame
Immortal Factotum
Livin La Vida Kitty Kat
Jul 2000
time: 23:06
25-05-2008 18:28
edit | quote
#4 | report |
Avatar Enlargement: We've got the solution


BTS Full Version

So I put the py file there, would this be on hotepad?

In addition, say I choose a World Builder map made by me, would this go in my Mods folder?

Currently I have my world Builder map in the Scenario (public files(

Ok, appreciate this!

Gramps

LDiCesare
GalCiv Apolyton EmpireCivilization IV Creators
King
Ashes
Jan 2001
time: 04:06
25-05-2008 18:50
edit | quote
#5 | report |
Support Apolyton buy from Amazon


It's something like this. You have one py file that you can edit with notepad/wordpad/whatever text editor (just beware the whitespaces and tabs - they are important)
Warning: It doesn't work for some reason.
But the structure is simple: put the directory in the mods folder and go advanced/Load a mod (or modify the shortcut to start as "C:\Program Files\Jeux\Sid Meier's Civilization 4\Beyond the Sword\Civ4BeyondSword.exe" mod=\Grandpa)

I don't get why hasBuilding is not found yet...

Basically I just added these lines to the file:
self.spawnRate = 2 in the __init__ function, and in
onBeinGameTurn:
if ( iGameTurn % self.spawnRate == 0 ):
self.spawnUnits()

def getNumPlayers(self):
iCount = 0
for i in range( gc.getMAX_CIV_PLAYERS() ):
if ( gc.getPlayer(i).isEverAlive() ):
iCount = iCount + 1
return iCount

def spawnUnits( self ):
unitID = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_WARRIOR')
buildingID = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_BARRACKS')
# Loop through all players' cities
for iPlayerLoop in range(self.getNumPlayers()):
pPlayer = PyPlayer(iPlayerLoop)
apCityList = pPlayer.getCityList()
for pCity in apCityList:
city = pCity.GetCy()
if( city.hasBuilding( buildingID ) ):
pPlayer.initUnit( unitID, city.getX(), city.getY(), UnitAITypes.NO_UNITAI )

If you remove the hasBuilding (and the tab on the following line), you'll get a unit spawned per city every 2 turns.
I must check why I can't find hasBuilding and it'll be done.

Attachment: grandpa.zip
This has been downloaded 0 time(s).

Last edited by LDiCesare on 25-05-2008 at 18:56

LDiCesare
GalCiv Apolyton EmpireCivilization IV Creators
King
Ashes
Jan 2001
time: 04:06
25-05-2008 19:02
edit | quote
#6 | report |
Support Apolyton buy from Amazon


OK, it's just isHasBuilding instead of hasBuilding. I reattach it below, but you can just edit the above file too.
Sorry it took that long for something I called fairly simple, but I almost deleted my Mods folder in the process of making the zip...
So, use notepad or something like that, change the spawnRate to what you'd like, and the UNIT_WARRIOR/BUILDING_BARRACKS accordingly.
I suppose it's possible to have some gneric code and make the xml files specify which building should spawn what and how often, but that would be more complicated.
Hope it works for you.

And yes it should work with whatever map you may like.

Attachment: grandpa.zip
This has been downloaded 0 time(s).

Last edited by LDiCesare on 25-05-2008 at 19:14

Grandpa Troll

PolyCast TeamApolytoners Hall of Fame
Immortal Factotum
Livin La Vida Kitty Kat
Jul 2000
time: 23:06
25-05-2008 19:25
edit | quote
#7 | report |
Increase Your PM Length


Thanks so much!

Just curious, I select Mode and then i can pick a scenario? (thats where my homemade map is)


Appreciate this so much!

Gramps

Grandpa Troll

PolyCast TeamApolytoners Hall of Fame
Immortal Factotum
Livin La Vida Kitty Kat
Jul 2000
time: 23:06
25-05-2008 19:44
edit | quote
#8 | report |
Got spare money?


C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Assets\XML\Buildings\CIV4BuildingClassInfos.xml

If I go here i can find the correct building lingo? (as in how I should define the building ID)



C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Assets\XML\Units\CIV4UnitInfos.xml


For Units I would go here to get correct unit namer?


Thanks in advance

Gramps

Grandpa Troll

PolyCast TeamApolytoners Hall of Fame
Immortal Factotum
Livin La Vida Kitty Kat
Jul 2000
time: 23:06
25-05-2008 19:51
edit | quote
#9 | report |
Avatar Enlargement: We've got the solution


Yet another question, please bear with me.


I make a mod folder names say Grandpa01 (for first Mod)

Now I have a notepad and do I put all commands on that one notepad (with a space between last command that closes it and the start of the next command)


or do I need one for each change I make?


One more inquiry, do I have to name the notepad anything or will it auto read when i load my mod?


I really do appreciate this wonderful help as I love to mod games, nothing super special mind you, just for my individual please!


Peace

Gramps

LDiCesare
GalCiv Apolyton EmpireCivilization IV Creators
King
Ashes
Jan 2001
time: 04:06
25-05-2008 20:34
edit | quote
#10 | report |
Support Apolyton or Terrorists Win


quote:
Just curious, I select Mode and then i can pick a scenario? (thats where my homemade map is)

I think so. Loading a mod shouldn't prevent you from loading a scenario that's compatible with it.

quote:
C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Assets\XML\Buildings\CIV4BuildingClassInfos.xml
C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Assets\XML\Units\CIV4UnitInfos.xml

Actually that's CIV4BuildigInfos and CIV4UnitInfos (the Class thing serves to distinguish unit and civ-specific units). Usually you have stuff like UNIT_WARRIOR and UNIT_CLASS_WARRIOR. I haven't tested what UNIT_CLASS_WARRIOR gives instead of UNIT_WARRIOR. I suspect it won"t work but it might give you a regular warrior or the UU (quechua) instead depending on the civ.


quote:
Now I have a notepad and do I put all commands on that one notepad (with a space between last command that closes it and the start of the next command)


or do I need one for each change I make?


One more inquiry, do I have to name the notepad anything or will it auto read when i load my mod?

I'm not sure if I get you correctly. The mod requires a certain structure. Namely, you need it to be in Mods directory, have its name, have an assets directory like in the zip I attached. Inside this Assets, you have a Python directory and can add an XML directory if you want to mod units for instance.
All the .py files you'll write will be read if I'm correct, so you can make as many files as you like and call them as you want, but they have to be consistent. For instance, the CvEventManager.py defines all the reactions to events like new turn, so you'd better put everything event related inside.
You can look at the structure of existing mods (Charlemagne for instance is not too complex) to understand better. Just avoid those like Rhye's or FfH as they are too complex to browse for a beginner.

Grandpa Troll

PolyCast TeamApolytoners Hall of Fame
Immortal Factotum
Livin La Vida Kitty Kat
Jul 2000
time: 23:06
25-05-2008 20:37
edit | quote
#11 | report |
Get a bigger avatar today!


ok, thanks

Addled Platypus

Alpha Centauri PBEMCall to Power PBEMCivilization IV PBEMBtS Tri-League
Emperor
comming at ya, with banana breath
Sep 2002
time: 20:06
25-05-2008 21:39 | www
edit | quote
#12 | report |
Enter the AD-FREE zone


what are your overall evil plans GT ???

Grandpa Troll

PolyCast TeamApolytoners Hall of Fame
Immortal Factotum
Livin La Vida Kitty Kat
Jul 2000
time: 23:06
25-05-2008 22:03
edit | quote
#13 | report |
Support Apolyton, buy Civilization: The Boardgame


quote:
Originally posted by Addled Platypus
what are your overall evil plans GT ???


I love modding

I wamt to make a large long game, and then put all AI on Deity, and no peace with any AI, and have fun vonquering them.


In Call To Power I have it down pat with the SLIC on how to do such things as adding PW, spawning units (similiar to what happens with CIV III Conquests in the scenario area.

Gramps

Grandpa Troll

PolyCast TeamApolytoners Hall of Fame
Immortal Factotum
Livin La Vida Kitty Kat
Jul 2000
time: 23:06
26-05-2008 21:42
edit | quote
#14 | report |
Support Apolyton, buy Call to Power 2


quote:
Originally posted by LDiCesare

I'm not sure if I get you correctly. The mod requires a certain structure. Namely, you need it to be in Mods directory, have its name, have an assets directory like in the zip I attached. Inside this Assets, you have a Python directory and can add an XML directory if you want to mod units for instance.
All the .py files you'll write will be read if I'm correct, so you can make as many files as you like and call them as you want, but they have to be consistent. For instance, the CvEventManager.py defines all the reactions to events like new turn, so you'd better put everything event related inside.
You can look at the structure of existing mods (Charlemagne for instance is not too complex) to understand better. Just avoid those like Rhye's or FfH as they are too complex to browse for a beginner.


I was wondering if it would be as easy as this from Call to Power SLIC


quote:
}

trigger 'AddSILOPW' when(g.player) {
SetPlayer(1, g.player);
i=0;

while (i < player.1.cities) {
SetCityByIndex(1, player.1, i);
if (CityHasBuilding(city, "IMPROVE_SILO")) {
SetPW(player.1, player.1.publicworkslevel + 22 * city.population);
}
i = i + 1;
}
}

trigger 'MakeCities' when (city.built) {
AddPops(city.1,1);
}
trigger 'LOQ_MoreSettlers' when (g.player > 0) {
if (g.year == 0) {
i = 0;
SetUnitByIndex(1, g.player, 0);
while (i < 25) {
CreateUnit(g.player, UnitType("UNIT_SETTLER"), unit.1.location, 1);
i = i + 1;
}
} else {
DisableTrigger('LOQ_MoreSettlers');
}


The top code gives extra public works and the bottom gives extra settlers at start

LDiCesare
GalCiv Apolyton EmpireCivilization IV Creators
King
Ashes
Jan 2001
time: 04:06
27-05-2008 06:06
edit | quote
#15 | report |
Help yourself to an AD-FREE life


The code snippet I put above shows how to create units. It's a bit more complex than PW because you must create them somewhere, is slightly more lengthy because you have to loop through players yourself but is basically the same.

For starting units, you can do it more easily in civ4 than CtP because you just need to change some xml file (can't remembre which) if I'm right.

Grandpa Troll

PolyCast TeamApolytoners Hall of Fame
Immortal Factotum
Livin La Vida Kitty Kat
Jul 2000
time: 23:06
28-05-2008 00:12
edit | quote
#16 | report |
Tired of ads?


quote:
Originally posted by LDiCesare
The code snippet I put above shows how to create units. It's a bit more complex than PW because you must create them somewhere, is slightly more lengthy because you have to loop through players yourself but is basically the same.

For starting units, you can do it more easily in civ4 than CtP because you just need to change some xml file (can't remembre which) if I'm right.


Thanks

In CTP all I needed was this SLIC, say spawn "X" tanks when I built barracks per turn

But I know little to nothing about code, only used small templates.

It took a while but am pretty fluent on setting on scenarios, such as extra gold for a terrain, excluding units , removing the abilities for units to pirate or pillage, now thats a bit tough, you need to go through manually and remove those commands.

Again, thanks for the feedback sir, allways a pleasure to try to learn!

LDiCesare
GalCiv Apolyton EmpireCivilization IV Creators
King
Ashes
Jan 2001
time: 04:06
28-05-2008 14:55
edit | quote
#17 | report |
Support Apolyton, buy Civilization 2


It shouldn't be too hard to get into python/xml if you learnt SLIC. One very good reason for that is that many CtP2 modders influenced Civ IV and its scripting abilities.

The thing is you can do so many things you may sometimes get lost. Value modifications (yield of gold per turn, building effects and such simple things) go in xml files, the rest into python. But even the amount of xml files is quite impressive.

snoopy369
PtWDG Vox ControliCivilization III PBEMCivilization III Democracy GameIron CiversApolyton UniversityCivilization IV: MultiplayerC4DG VoxC4DG The HordeC4DG Gathering Storm
C4DG Team Alpha CentauriansC4DG SarantiumC4DG The Mercenary TeamCiv4 InterSite DG: Apolyton TeamCivilization IV PBEMAge of Nations TeamPolyCast TeamBtS Tri-LeagueC4DG Team Banana
Technical Assistant
Of the Peanuts Gallery
Apr 2004
time: 22:06
28-05-2008 15:40
edit | quote
#18 | report |
Put an end to popups!


FYI, if you have questions about the specific desire in the OP, this is very similar to what Jon created in the Genghis Khan scenario in Warlords (a unit spawns units, ie the camp). I suggest looking at how he handles things in that script - he has interesting ways to accomplish things sometimes

  < Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 04:06.
Apolyton Time is 23:06.
    top of page
Rate This Thread:
Forum Jump:

 



  Contact Us - Apolyton Civilization Site - Support Us!
Log Out Unregistered
Powered by: vBulletin Version 2.0.3
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Page generated in 1.6326 seconds (25.39% PHP - 74.61% MySQL) with 35 queries
Page Loading Time:

apolyton.net | apolyton.com | civilization2.net | civilization3.net | civilization4.net | civilizationiv.info | calltopower.net | galciv.net | galciv2.net | moo3.net