Archived

This topic is now archived and is closed to further replies.

Anarkist

Farcry modding

Recommended Posts

I haven''t heard much regarding Farcry mods on this forum, and I find it strange as Lua seems to be a popular programming language around here and Farcry uses it extensively. Why exactly is that? I hope to see more people around here making use of the Cryengine and Lua for mod development.

Share this post


Link to post
Share on other sites
Plus, learning a new platform is _hard_ - which is why the sequels get all the attention - their platforms are easy. Only if a games is an astronomical success do they try and mod it without experience with the devkit.... of course, for some goddamn reason, they totally ignore whether or not it was meant to be modded. I mean people actually try to mod GTA3 by exe hacks. Plus there''s that Desert Combat thing, another mod that was made mainly just by brute hacking.

Funny how the actual quality of the toolkit just doesn''t seem to enter into the equation when it comes to the uber-hardcore TC modders.

Share this post


Link to post
Share on other sites
well Desert Combat was supported by Dice (afaik ... correct me if i''m wrong) so this was no brute hacking. Check out www.pandora-forces.de .. its a farcry mod I''m working on at the moment...

Share this post


Link to post
Share on other sites
Perhaps not much people know about FC here? I just stumbled across this site and think this is a good place to find more about Lua. Great to see a community dedicated to the scripting languages.

Share this post


Link to post
Share on other sites
FC is a new engine, therfore you guys have to wait for a while until there will be dedicated moding communities around it.
Offtopic: Lua is not the only scripting language, you know? :)

Share this post


Link to post
Share on other sites
Quote:
Original post by aarbro
Perhaps not much people know about FC here? I just stumbled across this site and think this is a good place to find more about Lua. Great to see a community dedicated to the scripting languages.


Well, I designed the FC script/modding system :) . So I guess there are people that know about FC here.
BTW I no longer work for crytek but if you got some questions I'm glad to help.

Share this post


Link to post
Share on other sites
FarCry is totally script access, no engine/C++? The last time I checked people were still awaiting on the SDK for FC, has it come around yet?

I was considering FC because HL2 is taking so god damn long to come out, I decided to bring my game to HL2 because I can start programming on it now (the original SDK is suppose 95 percent 'able to be ported').

Share this post


Link to post
Share on other sites
Quote:
Original post by fagiano
Well, I designed the FC script/modding system :) . So I guess there are people that know about FC here.
BTW I no longer work for crytek but if you got some questions I'm glad to help.


[wow] I'm very impressed! [inlove]

I have some experience in Far Cry modding with Lua. I found
it very easy to use and very powerful.

Share this post


Link to post
Share on other sites
Quote:
Original post by fagiano
Well, I designed the FC script/modding system :) . So I guess there are people that know about FC here.
BTW I no longer work for crytek but if you got some questions I'm glad to help.


Hi fagiano, looks like I'll visit here more often:) I can only say I'm impressed by the scripting possibilities in FC. Must have taken some time to design that system. Still very easy to create new functionality in and debug.

Actually I have one question about the state machine which I'm working with in an entity. I understand a state is a table of functions that replace the "global" events in the entity. When in a state, the events with the same name inside that state are used instead of the "global" ones. Is that right?

I know how to start the states but how do I stop using them and return to the ordinary events in the entity?

Share this post


Link to post
Share on other sites
Quote:
Original post by aarbro

Actually I have one question about the state machine which I'm working with in an entity. I understand a state is a table of functions that replace the "global" events in the entity. When in a state, the events with the same name inside that state are used instead of the "global" ones. Is that right?


Yes you are right. Usually you also have different handlers between client and server.


EntityName.Server.Idle = {
OnWhatever = function()
end
}

EntityName.Client.Idle = {
OnWhatever = function()
end
}


that is the common case for multiplayer entities.

Quote:

I know how to start the states but how do I stop using them and return to the ordinary events in the entity?


You can't. if an entity has states, you are always in one state. Usually I create a state 'Idle' that works as normal beahaviour.

ciao
Alberto

Share this post


Link to post
Share on other sites
Quote:
Original post by bkt
FarCry is totally script access, no engine/C++? The last time I checked people were still awaiting on the SDK for FC, has it come around yet?

I was considering FC because HL2 is taking so god damn long to come out, I decided to bring my game to HL2 because I can start programming on it now (the original SDK is suppose 95 percent 'able to be ported').


I'm not sure what crytek is going to ship with the SDK, I no longer work there. In any case in FC scripts are enough for 90% of the mods you can come out with. The C++ code doesn't have much logic in it. Personally I wouldn't bother with C++.

ciao
Alberto

Share this post


Link to post
Share on other sites
Hey guys, thanks for replying to my post. Sorry I haven't responded until now, but I've been busy lately.

I guess it makes sense that people don't mod games until they become more familiar with them and FC hasn't been available for that long. Its just that I see that there are many people here use Lua for scripting and thought it strange that there weren't more post regarding Farcry modding as it uses Lua extensively.

As for Desert Combat, the modders had too resort to brute force hacking to mod it at first (except unlike FC it had model exporters), until DICE released the Battlecraft map editor, which was already being developed by a guy from the modding community and was actually delayed until DICE had released the first expansion pack. AFAIK the closet thing to support they got was probably an early release of the tools.

Hey TangentZ are you working on a mod at the moment? If so which one. Aarbro and I are working on something at the moment and we need all the help we can get.

Share this post


Link to post
Share on other sites
Thanks, much appreciated fagiano,

I'll use the state machine in a different manner now. I haven't made my entities mp compliant yet but I'll look into that next. First sp that bring me to two new questions:

1. The save and load events: Are anything loaded/saved by default for an entity, such as property values? Or do I have to stream each variable "manually"?

2. Any idea how to capture a key that is pressed and held? I've found a function that captures a single key pressed, Input:GetXKeyPressedName(). However if I want to use it as a steering control for a vehicle it doesn't work. I need to know when the key is down and later released.

Share this post


Link to post
Share on other sites
Sorry I reply only now because in the last days I realocated to another country for a new job. I've been a bit busy :)

Quote:
Original post by aarbro
1. The save and load events: Are anything loaded/saved by default for an entity, such as property values? Or do I have to stream each variable "manually"?


Everything that is in the 'Properties' table gets automagically serialized, everything else you want to save has to be explicitly serialized.

Quote:
Original post by aarbro
2. Any idea how to capture a key that is pressed and held? I've found a function that captures a single key pressed put:GetXKeyPressedName(). However if I want to use it as a steering control for a vehicle it doesn't work. I need to know when the key is down and later released.


I've got to take a look to a vehicle script to refresh my memory, I do not remeber very well this part. I any case, if you tell me exactly what you are trining to do I can find a more elegant solution rather than polling GetXKeyPressedName().

ciao

Share this post


Link to post
Share on other sites
No problem. I've been rather late in replies myself here.

Actually what I'm looking for is a way to create a powered hangglider, like an ordinary aircraft. There was a q about this by NOVA_Maimer at the UBI forum but no solution was found. The idea is to use this combination:

Mouse --roll and pitch
Forward/w --power up
Backward/s --power down
Left/right/a/d --yaw left and right

For instance take the w/s keys, in the hangglider those keys are used for pitch there. I want to make them control the power instead, like engine rpm. But it's not really important what keys are used. Just how to make a variable change when a key is held down. When the key is held down the rpm should increase constantly.

In another project I've been polling GetXKeyPressedName for a trigger entity with success. It's a variant of the ProximityTrigger that can trap any key, not just the USE key. The idea is to make it possible for the player to enter a numerical code on the num keys for instance. It's using polling but only when the player is inside a small area so I don't think it'll be too costly. Still it's crude, if there is a way to get a system event for keys, the better. However, this method is not usable for the aircraft as only a single key pressed is recognized. When held down GetXKeyPressedName replies with nil.

Thanks again for taking the time to helping out and good luck at your new location.

Share this post


Link to post
Share on other sites
I actually believe the desert combat team MADE the mod tools, with help from Dice (I heard something about this awhile ago).

Anyway, I bought Farcry awhile ago and I am wondering how to mod it.
I should probally just wait till the SDK comes out because that should be ALOT easier.

Share this post


Link to post
Share on other sites
I don't have a copy of Farcry to try this, but if it's using Lua and there is a way to print to the console just do something like:

for k,v in pairs(_G)
print(k .. " : " .. v)
end

And watch as everything in the global namespace magically scrolls over your console.

Share this post


Link to post
Share on other sites
Quote:
Original post by DirectXXX
fagiano if you have time, can you explain the over all architecture of scripting interface to game engine. Also the event system please.



Far cry scripting architecture is relatively simple, is based on lua 4.1 alpha (hybrid version between 4 and 5)
everything is handled with a single lua_State.
I modified the VM in order to overcome several performance/memory problem created by the GC and
lua reference system.

the scripting handles most of the game code entities behaviour, game behaviour(aka gamerules),
materials (sound, decals and particles), AI, Weapons, hud & GUI.

the most interesting scripts are probably entity and gamerules scripts.

ENTITIES
Each entity class(type) has specific lua table that is used as prototype, the table gets cloned for each instance of the entity;
it defines the behaviour of the entity, plus informations for the editor to be able to enumerate parameters.
Each entity script is splitted into server and client table and can have one or more states.
States are synchronized through server and client. Each state can optionally implement as set of event handlers :

OnBeginState () when the entity enters in a certain state
OnContact(collider) collision with another entity
OnDamage() when it get shoot
OnTimer() a timer expires
OnUpdate() called every frame, if present
OnEndState() exit from a state
etc..(i forgot ;)

the entity 'self' is also filled with a certain amount of C++ functions to manipulate position,state,
orientation, load models, physicalize the geometry etc...

an entity looks like this(semi-pseudo code)


RotatingBox = {

--all the fields contained in the subtable Properties spawn in the
--editor properties window and can be configured
Properties = {
fileModel = "models/default_box.cgf"
}

--
angle = {x =0, y =0 , z =0}
}

--called at spawn time
function RotatingBox:OnInit()
--load the model
self:LoadModel(self.Properties.fileModel);
--registers the states
self:RegisterState("Stopped")
self:RegisterState("Rotating")
end

--server side script(runs only on the server
RotatingBox.Server = {
--stopped state
Stopped = {
--if a player comes in contact with the entity
--the entity goes in Rotating state
--beacause the state is sychronized through the net
--the entity works also online with no additional code
OnContact = function (collider)
--when a
if(collider.type == "Player") then
self:SetTimer(1000);
self:GotoState("Rotating");
end
end
}
--rotating state
Rotating = {
--until the player is on contact the box will reset the timer
--otherwise the timer expires and the box goes back in Stopped state
OnContact = function (collider)
self:SetTimer(1000);
end,
--stops the rotation
OnTimer = function()
self:GotoState("Stopped")
end
}

}

-- client side sctipt
RotatingBox.Server = {
--stopped state
Stopped = {
//does nothing
}
--rotating state
Rotating = {
--each frame
OnUpdate = function(delta)
local angles = self:GetAngles() --rotates on the Z axis
angles.z = angles.z + delta;
self:SetAngles(angles);
end
}

}


with this system far cry handles 90% of the entity logic.

a very important aspect of the system, is the fact of beeing able of call functions
from one entity to another. the editor wires them together filling some table at spawn time.
This allows stuff like changing state of an entity when a trigger entity is activated.
For instance a trigger could call rotatingboxinstance:GotoState("Rotating") when the player hits the trigger.
To do so we got functions like System:GetEntityByName() or System:GetEntity(id).

GAMERULES
Another important script is the 'game rules' script.
The game rules handle all games global events

OnClientConnect -- spawns the player entity, something like Server:SpawnEntity("Player")
OnClientDisconnect --guess
OnDamage --here we check if some damage has to be applied before we call the entity OnDamage()
etc...


HUD
well, we call Hud:Update() in the script System:DrawRectangle(),System:LoadTexture() ...etc

MATERIALS
is just a bounce of tables declaring particles,decals, sounds for a specific material.

AI
I'm never really got into AI scripts but are not very far from entity scripts, bounch of event handlers and
states(aka behaviours), stuff like OnEnemySeen() etc...

C++ BINDINGS
all the C++ binding are hand-coded through a C++ template, that has been a choice. I do not believe automatic
bindings , mapping the C++ 1:1 on scripts is against the pourpose of scripting.
the script interface must be higher level, is boring, but pays back.

Conclusion

Pros
-the system is very nice to work with and we got special C++ code just for actors(players and AI) and vehicles.
-writing entities is fun
-speed wise is more than enough(except for the GC problems)
-easy to integrate with tools
-modding the game takes 1/100000 than with C++(I wrote CTF in about day)

Cons
-lua worked well in prototyping stage, then when we got 6Mb+ of data in it the GC was killing the framerate
once a second, I had to put my hands in the VM and we had to set a bounch of scripting policies.
I can't immagine how could run on a console.
-the lua4-style reference system is very fragile, do not use it, after 30min of editing was dying.It uses
an integer to keep the reference number, if you got thousand of objects is going to overflow soon and bang!
I had to write a custom one... pretty much what squirrel uses.
-lua doesn't work with unicode, we had to use some XML files for localization
-we didn't have a debugger from the beginning...if you plan massive scripting a debugger is a must from day one.

I hope this is what you were asking for

ciao
Alberto


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi, I'm currently working on a mod for farcry with a friend of mine. We are both new to modding but we have a little help and decided to give it a shot. Anyways, I'm running into confusion when it comes to weapon animations. I dont have the first clue how to use the sandbox editor and I'm assuming I have to animate my weapons in there. Is this true? And if so can anyone point me in the right direction. Otherwise, is there any way to animate the weapons in 3DS max instead? Also, any related info about character animation/bone systems would be appreciated. Anyone?

Share this post


Link to post
Share on other sites