View previous topic :: View next topic |
Author |
Message |
Error Inside3D Staff

Joined: 05 Nov 2004 Posts: 558 Location: VA, USA
|
|
Back to top |
|
 |
GiffE
Joined: 08 Oct 2006 Posts: 141 Location: USA, CT
|
Posted: Mon Jun 30, 2008 2:01 am Post subject: |
|
|
Error wrote: | any update on this? |
Well I did one aswell, to make my weapon's scripted (i finished it a few days ago):
Code: |
entity LoadWeapon(string weapon_file)
{
local float f,count,i;
local string ln,key,value;
entity weap;
weap = spawn();
f = fopen(weapon_file, FILE_READ);
if(f != -1)
{
ln = fgets(f);
while(ln != string_null)
{
tokenizebyseparator(ln,"=");
key = argv(0);
value = argv(1);
if(key == "name")
weap.w_name = strzone(strireplace("_", " ", value));
else if(key == "viewmodel")
weap.v_model = strzone(value);
else if(key == "model")
weap.w_model = strzone(value);
else if(key == "type")
weap.w_type = stof(value);
else if(key == "clips")
weap.w_clips = stof(value);
else if(key == "clipsize")
weap.w_clipsize = stof(value);
else if(key == "firedelay")
weap.w_firedelay = stof(value);
else if(key == "weapondamage")
weap.w_weapdmg = stof(value);
else if(key == "fps_firestart")
weap.fps_firestart = stof(value);
else if(key == "fps_fireend")
weap.fps_fireend = stof(value);
else if(key == "fps_reloadstart")
weap.fps_reloadstart = stof(value);
else if(key == "fps_reloadend")
weap.fps_reloadend = stof(value);
else if(key == "maxleft")
weap.w_maxyaw_left = stof(value);
else if(key == "maxright")
weap.w_maxyaw_right = stof(value);
else if(key == "semiauto")
weap.w_semiauto = TRUE;
else if(key == "firesound")
weap.w_firesound = strzone(value);
else if(key == "reloadsound")
weap.w_reloadsound = strzone(value);
else if(key == "speedmult")
weap.w_speedmult = stof(value);
else if(key == "spreadmult")
weap.w_spreadmult = stov(value);
ln = fgets(f);
}
}
if(weap.w_semiauto != TRUE)
weap.w_semiauto = FALSE;
return weap;
}
|
basically it loads all of the info from a script file and puts it onto an entity. Then when a player switches weapons, it just copys all the info from that entity to the player.
Scripts are loaded on Map load so it will only effect load time rather than lag.
Heres an example of what the script looks like. I made it more INI style cause its easier to parse.
Code: | name=Berreta_M9
viewmodel=models/weapons2/mk23/mk23_1st.md3
model=models/weapons2/mk23/mk23.md3
type=1
clips=3
clipsize=7
firedelay=0.2
semiauto
ammotype=pistol
weapondamage=40
speedmult=1.1
spreadmult=10 10 -14
maxleft=5
maxright=-10
firesound=sound/weapons/mk23/fire.wav
reloadsound=sound/weapons/mk23/reload.wav
fps_firestart=1
fps_fireend=2
fps_reloadstart=3
fps_reloadend=24 |
I had a ton of data for each weapon, names are pretty explanitory. ( vid here to see some of the weapon stuff in action )
-Gif |
|
Back to top |
|
 |
Error Inside3D Staff

Joined: 05 Nov 2004 Posts: 558 Location: VA, USA
|
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2004 phpBB Group
|