Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Function Libraries

  1. #11

    Default

    Thanks for taking a look, Sor.

    Attached is the original guided missiles .pk3 file and my -attempt- to integrate
    variables for FFA/TDM and FriendlyFire on/off. The relevant portion starts
    at line 270 to 360.

    It was suggested at TMT to use the radiusdamage logic from the Kicknade v2 mod so
    I tried my best to integrate it. As it is now the missiles don't do any damage at all, at any setting, and
    the console gives the errormessage "Cannot cast NIL to vector".

    This is the thread at TMT about it:
    http://www.modtheater.com/threads/gu...e.28006/page-4


    Something I -did- manage was modifying the spawntrigger.scr so a red light shines under the missles
    to indicate they can not be taken, and switch to a green light when they are ready for launch. It might be
    a bit messy scripting but at least it works
    Attached Files Attached Files

  2. #12
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    You sure there are no other errors in the console? No offence, of course. But the problem definitely lies here:
    Code:
    DestroyMissile local.missile:
    
    	self stufftext "set ui_GuidedMissileHealth 0"
    	self iprint Boom!
    	local.missile.cam unbind local.missile
    	local.Exp = spawn models/emitters/fx_explosion_mine.tik origin local.missile.origin
    	local.Exp anim start
    	local.missile.jet remove
    	local.missile hide
    
    	for(local.i=1;local.i<=$player.size;local.i++)
    		{
    		if(self cansee $player[local.i])
    			{
    			if( vector_within $player[local.i].origin self.origin self.radius)
    				{
    				if(local.gametype == 1)
    					{
    					$player[local.i] thread do_damage self.player self.origin
    					}
    				else
    					{
    					if(local.teamdamage == 1)
    						{
    						$player[local.i] thread do_damage self.player self.origin
    						}
    				else
    						{
    						if($player[local.i].dmteam != self.dmteam)
    							{
    							$player[local.i] thread do_damage self.player self.origin
    							}
    						}
    					}
    				}	
    			}
    		}	
    	wait 1
    	self physics_on
    	self unglue local.missile.cam 
    	local.missile.cam remove
    	if(local.missile.trig != NIL && local.missile.trig != NULL)
    		local.missile.trig remove
    	switch(local.missile.team)
    		{
    		case allies:
    			if(level.GMAllies != "unlimited")
    				level.GMAllies++
    		break
    		case axis:
    			if(level.GMAxis != "unlimited")
    				level.GMAxis++
    		break
    		}
    	local.missile remove
    	local.Exp remove	
    	self waitthread Respawn
    	self.missile = NIL
    
    end
    (1) self.player is not defined. With an unavailable self.player, the damage command cannot work with NIL input.
    (2) local.gametype is not defined. The condition is never recognised as true and so FFA is not handled.
    (3) local.teamdamage is not defined. The condition is never recognised as true and so teamdamage is not handled.
    (4) self.radius is not defined. The input to vector_within is NIL and that's why you get that vector casting error.

    Try this:
    Code:
    DestroyMissile local.missile:
    
    	self stufftext "set ui_GuidedMissileHealth 0"
    	self iprint Boom!
    	local.missile.cam unbind local.missile
    	local.Exp = spawn models/emitters/fx_explosion_mine.tik origin local.missile.origin
    	local.Exp anim start
    	local.missile.jet remove
    	local.missile hide
    	local.radius = 250.0
    	for(local.i=1;local.i<=$player.size;local.i++)
    		{
    		if(self cansee $player[local.i])
    			{
    			if( vector_within $player[local.i].origin self.origin local.radius)
    				{
    				if((getcvar "g_gametype") == "1")
    					{
    					$player[local.i] thread do_damage self self.origin
    					}
    				else
    					{
    					if((getcvar "g_teamdamage") == "1")
    						{
    						$player[local.i] thread do_damage self self.origin
    						}
    						else
    						{
    						if($player[local.i].dmteam != self.dmteam)
    							{
    							$player[local.i] thread do_damage self self.origin
    							}
    						}
    					}
    				}	
    			}
    		}	
    	wait 1
    	self physics_on
    	self unglue local.missile.cam 
    	local.missile.cam remove
    	if(local.missile.trig != NIL && local.missile.trig != NULL)
    		local.missile.trig remove
    	switch(local.missile.team)
    		{
    		case allies:
    			if(level.GMAllies != "unlimited")
    				level.GMAllies++
    		break
    		case axis:
    			if(level.GMAxis != "unlimited")
    				level.GMAxis++
    		break
    		}
    	local.missile remove
    	local.Exp remove	
    	self waitthread Respawn
    	self.missile = NIL
    
    end
    Copy&pasting code never works. If it does, it is a purely coincidental miracle.
    Last edited by Sor; November 9th, 2012 at 09:32 AM.
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

  3. #13
    Über Prodigy & Developer Razo[R]apiD's Avatar
    Join Date
    May 2010
    Location
    Poland, Lublin
    Posts
    3,257

    Default

    Well, I think you should start a separate thread for this.

    @Sor,

    I'd still want to see a co-op going on here. I've got sort of a vision how I'd like to see it to work and it already works, at least for script libraries. The coding style can be refactored at any time. We'll for sure make few iterations before releasing it, and we'll have time for making it clearer.

    I think we should work together on completing this task. Thats why I started a Git repo for this. I thought that we would do it faster but I can't see any change really so instead of jumping from one decision to another, maybe we should just start adding content to the lib and whole framework.

    For example, we don't have any sort of mod config loader/parser. We still don't have final version of strings and math lib. I started doing something with files.scr to make it into the lib but didn't finish.

    Just add your own bits with proper comments on what have changed and why.

    If you have a better strings lib. Go ahead and replace the existing one. We can also revert if we decide we don't like it or something.

  4. #14
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    I see your point. But I still think tossing a bunch of scripts together is a nightmare to merge seamlessly together and debug.
    I'm fine with co-op as long as all participants have an fairly equal image of the end result and go about it thoroughly and efficiently.

    After all, isn't this meant to be used as standard scripting support for modders in the future? It needs to be foolproof, accessible and fast.
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

  5. #15
    Über Prodigy & Developer Razo[R]apiD's Avatar
    Join Date
    May 2010
    Location
    Poland, Lublin
    Posts
    3,257

    Default

    After all, isn't this meant to be used as standard scripting support for modders in the future? It needs to be foolproof, accessible and fast.

    It is. But I don't see a threat of tossing a bunch of scripts together. Things that are in the repo aren't meant for production at all. I just put there some stuff that we need to edit or take some code from (like old fixes), and write new stuff from scratch. Then we'll delete the rest.

    We've made a decision about the basic libraries we want to include. It's a matter of filling them in.

    The vision is to create a transparent framework, thats why I decided to take a route of libraries that can be put wherever you want, without the fear of collisions, and to allow scripters to create their libs and mods in such manner.

    If you don't like the way loader is currently written, say it. We can callaborate on it. Maybe you've got some good points that I didn't consider. And keep in mind that everything in this repo is a work in progress, so I bet (and hope) that it will dirastically change when we'll actually start to work on it.

    Current concept works. I didn't test it with robustness in mind yet, and I don't say it's coded in a best way it could be. But it's a start, as I said before, we'll have few iterations that will aim at optimizing the code, tweaking the structure and code organization.


    GIT gives us this freedom of commits and so on so we don't have to have everything right, clean and shiny from the start. We can mess with it, clean it up, revert, reorganize, fix and so on, just to work out best concepts and have the final product really stable and solid.

  6. #16
    Über Prodigy & Developer Razo[R]apiD's Avatar
    Join Date
    May 2010
    Location
    Poland, Lublin
    Posts
    3,257

    Default

    + Don't be afraid of editing someone elses code. If it's a good and commented change, everything is fine. If it turns out to be not really a good change, we can always revert etc.

  7. #17
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    All right by me. It's just that I'm a tad bit methodical and organised. I'll take a stab at it and then we'll see where we've gotten.

    Right now, I'm writing the array functions library. Unfortunately arrays in Morpheus Script are more flexible than most other programming languages.
    But so far I've made all functions handle every type of array and most, if not all of them, support full scanning to access the entire array, regardless of its dimensions.
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

  8. #18
    Developer Sor's Avatar
    Join Date
    Aug 2010
    Location
    The Medieval City of Bruges
    Posts
    747

    Default

    Wrote function that automatically executes all .scr scripts in main/global/autorun/ for reborn_loader:
    Code:
    __run:
    	if !(level.AUTORUN) {
    		level.AUTORUN = 1;
    		
    		level waittill prespawn;
    	
    		local.list = flist game.AUTORUN ".scr" 1;
    		local.exec[0] = NIL;
    		for (local.i = 0; local.i < local.list.size; local.i++) {
    			if (local.list[local.i][0] != ".") {
    				local.exec[local.exec.size] = local.list[local.i];
    			}
    		}
    		
    		conprintf "INFO[REBORN::autorun]: " local.exec.size " files are awaiting execution.\n"
    		//waitframe;
    		//waitthread $Array.Print local.exec 1;
    		for (local.i = 0; local.i < local.exec.size; local.i++) {
    			local.tmpStr = (game.AUTORUN + local.exec[local.i])
    			println "INFO[REBORN::autorun]: Executing " local.tmpStr " ...";
    			exec local.tmpStr;
    		}
    	}
    end;
    I will commit this later to the repo.
    Last edited by Sor; November 10th, 2012 at 05:53 PM.
    Morpheus Script (MoH) => You try to shoot yourself in the foot only to discover that MorpheusScript already shot your foot for you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •